From 88c4cd8d8716b590b6447d4d93662a3c303fd1f3 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 28 Jul 2015 10:21:33 -0300 Subject: [PATCH] Don't show brush boundaries when the brush & zoom are too small We can use the CROSS brush preview type instead of BRUSH_BOUNDARIES --- src/app/ui/editor/brush_preview.cpp | 26 ++++++++++++++++---------- src/app/ui/editor/brush_preview.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/app/ui/editor/brush_preview.cpp b/src/app/ui/editor/brush_preview.cpp index d19b39c2e..56144f75e 100644 --- a/src/app/ui/editor/brush_preview.cpp +++ b/src/app/ui/editor/brush_preview.cpp @@ -47,6 +47,7 @@ BrushPreview::BrushPreview(Editor* editor) : m_editor(editor) , m_type(CROSS) , m_onScreen(false) + , m_withRealPreview(false) , m_screenPosition(0, 0) , m_editorPosition(0, 0) { @@ -114,8 +115,9 @@ void BrushPreview::show(const gfx::Point& screenPos) bool isFloodfill = m_editor->getCurrentEditorTool()->getPointShape(0)->isFloodFill(); - // Setup the cursor type debrushding of several factors (current tool, - // foreground color, and layer transparency). + // Setup the cursor type depending on several factors (current tool, + // foreground color, layer transparency, brush size, etc.). + Brush* brush = getCurrentBrush(); color_t brush_color = getBrushColor(sprite, layer); color_t mask_color = sprite->transparentColor(); @@ -123,11 +125,13 @@ void BrushPreview::show(const gfx::Point& screenPos) m_type = SELECTION_CROSS; } else if ( - // Use cursor bounds for inks that are effects (eraser, blur, etc.) - (ink->isEffect()) || - // or when the brush color is transparent and we are not in the background layer - (layer && !layer->isBackground() && - brush_color == mask_color)) { + (brush->type() == kImageBrushType || + brush->size() > 1.0 / m_editor->zoom().scale()) && + (// Use cursor bounds for inks that are effects (eraser, blur, etc.) + (ink->isEffect()) || + // or when the brush color is transparent and we are not in the background layer + (layer && !layer->isBackground() && + brush_color == mask_color))) { m_type = BRUSH_BOUNDARIES; } else { @@ -141,7 +145,6 @@ void BrushPreview::show(const gfx::Point& screenPos) // Draw pixel/brush preview if ((m_type & CROSS) && m_editor->getState()->requireBrushPreview()) { - Brush* brush = getCurrentBrush(); gfx::Rect origBrushBounds = (isFloodfill ? gfx::Rect(0, 0, 1, 1): brush->bounds()); gfx::Rect brushBounds = origBrushBounds; brushBounds.offset(spritePos); @@ -191,6 +194,8 @@ void BrushPreview::show(const gfx::Point& screenPos) document->notifySpritePixelsModified( sprite, gfx::Region(m_lastBounds = brushBounds)); + + m_withRealPreview = true; } // Save area and draw the cursor @@ -241,11 +246,12 @@ void BrushPreview::hide() } // Clean pixel/brush preview - if ((m_type & CROSS) && - m_editor->getState()->requireBrushPreview()) { + if (m_withRealPreview) { document->destroyExtraCel(); document->notifySpritePixelsModified( sprite, gfx::Region(m_lastBounds)); + + m_withRealPreview = false; } m_onScreen = false; diff --git a/src/app/ui/editor/brush_preview.h b/src/app/ui/editor/brush_preview.h index 8ed1d7f7f..b88a5b66a 100644 --- a/src/app/ui/editor/brush_preview.h +++ b/src/app/ui/editor/brush_preview.h @@ -85,6 +85,7 @@ namespace app { // The brush preview is on the screen. bool m_onScreen; + bool m_withRealPreview; gfx::Point m_screenPosition; // Position in the screen (view) gfx::Point m_editorPosition; // Position in the editor (model)