mirror of https://github.com/aseprite/aseprite.git
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)
|
ColorPopup::ColorPopup(bool canPin)
|
||||||
: PopupWindowPin("Color Selector", ClickBehavior::CloseOnClickInOtherWindow)
|
: PopupWindowPin("Color Selector",
|
||||||
|
ClickBehavior::CloseOnClickInOtherWindow,
|
||||||
|
canPin)
|
||||||
, m_vbox(VERTICAL)
|
, m_vbox(VERTICAL)
|
||||||
, m_topBox(HORIZONTAL)
|
, m_topBox(HORIZONTAL)
|
||||||
, m_color(app::Color::fromMask())
|
, m_color(app::Color::fromMask())
|
||||||
|
|
@ -77,12 +79,22 @@ ColorPopup::ColorPopup(bool canPin)
|
||||||
m_topBox.addChild(&m_colorType);
|
m_topBox.addChild(&m_colorType);
|
||||||
m_topBox.addChild(new Separator("", VERTICAL));
|
m_topBox.addChild(new Separator("", VERTICAL));
|
||||||
m_topBox.addChild(&m_hexColorEntry);
|
m_topBox.addChild(&m_hexColorEntry);
|
||||||
|
|
||||||
|
// Move close button (decorative widget) inside the m_topBox
|
||||||
{
|
{
|
||||||
Box* miniVbox = new Box(VERTICAL);
|
Widget* closeButton = nullptr;
|
||||||
miniVbox->addChild(getPin());
|
WidgetsList decorators;
|
||||||
|
for (auto child : children()) {
|
||||||
|
if (child->isDecorative()) {
|
||||||
|
closeButton = child;
|
||||||
|
removeChild(child);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
m_topBox.addChild(new BoxFiller);
|
m_topBox.addChild(new BoxFiller);
|
||||||
m_topBox.addChild(miniVbox);
|
m_topBox.addChild(closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vbox.addChild(&m_topBox);
|
m_vbox.addChild(&m_topBox);
|
||||||
m_vbox.addChild(&m_colorPaletteContainer);
|
m_vbox.addChild(&m_colorPaletteContainer);
|
||||||
m_vbox.addChild(&m_rgbSliders);
|
m_vbox.addChild(&m_rgbSliders);
|
||||||
|
|
@ -98,9 +110,6 @@ ColorPopup::ColorPopup(bool canPin)
|
||||||
m_graySlider.ColorChange.connect(&ColorPopup::onColorSlidersChange, this);
|
m_graySlider.ColorChange.connect(&ColorPopup::onColorSlidersChange, this);
|
||||||
m_hexColorEntry.ColorChange.connect(&ColorPopup::onColorHexEntryChange, this);
|
m_hexColorEntry.ColorChange.connect(&ColorPopup::onColorHexEntryChange, this);
|
||||||
|
|
||||||
if (!m_canPin)
|
|
||||||
showPin(false);
|
|
||||||
|
|
||||||
selectColorType(app::Color::RgbType);
|
selectColorType(app::Color::RgbType);
|
||||||
setSizeHint(gfx::Size(300*guiscale(), sizeHint().h));
|
setSizeHint(gfx::Size(300*guiscale(), sizeHint().h));
|
||||||
|
|
||||||
|
|
@ -112,7 +121,6 @@ ColorPopup::ColorPopup(bool canPin)
|
||||||
|
|
||||||
ColorPopup::~ColorPopup()
|
ColorPopup::~ColorPopup()
|
||||||
{
|
{
|
||||||
getPin()->parent()->removeChild(getPin());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPopup::setColor(const app::Color& color, SetColorOptions options)
|
void ColorPopup::setColor(const app::Color& color, SetColorOptions options)
|
||||||
|
|
|
||||||
|
|
@ -26,45 +26,20 @@ namespace app {
|
||||||
using namespace app::skin;
|
using namespace app::skin;
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
PopupWindowPin::PopupWindowPin(const std::string& text, ClickBehavior clickBehavior)
|
PopupWindowPin::PopupWindowPin(const std::string& text,
|
||||||
: PopupWindow(text, clickBehavior)
|
const ClickBehavior clickBehavior,
|
||||||
, m_pin("")
|
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);
|
m_pinned = pinned;
|
||||||
}
|
if (m_pinned)
|
||||||
|
|
||||||
void PopupWindowPin::setPinned(bool pinned)
|
|
||||||
{
|
|
||||||
m_pin.setSelected(pinned);
|
|
||||||
|
|
||||||
Event ev(this);
|
|
||||||
onPinClick(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopupWindowPin::onPinClick(Event& ev)
|
|
||||||
{
|
|
||||||
if (m_pin.isSelected()) {
|
|
||||||
makeFloating();
|
makeFloating();
|
||||||
}
|
|
||||||
else {
|
|
||||||
gfx::Rect rc = bounds();
|
|
||||||
rc.enlarge(8);
|
|
||||||
setHotRegion(gfx::Region(rc));
|
|
||||||
makeFixed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PopupWindowPin::onProcessMessage(Message* msg)
|
bool PopupWindowPin::onProcessMessage(Message* msg)
|
||||||
|
|
@ -72,7 +47,7 @@ bool PopupWindowPin::onProcessMessage(Message* msg)
|
||||||
switch (msg->type()) {
|
switch (msg->type()) {
|
||||||
|
|
||||||
case kOpenMessage: {
|
case kOpenMessage: {
|
||||||
if (!isPinned())
|
if (!m_pinned)
|
||||||
makeFixed();
|
makeFixed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +63,7 @@ void PopupWindowPin::onWindowMovement()
|
||||||
|
|
||||||
// If the window isn't pinned and we move it, we can automatically
|
// If the window isn't pinned and we move it, we can automatically
|
||||||
// pin it.
|
// pin it.
|
||||||
if (!m_pin.isSelected())
|
if (!m_pinned)
|
||||||
setPinned(true);
|
setPinned(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,25 +15,19 @@ namespace app {
|
||||||
|
|
||||||
class PopupWindowPin : public ui::PopupWindow {
|
class PopupWindowPin : public ui::PopupWindow {
|
||||||
public:
|
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_pinned; }
|
||||||
bool isPinned() const { return m_pin.isSelected(); }
|
void setPinned(const bool pinned);
|
||||||
void setPinned(bool pinned);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool onProcessMessage(ui::Message* msg) override;
|
virtual bool onProcessMessage(ui::Message* msg) override;
|
||||||
virtual void onWindowMovement() 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:
|
private:
|
||||||
void onPinClick(ui::Event& ev);
|
bool m_pinned;
|
||||||
|
|
||||||
ui::CheckBox m_pin;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void onSizeHint(SizeHintEvent& ev) override {
|
||||||
|
ev.setSizeHint(SkinTheme::instance()->parts.windowCloseButtonNormal()->size());
|
||||||
|
}
|
||||||
|
|
||||||
void onClick(Event& ev) override {
|
void onClick(Event& ev) override {
|
||||||
Button::onClick(ev);
|
Button::onClick(ev);
|
||||||
closeWindow();
|
closeWindow();
|
||||||
|
|
@ -1666,6 +1671,7 @@ void SkinTheme::paintWindowButton(ui::PaintEvent& ev)
|
||||||
else
|
else
|
||||||
part = parts.windowCloseButtonNormal();
|
part = parts.windowCloseButtonNormal();
|
||||||
|
|
||||||
|
g->fillRect(BGCOLOR, rc);
|
||||||
g->drawRgbaSurface(part->bitmap(0), rc.x, rc.y);
|
g->drawRgbaSurface(part->bitmap(0), rc.x, rc.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,9 @@ namespace ui {
|
||||||
using namespace gfx;
|
using namespace gfx;
|
||||||
|
|
||||||
PopupWindow::PopupWindow(const std::string& text,
|
PopupWindow::PopupWindow(const std::string& text,
|
||||||
ClickBehavior clickBehavior,
|
const ClickBehavior clickBehavior,
|
||||||
EnterBehavior enterBehavior)
|
const EnterBehavior enterBehavior,
|
||||||
|
const bool withCloseButton)
|
||||||
: Window(text.empty() ? WithoutTitleBar: WithTitleBar, text)
|
: Window(text.empty() ? WithoutTitleBar: WithTitleBar, text)
|
||||||
, m_clickBehavior(clickBehavior)
|
, m_clickBehavior(clickBehavior)
|
||||||
, m_enterBehavior(enterBehavior)
|
, m_enterBehavior(enterBehavior)
|
||||||
|
|
@ -33,7 +34,8 @@ PopupWindow::PopupWindow(const std::string& text,
|
||||||
setWantFocus(false);
|
setWantFocus(false);
|
||||||
setAlign(LEFT | TOP);
|
setAlign(LEFT | TOP);
|
||||||
|
|
||||||
removeDecorativeWidgets();
|
if (!withCloseButton)
|
||||||
|
removeDecorativeWidgets();
|
||||||
|
|
||||||
initTheme();
|
initTheme();
|
||||||
noBorderNoChildSpacing();
|
noBorderNoChildSpacing();
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,9 @@ namespace ui {
|
||||||
};
|
};
|
||||||
|
|
||||||
PopupWindow(const std::string& text = "",
|
PopupWindow(const std::string& text = "",
|
||||||
ClickBehavior clickBehavior = ClickBehavior::CloseOnClickOutsideHotRegion,
|
const ClickBehavior clickBehavior = ClickBehavior::CloseOnClickOutsideHotRegion,
|
||||||
EnterBehavior enterBehavior = EnterBehavior::CloseOnEnter);
|
const EnterBehavior enterBehavior = EnterBehavior::CloseOnEnter,
|
||||||
|
const bool withCloseButton = false);
|
||||||
~PopupWindow();
|
~PopupWindow();
|
||||||
|
|
||||||
// Sets the hot region. This region indicates the area where the
|
// Sets the hot region. This region indicates the area where the
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue