mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 21:19:10 +00:00
Add SelectionAsGrid command
This commit is contained in:
parent
3dff25246b
commit
c159a3c4b5
@ -641,6 +641,7 @@
|
||||
<item command="ShowGrid" text="Show &Grid" />
|
||||
<item command="SnapToGrid" text="&Snap to Grid" />
|
||||
<item command="GridSettings" text="Gri&d Settings" />
|
||||
<item command="SelectionAsGrid" text="Select&ion as Grid" />
|
||||
<separator />
|
||||
<item command="SetLoopSection" text="Set &Loop Section" />
|
||||
<item command="ShowOnionSkin" text="Show &Onion Skin" />
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "app/app.h"
|
||||
#include "app/commands/command.h"
|
||||
#include "app/context.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/document.h"
|
||||
#include "app/find_widget.h"
|
||||
#include "app/load_widget.h"
|
||||
@ -19,6 +20,8 @@
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/mask.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
namespace app {
|
||||
@ -37,12 +40,12 @@ public:
|
||||
Command* clone() const override { return new ShowGridCommand(*this); }
|
||||
|
||||
protected:
|
||||
bool onChecked(Context* ctx) {
|
||||
bool onChecked(Context* ctx) override {
|
||||
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
|
||||
return docPref.grid.visible();
|
||||
}
|
||||
|
||||
void onExecute(Context* ctx) {
|
||||
void onExecute(Context* ctx) override {
|
||||
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
|
||||
docPref.grid.visible(!docPref.grid.visible());
|
||||
}
|
||||
@ -59,12 +62,12 @@ public:
|
||||
Command* clone() const override { return new ShowPixelGridCommand(*this); }
|
||||
|
||||
protected:
|
||||
bool onChecked(Context* ctx) {
|
||||
bool onChecked(Context* ctx) override {
|
||||
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
|
||||
return docPref.pixelGrid.visible();
|
||||
}
|
||||
|
||||
void onExecute(Context* ctx) {
|
||||
void onExecute(Context* ctx) override {
|
||||
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
|
||||
docPref.pixelGrid.visible(!docPref.pixelGrid.visible());
|
||||
}
|
||||
@ -81,12 +84,12 @@ public:
|
||||
Command* clone() const override { return new SnapToGridCommand(*this); }
|
||||
|
||||
protected:
|
||||
bool onChecked(Context* ctx) {
|
||||
bool onChecked(Context* ctx) override {
|
||||
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
|
||||
return docPref.grid.snap();
|
||||
}
|
||||
|
||||
void onExecute(Context* ctx) {
|
||||
void onExecute(Context* ctx) override {
|
||||
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
|
||||
bool newValue = !docPref.grid.snap();
|
||||
docPref.grid.snap(newValue);
|
||||
@ -95,14 +98,41 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
class SelectionAsGridCommand : public Command {
|
||||
public:
|
||||
SelectionAsGridCommand()
|
||||
: Command("SelectionAsGrid",
|
||||
"Selection as Grid",
|
||||
CmdUIOnlyFlag) {
|
||||
}
|
||||
|
||||
Command* clone() const override { return new SelectionAsGridCommand(*this); }
|
||||
|
||||
protected:
|
||||
bool onEnabled(Context* ctx) override {
|
||||
return (ctx->activeDocument() &&
|
||||
ctx->activeDocument()->isMaskVisible());
|
||||
}
|
||||
|
||||
void onExecute(Context* ctx) override {
|
||||
const ContextReader reader(ctx);
|
||||
const Document* document = reader.document();
|
||||
const Mask* mask(document->mask());
|
||||
DocumentPreferences& docPref =
|
||||
Preferences::instance().document(ctx->activeDocument());
|
||||
|
||||
docPref.grid.bounds(mask->bounds());
|
||||
}
|
||||
};
|
||||
|
||||
class GridSettingsCommand : public Command {
|
||||
public:
|
||||
GridSettingsCommand();
|
||||
Command* clone() const override { return new GridSettingsCommand(*this); }
|
||||
|
||||
protected:
|
||||
bool onEnabled(Context* context);
|
||||
void onExecute(Context* context);
|
||||
bool onEnabled(Context* context) override;
|
||||
void onExecute(Context* context) override;
|
||||
};
|
||||
|
||||
GridSettingsCommand::GridSettingsCommand()
|
||||
@ -168,4 +198,9 @@ Command* CommandFactory::createGridSettingsCommand()
|
||||
return new GridSettingsCommand;
|
||||
}
|
||||
|
||||
Command* CommandFactory::createSelectionAsGridCommand()
|
||||
{
|
||||
return new SelectionAsGridCommand;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -101,6 +101,7 @@ FOR_EACH_COMMAND(SavePalette)
|
||||
FOR_EACH_COMMAND(Scroll)
|
||||
FOR_EACH_COMMAND(SetColorSelector)
|
||||
FOR_EACH_COMMAND(SetLoopSection)
|
||||
FOR_EACH_COMMAND(SelectionAsGrid)
|
||||
FOR_EACH_COMMAND(SetPalette)
|
||||
FOR_EACH_COMMAND(SetPaletteEntrySize)
|
||||
FOR_EACH_COMMAND(ShowGrid)
|
||||
|
Loading…
Reference in New Issue
Block a user