Refactor "View > Preview > Brush Preview" to be a global option (fix #4876)

Co-authored-by: David Capello <david@igara.com>
This commit is contained in:
sharkboi 2024-12-11 21:33:30 +01:00 committed by David Capello
parent e66df8da12
commit 8d30a18ed5
3 changed files with 8 additions and 6 deletions

View File

@ -216,6 +216,7 @@
<option id="cursor_color" type="app::Color" default="app::Color::fromMask()" />
<option id="painting_cursor_type" type="PaintingCursorType" default="PaintingCursorType::CROSSHAIR_ON_SPRITE" />
<option id="brush_preview" type="BrushPreview" default="BrushPreview::FULL" />
<option id="brush_preview_in_preview" type="bool" default="false" />
<option id="snap_to_grid" type="bool" default="false" />
</section>
<section id="preview" text="Preview">
@ -608,7 +609,6 @@
<option id="grid" type="bool" default="false" />
<option id="pixel_grid" type="bool" default="false" />
<option id="brush_preview" type="bool" default="true" />
<option id="brush_preview_in_preview" type="bool" default="false" />
<option id="slices" type="bool" default="true" />
<option id="auto_guides" type="bool" default="true" />
<option id="tile_numbers" type="bool" default="true" />

View File

@ -142,6 +142,8 @@ protected:
}
};
// This command works as a global preference (toogling the Brush
// Preview in the Preview window), not based on the active document.
class ShowBrushPreviewInPreviewCommand : public Command {
public:
ShowBrushPreviewInPreviewCommand()
@ -152,14 +154,14 @@ public:
protected:
bool onChecked(Context* ctx) override
{
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
return docPref.show.brushPreviewInPreview();
Preferences& pref = Preferences::instance();
return pref.cursor.brushPreviewInPreview();
}
void onExecute(Context* ctx) override
{
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
docPref.show.brushPreviewInPreview(!docPref.show.brushPreviewInPreview());
Preferences& pref = Preferences::instance();
pref.cursor.brushPreviewInPreview(!pref.cursor.brushPreviewInPreview());
}
};

View File

@ -692,7 +692,7 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g,
// 3) we are drawing the brush preview in a preview editor
// and preferences (brushPreviewInPreview) says that we
// should do that.
|| m_docPref.show.brushPreviewInPreview())) {
|| pref.cursor.brushPreviewInPreview())) {
m_renderEngine->setExtraImage(extraCel->type(),
extraCel->cel(),
extraCel->image(),