Add a simple DeveloperConsole for debugging purposes (F11 key).

This commit is contained in:
David Capello 2011-03-26 20:43:43 -03:00
parent 7dd873b1a7
commit d95919beb5
4 changed files with 109 additions and 0 deletions

View File

@ -14,6 +14,7 @@
<key command="SaveFileCopyAs" shortcut="Ctrl+Shift+C" />
<key command="CloseFile" shortcut="Ctrl+W" />
<key command="CloseAllFiles" shortcut="Ctrl+Shift+W" />
<key command="DeveloperConsole" shortcut="F11" />
<key command="ScreenShot" shortcut="F12" />
<key command="Exit" shortcut="Ctrl+Q" />
<key command="Exit" shortcut="Esc" />

View File

@ -108,6 +108,7 @@ add_library(aseprite-library
commands/cmd_crop.cpp
commands/cmd_cut.cpp
commands/cmd_deselect_mask.cpp
commands/cmd_developer_console.cpp
commands/cmd_donate.cpp
commands/cmd_duplicate_layer.cpp
commands/cmd_duplicate_sprite.cpp

View File

@ -0,0 +1,106 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2011 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "commands/command.h"
#include "context.h"
#include "document.h"
#include "documents.h"
#include "gui/box.h"
#include "gui/button.h"
#include "gui/combobox.h"
#include "gui/frame.h"
class DeveloperConsole : public Frame
{
public:
DeveloperConsole()
: Frame(false, "Developer Console")
, m_vbox(JI_VERTICAL)
{
jwidget_add_child(&m_vbox, &m_docs);
jwidget_add_child(this, &m_vbox);
remap_window();
center_window();
}
void updateDocuments(Context* context)
{
m_docs.removeAllItems();
m_docs.addItem("Documents");
for (Documents::const_iterator
it = context->getDocuments().begin(),
end = context->getDocuments().end(); it != end; ++it) {
m_docs.addItem((*it)->getFilename());
}
m_docs.addItem("---------");
}
private:
Box m_vbox;
ComboBox m_docs;
};
class DeveloperConsoleCommand : public Command
{
public:
DeveloperConsoleCommand();
~DeveloperConsoleCommand();
protected:
void onExecute(Context* context);
DeveloperConsole* m_devConsole;
};
DeveloperConsoleCommand::DeveloperConsoleCommand()
: Command("DeveloperConsole",
"DeveloperConsole",
CmdUIOnlyFlag)
{
m_devConsole = NULL;
}
DeveloperConsoleCommand::~DeveloperConsoleCommand()
{
// delete m_devConsole;
}
void DeveloperConsoleCommand::onExecute(Context* context)
{
if (!m_devConsole) {
m_devConsole = new DeveloperConsole();
}
else if (m_devConsole->isVisible()) {
m_devConsole->closeWindow(NULL);
return;
}
m_devConsole->updateDocuments(context);
m_devConsole->open_window_bg();
}
//////////////////////////////////////////////////////////////////////
// CommandFactory
Command* CommandFactory::createDeveloperConsoleCommand()
{
return new DeveloperConsoleCommand;
}

View File

@ -39,6 +39,7 @@ FOR_EACH_COMMAND(CropSprite)
FOR_EACH_COMMAND(Cut)
FOR_EACH_COMMAND(DeselectMask)
FOR_EACH_COMMAND(Despeckle)
FOR_EACH_COMMAND(DeveloperConsole)
FOR_EACH_COMMAND(Donate)
FOR_EACH_COMMAND(DuplicateLayer)
FOR_EACH_COMMAND(DuplicateSprite)