From ff166107ede7810e41ef98cf0a78522eda5707b5 Mon Sep 17 00:00:00 2001 From: David Capello Date: Sun, 2 Feb 2014 19:14:27 -0300 Subject: [PATCH] Don't show grid and mask in mini editor --- src/app/ui/document_view.cpp | 5 +++-- src/app/ui/editor/editor.cpp | 12 +++++++++++- src/app/ui/editor/editor.h | 11 ++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/app/ui/document_view.cpp b/src/app/ui/document_view.cpp index 0fa7a8916..c960a90f4 100644 --- a/src/app/ui/document_view.cpp +++ b/src/app/ui/document_view.cpp @@ -130,8 +130,9 @@ DocumentView::DocumentView(Document* document, Type type) , m_document(document) , m_view(new EditorView(type == Normal ? EditorView::CurrentEditorMode: EditorView::AlwaysSelected)) - , m_editor(type == Normal ? new AppEditor(document): - new Editor(document)) + , m_editor(type == Normal ? + new AppEditor(document): + new Editor(document, Editor::kNoneFlag)) // Don't show grid/mask in mini preview { addChild(m_view); diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index f5bdefb1c..56d63368a 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -129,7 +129,7 @@ private: Editor* m_editor; }; -Editor::Editor(Document* document) +Editor::Editor(Document* document, EditorFlags flags) : Widget(editor_type()) , m_state(new StandbyState()) , m_decorator(NULL) @@ -141,6 +141,7 @@ Editor::Editor(Document* document) , m_mask_timer(100, this) , m_customizationDelegate(NULL) , m_docView(NULL) + , m_flags(flags) { // Add the first state into the history. m_statesHistory.push(m_state); @@ -500,6 +501,9 @@ void Editor::drawSpriteClipped(const gfx::Region& updateRegion) */ void Editor::drawMask() { + if ((m_flags & kShowMaskFlag) == 0) + return; + View* view = View::getView(this); Rect vp = view->getViewportBounds(); Point scroll = view->getViewScroll(); @@ -555,6 +559,9 @@ void Editor::drawMask() void Editor::drawMaskSafe() { + if ((m_flags & kShowMaskFlag) == 0) + return; + if (isVisible() && m_document && m_document->getBoundariesSegments()) { @@ -590,6 +597,9 @@ void Editor::drawMaskSafe() void Editor::drawGrid(const Rect& gridBounds, const app::Color& color) { + if ((m_flags & kShowGridFlag) == 0) + return; + // Copy the grid bounds Rect grid(gridBounds); if (grid.w < 1 || grid.h < 1) diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h index 544c71f67..76f4444f2 100644 --- a/src/app/ui/editor/editor.h +++ b/src/app/ui/editor/editor.h @@ -59,7 +59,14 @@ namespace app { class Editor : public ui::Widget { public: - Editor(Document* document); + enum EditorFlags { + kNoneFlag = 0, + kShowGridFlag = 1, + kShowMaskFlag = 2, + kDefaultEditorFlags = kShowGridFlag | kShowMaskFlag, + }; + + Editor(Document* document, EditorFlags flags = kDefaultEditorFlags); ~Editor(); DocumentView* getDocumentView() { return m_docView; } @@ -245,6 +252,8 @@ namespace app { DocumentView* m_docView; gfx::Point m_oldPos; + + EditorFlags m_flags; }; ui::WidgetType editor_type();