[aseprite] 102/196: Add ShowBrushPreview command so the user can hide the brush preview with a keyboard shortcut (fix #792)
Tobias Hansen
thansen at moszumanska.debian.org
Wed Apr 20 18:50:07 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 8b161dac0aa9b83f0b4c69a4d35975527bf6d4e4
Author: David Capello <davidcapello at gmail.com>
Date: Thu Mar 24 14:45:28 2016 -0300
Add ShowBrushPreview command so the user can hide the brush preview with a keyboard shortcut (fix #792)
---
data/gui.xml | 2 ++
data/pref.xml | 1 +
src/app/commands/cmd_show.cpp | 33 +++++++++++++++++++++++++++++++++
src/app/commands/commands_list.h | 1 +
src/app/ui/editor/brush_preview.cpp | 19 +++++++++++++++++--
src/app/ui/editor/editor.h | 1 +
6 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/data/gui.xml b/data/gui.xml
index dd365d9..a182383 100644
--- a/data/gui.xml
+++ b/data/gui.xml
@@ -726,6 +726,8 @@
<item command="ShowSelectionEdges" text="&Selection Edges" />
<item command="ShowGrid" text="&Grid" />
<item command="ShowPixelGrid" text="&Pixel Grid" />
+ <separator />
+ <item command="ShowBrushPreview" text="&Brush Preview" />
</menu>
<separator />
<menu text="&Grid">
diff --git a/data/pref.xml b/data/pref.xml
index b99f9e3..656de3a 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -289,6 +289,7 @@
<option id="selection_edges" type="bool" default="true" />
<option id="grid" type="bool" default="false" migrate="grid.visible" />
<option id="pixel_grid" type="bool" default="false" migrate="pixel_grid.visible" />
+ <option id="brush_preview" type="bool" default="true" />
</section>
</document>
diff --git a/src/app/commands/cmd_show.cpp b/src/app/commands/cmd_show.cpp
index e7620aa..7e08e6c 100644
--- a/src/app/commands/cmd_show.cpp
+++ b/src/app/commands/cmd_show.cpp
@@ -11,6 +11,7 @@
#include "app/commands/command.h"
#include "app/context.h"
+#include "app/modules/gui.h"
#include "app/pref/preferences.h"
namespace app {
@@ -118,6 +119,33 @@ protected:
}
};
+class ShowBrushPreviewCommand : public Command {
+public:
+ ShowBrushPreviewCommand()
+ : Command("ShowBrushPreview",
+ "Show Brush Preview",
+ CmdUIOnlyFlag) {
+ }
+
+ Command* clone() const override { return new ShowBrushPreviewCommand(*this); }
+
+protected:
+ bool onChecked(Context* ctx) override {
+ DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
+ return docPref.show.brushPreview();
+ }
+
+ void onExecute(Context* ctx) override {
+ DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
+ docPref.show.brushPreview(!docPref.show.brushPreview());
+
+ // TODO we shouldn't need this, but it happens to be that the
+ // Preview editor isn't being updated correctly when we change the
+ // brush preview state.
+ update_screen_for_document(ctx->activeDocument());
+ }
+};
+
Command* CommandFactory::createShowExtrasCommand()
{
return new ShowExtrasCommand;
@@ -138,4 +166,9 @@ Command* CommandFactory::createShowSelectionEdgesCommand()
return new ShowSelectionEdgesCommand;
}
+Command* CommandFactory::createShowBrushPreviewCommand()
+{
+ return new ShowBrushPreviewCommand;
+}
+
} // namespace app
diff --git a/src/app/commands/commands_list.h b/src/app/commands/commands_list.h
index a558ac3..7a514cd 100644
--- a/src/app/commands/commands_list.h
+++ b/src/app/commands/commands_list.h
@@ -116,6 +116,7 @@ FOR_EACH_COMMAND(SetLoopSection)
FOR_EACH_COMMAND(SetPalette)
FOR_EACH_COMMAND(SetPaletteEntrySize)
FOR_EACH_COMMAND(SetSameInk)
+FOR_EACH_COMMAND(ShowBrushPreview)
FOR_EACH_COMMAND(ShowExtras)
FOR_EACH_COMMAND(ShowGrid)
FOR_EACH_COMMAND(ShowOnionSkin)
diff --git a/src/app/ui/editor/brush_preview.cpp b/src/app/ui/editor/brush_preview.cpp
index d669ab1..4734155 100644
--- a/src/app/ui/editor/brush_preview.cpp
+++ b/src/app/ui/editor/brush_preview.cpp
@@ -96,7 +96,8 @@ void BrushPreview::show(const gfx::Point& screenPos)
m_editor->getUpdateRegion());
// Get cursor color
- app::Color app_cursor_color = Preferences::instance().editor.cursorColor();
+ const auto& pref = Preferences::instance();
+ app::Color app_cursor_color = pref.editor.cursorColor();
gfx::Color ui_cursor_color = color_utils::color_for_ui(app_cursor_color);
m_blackAndWhiteNegative = (app_cursor_color.getType() == app::Color::MaskType);
@@ -138,7 +139,21 @@ void BrushPreview::show(const gfx::Point& screenPos)
}
bool usePreview = false;
- switch (Preferences::instance().editor.brushPreview()) {
+
+ auto brushPreview = pref.editor.brushPreview();
+
+ // If the brush preview is hidden, we step down one level. E.g. If
+ // we have full-brush preview, we move to edges, or if it's edges,
+ // we don't show it at all.
+ if (!m_editor->docPref().show.brushPreview()) {
+ switch (brushPreview) {
+ case app::gen::BrushPreview::NONE: break;
+ case app::gen::BrushPreview::EDGES: brushPreview = app::gen::BrushPreview::NONE; break;
+ case app::gen::BrushPreview::FULL: brushPreview = app::gen::BrushPreview::EDGES; break;
+ }
+ }
+
+ switch (brushPreview) {
case app::gen::BrushPreview::NONE:
m_type = CROSS;
break;
diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h
index cfe1966..7a2e0af 100644
--- a/src/app/ui/editor/editor.h
+++ b/src/app/ui/editor/editor.h
@@ -120,6 +120,7 @@ namespace app {
Sprite* sprite() { return m_sprite; }
Layer* layer() { return m_layer; }
frame_t frame() { return m_frame; }
+ DocumentPreferences& docPref() { return m_docPref; }
void getSite(Site* site) const;
Site getSite() const;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list