mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-18 20:42:31 +00:00
Make fg/bg color selector dialogs resizable (fix #1250)
This commit is contained in:
parent
bd219ada10
commit
75894073d4
@ -279,7 +279,8 @@ void ColorButton::openSelectorDialog()
|
|||||||
|
|
||||||
gfx::Rect winBounds = m_windowDefaultBounds;
|
gfx::Rect winBounds = m_windowDefaultBounds;
|
||||||
if (!pinned) {
|
if (!pinned) {
|
||||||
winBounds = m_window->bounds();
|
winBounds = gfx::Rect(m_window->bounds().origin(),
|
||||||
|
m_window->sizeHint());
|
||||||
winBounds.x = MID(0, bounds().x, ui::display_w()-winBounds.w);
|
winBounds.x = MID(0, bounds().x, ui::display_w()-winBounds.w);
|
||||||
if (bounds().y2() <= ui::display_h()-winBounds.h)
|
if (bounds().y2() <= ui::display_h()-winBounds.h)
|
||||||
winBounds.y = MAX(0, bounds().y2());
|
winBounds.y = MAX(0, bounds().y2());
|
||||||
|
@ -55,6 +55,7 @@ ColorPopup::ColorPopup(bool canPin)
|
|||||||
, m_colorPalette(false, PaletteView::SelectOneColor, this, 7*guiscale())
|
, m_colorPalette(false, PaletteView::SelectOneColor, this, 7*guiscale())
|
||||||
, m_colorType(5)
|
, m_colorType(5)
|
||||||
, m_maskLabel("Transparent Color Selected")
|
, m_maskLabel("Transparent Color Selected")
|
||||||
|
, m_canPin(canPin)
|
||||||
, m_disableHexUpdate(false)
|
, m_disableHexUpdate(false)
|
||||||
{
|
{
|
||||||
m_colorType.addItem("Index");
|
m_colorType.addItem("Index");
|
||||||
@ -94,7 +95,7 @@ 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 (!canPin)
|
if (!m_canPin)
|
||||||
showPin(false);
|
showPin(false);
|
||||||
|
|
||||||
selectColorType(app::Color::RgbType);
|
selectColorType(app::Color::RgbType);
|
||||||
@ -135,6 +136,26 @@ app::Color ColorPopup::getColor() const
|
|||||||
return m_color;
|
return m_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorPopup::onMakeFloating()
|
||||||
|
{
|
||||||
|
PopupWindowPin::onMakeFloating();
|
||||||
|
|
||||||
|
if (m_canPin) {
|
||||||
|
setSizeable(true);
|
||||||
|
setMoveable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorPopup::onMakeFixed()
|
||||||
|
{
|
||||||
|
PopupWindowPin::onMakeFixed();
|
||||||
|
|
||||||
|
if (m_canPin) {
|
||||||
|
setSizeable(false);
|
||||||
|
setMoveable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ColorPopup::onPaletteViewIndexChange(int index, ui::MouseButtons buttons)
|
void ColorPopup::onPaletteViewIndexChange(int index, ui::MouseButtons buttons)
|
||||||
{
|
{
|
||||||
setColorWithSignal(app::Color::fromIndex(index));
|
setColorWithSignal(app::Color::fromIndex(index));
|
||||||
|
@ -41,6 +41,8 @@ namespace app {
|
|||||||
base::Signal1<void, const app::Color&> ColorChange;
|
base::Signal1<void, const app::Color&> ColorChange;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void onMakeFloating() override;
|
||||||
|
void onMakeFixed() override;
|
||||||
void onColorSlidersChange(ColorSlidersChangeEvent& ev);
|
void onColorSlidersChange(ColorSlidersChangeEvent& ev);
|
||||||
void onColorHexEntryChange(const app::Color& color);
|
void onColorHexEntryChange(const app::Color& color);
|
||||||
void onColorTypeClick();
|
void onColorTypeClick();
|
||||||
@ -66,6 +68,7 @@ namespace app {
|
|||||||
GraySlider m_graySlider;
|
GraySlider m_graySlider;
|
||||||
ui::Label m_maskLabel;
|
ui::Label m_maskLabel;
|
||||||
base::ScopedConnection m_onPaletteChangeConn;
|
base::ScopedConnection m_onPaletteChangeConn;
|
||||||
|
bool m_canPin;
|
||||||
|
|
||||||
// This variable is used to avoid updating the m_hexColorEntry text
|
// This variable is used to avoid updating the m_hexColorEntry text
|
||||||
// when the color change is generated from a
|
// when the color change is generated from a
|
||||||
|
@ -81,19 +81,14 @@ bool PopupWindowPin::onProcessMessage(Message* msg)
|
|||||||
return PopupWindow::onProcessMessage(msg);
|
return PopupWindow::onProcessMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWindowPin::onHitTest(HitTestEvent& ev)
|
void PopupWindowPin::onWindowMovement()
|
||||||
{
|
{
|
||||||
PopupWindow::onHitTest(ev);
|
PopupWindow::onWindowMovement();
|
||||||
|
|
||||||
if ((m_pin.isSelected()) &&
|
// If the window isn't pinned and we move it, we can automatically
|
||||||
(ev.hit() == HitTestClient)) {
|
// pin it.
|
||||||
if (ev.point().x <= bounds().x+2)
|
if (!m_pin.isSelected())
|
||||||
ev.setHit(HitTestBorderW);
|
setPinned(true);
|
||||||
else if (ev.point().x >= bounds().x2()-3)
|
|
||||||
ev.setHit(HitTestBorderE);
|
|
||||||
else
|
|
||||||
ev.setHit(HitTestCaption);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -23,7 +23,7 @@ namespace app {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool onProcessMessage(ui::Message* msg) override;
|
virtual bool onProcessMessage(ui::Message* msg) override;
|
||||||
virtual void onHitTest(ui::HitTestEvent& ev) override;
|
virtual void onWindowMovement() override;
|
||||||
|
|
||||||
// The pin. Your derived class must add this pin in some place of
|
// 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
|
// the frame as a children, and you must to remove the pin from the
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2001-2013, 2015 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -26,6 +26,7 @@ PopupWindow::PopupWindow(const std::string& text,
|
|||||||
, m_clickBehavior(clickBehavior)
|
, m_clickBehavior(clickBehavior)
|
||||||
, m_enterBehavior(enterBehavior)
|
, m_enterBehavior(enterBehavior)
|
||||||
, m_filtering(false)
|
, m_filtering(false)
|
||||||
|
, m_fixed(false)
|
||||||
{
|
{
|
||||||
setSizeable(false);
|
setSizeable(false);
|
||||||
setMoveable(false);
|
setMoveable(false);
|
||||||
@ -64,12 +65,18 @@ void PopupWindow::makeFloating()
|
|||||||
{
|
{
|
||||||
stopFilteringMessages();
|
stopFilteringMessages();
|
||||||
setMoveable(true);
|
setMoveable(true);
|
||||||
|
m_fixed = false;
|
||||||
|
|
||||||
|
onMakeFloating();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWindow::makeFixed()
|
void PopupWindow::makeFixed()
|
||||||
{
|
{
|
||||||
startFilteringMessages();
|
startFilteringMessages();
|
||||||
setMoveable(false);
|
setMoveable(false);
|
||||||
|
m_fixed = true;
|
||||||
|
|
||||||
|
onMakeFixed();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PopupWindow::onProcessMessage(Message* msg)
|
bool PopupWindow::onProcessMessage(Message* msg)
|
||||||
@ -91,7 +98,7 @@ bool PopupWindow::onProcessMessage(Message* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kMouseLeaveMessage:
|
case kMouseLeaveMessage:
|
||||||
if (m_hotRegion.isEmpty() && !isMoveable())
|
if (m_hotRegion.isEmpty() && m_fixed)
|
||||||
closeWindow(nullptr);
|
closeWindow(nullptr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -139,7 +146,7 @@ bool PopupWindow::onProcessMessage(Message* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kMouseMoveMessage:
|
case kMouseMoveMessage:
|
||||||
if (!isMoveable() &&
|
if (m_fixed &&
|
||||||
!m_hotRegion.isEmpty() &&
|
!m_hotRegion.isEmpty() &&
|
||||||
manager()->getCapture() == NULL) {
|
manager()->getCapture() == NULL) {
|
||||||
gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
|
gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
|
||||||
@ -202,19 +209,34 @@ void PopupWindow::onInitTheme(InitThemeEvent& ev)
|
|||||||
|
|
||||||
void PopupWindow::onHitTest(HitTestEvent& ev)
|
void PopupWindow::onHitTest(HitTestEvent& ev)
|
||||||
{
|
{
|
||||||
|
Window::onHitTest(ev);
|
||||||
|
|
||||||
Widget* picked = manager()->pick(ev.point());
|
Widget* picked = manager()->pick(ev.point());
|
||||||
if (picked) {
|
if (picked) {
|
||||||
WidgetType type = picked->type();
|
WidgetType type = picked->type();
|
||||||
if ((type == kWindowWidget && picked == this) ||
|
if (type == kWindowWidget && picked == this) {
|
||||||
type == kBoxWidget ||
|
if (isSizeable() && (ev.hit() == HitTestBorderNW ||
|
||||||
type == kLabelWidget ||
|
ev.hit() == HitTestBorderN ||
|
||||||
type == kGridWidget ||
|
ev.hit() == HitTestBorderNE ||
|
||||||
type == kSeparatorWidget) {
|
ev.hit() == HitTestBorderE ||
|
||||||
ev.setHit(HitTestCaption);
|
ev.hit() == HitTestBorderSE ||
|
||||||
return;
|
ev.hit() == HitTestBorderS ||
|
||||||
|
ev.hit() == HitTestBorderSW ||
|
||||||
|
ev.hit() == HitTestBorderW)) {
|
||||||
|
// Use the hit value from Window::onHitTest()
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ev.setHit(isMoveable() ? HitTestCaption: HitTestClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == kBoxWidget ||
|
||||||
|
type == kLabelWidget ||
|
||||||
|
type == kGridWidget ||
|
||||||
|
type == kSeparatorWidget) {
|
||||||
|
ev.setHit(isMoveable() ? HitTestCaption: HitTestClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Window::onHitTest(ev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupWindow::startFilteringMessages()
|
void PopupWindow::startFilteringMessages()
|
||||||
@ -241,4 +263,14 @@ void PopupWindow::stopFilteringMessages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupWindow::onMakeFloating()
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupWindow::onMakeFixed()
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2001-2013, 2015 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -46,6 +46,9 @@ namespace ui {
|
|||||||
void onInitTheme(InitThemeEvent& ev) override;
|
void onInitTheme(InitThemeEvent& ev) override;
|
||||||
void onHitTest(HitTestEvent& ev) override;
|
void onHitTest(HitTestEvent& ev) override;
|
||||||
|
|
||||||
|
virtual void onMakeFloating();
|
||||||
|
virtual void onMakeFixed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startFilteringMessages();
|
void startFilteringMessages();
|
||||||
void stopFilteringMessages();
|
void stopFilteringMessages();
|
||||||
@ -54,6 +57,7 @@ namespace ui {
|
|||||||
EnterBehavior m_enterBehavior;
|
EnterBehavior m_enterBehavior;
|
||||||
gfx::Region m_hotRegion;
|
gfx::Region m_hotRegion;
|
||||||
bool m_filtering;
|
bool m_filtering;
|
||||||
|
bool m_fixed;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2001-2015 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -182,6 +182,11 @@ void Window::onWindowResize()
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::onWindowMovement()
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
void Window::remapWindow()
|
void Window::remapWindow()
|
||||||
{
|
{
|
||||||
if (m_isAutoRemap) {
|
if (m_isAutoRemap) {
|
||||||
@ -579,6 +584,8 @@ void Window::moveWindow(const gfx::Rect& rect, bool use_blit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
manager->invalidateDisplayRegion(invalidManagerRegion);
|
manager->invalidateDisplayRegion(invalidManagerRegion);
|
||||||
|
|
||||||
|
onWindowMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2001-2013, 2015 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -46,6 +46,7 @@ namespace ui {
|
|||||||
bool isDesktop() const { return m_isDesktop; }
|
bool isDesktop() const { return m_isDesktop; }
|
||||||
bool isOnTop() const { return m_isOnTop; }
|
bool isOnTop() const { return m_isOnTop; }
|
||||||
bool isWantFocus() const { return m_isWantFocus; }
|
bool isWantFocus() const { return m_isWantFocus; }
|
||||||
|
bool isSizeable() const { return m_isSizeable; }
|
||||||
bool isMoveable() const { return m_isMoveable; }
|
bool isMoveable() const { return m_isMoveable; }
|
||||||
|
|
||||||
HitTest hitTest(const gfx::Point& point);
|
HitTest hitTest(const gfx::Point& point);
|
||||||
@ -67,6 +68,7 @@ namespace ui {
|
|||||||
virtual void onClose(CloseEvent& ev);
|
virtual void onClose(CloseEvent& ev);
|
||||||
virtual void onHitTest(HitTestEvent& ev);
|
virtual void onHitTest(HitTestEvent& ev);
|
||||||
virtual void onWindowResize();
|
virtual void onWindowResize();
|
||||||
|
virtual void onWindowMovement();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void windowSetPosition(const gfx::Rect& rect);
|
void windowSetPosition(const gfx::Rect& rect);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user