| 1 | // Aseprite | 
|---|
| 2 | // Copyright (C) 2021  Igara Studio S.A. | 
|---|
| 3 | // | 
|---|
| 4 | // This program is distributed under the terms of | 
|---|
| 5 | // the End-User License Agreement for Aseprite. | 
|---|
| 6 |  | 
|---|
| 7 | #ifndef APP_INLINE_COMMAND_EXECUTION_H_INCLUDED | 
|---|
| 8 | #define APP_INLINE_COMMAND_EXECUTION_H_INCLUDED | 
|---|
| 9 | #pragma once | 
|---|
| 10 |  | 
|---|
| 11 | #include "app/commands/command.h" | 
|---|
| 12 |  | 
|---|
| 13 | namespace app { | 
|---|
| 14 |  | 
|---|
| 15 | // This class was created to simulate a Command Execution behavior. | 
|---|
| 16 | // Particularly, this class is used in color_bar.cpp | 
|---|
| 17 | // (solved issue: locked ContextWriter during a ui palette changes | 
|---|
| 18 | // while the current editor state is MovingPixelsState) | 
|---|
| 19 |  | 
|---|
| 20 | class InlineCommandExecution : public Command { | 
|---|
| 21 | public: | 
|---|
| 22 | InlineCommandExecution(Context* ctx) | 
|---|
| 23 | : Command( "", CmdUIOnlyFlag) | 
|---|
| 24 | , m_context(ctx) | 
|---|
| 25 | { | 
|---|
| 26 | CommandExecutionEvent ev(this); | 
|---|
| 27 | m_context->BeforeCommandExecution(ev); | 
|---|
| 28 | } | 
|---|
| 29 | ~InlineCommandExecution() | 
|---|
| 30 | { | 
|---|
| 31 | CommandExecutionEvent ev(this); | 
|---|
| 32 | m_context->AfterCommandExecution(ev); | 
|---|
| 33 | } | 
|---|
| 34 | private: | 
|---|
| 35 | Context* m_context; | 
|---|
| 36 | }; | 
|---|
| 37 |  | 
|---|
| 38 | } // namespace app | 
|---|
| 39 |  | 
|---|
| 40 | #endif | 
|---|
| 41 |  | 
|---|