From 898eebbf4bf2325508bfd883aa361060f86587f4 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 9 Mar 2026 11:03:50 +0300 Subject: [PATCH] [img-editor] Fixed non-clickable bottom area by masking editor controls. --- .../editor/photo_editor_controls.cpp | 49 +++++++++++++++++++ .../editor/photo_editor_controls.h | 1 + 2 files changed, 50 insertions(+) diff --git a/Telegram/SourceFiles/editor/photo_editor_controls.cpp b/Telegram/SourceFiles/editor/photo_editor_controls.cpp index 26add10021..9ed96cf227 100644 --- a/Telegram/SourceFiles/editor/photo_editor_controls.cpp +++ b/Telegram/SourceFiles/editor/photo_editor_controls.cpp @@ -16,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/painter.h" #include "styles/style_editor.h" +#include + namespace Editor { class EdgeButton final : public Ui::RippleButton { @@ -329,6 +331,24 @@ PhotoEditorControls::PhotoEditorControls( _paintTopButtons->setVisible(shown); }, _paintBottomButtons->lifetime()); + auto aboutChanges = _about + ? rpl::merge( + _about->geometryValue() | rpl::to_empty, + _about->shownValue() | rpl::to_empty) + : rpl::never<>() | rpl::type_erased; + rpl::merge( + geometryValue() | rpl::to_empty, + _transformButtons->geometryValue() | rpl::to_empty, + _transformButtons->shownValue() | rpl::to_empty, + _paintBottomButtons->geometryValue() | rpl::to_empty, + _paintBottomButtons->shownValue() | rpl::to_empty, + _paintTopButtons->geometryValue() | rpl::to_empty, + _paintTopButtons->shownValue() | rpl::to_empty, + std::move(aboutChanges) + ) | rpl::on_next([=] { + updateInputMask(); + }, lifetime()); + controllers->undoController->setPerformRequestChanges(rpl::merge( _undoButton->clicks() | rpl::map_to(Undo::Undo), _redoButton->clicks() | rpl::map_to(Undo::Redo), @@ -403,6 +423,8 @@ PhotoEditorControls::PhotoEditorControls( _flipButton->setIconOverride(icon, icon); }, _flipButton->lifetime()); + updateInputMask(); + } rpl::producer PhotoEditorControls::rotateRequests() const { @@ -517,6 +539,33 @@ void PhotoEditorControls::showAnimated( } } +void PhotoEditorControls::updateInputMask() { + auto region = QRegion(); + const auto visibleRect = rect(); + const auto add = [&](not_null widget) { + if (!widget->isHidden()) { + const auto geometry = widget->geometry() & visibleRect; + if (!geometry.isEmpty()) { + region += geometry; + } + } + }; + add(_transformButtons); + add(_paintBottomButtons); + add(_paintTopButtons); + if (_about && !_about->isHidden()) { + const auto geometry = _about->geometry() & visibleRect; + if (!geometry.isEmpty()) { + region += geometry; + } + } + if (region.isEmpty()) { + clearMask(); + } else { + setMask(region); + } +} + void PhotoEditorControls::applyMode(const PhotoEditorMode &mode) { _mode = mode; } diff --git a/Telegram/SourceFiles/editor/photo_editor_controls.h b/Telegram/SourceFiles/editor/photo_editor_controls.h index a70b0a2f68..920902f4a5 100644 --- a/Telegram/SourceFiles/editor/photo_editor_controls.h +++ b/Telegram/SourceFiles/editor/photo_editor_controls.h @@ -53,6 +53,7 @@ private: void showAnimated( PhotoEditorMode::Mode mode, anim::type animated = anim::type::normal); + void updateInputMask(); int bottomButtonsTop() const;