mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-03 20:54:01 +00:00
Add PaletteIndexChangeEvent for PaletteView::IndexChange event
This was added to avoid deprecated jmouse_b(0) function in ColorBar::onPaletteIndexChange().
This commit is contained in:
parent
a35c32dcfe
commit
0a7bbfba6b
@ -202,14 +202,13 @@ void ColorBar::onPaletteButtonDropDownClick()
|
||||
}
|
||||
}
|
||||
|
||||
void ColorBar::onPaletteIndexChange(int index)
|
||||
void ColorBar::onPaletteIndexChange(PaletteIndexChangeEvent& ev)
|
||||
{
|
||||
m_lock = true;
|
||||
|
||||
app::Color color = app::Color::fromIndex(index);
|
||||
app::Color color = app::Color::fromIndex(ev.index());
|
||||
|
||||
// TODO create a PaletteChangeEvent and take left/right mouse button from there
|
||||
if ((jmouse_b(0) & kButtonRight) == kButtonRight)
|
||||
if ((ev.buttons() & kButtonRight) == kButtonRight)
|
||||
setBgColor(color);
|
||||
else
|
||||
setFgColor(color);
|
||||
|
@ -35,6 +35,7 @@
|
||||
namespace app {
|
||||
class ColorButton;
|
||||
class PalettesLoader;
|
||||
class PaletteIndexChangeEvent;
|
||||
|
||||
class ColorBar : public ui::Box {
|
||||
static ColorBar* m_instance;
|
||||
@ -64,7 +65,7 @@ namespace app {
|
||||
protected:
|
||||
void onPaletteButtonClick();
|
||||
void onPaletteButtonDropDownClick();
|
||||
void onPaletteIndexChange(int index);
|
||||
void onPaletteIndexChange(PaletteIndexChangeEvent& ev);
|
||||
void onFgColorButtonChange(const app::Color& color);
|
||||
void onBgColorButtonChange(const app::Color& color);
|
||||
void onColorButtonChange(const app::Color& color);
|
||||
|
@ -172,9 +172,9 @@ app::Color ColorSelector::getColor() const
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void ColorSelector::onColorPaletteIndexChange(int index)
|
||||
void ColorSelector::onColorPaletteIndexChange(PaletteIndexChangeEvent& ev)
|
||||
{
|
||||
setColorWithSignal(app::Color::fromIndex(index));
|
||||
setColorWithSignal(app::Color::fromIndex(ev.index()));
|
||||
}
|
||||
|
||||
void ColorSelector::onColorSlidersChange(ColorSlidersChangeEvent& ev)
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "ui/view.h"
|
||||
|
||||
namespace app {
|
||||
class PaletteIndexChangeEvent;
|
||||
|
||||
class ColorSelector : public PopupWindowPin {
|
||||
public:
|
||||
@ -52,7 +53,7 @@ namespace app {
|
||||
Signal1<void, const app::Color&> ColorChange;
|
||||
|
||||
protected:
|
||||
void onColorPaletteIndexChange(int index);
|
||||
void onColorPaletteIndexChange(PaletteIndexChangeEvent& ev);;
|
||||
void onColorSlidersChange(ColorSlidersChangeEvent& ev);
|
||||
void onColorHexEntryChange(const app::Color& color);
|
||||
void onColorTypeButtonClick(ui::Event& ev);
|
||||
|
@ -238,7 +238,8 @@ bool PaletteView::onProcessMessage(Message* msg)
|
||||
selectColor(idx);
|
||||
|
||||
// Emit signal
|
||||
IndexChange(idx);
|
||||
PaletteIndexChangeEvent ev(this, idx, mouseMsg->buttons());
|
||||
IndexChange(ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,29 @@
|
||||
|
||||
#include "base/connection.h"
|
||||
#include "base/signal.h"
|
||||
#include "ui/event.h"
|
||||
#include "ui/mouse_buttons.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace app {
|
||||
|
||||
class PaletteIndexChangeEvent : public ui::Event {
|
||||
public:
|
||||
PaletteIndexChangeEvent(ui::Widget* source, int index, ui::MouseButtons buttons)
|
||||
: Event(source)
|
||||
, m_index(index)
|
||||
, m_buttons(buttons) { }
|
||||
|
||||
int index() const { return m_index; }
|
||||
ui::MouseButtons buttons() const { return m_buttons; }
|
||||
|
||||
private:
|
||||
int m_index;
|
||||
ui::MouseButtons m_buttons;
|
||||
};
|
||||
|
||||
class PaletteView : public ui::Widget {
|
||||
public:
|
||||
typedef std::vector<bool> SelectedEntries;
|
||||
@ -49,7 +66,7 @@ namespace app {
|
||||
app::Color getColorByPosition(int x, int y);
|
||||
|
||||
// Signals
|
||||
Signal1<void, int> IndexChange;
|
||||
Signal1<void, PaletteIndexChangeEvent&> IndexChange;
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(ui::Message* msg) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user