mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-06 06:50:07 +00:00
Add ShowBrushPreview command so the user can hide the brush preview with a keyboard shortcut (fix #792)
This commit is contained in:
parent
9face9458e
commit
8b161dac0a
@ -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">
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user