Rename EditorState::onBefore/AfterChangeState to onLeave/EnterState()

This is to avoid confusion about the meaning of these callbacks.
This commit is contained in:
David Capello 2015-05-10 19:32:42 -03:00
parent 38526f3b9e
commit cd1f764d85
10 changed files with 20 additions and 20 deletions

View File

@ -188,7 +188,7 @@ Editor::Editor(Document* document, EditorFlags flags)
m_document->addObserver(this);
m_state->onAfterChangeState(this);
m_state->onEnterState(this);
}
Editor::~Editor()
@ -220,12 +220,12 @@ void Editor::setStateInternal(const EditorStatePtr& newState)
// Fire before change state event, set the state, and fire after
// change state event.
EditorState::BeforeChangeAction beforeChangeAction =
m_state->onBeforeChangeState(this, newState.get());
EditorState::LeaveAction leaveAction =
m_state->onLeaveState(this, newState.get());
// Push a new state
if (newState) {
if (beforeChangeAction == EditorState::DiscardState)
if (leaveAction == EditorState::DiscardState)
m_statesHistory.pop();
m_statesHistory.push(newState);
@ -242,7 +242,7 @@ void Editor::setStateInternal(const EditorStatePtr& newState)
ASSERT(m_state);
// Change to the new state.
m_state->onAfterChangeState(this);
m_state->onEnterState(this);
// Notify observers
m_observers.notifyStateChanged(this);

View File

@ -37,7 +37,7 @@ namespace app {
// drawing in the active sprite, etc.).
class EditorState {
public:
enum BeforeChangeAction {
enum LeaveAction {
DiscardState,
KeepState
};
@ -52,13 +52,13 @@ namespace app {
// Called just before this state is replaced by a new state in the
// Editor::setState() method. Returns true if this state should be
// kept in the EditorStatesHistory.
virtual BeforeChangeAction onBeforeChangeState(Editor* editor, EditorState* newState) {
virtual LeaveAction onLeaveState(Editor* editor, EditorState* newState) {
return KeepState;
}
// Called when this instance is set as the new Editor's state when
// Editor::setState() method is used.
virtual void onAfterChangeState(Editor* editor) { }
virtual void onEnterState(Editor* editor) { }
// Called just before the state will be removed from the
// EditorStatesHistory. This event is useful to remove the

View File

@ -119,7 +119,7 @@ void MovingPixelsState::translate(const gfx::Point& delta)
m_pixelsMovement->dropImageTemporarily();
}
EditorState::BeforeChangeAction MovingPixelsState::onBeforeChangeState(Editor* editor, EditorState* newState)
EditorState::LeaveAction MovingPixelsState::onLeaveState(Editor* editor, EditorState* newState)
{
ASSERT(m_pixelsMovement);
ASSERT(editor == m_editor);
@ -513,7 +513,7 @@ void MovingPixelsState::setTransparentColor(const app::Color& color)
void MovingPixelsState::dropPixels()
{
// Just change to default state (StandbyState generally). We'll
// receive an onBeforeChangeState() event after this call.
// receive an onLeaveState() event after this call.
m_editor->backToPreviousState();
}

View File

@ -38,7 +38,7 @@ namespace app {
void translate(const gfx::Point& delta);
// EditorState
virtual BeforeChangeAction onBeforeChangeState(Editor* editor, EditorState* newState) override;
virtual LeaveAction onLeaveState(Editor* editor, EditorState* newState) override;
virtual void onCurrentToolChange(Editor* editor) override;
virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override;
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;

View File

@ -40,9 +40,9 @@ PlayState::PlayState()
&PlayState::onBeforeCommandExecution, this);
}
void PlayState::onAfterChangeState(Editor* editor)
void PlayState::onEnterState(Editor* editor)
{
StateWithWheelBehavior::onAfterChangeState(editor);
StateWithWheelBehavior::onEnterState(editor);
if (!m_editor) {
m_editor = editor;
@ -60,7 +60,7 @@ void PlayState::onAfterChangeState(Editor* editor)
m_playTimer.start();
}
EditorState::BeforeChangeAction PlayState::onBeforeChangeState(Editor* editor, EditorState* newState)
EditorState::LeaveAction PlayState::onLeaveState(Editor* editor, EditorState* newState)
{
if (!m_toScroll) {
m_editor->setFrame(m_refFrame);

View File

@ -21,8 +21,8 @@ namespace app {
public:
PlayState();
void onAfterChangeState(Editor* editor) override;
BeforeChangeAction onBeforeChangeState(Editor* editor, EditorState* newState) override;
void onEnterState(Editor* editor) override;
LeaveAction onLeaveState(Editor* editor, EditorState* newState) override;
bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override;
bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;
bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;

View File

@ -60,7 +60,7 @@ void SelectBoxState::setBoxBounds(const gfx::Rect& box)
m_rulers[V2] = Ruler(Ruler::Vertical, box.x+box.w);
}
void SelectBoxState::onAfterChangeState(Editor* editor)
void SelectBoxState::onEnterState(Editor* editor)
{
updateContextBar();

View File

@ -56,7 +56,7 @@ namespace app {
void setBoxBounds(const gfx::Rect& rc);
// EditorState overrides
virtual void onAfterChangeState(Editor* editor) override;
virtual void onEnterState(Editor* editor) override;
virtual void onBeforePopState(Editor* editor) override;
virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override;
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;

View File

@ -84,7 +84,7 @@ StandbyState::~StandbyState()
delete m_decorator;
}
void StandbyState::onAfterChangeState(Editor* editor)
void StandbyState::onEnterState(Editor* editor)
{
editor->setDecorator(m_decorator);
}

View File

@ -21,7 +21,7 @@ namespace app {
public:
StandbyState();
virtual ~StandbyState();
virtual void onAfterChangeState(Editor* editor) override;
virtual void onEnterState(Editor* editor) override;
virtual void onCurrentToolChange(Editor* editor) override;
virtual void onQuickToolChange(Editor* editor) override;
virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override;