mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-04 15:40:10 +00:00
Save ColorBar box size in preferences
This commit is contained in:
parent
a1d2b5e0dc
commit
fd62a60472
@ -81,6 +81,9 @@
|
||||
<section id="news">
|
||||
<option id="cache_file" type="std::string" />
|
||||
</section>
|
||||
<section id="color_bar">
|
||||
<option id="box_size" type="int" default="7" />
|
||||
</section>
|
||||
</global>
|
||||
|
||||
<tool>
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "app/ui/color_bar.h"
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/cmd/remap_colors.h"
|
||||
#include "app/cmd/set_palette.h"
|
||||
#include "app/color.h"
|
||||
@ -20,6 +21,7 @@
|
||||
#include "app/context_access.h"
|
||||
#include "app/ini_file.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/transaction.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
@ -75,7 +77,8 @@ ColorBar* ColorBar::m_instance = NULL;
|
||||
ColorBar::ColorBar(int align)
|
||||
: Box(align)
|
||||
, m_paletteButton("Edit Palette")
|
||||
, m_paletteView(true, this)
|
||||
, m_paletteView(true, this,
|
||||
App::instance()->preferences().colorBar.boxSize() * guiscale())
|
||||
, m_remapButton("Remap")
|
||||
, m_fgColor(app::Color::fromRgb(255, 255, 255), IMAGE_RGB)
|
||||
, m_bgColor(app::Color::fromRgb(0, 0, 0), IMAGE_RGB)
|
||||
@ -269,6 +272,11 @@ void ColorBar::onPaletteViewRemapColors(const Remap& remap, const Palette* newPa
|
||||
}
|
||||
}
|
||||
|
||||
void ColorBar::onPaletteViewChangeSize(int boxsize)
|
||||
{
|
||||
App::instance()->preferences().colorBar.boxSize(boxsize / guiscale());
|
||||
}
|
||||
|
||||
void ColorBar::onFgColorButtonChange(const app::Color& color)
|
||||
{
|
||||
if (!m_lock)
|
||||
|
@ -64,6 +64,7 @@ namespace app {
|
||||
// PaletteViewDelegate impl
|
||||
void onPaletteViewIndexChange(int index, ui::MouseButtons buttons) override;
|
||||
void onPaletteViewRemapColors(const doc::Remap& remap, const doc::Palette* newPalette) override;
|
||||
void onPaletteViewChangeSize(int boxsize) override;
|
||||
|
||||
private:
|
||||
class ScrollableView : public ui::View {
|
||||
|
@ -55,7 +55,7 @@ ColorSelector::ColorSelector()
|
||||
, m_vbox(JI_VERTICAL)
|
||||
, m_topBox(JI_HORIZONTAL)
|
||||
, m_color(app::Color::fromMask())
|
||||
, m_colorPalette(false, this)
|
||||
, m_colorPalette(false, this, 7*guiscale())
|
||||
, m_indexButton("Index", 1, kButtonWidget)
|
||||
, m_rgbButton("RGB", 1, kButtonWidget)
|
||||
, m_hsvButton("HSB", 1, kButtonWidget)
|
||||
|
@ -51,13 +51,13 @@ WidgetType palette_view_type()
|
||||
return type;
|
||||
}
|
||||
|
||||
PaletteView::PaletteView(bool editable, PaletteViewDelegate* delegate)
|
||||
PaletteView::PaletteView(bool editable, PaletteViewDelegate* delegate, int boxsize)
|
||||
: Widget(palette_view_type())
|
||||
, m_state(State::WAITING)
|
||||
, m_editable(editable)
|
||||
, m_delegate(delegate)
|
||||
, m_columns(16)
|
||||
, m_boxsize(7*guiscale())
|
||||
, m_boxsize(boxsize)
|
||||
, m_currentEntry(-1)
|
||||
, m_rangeAnchor(-1)
|
||||
, m_selectedEntries(Palette::MaxColors, false)
|
||||
@ -248,6 +248,9 @@ bool PaletteView::onProcessMessage(Message* msg)
|
||||
int z = delta.x - delta.y;
|
||||
m_boxsize += z * guiscale();
|
||||
m_boxsize = MID(4*guiscale(), m_boxsize, 32*guiscale());
|
||||
if (m_delegate)
|
||||
m_delegate->onPaletteViewChangeSize(m_boxsize);
|
||||
|
||||
view->layout();
|
||||
}
|
||||
else {
|
||||
|
@ -28,13 +28,14 @@ namespace app {
|
||||
virtual ~PaletteViewDelegate() { }
|
||||
virtual void onPaletteViewIndexChange(int index, ui::MouseButtons buttons) { }
|
||||
virtual void onPaletteViewRemapColors(const doc::Remap& remap, const doc::Palette* newPalette) { }
|
||||
virtual void onPaletteViewChangeSize(int boxsize) { }
|
||||
};
|
||||
|
||||
class PaletteView : public ui::Widget {
|
||||
public:
|
||||
typedef std::vector<bool> SelectedEntries;
|
||||
|
||||
PaletteView(bool editable, PaletteViewDelegate* delegate);
|
||||
PaletteView(bool editable, PaletteViewDelegate* delegate, int boxsize);
|
||||
|
||||
int getColumns() const { return m_columns; }
|
||||
void setColumns(int columns);
|
||||
|
Loading…
x
Reference in New Issue
Block a user