mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-09 18:44:46 +00:00
parent
2ac04c1c16
commit
7278f649f4
@ -401,9 +401,23 @@ void PaletteEntryEditor::onCloseWindow()
|
|||||||
ColorBar::instance()->setPaletteEditorButtonState(false);
|
ColorBar::instance()->setPaletteEditorButtonState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaletteEntryEditor::onFgBgColorChange(const app::Color& color)
|
void PaletteEntryEditor::onFgBgColorChange(const app::Color& _color)
|
||||||
{
|
{
|
||||||
if (color.isValid() && color.getType() == app::Color::IndexType) {
|
app::Color color = _color;
|
||||||
|
|
||||||
|
if (!color.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (color.getType() != app::Color::IndexType) {
|
||||||
|
PaletteView* paletteView = ColorBar::instance()->getPaletteView();
|
||||||
|
int index = paletteView->getSelectedEntry();
|
||||||
|
if (index < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
color = app::Color::fromIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color.getType() == app::Color::IndexType) {
|
||||||
setColor(color);
|
setColor(color);
|
||||||
resetRelativeInfo();
|
resetRelativeInfo();
|
||||||
}
|
}
|
||||||
|
@ -220,14 +220,20 @@ app::Color ColorBar::getBgColor()
|
|||||||
void ColorBar::setFgColor(const app::Color& color)
|
void ColorBar::setFgColor(const app::Color& color)
|
||||||
{
|
{
|
||||||
m_fgColor.setColor(color);
|
m_fgColor.setColor(color);
|
||||||
m_paletteView.invalidate();
|
|
||||||
|
if (!m_lock)
|
||||||
|
onColorButtonChange(color);
|
||||||
|
|
||||||
FgColorChange(color);
|
FgColorChange(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorBar::setBgColor(const app::Color& color)
|
void ColorBar::setBgColor(const app::Color& color)
|
||||||
{
|
{
|
||||||
m_bgColor.setColor(color);
|
m_bgColor.setColor(color);
|
||||||
m_paletteView.invalidate();
|
|
||||||
|
if (!m_lock)
|
||||||
|
onColorButtonChange(color);
|
||||||
|
|
||||||
BgColorChange(color);
|
BgColorChange(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,8 +476,8 @@ void ColorBar::onFgColorButtonChange(const app::Color& color)
|
|||||||
m_paletteView.invalidate();
|
m_paletteView.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
FgColorChange(color);
|
|
||||||
onColorButtonChange(color);
|
onColorButtonChange(color);
|
||||||
|
FgColorChange(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorBar::onBgColorButtonChange(const app::Color& color)
|
void ColorBar::onBgColorButtonChange(const app::Color& color)
|
||||||
@ -481,26 +487,29 @@ void ColorBar::onBgColorButtonChange(const app::Color& color)
|
|||||||
m_paletteView.invalidate();
|
m_paletteView.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
BgColorChange(color);
|
|
||||||
onColorButtonChange(color);
|
onColorButtonChange(color);
|
||||||
|
BgColorChange(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorBar::onColorButtonChange(const app::Color& color)
|
void ColorBar::onColorButtonChange(const app::Color& color)
|
||||||
{
|
{
|
||||||
if (color.getType() == app::Color::IndexType)
|
if (color.getType() == app::Color::IndexType)
|
||||||
m_paletteView.selectColor(color.getIndex());
|
m_paletteView.selectColor(color.getIndex());
|
||||||
|
else {
|
||||||
|
m_paletteView.selectExactMatchColor(color);
|
||||||
|
|
||||||
|
// As foreground or background color changed, we've to redraw the
|
||||||
|
// palette view fg/bg indicators.
|
||||||
|
m_paletteView.invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorBar::onPickSpectrum(const app::Color& color, ui::MouseButtons buttons)
|
void ColorBar::onPickSpectrum(const app::Color& color, ui::MouseButtons buttons)
|
||||||
{
|
{
|
||||||
m_lock = true;
|
|
||||||
|
|
||||||
if ((buttons & kButtonRight) == kButtonRight)
|
if ((buttons & kButtonRight) == kButtonRight)
|
||||||
setBgColor(color);
|
setBgColor(color);
|
||||||
else
|
else
|
||||||
setFgColor(color);
|
setFgColor(color);
|
||||||
|
|
||||||
m_lock = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorBar::onReverseColors()
|
void ColorBar::onReverseColors()
|
||||||
|
@ -121,6 +121,13 @@ void PaletteView::selectColor(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaletteView::selectExactMatchColor(const app::Color& color)
|
||||||
|
{
|
||||||
|
int index = findExactIndex(color);
|
||||||
|
if (index >= 0)
|
||||||
|
selectColor(index);
|
||||||
|
}
|
||||||
|
|
||||||
void PaletteView::selectRange(int index1, int index2)
|
void PaletteView::selectRange(int index1, int index2)
|
||||||
{
|
{
|
||||||
m_rangeAnchor = index1;
|
m_rangeAnchor = index1;
|
||||||
@ -763,7 +770,8 @@ void PaletteView::setCursor()
|
|||||||
ui::set_mouse_cursor(kArrowCursor);
|
ui::set_mouse_cursor(kArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaletteView::findExactIndex(const app::Color& color) const
|
// static
|
||||||
|
int PaletteView::findExactIndex(const app::Color& color)
|
||||||
{
|
{
|
||||||
switch (color.getType()) {
|
switch (color.getType()) {
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ namespace app {
|
|||||||
|
|
||||||
void deselect();
|
void deselect();
|
||||||
void selectColor(int index);
|
void selectColor(int index);
|
||||||
|
void selectExactMatchColor(const app::Color& color);
|
||||||
void selectRange(int index1, int index2);
|
void selectRange(int index1, int index2);
|
||||||
|
|
||||||
int getSelectedEntry() const;
|
int getSelectedEntry() const;
|
||||||
@ -123,7 +124,7 @@ namespace app {
|
|||||||
bool pickedXY(const doc::PalettePicks& entries, int i, int dx, int dy) const;
|
bool pickedXY(const doc::PalettePicks& entries, int i, int dx, int dy) const;
|
||||||
void updateCopyFlag(ui::Message* msg);
|
void updateCopyFlag(ui::Message* msg);
|
||||||
void setCursor();
|
void setCursor();
|
||||||
int findExactIndex(const app::Color& color) const;
|
static int findExactIndex(const app::Color& color);
|
||||||
|
|
||||||
State m_state;
|
State m_state;
|
||||||
bool m_editable;
|
bool m_editable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user