mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
[img-editor] Fixed non-clickable bottom area by masking editor controls.
This commit is contained in:
@@ -16,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/painter.h"
|
||||
#include "styles/style_editor.h"
|
||||
|
||||
#include <QRegion>
|
||||
|
||||
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<int> 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<const QWidget*> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user