Remove ConfigureTools command

These options were replaced with commands in "View" menu.
This commit is contained in:
David Capello 2015-08-10 18:52:29 -03:00
parent d796c88f6f
commit a34931db3d
7 changed files with 3 additions and 280 deletions

View File

@ -51,7 +51,6 @@
<key command="ConvolutionMatrix" shortcut="F9" />
<key command="ColorCurve" shortcut="Ctrl+M" mac="Cmd+M" />
<key command="ColorCurve" shortcut="F10" />
<key command="ConfigureTools" shortcut="C" />
<key command="Options" shortcut="Ctrl+K" mac="Cmd+," />
<key command="Options" shortcut="Ctrl+Shift+O" mac="Cmd+Shift+O" /> <!-- TODO remove this shortcut in v1.1 -->
<key command="KeyboardShortcuts" shortcut="Ctrl+Alt+Shift+K" mac="Cmd+Alt+Shift+K" />
@ -521,7 +520,6 @@
<item command="Despeckle" text="&amp;Despeckle (median filter)" />
</menu>
<separator />
<item command="ConfigureTools" text="Tool&amp;s..." />
<item command="KeyboardShortcuts" text="&amp;Keyboard Shortcuts..." />
<item command="Options" text="Pre&amp;ferences..." />
</menu>

View File

@ -1,22 +0,0 @@
<!-- ASEPRITE -->
<!-- Copyright (C) 2001-2014 by David Capello -->
<gui>
<window text="Tools Configuration" id="tools_configuration">
<box vertical="true" childspacing="0">
<box horizontal="true" expansive="true">
<box vertical="true" childspacing="2">
<box horizontal="true" childspacing="0">
<check text="Tiled" id="tiled" />
<check text="x" id="tiled_x" />
<check text="y" id="tiled_y" />
</box>
<separator text="Grid:" horizontal="true" left="true" />
<check text="Snap to Grid" id="snap_to_grid" />
<check text="View Grid" id="view_grid" />
<check text="Pixel Grid" id="pixel_grid" />
<button text="Set &amp;Grid" id="set_grid" />
</box>
</box>
</box>
</window>
</gui>

View File

