Moved text selection utils to td_ui.

This commit is contained in:
23rd 2021-07-26 06:59:25 +03:00
parent 793f748d2e
commit 6e2f8eb9a7
23 changed files with 89 additions and 52 deletions

View file

@ -47,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "mainwidget.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "main/main_session.h"
#include "main/main_session_settings.h"
#include "core/application.h"

View file

@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_groups.h"
#include "data/data_media_types.h"
#include "lang/lang_keys.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "app.h"
#include "styles/style_chat.h"

View file

@ -23,7 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h"
#include "core/click_handler_types.h"
#include "apiwrap.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h"
#include "window/window_peer_menu.h"

View file

@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "window/window_session_controller.h"
#include "apiwrap.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "facades.h"
#include "styles/style_widgets.h"
#include "styles/style_chat.h"

View file

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "ui/text/format_values.h"
#include "layout.h" // FullSelection
#include "layout/layout_selection.h" // FullSelection
#include "history/history.h"
#include "history/history_item.h"
#include "history/view/history_view_element.h"

View file

@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/media/history_view_contact.h"
#include "lang/lang_keys.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "mainwindow.h"
#include "boxes/add_contact_box.h"
#include "history/history_item_components.h"

View file

@ -21,7 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/format_song_document_name.h"
#include "ui/cached_round_corners.h"
#include "ui/ui_utility.h"
#include "layout.h" // FullSelection
#include "layout/layout_selection.h" // FullSelection
#include "data/data_session.h"
#include "data/data_document.h"
#include "data/data_document_media.h"

View file

@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/media/history_view_game.h"
#include "lang/lang_keys.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "history/history_item_components.h"
#include "history/history.h"
#include "history/view/history_view_element.h"

View file

@ -36,7 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_file_click_handler.h"
#include "data/data_file_origin.h"
#include "data/data_document_media.h"
#include "layout.h" // FullSelection
#include "layout/layout_selection.h" // FullSelection
#include "styles/style_chat.h"
namespace HistoryView {

View file

@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/media/history_view_invoice.h"
#include "lang/lang_keys.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
#include "history/view/media/history_view_photo.h"

View file

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_location.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "history/history.h"
#include "history/history_item_components.h"
#include "history/history_item.h"

View file

@ -18,7 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "ui/grouped_layout.h"
#include "ui/text/text_options.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "styles/style_chat.h"
namespace HistoryView {

View file

@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item_components.h"
#include "lottie/lottie_single_player.h"
#include "ui/cached_round_corners.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "styles/style_chat.h"
namespace HistoryView {

View file

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_photo.h"
#include "layout.h"
#include "layout/layout_selection.h"
#include "history/history_item_components.h"
#include "history/history_item.h"
#include "history/history.h"

View file

@ -28,7 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/unixtime.h"
#include "base/timer.h"
#include "main/main_session.h"
#include "layout.h" // FullSelection
#include "layout/layout_selection.h" // FullSelection
#include "apiwrap.h"
#include "styles/style_chat.h"
#include "styles/style_widgets.h"

View file

@ -21,7 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/format_values.h"
#include "ui/cached_round_corners.h"
#include "ui/ui_utility.h"
#include "layout.h" // FullSelection
#include "layout/layout_selection.h" // FullSelection
#include "styles/style_chat.h"
namespace HistoryView {

View file

@ -20,7 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_options.h"
#include "ui/text/format_values.h"
#include "ui/cached_round_corners.h"
#include "layout.h" // FullSelection
#include "layout/layout_selection.h" // FullSelection
#include "data/data_session.h"
#include "data/data_media_types.h"
#include "data/data_web_page.h"

View file

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/info_controller.h"
#include "overview/overview_layout.h"
#include "layout/layout_mosaic.h"
#include "layout/layout_selection.h"
#include "data/data_media_types.h"
#include "data/data_photo.h"
#include "data/data_document.h"

View file

@ -18,42 +18,6 @@ namespace Ui {
enum CachedRoundCorners : int;
} // namespace Ui
constexpr auto FullSelection = TextSelection { 0xFFFF, 0xFFFF };
inline bool IsSubGroupSelection(TextSelection selection) {
return (selection.from == 0xFFFF) && (selection.to != 0xFFFF);
}
inline bool IsGroupItemSelection(
TextSelection selection,
int index) {
Expects(index >= 0 && index < 0x0F);
return IsSubGroupSelection(selection) && (selection.to & (1 << index));
}
[[nodiscard]] inline TextSelection AddGroupItemSelection(
TextSelection selection,
int index) {
Expects(index >= 0 && index < 0x0F);
const auto bit = uint16(1U << index);
return TextSelection(
0xFFFF,
IsSubGroupSelection(selection) ? (selection.to | bit) : bit);
}
[[nodiscard]] inline TextSelection RemoveGroupItemSelection(
TextSelection selection,
int index) {
Expects(index >= 0 && index < 0x0F);
const auto bit = uint16(1U << index);
return IsSubGroupSelection(selection)
? TextSelection(0xFFFF, selection.to & ~bit)
: selection;
}
int32 documentColorIndex(DocumentData *document, QString &ext);
style::color documentColor(int colorIndex);
style::color documentDarkColor(int colorIndex);

View file

@ -0,0 +1,42 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "layout/layout_selection.h"
bool IsSubGroupSelection(TextSelection selection) {
return (selection.from == 0xFFFF) && (selection.to != 0xFFFF);
}
bool IsGroupItemSelection(
TextSelection selection,
int index) {
Expects(index >= 0 && index < 0x0F);
return IsSubGroupSelection(selection) && (selection.to & (1 << index));
}
TextSelection AddGroupItemSelection(
TextSelection selection,
int index) {
Expects(index >= 0 && index < 0x0F);
const auto bit = uint16(1U << index);
return TextSelection(
0xFFFF,
IsSubGroupSelection(selection) ? (selection.to | bit) : bit);
}
TextSelection RemoveGroupItemSelection(
TextSelection selection,
int index) {
Expects(index >= 0 && index < 0x0F);
const auto bit = uint16(1U << index);
return IsSubGroupSelection(selection)
? TextSelection(0xFFFF, selection.to & ~bit)
: selection;
}

View file

@ -0,0 +1,26 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "ui/text/text.h"
constexpr auto FullSelection = TextSelection { 0xFFFF, 0xFFFF };
[[nodiscard]] bool IsSubGroupSelection(TextSelection selection);
[[nodiscard]] bool IsGroupItemSelection(
TextSelection selection,
int index);
[[nodiscard]] TextSelection AddGroupItemSelection(
TextSelection selection,
int index);
[[nodiscard]] TextSelection RemoveGroupItemSelection(
TextSelection selection,
int index);

View file

@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/add_contact_box.h"
#include "boxes/confirm_box.h"
#include "lang/lang_keys.h"
#include "layout/layout_selection.h"
#include "mainwidget.h"
#include "storage/file_upload.h"
#include "mainwindow.h"

View file

@ -66,6 +66,8 @@ PRIVATE
layout/layout_mosaic.h
layout/layout_position.cpp
layout/layout_position.h
layout/layout_selection.cpp
layout/layout_selection.h
media/clip/media_clip_check_streaming.cpp
media/clip/media_clip_check_streaming.h