mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-21 16:20:53 +00:00
Replace "pin" icon with the regular "close" button
I was contacted several times by people that cannot close these pinned popups window. The best solution is to do the same that a regular window: show the close button.
This commit is contained in:
parent
53d36b66be
commit
812e75f613
@ -48,7 +48,9 @@ enum {
|
||||
};
|
||||
|
||||
ColorPopup::ColorPopup(bool canPin)
|
||||
: PopupWindowPin("Color Selector", ClickBehavior::CloseOnClickInOtherWindow)
|
||||
: PopupWindowPin("Color Selector",
|
||||
ClickBehavior::CloseOnClickInOtherWindow,
|
||||
canPin)
|
||||
, m_vbox(VERTICAL)
|
||||
, m_topBox(HORIZONTAL)
|
||||
, m_color(app::Color::fromMask())
|
||||
@ -77,12 +79,22 @@ ColorPopup::ColorPopup(bool canPin)
|
||||
m_topBox.addChild(&m_colorType);
|
||||
m_topBox.addChild(new Separator("", VERTICAL));
|
||||
m_topBox.addChild(&m_hexColorEntry);
|
||||
|
||||
// Move close button (decorative widget) inside the m_topBox
|
||||
{
|
||||
Box* miniVbox = new Box(VERTICAL);
|
||||
miniVbox->addChild(getPin());
|
||||
Widget* closeButton = nullptr;
|
||||
WidgetsList decorators;
|
||||
for (auto child : children()) {
|
||||
if (child->isDecorative()) {
|
||||
closeButton = child;
|
||||
removeChild(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_topBox.addChild(new BoxFiller);
|
||||
m_topBox.addChild(miniVbox);
|
||||
m_topBox.addChild(closeButton);
|
||||
}
|
||||
|
||||
m_vbox.addChild(&m_topBox);
|
||||
m_vbox.addChild(&m_colorPaletteContainer);
|
||||
m_vbox.addChild(&m_rgbSliders);
|
||||
@ -98,9 +110,6 @@ ColorPopup::ColorPopup(bool canPin)
|
||||
m_graySlider.ColorChange.connect(&ColorPopup::onColorSlidersChange, this);
|
||||
m_hexColorEntry.ColorChange.connect(&ColorPopup::onColorHexEntryChange, this);
|
||||
|
||||
if (!m_canPin)
|
||||
showPin(false);
|
||||
|
||||
selectColorType(app::Color::RgbType);
|
||||
setSizeHint(gfx::Size(300*guiscale(), sizeHint().h));
|
||||
|
||||
@ -112,7 +121,6 @@ ColorPopup::ColorPopup(bool canPin)
|
||||
|
||||
ColorPopup::~ColorPopup()
|
||||
{
|
||||
getPin()->parent()->removeChild(getPin());
|
||||
}
|
||||
|
||||
void ColorPopup::setColor(const app::Color& color, SetColorOptions options)
|
||||
|
@ -26,45 +26,20 @@ namespace app {
|
||||
using namespace app::skin;
|
||||
using namespace ui;
|
||||
|
||||
PopupWindowPin::PopupWindowPin(const std::string& text, ClickBehavior clickBehavior)
|
||||
: PopupWindow(text, clickBehavior)
|
||||
, m_pin("")
|
||||
PopupWindowPin::PopupWindowPin(const std::string& text,
|
||||
const ClickBehavior clickBehavior,
|
||||
const bool canPin)
|
||||
: PopupWindow(text, clickBehavior,
|
||||
EnterBehavior::CloseOnEnter, canPin)
|
||||
, m_pinned(false)
|
||||
{
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
m_pin.setFocusStop(false);
|
||||
m_pin.Click.connect(&PopupWindowPin::onPinClick, this);
|
||||
m_pin.setIconInterface(
|
||||
new ButtonIconImpl(theme->parts.unpinned(),
|
||||
theme->parts.pinned(),
|
||||
theme->parts.unpinned(),
|
||||
CENTER | MIDDLE));
|
||||
}
|
||||
|
||||
void PopupWindowPin::showPin(bool state)
|
||||
void PopupWindowPin::setPinned(const bool pinned)
|
||||
{
|
||||
m_pin.setVisible(state);
|
||||
}
|
||||
|
||||
void PopupWindowPin::setPinned(bool pinned)
|
||||
{
|
||||
m_pin.setSelected(pinned);
|
||||
|
||||
Event ev(this);
|
||||
onPinClick(ev);
|
||||
}
|
||||
|
||||
void PopupWindowPin::onPinClick(Event& ev)
|
||||
{
|
||||
if (m_pin.isSelected()) {
|
||||
m_pinned = pinned;
|
||||
if (m_pinned)
|
||||
makeFloating();
|
||||
}
|
||||
else {
|
||||
gfx::Rect rc = bounds();
|
||||
rc.enlarge(8);
|
||||
setHotRegion(gfx::Region(rc));
|
||||
makeFixed();
|
||||
}
|
||||
}
|
||||
|
||||
bool PopupWindowPin::onProcessMessage(Message* msg)
|
||||
@ -72,7 +47,7 @@ bool PopupWindowPin::onProcessMessage(Message* msg)
|
||||
switch (msg->type()) {
|
||||
|
||||
case kOpenMessage: {
|
||||
if (!isPinned())
|
||||
if (!m_pinned)
|
||||
makeFixed();
|
||||
break;
|
||||
}
|
||||
@ -88,7 +63,7 @@ void PopupWindowPin::onWindowMovement()
|
||||
|
||||
// If the window isn't pinned and we move it, we can automatically
|
||||
// pin it.
|
||||
if (!m_pin.isSelected())
|
||||
if (!m_pinned)
|
||||
setPinned(true);
|
||||
}
|
||||
|
||||
|
@ -15,25 +15,19 @@ namespace app {
|
||||
|
||||
class PopupWindowPin : public ui::PopupWindow {
|
||||
public:
|
||||
PopupWindowPin(const std::string& text, ClickBehavior clickBehavior);
|
||||
PopupWindowPin(const std::string& text,
|
||||
const ClickBehavior clickBehavior,
|
||||
const bool canPin = false);
|
||||
|
||||
void showPin(bool state);
|
||||
bool isPinned() const { return m_pin.isSelected(); }
|
||||
void setPinned(bool pinned);
|
||||
bool isPinned() const { return m_pinned; }
|
||||
void setPinned(const bool pinned);
|
||||
|
||||
protected:
|
||||
virtual bool onProcessMessage(ui::Message* msg) override;
|
||||
virtual void onWindowMovement() override;
|
||||
|
||||
// The pin. Your derived class must add this pin in some place of
|
||||
// the frame as a children, and you must to remove the pin from the
|
||||
// parent in your class's dtor.
|
||||
ui::CheckBox* getPin() { return &m_pin; }
|
||||
|
||||
private:
|
||||
void onPinClick(ui::Event& ev);
|
||||
|
||||
ui::CheckBox m_pin;
|
||||
bool m_pinned;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -60,6 +60,11 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void onSizeHint(SizeHintEvent& ev) override {
|
||||
ev.setSizeHint(SkinTheme::instance()->parts.windowCloseButtonNormal()->size());
|
||||
}
|
||||
|
||||
void onClick(Event& ev) override {
|
||||
Button::onClick(ev);
|
||||
closeWindow();
|
||||
@ -1666,6 +1671,7 @@ void SkinTheme::paintWindowButton(ui::PaintEvent& ev)
|
||||
else
|
||||
part = parts.windowCloseButtonNormal();
|
||||
|
||||
g->fillRect(BGCOLOR, rc);
|
||||
g->drawRgbaSurface(part->bitmap(0), rc.x, rc.y);
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,9 @@ namespace ui {
|
||||
using namespace gfx;
|
||||
|
||||
PopupWindow::PopupWindow(const std::string& text,
|
||||
ClickBehavior clickBehavior,
|
||||
EnterBehavior enterBehavior)
|
||||
const ClickBehavior clickBehavior,
|
||||
const EnterBehavior enterBehavior,
|
||||
const bool withCloseButton)
|
||||
: Window(text.empty() ? WithoutTitleBar: WithTitleBar, text)
|
||||
, m_clickBehavior(clickBehavior)
|
||||
, m_enterBehavior(enterBehavior)
|
||||
@ -33,7 +34,8 @@ PopupWindow::PopupWindow(const std::string& text,
|
||||
setWantFocus(false);
|
||||
setAlign(LEFT | TOP);
|
||||
|
||||
removeDecorativeWidgets();
|
||||
if (!withCloseButton)
|
||||
removeDecorativeWidgets();
|
||||
|
||||
initTheme();
|
||||
noBorderNoChildSpacing();
|
||||
|
@ -26,8 +26,9 @@ namespace ui {
|
||||
};
|
||||
|
||||
PopupWindow(const std::string& text = "",
|
||||
ClickBehavior clickBehavior = ClickBehavior::CloseOnClickOutsideHotRegion,
|
||||
EnterBehavior enterBehavior = EnterBehavior::CloseOnEnter);
|
||||
const ClickBehavior clickBehavior = ClickBehavior::CloseOnClickOutsideHotRegion,
|
||||
const EnterBehavior enterBehavior = EnterBehavior::CloseOnEnter,
|
||||
const bool withCloseButton = false);
|
||||
~PopupWindow();
|
||||
|
||||
// Sets the hot region. This region indicates the area where the
|
||||
|
Loading…
x
Reference in New Issue
Block a user