@ -155,7 +155,6 @@ add_library(app-lib
commands/cmd_clear_cel.cpp
commands/cmd_close_file.cpp
commands/cmd_color_quantization.cpp
commands/cmd_configure_tools.cpp
commands/cmd_copy.cpp
commands/cmd_copy_cel.cpp
commands/cmd_crop.cpp

View File

@ -1,210 +0,0 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/command.h"
#include "app/commands/commands.h"
#include "app/console.h"
#include "app/context_access.h"
#include "app/find_widget.h"
#include "app/load_widget.h"
#include "app/modules/gfx.h"
#include "app/modules/gui.h"
#include "app/pref/preferences.h"
#include "app/ui/color_button.h"
#include "app/ui/editor/editor.h"
#include "app/ui/status_bar.h"
#include "app/ui_context.h"
#include "base/bind.h"
#include "doc/context_observer.h"
#include "doc/mask.h"
#include "gfx/size.h"
#include "ui/ui.h"
#include "generated_tools_configuration.h"
namespace app {
using namespace gfx;
using namespace ui;
using namespace app::tools;
class ToolsConfigurationWindow : public app::gen::ToolsConfiguration,
public doc::ContextObserver {
public:
ToolsConfigurationWindow(Context* ctx)
: m_ctx(ctx)
, m_lastDocument(nullptr) {
m_ctx->addObserver(this);
// Slots
this->Close.connect(Bind<void>(&ToolsConfigurationWindow::onWindowClose, this));
tiled()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onTiledClick, this));
tiledX()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onTiledXYClick, this, filters::TiledMode::X_AXIS, tiledX()));
tiledY()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onTiledXYClick, this, filters::TiledMode::Y_AXIS, tiledY()));
viewGrid()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onViewGridClick, this));
pixelGrid()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onPixelGridClick, this));
setGrid()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onSetGridClick, this));
snapToGrid()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onSnapToGridClick, this));
remapWindow();
centerWindow();
load_window_pos(this, "ConfigureTool");
updateUI();
}
~ToolsConfigurationWindow() {
m_ctx->removeObserver(this);
}
private:
Preferences& preferences() {
return Preferences::instance();
}
DocumentPreferences& docPref() {
return preferences().document(m_ctx->activeDocument());
}
void onActiveSiteChange(const doc::Site& site) override {
if (m_lastDocument != site.document())
updateUI();
}
void updateUI() {
DocumentPreferences& docPref = this->docPref();
tiled()->setSelected(docPref.tiled.mode() != filters::TiledMode::NONE);
tiledX()->setSelected(int(docPref.tiled.mode()) & int(filters::TiledMode::X_AXIS) ? true: false);
tiledY()->setSelected(int(docPref.tiled.mode()) & int(filters::TiledMode::Y_AXIS) ? true: false);
snapToGrid()->setSelected(docPref.grid.snap());
viewGrid()->setSelected(docPref.grid.visible());
pixelGrid()->setSelected(docPref.pixelGrid.visible());
m_lastDocument = m_ctx->activeDocument();
}
void onWindowClose() {
save_window_pos(this, "ConfigureTool");
}
void onTiledClick() {
bool flag = tiled()->isSelected();
docPref().tiled.mode(
flag ? filters::TiledMode::BOTH:
filters::TiledMode::NONE);
tiledX()->setSelected(flag);
tiledY()->setSelected(flag);
}
void onTiledXYClick(filters::TiledMode tiled_axis, CheckBox* checkbox) {
int tiled_mode = int(docPref().tiled.mode());
if (checkbox->isSelected())
tiled_mode |= int(tiled_axis);
else
tiled_mode &= ~int(tiled_axis);
checkbox->findSibling("tiled")->setSelected(
tiled_mode != int(filters::TiledMode::NONE));
docPref().tiled.mode(filters::TiledMode(tiled_mode));
}
void onViewGridClick() {
docPref().grid.visible(viewGrid()->isSelected());
}
void onPixelGridClick() {
docPref().pixelGrid.visible(pixelGrid()->isSelected());
}
void onSetGridClick() {
try {
// TODO use the same context as in ConfigureTools::onExecute
const ContextReader reader(UIContext::instance());
const Document* document = reader.document();
if (document && document->isMaskVisible()) {
const Mask* mask(document->mask());
docPref().grid.bounds(mask->bounds());
}
else {
Command* grid_settings_cmd =
CommandsModule::instance()->getCommandByName(CommandId::GridSettings);
UIContext::instance()->executeCommand(grid_settings_cmd);
}
}
catch (LockedDocumentException& e) {
Console::showException(e);
}
}
void onSnapToGridClick() {
docPref().grid.snap(snapToGrid()->isSelected());
}
Context* m_ctx;
Document* m_lastDocument;
};
class ConfigureTools : public Command {
public:
ConfigureTools();
Command* clone() const override { return new ConfigureTools(*this); }
protected:
void onExecute(Context* context) override;
};
static ToolsConfigurationWindow* window;
ConfigureTools::ConfigureTools()
: Command("ConfigureTools",
"Configure Tools",
CmdUIOnlyFlag)
{
}
// Slot for App::Exit signal
static void on_exit_delete_this_widget()
{
ASSERT(window != NULL);
delete window;
}
void ConfigureTools::onExecute(Context* context)
{
if (!window) {
window = new ToolsConfigurationWindow(context);
App::instance()->Exit.connect(&on_exit_delete_this_widget);
}
// If the window is opened, close it
else if (window->isVisible()) {
window->closeWindow(NULL);
return;
}
window->openWindow();
}
Command* CommandFactory::createConfigureToolsCommand()
{
return new ConfigureTools;
}
} // namespace app

View File

@ -21,7 +21,6 @@ FOR_EACH_COMMAND(CloseAllFiles)
FOR_EACH_COMMAND(CloseFile)
FOR_EACH_COMMAND(ColorCurve)
FOR_EACH_COMMAND(ColorQuantization)
FOR_EACH_COMMAND(ConfigureTools)
FOR_EACH_COMMAND(ConvolutionMatrix)
FOR_EACH_COMMAND(Copy)
FOR_EACH_COMMAND(CopyCel)

