mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 13:21:34 +00:00
Fix floating close button in ColorPopup when the window is too narrow
This commit is contained in:
parent
3f5bfa6d99
commit
35764bd969
@ -175,6 +175,7 @@ ColorPopup::ColorPopup(const ColorButtonOptions& options)
|
||||
, m_vbox(VERTICAL)
|
||||
, m_topBox(HORIZONTAL)
|
||||
, m_color(app::Color::fromMask())
|
||||
, m_closeButton(nullptr)
|
||||
, m_colorPaletteContainer(options.showIndexTab ?
|
||||
new ui::View: nullptr)
|
||||
, m_colorPalette(options.showIndexTab ?
|
||||
@ -224,19 +225,18 @@ ColorPopup::ColorPopup(const ColorButtonOptions& options)
|
||||
// TODO fix this hack for close button in popup window
|
||||
// Move close button (decorative widget) inside the m_topBox
|
||||
{
|
||||
Widget* closeButton = nullptr;
|
||||
WidgetsList decorators;
|
||||
for (auto child : children()) {
|
||||
if (child->type() == kWindowCloseButtonWidget) {
|
||||
closeButton = child;
|
||||
m_closeButton = child;
|
||||
removeChild(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (closeButton) {
|
||||
if (m_closeButton) {
|
||||
m_topBox.addChild(new BoxFiller);
|
||||
VBox* vbox = new VBox;
|
||||
vbox->addChild(closeButton);
|
||||
vbox->addChild(m_closeButton);
|
||||
m_topBox.addChild(vbox);
|
||||
}
|
||||
}
|
||||
@ -309,6 +309,19 @@ app::Color ColorPopup::getColor() const
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void ColorPopup::onWindowResize()
|
||||
{
|
||||
PopupWindowPin::onWindowResize();
|
||||
|
||||
if (m_closeButton) {
|
||||
gfx::Rect rc = m_closeButton->bounds();
|
||||
if (rc.x2() > bounds().x2()) {
|
||||
rc.x = bounds().x2() - rc.w;
|
||||
m_closeButton->setBounds(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ColorPopup::onMakeFloating()
|
||||
{
|
||||
PopupWindowPin::onMakeFloating();
|
||||
|
@ -43,6 +43,7 @@ namespace app {
|
||||
obs::signal<void(const app::Color&)> ColorChange;
|
||||
|
||||
protected:
|
||||
void onWindowResize() override;
|
||||
void onMakeFloating() override;
|
||||
void onMakeFixed() override;
|
||||
void onColorSlidersChange(ColorSlidersChangeEvent& ev);
|
||||
@ -72,6 +73,7 @@ namespace app {
|
||||
ui::TooltipManager m_tooltips;
|
||||
ui::Box m_topBox;
|
||||
app::Color m_color;
|
||||
Widget* m_closeButton;
|
||||
ui::View* m_colorPaletteContainer;
|
||||
PaletteView* m_colorPalette;
|
||||
SimpleColors* m_simpleColors;
|
||||
|
Loading…
x
Reference in New Issue
Block a user