Don't close the Preview window if we close an unrelated Editor

This commit is contained in:
David Capello 2015-05-18 21:28:30 -03:00
parent e106f6feec
commit e973aa0cc7
3 changed files with 21 additions and 6 deletions

View File

@ -65,22 +65,25 @@ public:
// EditorObserver implementation
void dispose() override {
App::instance()->getMainWindow()->getPreviewEditor()->updateUsingEditor(NULL);
PreviewEditorWindow* preview =
App::instance()->getMainWindow()->getPreviewEditor();
if (preview->relatedEditor() == this)
updatePreviewEditor(nullptr);
}
void onScrollChanged(Editor* editor) override {
if (current_editor == this)
App::instance()->getMainWindow()->getPreviewEditor()->updateUsingEditor(this);
updatePreviewEditor(this);
}
void onAfterFrameChanged(Editor* editor) override {
App::instance()->getMainWindow()->getPreviewEditor()->updateUsingEditor(this);
updatePreviewEditor(this);
set_current_palette(editor->sprite()->palette(editor->frame()), true);
}
void onAfterLayerChanged(Editor* editor) override {
App::instance()->getMainWindow()->getPreviewEditor()->updateUsingEditor(this);
updatePreviewEditor(this);
}
// EditorCustomizationDelegate implementation
@ -161,6 +164,11 @@ protected:
}
private:
void updatePreviewEditor(Editor* editor) {
App::instance()->getMainWindow()->getPreviewEditor()->updateUsingEditor(editor);
}
bool isKeyActionPressed(KeyAction action) {
if (Key* key = KeyboardShortcuts::instance()->action(action))
return key->checkFromAllegroKeyArray();

View File

@ -175,6 +175,7 @@ PreviewEditorWindow::PreviewEditorWindow()
, m_playButton(new MiniPlayButton())
, m_refFrame(0)
, m_aniSpeed(1.0)
, m_relatedEditor(nullptr)
{
child_spacing = 0;
setAutoRemap(false);
@ -297,12 +298,15 @@ void PreviewEditorWindow::updateUsingEditor(Editor* editor)
{
if (!m_isEnabled || !editor) {
hideWindow();
m_relatedEditor = nullptr;
return;
}
if (editor != current_editor)
if (!editor->isActive())
return;
m_relatedEditor = editor;
Document* document = editor->document();
Editor* miniEditor = (m_docView ? m_docView->getEditor(): NULL);

View File

@ -28,6 +28,8 @@ namespace app {
void updateUsingEditor(Editor* editor);
void uncheckCenterButton();
Editor* relatedEditor() const { return m_relatedEditor; }
protected:
bool onProcessMessage(ui::Message* msg) override;
void onClose(ui::CloseEvent& ev) override;
@ -45,6 +47,7 @@ namespace app {
MiniPlayButton* m_playButton;
doc::frame_t m_refFrame;
double m_aniSpeed;
Editor* m_relatedEditor;
};
} // namespace app