View File

@ -143,15 +143,6 @@ bool ToolBar::onProcessMessage(Message* msg)
}
}
toolrc = getToolGroupBounds(ConfigureToolIndex);
if (mouseMsg->position().y >= toolrc.y &&
mouseMsg->position().y < toolrc.y+toolrc.h) {
Command* conf_tools_cmd =
CommandsModule::instance()->getCommandByName(CommandId::ConfigureTools);
UIContext::instance()->executeCommand(conf_tools_cmd);
}
toolrc = getToolGroupBounds(PreviewVisibilityIndex);
if (mouseMsg->position().y >= toolrc.y &&
mouseMsg->position().y < toolrc.y+toolrc.h) {
@ -191,12 +182,6 @@ bool ToolBar::onProcessMessage(Message* msg)
}
}
toolrc = getToolGroupBounds(ConfigureToolIndex);
if (mouseMsg->position().y >= toolrc.y &&
mouseMsg->position().y < toolrc.y+toolrc.h) {
new_hot_index = ConfigureToolIndex;
}
toolrc = getToolGroupBounds(PreviewVisibilityIndex);
if (mouseMsg->position().y >= toolrc.y &&
mouseMsg->position().y < toolrc.y+toolrc.h) {
@ -341,27 +326,10 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
}
}
// Draw button to show tool configuration
toolrc = getToolGroupBounds(ConfigureToolIndex);
toolrc.offset(-getBounds().x, -getBounds().y);
bool isHot = (m_hotIndex == ConfigureToolIndex);
theme->drawRect(
g, toolrc,
(isHot ? theme->parts.toolbuttonHot().get():
theme->parts.toolbuttonLast().get()),
(isHot ? hotFace: normalFace));
she::Surface* icon = theme->getToolIcon("configuration");
if (icon) {
g->drawRgbaSurface(icon,
toolrc.x+toolrc.w/2-icon->width()/2,
toolrc.y+toolrc.h/2-icon->height()/2);
}
// Draw button to show/hide preview
toolrc = getToolGroupBounds(PreviewVisibilityIndex);
toolrc.offset(-getBounds().x, -getBounds().y);
isHot = (m_hotIndex == PreviewVisibilityIndex ||
bool isHot = (m_hotIndex == PreviewVisibilityIndex ||
App::instance()->getMainWindow()->getPreviewEditor()->isPreviewEnabled());
theme->drawRect(
g,
@ -370,7 +338,7 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
theme->parts.toolbuttonLast().get()),
(isHot ? hotFace: normalFace));
icon = theme->getToolIcon("minieditor");
she::Surface* icon = theme->getToolIcon("minieditor");
if (icon) {
g->drawRgbaSurface(icon,
toolrc.x+toolrc.w/2-icon->width()/2,
@ -471,11 +439,6 @@ Rect ToolBar::getToolGroupBounds(int group_index)
switch (group_index) {
case ConfigureToolIndex:
rc.y += groups*(iconsize.h-1*guiscale())+ 8*guiscale();
rc.h = iconsize.h+2*guiscale();
break;
case PreviewVisibilityIndex:
rc.y += rc.h - iconsize.h - 2*guiscale();
rc.h = iconsize.h+2*guiscale();
@ -534,9 +497,6 @@ void ToolBar::openTipWindow(int group_index, Tool* tool)
tooltip += key->accels().front().toString();
}
}
else if (group_index == ConfigureToolIndex) {
tooltip = "Configure Tool";
}
else if (group_index == PreviewVisibilityIndex) {
if (App::instance()->getMainWindow()->getPreviewEditor()->isPreviewEnabled())
tooltip = "Hide Preview";

View File

@ -35,8 +35,7 @@ namespace app {
static ToolBar* instance() { return m_instance; }
static const int NoneIndex = -1;
static const int ConfigureToolIndex = -2;
static const int PreviewVisibilityIndex = -3;
static const int PreviewVisibilityIndex = -2;
ToolBar();
~ToolBar();