mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-23 22:43:32 +00:00
Added grid_settings command (feature #2874433).
This commit is contained in:
parent
182ee290d0
commit
5665b7dd1a
@ -275,6 +275,8 @@
|
||||
</menu>
|
||||
<separator />
|
||||
<menu text="&Grid">
|
||||
<item command="grid_settings" text="Grid Se&ttings" />
|
||||
<separator />
|
||||
<item command="show_grid" text="Show &Grid" />
|
||||
<item command="snap_to_grid" text="&Snap to Grid" />
|
||||
</menu>
|
||||
|
27
data/widgets/grid_settings.xml
Normal file
27
data/widgets/grid_settings.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<!-- ASE - Allegro Sprite Editor -->
|
||||
<!-- Copyright (C) 2001-2010 by David Capello -->
|
||||
<jinete>
|
||||
<window text="Grid Settings" name="grid_settings">
|
||||
<grid columns="4">
|
||||
|
||||
<label text="X:" />
|
||||
<entry name="grid_x" text="" maxsize="4" magnetic="true" />
|
||||
|
||||
<label text="Y:" />
|
||||
<entry name="grid_y" text="" maxsize="4" />
|
||||
|
||||
<label text="Width:" />
|
||||
<entry name="grid_w" text="" maxsize="4" />
|
||||
|
||||
<label text="Height:" />
|
||||
<entry name="grid_h" text="" maxsize="4" />
|
||||
|
||||
<separator horizontal="true" cell_hspan="4" />
|
||||
|
||||
<box horizontal="true" homogeneous="true" cell_hspan="4" cell_align="right">
|
||||
<button text="&OK" name="ok" magnetic="true" minwidth="60" />
|
||||
<button text="&Cancel" />
|
||||
</box>
|
||||
</grid>
|
||||
</window>
|
||||
</jinete>
|
@ -23,23 +23,24 @@
|
||||
#include "jinete/jinete.h"
|
||||
#include "Vaca/Bind.h"
|
||||
|
||||
#include "commands/command.h"
|
||||
#include "app.h"
|
||||
#include "commands/command.h"
|
||||
#include "commands/commands.h"
|
||||
#include "modules/editors.h"
|
||||
#include "modules/gfx.h"
|
||||
#include "modules/gui.h"
|
||||
#include "modules/rootmenu.h"
|
||||
#include "raster/pen.h"
|
||||
#include "raster/image.h"
|
||||
#include "raster/mask.h"
|
||||
#include "raster/pen.h"
|
||||
#include "raster/sprite.h"
|
||||
#include "settings/settings.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "ui_context.h"
|
||||
#include "widgets/colbut.h"
|
||||
#include "widgets/editor.h"
|
||||
#include "widgets/groupbut.h"
|
||||
#include "widgets/statebar.h"
|
||||
#include "settings/settings.h"
|
||||
|
||||
static Frame* window = NULL;
|
||||
|
||||
@ -463,16 +464,15 @@ static bool set_grid_button_select_hook(JWidget widget, void *data)
|
||||
refresh_all_editors();
|
||||
}
|
||||
else {
|
||||
jalert(_("Error"
|
||||
"<<You have to select a sprite with mask."
|
||||
"<<The boundaries of the mask will be used"
|
||||
"<<to specify the grid area.||&OK"));
|
||||
Command* grid_settings_cmd =
|
||||
CommandsModule::instance()->get_command_by_name(CommandId::grid_settings);
|
||||
|
||||
UIContext::instance()->execute_command(grid_settings_cmd, NULL);
|
||||
}
|
||||
}
|
||||
catch (locked_sprite_exception& e) {
|
||||
e.show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,16 @@
|
||||
|
||||
#include <allegro/unicode.h>
|
||||
|
||||
#include "jinete/jwindow.h"
|
||||
|
||||
#include "commands/command.h"
|
||||
#include "context.h"
|
||||
#include "app.h"
|
||||
#include "modules/editors.h"
|
||||
#include "modules/gui.h"
|
||||
#include "settings/settings.h"
|
||||
#include "widgets/statebar.h"
|
||||
#include "ui_context.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// show_grid
|
||||
@ -98,6 +102,66 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// grid_settings
|
||||
|
||||
class GridSettingsCommand : public Command
|
||||
{
|
||||
public:
|
||||
GridSettingsCommand();
|
||||
Command* clone() const { return new GridSettingsCommand(*this); }
|
||||
|
||||
protected:
|
||||
bool enabled(Context* context);
|
||||
void execute(Context* context);
|
||||
};
|
||||
|
||||
GridSettingsCommand::GridSettingsCommand()
|
||||
: Command("grid_settings",
|
||||
"Grid Settings",
|
||||
CmdUIOnlyFlag)
|
||||
{
|
||||
}
|
||||
|
||||
bool GridSettingsCommand::enabled(Context* context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void GridSettingsCommand::execute(Context* context)
|
||||
{
|
||||
JWidget grid_x, grid_y, grid_w, grid_h, button_ok;
|
||||
|
||||
FramePtr window(load_widget("grid_settings.xml", "grid_settings"));
|
||||
get_widgets(window,
|
||||
"ok", &button_ok,
|
||||
"grid_x", &grid_x,
|
||||
"grid_y", &grid_y,
|
||||
"grid_w", &grid_w,
|
||||
"grid_h", &grid_h, NULL);
|
||||
|
||||
Rect bounds = UIContext::instance()->getSettings()->getGridBounds();
|
||||
|
||||
grid_x->setTextf("%d", bounds.x);
|
||||
grid_y->setTextf("%d", bounds.y);
|
||||
grid_w->setTextf("%d", bounds.w);
|
||||
grid_h->setTextf("%d", bounds.h);
|
||||
|
||||
window->open_window_fg();
|
||||
|
||||
if (window->get_killer() == button_ok) {
|
||||
bounds.x = grid_x->getTextInt();
|
||||
bounds.y = grid_y->getTextInt();
|
||||
bounds.w = grid_w->getTextInt();
|
||||
bounds.h = grid_h->getTextInt();
|
||||
|
||||
UIContext::instance()->getSettings()->setGridBounds(bounds);
|
||||
|
||||
if (UIContext::instance()->getSettings()->getGridVisible())
|
||||
refresh_all_editors();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CommandFactory
|
||||
|
||||
@ -110,3 +174,8 @@ Command* CommandFactory::create_snap_to_grid_command()
|
||||
{
|
||||
return new SnapToGridCommand;
|
||||
}
|
||||
|
||||
Command* CommandFactory::create_grid_settings_command()
|
||||
{
|
||||
return new GridSettingsCommand;
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ FOR_EACH_COMMAND(goto_next_frame)
|
||||
FOR_EACH_COMMAND(goto_next_layer)
|
||||
FOR_EACH_COMMAND(goto_previous_frame)
|
||||
FOR_EACH_COMMAND(goto_previous_layer)
|
||||
FOR_EACH_COMMAND(grid_settings)
|
||||
FOR_EACH_COMMAND(invert_color)
|
||||
FOR_EACH_COMMAND(invert_mask)
|
||||
FOR_EACH_COMMAND(layer_from_background)
|
||||
|
Loading…
x
Reference in New Issue
Block a user