diff --git a/Telegram/SourceFiles/editor/color_picker.cpp b/Telegram/SourceFiles/editor/color_picker.cpp index adf20e7566..43416ac70a 100644 --- a/Telegram/SourceFiles/editor/color_picker.cpp +++ b/Telegram/SourceFiles/editor/color_picker.cpp @@ -370,6 +370,9 @@ ColorPicker::ColorPicker( _parent->sizeValue( ) | rpl::on_next([=](const QSize &size) { moveSizeControl(size); + if (_paletteVisible) { + rebuildPalette(); + } }, _sizeControl->lifetime()); _sizeControlHoverArea->events( @@ -635,6 +638,23 @@ void ColorPicker::rebuildPalette() { } if (!hasCurrent) { colors.push_back(_brush.color); + + const auto &padding = st::photoEditorButtonBarPadding; + const auto size = st::photoEditorColorPaletteItemSize; + const auto gap = st::photoEditorColorPaletteGap; + const auto barWidth = std::min( + st::photoEditorButtonBarWidth, + _parent->width()) + - rect::m::sum::h(padding) + - st::photoEditorUndoButton.width + - st::photoEditorRedoButton.width; + const auto count = int(colors.size()); + const auto paletteWidth = count * size + + (count - 1) * gap + + (gap + size); + if (paletteWidth > barWidth && colors.size() > 2) { + colors.erase(colors.end() - 2); + } } auto index = uint8(0); diff --git a/Telegram/SourceFiles/editor/photo_editor_controls.cpp b/Telegram/SourceFiles/editor/photo_editor_controls.cpp index 6a824f7a9c..f090b3c5d2 100644 --- a/Telegram/SourceFiles/editor/photo_editor_controls.cpp +++ b/Telegram/SourceFiles/editor/photo_editor_controls.cpp @@ -516,11 +516,11 @@ rpl::producer<> PhotoEditorControls::cancelRequests() const { _transformCancel->clicks() | rpl::to_empty, _paintCancel->clicks() | rpl::to_empty, _keyPresses.events( - ) | rpl::filter([=](not_null e) { - const auto key = e->key(); - return (key == Qt::Key_Escape) - && !_toggledBarAnimation.animating(); - }) | rpl::to_empty); + ) | rpl::filter([=](not_null e) { + const auto key = e->key(); + return (key == Qt::Key_Escape) + && !_toggledBarAnimation.animating(); + }) | rpl::to_empty); } rpl::producer PhotoEditorControls::aspectRatioChanges() const {