Now mini editor's frame is synced with current editor's frame

This commit is contained in:
David Capello 2013-03-14 21:40:37 -03:00
parent dbffd6c42a
commit 163af12313
6 changed files with 21 additions and 6 deletions

View File

@ -60,14 +60,18 @@ public:
App::instance()->getMainWindow()->getMiniEditor()->updateUsingEditor(NULL);
}
void scrollChanged(Editor* editor) OVERRIDE {
void onScrollChanged(Editor* editor) OVERRIDE {
App::instance()->getMainWindow()->getMiniEditor()->updateUsingEditor(this);
}
void stateChanged(Editor* editor) OVERRIDE {
void onStateChanged(Editor* editor) OVERRIDE {
// Do nothing
}
void onFrameChanged(Editor* editor) OVERRIDE {
App::instance()->getMainWindow()->getMiniEditor()->updateUsingEditor(this);
}
// EditorCustomizationDelegate implementation
tools::Tool* getQuickTool(tools::Tool* currentTool) OVERRIDE {
return get_selected_quicktool(currentTool);

View File

@ -248,6 +248,7 @@ void Editor::setFrame(FrameNumber frame)
{
if (m_frame != frame) {
m_frame = frame;
m_observers.notifyFrameChanged(this);
invalidate();
updateStatusBar();

View File

@ -28,10 +28,13 @@ public:
virtual void dispose() = 0;
// Called when the editor's state changes.
virtual void stateChanged(Editor* editor) = 0;
virtual void onStateChanged(Editor* editor) = 0;
// Called when the scroll or zoom of the editor changes.
virtual void scrollChanged(Editor* editor) = 0;
virtual void onScrollChanged(Editor* editor) = 0;
// Called when the current frame of the editor changes.
virtual void onFrameChanged(Editor* editor) = 0;
};
#endif // WIDGETS_EDITOR_OBSERVER_H_INCLUDED

View File

@ -39,10 +39,15 @@ void EditorObservers::removeObserver(EditorObserver* observer)
void EditorObservers::notifyStateChanged(Editor* editor)
{
m_observers.notifyObservers(&EditorObserver::stateChanged, editor);
m_observers.notifyObservers(&EditorObserver::onStateChanged, editor);
}
void EditorObservers::notifyScrollChanged(Editor* editor)
{
m_observers.notifyObservers(&EditorObserver::scrollChanged, editor);
m_observers.notifyObservers(&EditorObserver::onScrollChanged, editor);
}
void EditorObservers::notifyFrameChanged(Editor* editor)
{
m_observers.notifyObservers(&EditorObserver::onFrameChanged, editor);
}

View File

@ -34,6 +34,7 @@ public:
void notifyStateChanged(Editor* editor);
void notifyScrollChanged(Editor* editor);
void notifyFrameChanged(Editor* editor);
private:
Observers<EditorObserver> m_observers;

View File

@ -210,6 +210,7 @@ void MiniEditorWindow::updateUsingEditor(Editor* editor)
}
miniEditor->centerInSpritePoint(pt.x, pt.y);
miniEditor->setFrame(editor->getFrame());
}
else {
hideWindow();