Skip to content

Commit

Permalink
Add extra options to show brush preview with Eraser/Blur/etc. tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Aug 3, 2020
1 parent 8c0f81c commit 8b61169
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions data/pref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<value id="NONE" value="0" />
<value id="EDGES" value="1" />
<value id="FULL" value="2" />
<value id="FULLALL" value="3" />
<value id="FULLNEDGES" value="4" />
</enum>
<enum id="BgType">
<value id="CHECKED_16x16" value="0" />
Expand Down
6 changes: 4 additions & 2 deletions data/strings/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,10 @@ simple_crosshair = Simple Crosshair
crosshair_on_sprite = Crosshair on Sprite
brush_preview = Brush Preview:
brush_preview_none = None
brush_preview_edges = Brush Edges
brush_preview_full = Full Real-time Brush Preview
brush_preview_edges = Edges Only
brush_preview_full = Full Preview
brush_preview_fullall = Full Preview with All Tools
brush_preview_fullnedges = Full Preview and Edges
cursor_color_type = Crosshair && Brush Edges Color:
cursor_neg_bw = Negative Black and White
cursor_specific_color = Specific Color
Expand Down
2 changes: 2 additions & 0 deletions data/widgets/options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@
<listitem text="@.brush_preview_none" value="0" />
<listitem text="@.brush_preview_edges" value="1" />
<listitem text="@.brush_preview_full" value="2" />
<listitem text="@.brush_preview_fullall" value="3" />
<listitem text="@.brush_preview_fullnedges" value="4" />
</combobox>

<label text="@.cursor_color_type" />
Expand Down
24 changes: 21 additions & 3 deletions src/app/ui/editor/brush_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void BrushPreview::show(const gfx::Point& screenPos)
(ink->isEffect()) ||
// or when the brush color is transparent and we are not in the background layer
(!ink->isShading() &&
(layer && !layer->isBackground()) &&
(layer && layer->isTransparent()) &&
((sprite->pixelFormat() == IMAGE_INDEXED && brush_color == mask_index) ||
(sprite->pixelFormat() == IMAGE_RGB && rgba_geta(brush_color) == 0) ||
(sprite->pixelFormat() == IMAGE_GRAYSCALE && graya_geta(brush_color) == 0))))) {
Expand All @@ -160,6 +160,8 @@ void BrushPreview::show(const gfx::Point& screenPos)
}

bool showPreview = false;
bool showPreviewWithEdges = false;
bool cancelEdges = false;
auto brushPreview = pref.cursor.brushPreview();
if (!m_editor->docPref().show.brushPreview())
brushPreview = app::gen::BrushPreview::NONE;
Expand All @@ -172,7 +174,18 @@ void BrushPreview::show(const gfx::Point& screenPos)
m_type = BRUSH_BOUNDARIES;
break;
case app::gen::BrushPreview::FULL:
case app::gen::BrushPreview::FULLALL:
case app::gen::BrushPreview::FULLNEDGES:
showPreview = m_editor->getState()->requireBrushPreview();
switch (brushPreview) {
case app::gen::BrushPreview::FULLALL:
m_type = CROSSHAIR;
cancelEdges = true;
break;
case app::gen::BrushPreview::FULLNEDGES:
showPreviewWithEdges = true;
break;
}
break;
}

Expand All @@ -183,6 +196,8 @@ void BrushPreview::show(const gfx::Point& screenPos)
// layer) we don't show the brush preview temporally.
if (showPreview && m_editor->isExtraCelLocked()) {
showPreview = false;
showPreviewWithEdges = false;
cancelEdges = false;
m_type |= BRUSH_BOUNDARIES;
}

Expand All @@ -195,9 +210,12 @@ void BrushPreview::show(const gfx::Point& screenPos)
// For cursor type 'bounds' we have to generate cursor boundaries
if (m_type & BRUSH_BOUNDARIES) {
if (brush->type() != kImageBrushType)
showPreview = false;
generateBoundaries();
showPreview = showPreviewWithEdges;
if (cancelEdges)
m_type &= ~BRUSH_BOUNDARIES;
}
if (m_type & BRUSH_BOUNDARIES)
generateBoundaries();

// Draw pixel/brush preview
if (showPreview) {
Expand Down

0 comments on commit 8b61169

Please sign in to comment.