1// Aseprite
2// Copyright (C) 2001-2017 David Capello
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifdef HAVE_CONFIG_H
8#include "config.h"
9#endif
10
11#include "app/app.h"
12#include "app/commands/command.h"
13#include "app/commands/params.h"
14#include "app/ui/color_bar.h"
15
16namespace app {
17
18class SetPaletteEntrySizeCommand : public Command {
19public:
20 SetPaletteEntrySizeCommand();
21
22protected:
23 void onLoadParams(const Params& params) override;
24 bool onChecked(Context* context) override;
25 void onExecute(Context* context) override;
26
27private:
28 int m_size;
29};
30
31SetPaletteEntrySizeCommand::SetPaletteEntrySizeCommand()
32 : Command(CommandId::SetPaletteEntrySize(), CmdUIOnlyFlag)
33 , m_size(7)
34{
35}
36
37void SetPaletteEntrySizeCommand::onLoadParams(const Params& params)
38{
39 if (params.has_param("size"))
40 m_size = params.get_as<int>("size");
41}
42
43bool SetPaletteEntrySizeCommand::onChecked(Context* context)
44{
45 return (ColorBar::instance()->getPaletteView()->getBoxSize() == m_size);
46}
47
48void SetPaletteEntrySizeCommand::onExecute(Context* context)
49{
50 ColorBar::instance()->getPaletteView()->setBoxSize(m_size);
51}
52
53Command* CommandFactory::createSetPaletteEntrySizeCommand()
54{
55 return new SetPaletteEntrySizeCommand;
56}
57
58} // namespace app
59