mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-27 06:35:16 +00:00
Add options to change palette entry size
This commit is contained in:
parent
5437ccd2a2
commit
d3dbc11451
10
data/gui.xml
10
data/gui.xml
@ -726,6 +726,16 @@
|
||||
<param name="switch" value="true" />
|
||||
</item>
|
||||
<separator />
|
||||
<item command="SetPaletteEntrySize" text="&Small Size">
|
||||
<param name="size" value="7" />
|
||||
</item>
|
||||
<item command="SetPaletteEntrySize" text="&Medium Size">
|
||||
<param name="size" value="11" />
|
||||
</item>
|
||||
<item command="SetPaletteEntrySize" text="&Large Size">
|
||||
<param name="size" value="17" />
|
||||
</item>
|
||||
<separator />
|
||||
<item command="LoadPalette" text="&Load Palette" />
|
||||
<item command="SavePalette" text="&Save Palette" />
|
||||
</menu>
|
||||
|
@ -87,7 +87,7 @@
|
||||
<option id="cache_file" type="std::string" />
|
||||
</section>
|
||||
<section id="color_bar">
|
||||
<option id="box_size" type="int" default="7" />
|
||||
<option id="box_size" type="int" default="11" />
|
||||
</section>
|
||||
<section id="updater">
|
||||
<option id="inits" type="int" default="0" migrate="Updater.Inits" />
|
||||
|
@ -203,6 +203,7 @@ add_library(app-lib
|
||||
commands/cmd_scroll.cpp
|
||||
commands/cmd_set_loop_section.cpp
|
||||
commands/cmd_set_palette.cpp
|
||||
commands/cmd_set_palette_entry_size.cpp
|
||||
commands/cmd_sprite_properties.cpp
|
||||
commands/cmd_sprite_size.cpp
|
||||
commands/cmd_switch_colors.cpp
|
||||
|
62
src/app/commands/cmd_set_palette_entry_size.cpp
Normal file
62
src/app/commands/cmd_set_palette_entry_size.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/commands/command.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
class SetPaletteEntrySizeCommand : public Command {
|
||||
public:
|
||||
SetPaletteEntrySizeCommand();
|
||||
Command* clone() const override { return new SetPaletteEntrySizeCommand(*this); }
|
||||
|
||||
protected:
|
||||
void onLoadParams(const Params& params) override;
|
||||
bool onChecked(Context* context) override;
|
||||
void onExecute(Context* context) override;
|
||||
|
||||
private:
|
||||
int m_size;
|
||||
};
|
||||
|
||||
SetPaletteEntrySizeCommand::SetPaletteEntrySizeCommand()
|
||||
: Command("SetPaletteEntrySize",
|
||||
"Set Palette Entry Size",
|
||||
CmdUIOnlyFlag)
|
||||
, m_size(7)
|
||||
{
|
||||
}
|
||||
|
||||
void SetPaletteEntrySizeCommand::onLoadParams(const Params& params)
|
||||
{
|
||||
if (params.has_param("size"))
|
||||
m_size = params.get_as<int>("size");
|
||||
}
|
||||
|
||||
bool SetPaletteEntrySizeCommand::onChecked(Context* context)
|
||||
{
|
||||
return (ColorBar::instance()->getPaletteView()->getBoxSize() == m_size);
|
||||
}
|
||||
|
||||
void SetPaletteEntrySizeCommand::onExecute(Context* context)
|
||||
{
|
||||
ColorBar::instance()->getPaletteView()->setBoxSize(m_size);
|
||||
}
|
||||
|
||||
Command* CommandFactory::createSetPaletteEntrySizeCommand()
|
||||
{
|
||||
return new SetPaletteEntrySizeCommand;
|
||||
}
|
||||
|
||||
} // namespace app
|
@ -99,6 +99,7 @@ FOR_EACH_COMMAND(SavePalette)
|
||||
FOR_EACH_COMMAND(Scroll)
|
||||
FOR_EACH_COMMAND(SetLoopSection)
|
||||
FOR_EACH_COMMAND(SetPalette)
|
||||
FOR_EACH_COMMAND(SetPaletteEntrySize)
|
||||
FOR_EACH_COMMAND(ShowGrid)
|
||||
FOR_EACH_COMMAND(ShowOnionSkin)
|
||||
FOR_EACH_COMMAND(ShowPixelGrid)
|
||||
|
@ -171,6 +171,25 @@ app::Color PaletteView::getColorByPosition(const gfx::Point& pos)
|
||||
return app::Color::fromMask();
|
||||
}
|
||||
|
||||
int PaletteView::getBoxSize() const
|
||||
{
|
||||
return m_boxsize / guiscale();
|
||||
}
|
||||
|
||||
void PaletteView::setBoxSize(int boxsize)
|
||||
{
|
||||
m_boxsize = MID(4*guiscale(), boxsize, 32*guiscale());
|
||||
m_boxsize = boxsize * guiscale();
|
||||
|
||||
if (m_delegate)
|
||||
m_delegate->onPaletteViewChangeSize(m_boxsize);
|
||||
|
||||
View* view = View::getView(this);
|
||||
if (view)
|
||||
view->layout();
|
||||
|
||||
}
|
||||
|
||||
bool PaletteView::onProcessMessage(Message* msg)
|
||||
{
|
||||
switch (msg->type()) {
|
||||
@ -246,12 +265,7 @@ bool PaletteView::onProcessMessage(Message* msg)
|
||||
|
||||
if (msg->onlyCtrlPressed()) {
|
||||
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();
|
||||
setBoxSize(m_boxsize + z * guiscale());
|
||||
}
|
||||
else {
|
||||
gfx::Point scroll = view->getViewScroll();
|
||||
|
@ -50,6 +50,9 @@ namespace app {
|
||||
|
||||
app::Color getColorByPosition(const gfx::Point& pos);
|
||||
|
||||
int getBoxSize() const;
|
||||
void setBoxSize(int boxsize);
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(ui::Message* msg) override;
|
||||
void onPaint(ui::PaintEvent& ev) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user