From 99deaf6005749aa3d5e55bf5ce1c2b0c7c87dfd7 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 5 Feb 2021 12:24:26 +0300 Subject: [PATCH] Added dummy buttons to PhotoEditorControls. --- Telegram/SourceFiles/editor/editor.style | 23 +++++++++++++++++++ Telegram/SourceFiles/editor/photo_editor.cpp | 9 +++++++- .../editor/photo_editor_controls.cpp | 23 ++++++++++++++++++- .../editor/photo_editor_controls.h | 6 +++++ Telegram/cmake/td_ui.cmake | 1 + 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 Telegram/SourceFiles/editor/editor.style diff --git a/Telegram/SourceFiles/editor/editor.style b/Telegram/SourceFiles/editor/editor.style new file mode 100644 index 0000000000..718c7fe980 --- /dev/null +++ b/Telegram/SourceFiles/editor/editor.style @@ -0,0 +1,23 @@ +/* +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 +*/ +using "ui/basic.style"; + +using "boxes/boxes.style"; +using "ui/widgets/widgets.style"; +using "ui/chat/chat.style"; + +photoEditorControlsHeight: 100px; + +photoEditorRotateButton: IconButton(historyAttach) { + icon: icon {{ "send_control_attach", historyComposeIconFg }}; + iconOver: icon {{ "send_control_attach", historyComposeIconFgOver }}; +} +photoEditorFlipButton: IconButton(historyAttach) { + icon: icon {{ "send_control_attach", historyComposeIconFg }}; + iconOver: icon {{ "send_control_attach", historyComposeIconFgOver }}; +} diff --git a/Telegram/SourceFiles/editor/photo_editor.cpp b/Telegram/SourceFiles/editor/photo_editor.cpp index 5fde53f302..4f347ecdc6 100644 --- a/Telegram/SourceFiles/editor/photo_editor.cpp +++ b/Telegram/SourceFiles/editor/photo_editor.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "editor/photo_editor_content.h" #include "editor/photo_editor_controls.h" +#include "styles/style_editor.h" namespace Editor { @@ -20,7 +21,13 @@ PhotoEditor::PhotoEditor( , _controls(base::make_unique_q(this)) { sizeValue( ) | rpl::start_with_next([=](const QSize &size) { - _content->resize(size); + const auto geometry = QRect(QPoint(), size); + const auto contentRect = geometry + - style::margins(0, 0, 0, st::photoEditorControlsHeight); + _content->setGeometry(contentRect); + const auto controlsRect = geometry + - style::margins(0, contentRect.height(), 0, 0); + _controls->setGeometry(controlsRect); }, lifetime()); } diff --git a/Telegram/SourceFiles/editor/photo_editor_controls.cpp b/Telegram/SourceFiles/editor/photo_editor_controls.cpp index c7e9911ba6..d9de683f0e 100644 --- a/Telegram/SourceFiles/editor/photo_editor_controls.cpp +++ b/Telegram/SourceFiles/editor/photo_editor_controls.cpp @@ -8,6 +8,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "editor/photo_editor_controls.h" #include "ui/cached_round_corners.h" +#include "ui/widgets/buttons.h" +#include "styles/style_editor.h" + namespace Editor { class HorizontalContainer final : public Ui::RpWidget { @@ -40,10 +43,28 @@ PhotoEditorControls::PhotoEditorControls( not_null parent, bool doneControls) : RpWidget(parent) -, _buttonsContainer(base::make_unique_q(this)) { +, _buttonsContainer(base::make_unique_q(this)) +, _rotateButton(base::make_unique_q( + _buttonsContainer, + st::photoEditorRotateButton)) +, _flipButton(base::make_unique_q( + _buttonsContainer, + st::photoEditorFlipButton)) { _buttonsContainer->updateChildrenPosition(); + paintRequest( + ) | rpl::start_with_next([=](const QRect &clip) { + Painter p(this); + + Ui::FillRoundRect( + p, + _buttonsContainer->geometry(), + st::mediaviewSaveMsgBg, + Ui::MediaviewSaveCorners); + + }, lifetime()); + sizeValue( ) | rpl::start_with_next([=](const QSize &size) { diff --git a/Telegram/SourceFiles/editor/photo_editor_controls.h b/Telegram/SourceFiles/editor/photo_editor_controls.h index 783424c67f..a7f1f95b9e 100644 --- a/Telegram/SourceFiles/editor/photo_editor_controls.h +++ b/Telegram/SourceFiles/editor/photo_editor_controls.h @@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" +namespace Ui { +class IconButton; +} // namespace Ui + namespace Editor { class HorizontalContainer; @@ -22,6 +26,8 @@ public: private: const base::unique_qptr _buttonsContainer; + const base::unique_qptr _rotateButton; + const base::unique_qptr _flipButton; }; diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake index c497b3482f..fb9fccc912 100644 --- a/Telegram/cmake/td_ui.cmake +++ b/Telegram/cmake/td_ui.cmake @@ -30,6 +30,7 @@ set(style_files media/view/media_view.style overview/overview.style window/window.style + editor/editor.style ) set(dependent_style_files