mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 01:20:25 +00:00
Replace the dummy developer "console" with a WorkspaceView
This is completely experimental stuff. Just added this because the previous window doesn't make sense.
This commit is contained in:
parent
43ed994812
commit
3c2e01b5d8
@ -156,6 +156,7 @@ add_library(app-lib
|
|||||||
ui/color_selector.cpp
|
ui/color_selector.cpp
|
||||||
ui/color_sliders.cpp
|
ui/color_sliders.cpp
|
||||||
ui/context_bar.cpp
|
ui/context_bar.cpp
|
||||||
|
ui/devconsole_view.cpp
|
||||||
ui/document_view.cpp
|
ui/document_view.cpp
|
||||||
ui/drop_down_button.cpp
|
ui/drop_down_button.cpp
|
||||||
ui/editor/cursor.cpp
|
ui/editor/cursor.cpp
|
||||||
|
@ -20,10 +20,14 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/context.h"
|
#include "app/context.h"
|
||||||
#include "app/document.h"
|
#include "app/document.h"
|
||||||
#include "app/documents.h"
|
#include "app/documents.h"
|
||||||
|
#include "app/ui/devconsole_view.h"
|
||||||
|
#include "app/ui/main_window.h"
|
||||||
|
#include "app/ui/workspace.h"
|
||||||
#include "ui/box.h"
|
#include "ui/box.h"
|
||||||
#include "ui/button.h"
|
#include "ui/button.h"
|
||||||
#include "ui/combobox.h"
|
#include "ui/combobox.h"
|
||||||
@ -33,36 +37,6 @@ namespace app {
|
|||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
class DeveloperConsole : public Window {
|
|
||||||
public:
|
|
||||||
DeveloperConsole()
|
|
||||||
: Window(WithTitleBar, "Developer Console")
|
|
||||||
, m_vbox(JI_VERTICAL)
|
|
||||||
{
|
|
||||||
m_vbox.addChild(&m_docs);
|
|
||||||
addChild(&m_vbox);
|
|
||||||
|
|
||||||
remapWindow();
|
|
||||||
centerWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
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().c_str());
|
|
||||||
}
|
|
||||||
m_docs.addItem("---------");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Box m_vbox;
|
|
||||||
ComboBox m_docs;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DeveloperConsoleCommand : public Command {
|
class DeveloperConsoleCommand : public Command {
|
||||||
public:
|
public:
|
||||||
DeveloperConsoleCommand();
|
DeveloperConsoleCommand();
|
||||||
@ -71,7 +45,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void onExecute(Context* context);
|
void onExecute(Context* context);
|
||||||
|
|
||||||
DeveloperConsole* m_devConsole;
|
DevConsoleView* m_devConsole;
|
||||||
};
|
};
|
||||||
|
|
||||||
DeveloperConsoleCommand::DeveloperConsoleCommand()
|
DeveloperConsoleCommand::DeveloperConsoleCommand()
|
||||||
@ -84,21 +58,19 @@ DeveloperConsoleCommand::DeveloperConsoleCommand()
|
|||||||
|
|
||||||
DeveloperConsoleCommand::~DeveloperConsoleCommand()
|
DeveloperConsoleCommand::~DeveloperConsoleCommand()
|
||||||
{
|
{
|
||||||
// delete m_devConsole;
|
delete m_devConsole;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeveloperConsoleCommand::onExecute(Context* context)
|
void DeveloperConsoleCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
if (!m_devConsole) {
|
if (!m_devConsole) {
|
||||||
m_devConsole = new DeveloperConsole();
|
m_devConsole = new DevConsoleView();
|
||||||
}
|
|
||||||
else if (m_devConsole->isVisible()) {
|
App::instance()->getMainWindow()->getWorkspace()->addView(m_devConsole);
|
||||||
m_devConsole->closeWindow(NULL);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_devConsole->updateDocuments(context);
|
App::instance()->getMainWindow()->getTabsBar()->selectTab(m_devConsole);
|
||||||
m_devConsole->openWindow();
|
App::instance()->getMainWindow()->getWorkspace()->setActiveView(m_devConsole);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command* CommandFactory::createDeveloperConsoleCommand()
|
Command* CommandFactory::createDeveloperConsoleCommand()
|
||||||
|
121
src/app/ui/devconsole_view.cpp
Normal file
121
src/app/ui/devconsole_view.cpp
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/* Aseprite
|
||||||
|
* Copyright (C) 2001-2014 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "app/ui/devconsole_view.h"
|
||||||
|
|
||||||
|
#include "ui/entry.h"
|
||||||
|
#include "ui/message.h"
|
||||||
|
#include "ui/textbox.h"
|
||||||
|
#include "ui/view.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
|
||||||
|
using namespace ui;
|
||||||
|
|
||||||
|
class DevConsoleView::CommmandEntry : public Entry {
|
||||||
|
public:
|
||||||
|
CommmandEntry() : Entry(256, "") {
|
||||||
|
setFocusStop(true);
|
||||||
|
setFocusMagnet(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Signal1<void, const std::string&> ExecuteCommand;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool onProcessMessage(Message* msg) OVERRIDE {
|
||||||
|
switch (msg->type()) {
|
||||||
|
case kKeyDownMessage:
|
||||||
|
if (hasFocus()) {
|
||||||
|
KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
|
||||||
|
KeyScancode scancode = keymsg->scancode();
|
||||||
|
|
||||||
|
switch (scancode) {
|
||||||
|
case kKeyEnter:
|
||||||
|
case kKeyEnterPad: {
|
||||||
|
std::string cmd = getText();
|
||||||
|
ExecuteCommand(cmd);
|
||||||
|
setText("");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return Entry::onProcessMessage(msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DevConsoleView::DevConsoleView()
|
||||||
|
: Box(JI_VERTICAL)
|
||||||
|
, m_textBox("Welcome Aseprite Console\n(experimental)", JI_LEFT)
|
||||||
|
, m_label(">")
|
||||||
|
, m_entry(new CommmandEntry)
|
||||||
|
{
|
||||||
|
addChild(&m_view);
|
||||||
|
addChild(&m_bottomBox);
|
||||||
|
|
||||||
|
m_bottomBox.addChild(&m_label);
|
||||||
|
m_bottomBox.addChild(m_entry);
|
||||||
|
|
||||||
|
m_view.attachToView(&m_textBox);
|
||||||
|
m_view.setExpansive(true);
|
||||||
|
m_entry->setExpansive(true);
|
||||||
|
|
||||||
|
m_entry->ExecuteCommand.connect(&DevConsoleView::onExecuteCommand, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
DevConsoleView::~DevConsoleView()
|
||||||
|
{
|
||||||
|
// m_document->removeObserver(this);
|
||||||
|
// delete m_editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DevConsoleView::getTabText()
|
||||||
|
{
|
||||||
|
return "Console";
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceView* DevConsoleView::cloneWorkspaceView()
|
||||||
|
{
|
||||||
|
return new DevConsoleView();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevConsoleView::onWorkspaceViewSelected()
|
||||||
|
{
|
||||||
|
m_entry->requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevConsoleView::onClonedFrom(WorkspaceView* from)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DevConsoleView::onProcessMessage(Message* msg)
|
||||||
|
{
|
||||||
|
return Box::onProcessMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevConsoleView::onExecuteCommand(const std::string& cmd)
|
||||||
|
{
|
||||||
|
m_textBox.setText(m_textBox.getText() + "\n" + cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace app
|
64
src/app/ui/devconsole_view.h
Normal file
64
src/app/ui/devconsole_view.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* Aseprite
|
||||||
|
* Copyright (C) 2001-2014 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef APP_UI_DEVCONSOLE_VIEW_H_INCLUDED
|
||||||
|
#define APP_UI_DEVCONSOLE_VIEW_H_INCLUDED
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "app/ui/tabs.h"
|
||||||
|
#include "app/ui/workspace_view.h"
|
||||||
|
#include "base/compiler_specific.h"
|
||||||
|
#include "ui/box.h"
|
||||||
|
#include "ui/label.h"
|
||||||
|
#include "ui/textbox.h"
|
||||||
|
#include "ui/view.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
class DevConsoleView : public ui::Box
|
||||||
|
, public TabView
|
||||||
|
, public WorkspaceView {
|
||||||
|
public:
|
||||||
|
DevConsoleView();
|
||||||
|
~DevConsoleView();
|
||||||
|
|
||||||
|
// TabView implementation
|
||||||
|
std::string getTabText() OVERRIDE;
|
||||||
|
|
||||||
|
// WorkspaceView implementation
|
||||||
|
ui::Widget* getContentWidget() OVERRIDE { return this; }
|
||||||
|
WorkspaceView* cloneWorkspaceView() OVERRIDE;
|
||||||
|
void onWorkspaceViewSelected() OVERRIDE;
|
||||||
|
void onClonedFrom(WorkspaceView* from) OVERRIDE;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool onProcessMessage(ui::Message* msg) OVERRIDE;
|
||||||
|
void onExecuteCommand(const std::string& cmd);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class CommmandEntry;
|
||||||
|
|
||||||
|
ui::View m_view;
|
||||||
|
ui::TextBox m_textBox;
|
||||||
|
ui::HBox m_bottomBox;
|
||||||
|
ui::Label m_label;
|
||||||
|
CommmandEntry* m_entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace app
|
||||||
|
|
||||||
|
#endif
|
@ -171,6 +171,11 @@ WorkspaceView* DocumentView::cloneWorkspaceView()
|
|||||||
return new DocumentView(m_document, Normal);
|
return new DocumentView(m_document, Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DocumentView::onWorkspaceViewSelected()
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
void DocumentView::onClonedFrom(WorkspaceView* from)
|
void DocumentView::onClonedFrom(WorkspaceView* from)
|
||||||
{
|
{
|
||||||
Editor* newEditor = getEditor();
|
Editor* newEditor = getEditor();
|
||||||
|
@ -58,6 +58,7 @@ namespace app {
|
|||||||
// WorkspaceView implementation
|
// WorkspaceView implementation
|
||||||
ui::Widget* getContentWidget() OVERRIDE { return this; }
|
ui::Widget* getContentWidget() OVERRIDE { return this; }
|
||||||
WorkspaceView* cloneWorkspaceView() OVERRIDE;
|
WorkspaceView* cloneWorkspaceView() OVERRIDE;
|
||||||
|
void onWorkspaceViewSelected() OVERRIDE;
|
||||||
void onClonedFrom(WorkspaceView* from) OVERRIDE;
|
void onClonedFrom(WorkspaceView* from) OVERRIDE;
|
||||||
|
|
||||||
// DocumentObserver implementation
|
// DocumentObserver implementation
|
||||||
|
@ -84,6 +84,9 @@ void WorkspacePart::setActiveView(WorkspaceView* view)
|
|||||||
newContent->requestFocus();
|
newContent->requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_activeView)
|
||||||
|
m_activeView->onWorkspaceViewSelected();
|
||||||
|
|
||||||
layout();
|
layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ namespace app {
|
|||||||
|
|
||||||
virtual ui::Widget* getContentWidget() = 0;
|
virtual ui::Widget* getContentWidget() = 0;
|
||||||
virtual WorkspaceView* cloneWorkspaceView() = 0;
|
virtual WorkspaceView* cloneWorkspaceView() = 0;
|
||||||
|
virtual void onWorkspaceViewSelected() = 0;
|
||||||
|
|
||||||
// Called after the view is added in the correct position inside
|
// Called after the view is added in the correct position inside
|
||||||
// the workspace. It can be used to copy/clone scroll position
|
// the workspace. It can be used to copy/clone scroll position
|
||||||
|
Loading…
x
Reference in New Issue
Block a user