Don't show grid and mask in mini editor

This commit is contained in:
David Capello 2014-02-02 19:14:27 -03:00
parent 0d7f4498b9
commit ff166107ed
3 changed files with 24 additions and 4 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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();