mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 10:20:48 +00:00
Add app::StartView (work-in-progress)
This commit is contained in:
parent
0a01828ffe
commit
dd2839a49a
1
TODO.md
1
TODO.md
@ -37,6 +37,7 @@
|
||||
|
||||
# WIP
|
||||
|
||||
* Start view (src/app/ui/start_view.cpp)
|
||||
* Data recovery (src/app/data_recovery.cpp)
|
||||
* Projects (src/app/project.cpp)
|
||||
* Scriting support (src/scripting/engine.cpp)
|
||||
|
@ -184,6 +184,7 @@ add_library(app-library
|
||||
ui/skin/skin_theme.cpp
|
||||
ui/skin/style.cpp
|
||||
ui/skin/style_sheet.cpp
|
||||
ui/start_view.cpp
|
||||
ui/status_bar.cpp
|
||||
ui/tabs.cpp
|
||||
ui/timeline.cpp
|
||||
|
@ -35,12 +35,14 @@
|
||||
#include "app/ui/editor/editor_view.h"
|
||||
#include "app/ui/main_menu_bar.h"
|
||||
#include "app/ui/mini_editor.h"
|
||||
#include "app/ui/start_view.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui/tabs.h"
|
||||
#include "app/ui/timeline.h"
|
||||
#include "app/ui/toolbar.h"
|
||||
#include "app/ui/workspace.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "ui/message.h"
|
||||
#include "ui/splitter.h"
|
||||
#include "ui/system.h"
|
||||
#include "ui/view.h"
|
||||
@ -54,6 +56,7 @@ MainWindow::MainWindow()
|
||||
, m_lastSplitterPos(0.0)
|
||||
, m_lastTimelineSplitterPos(75.0)
|
||||
, m_advancedMode(false)
|
||||
, m_startView(NULL)
|
||||
{
|
||||
setId("main_window");
|
||||
|
||||
@ -116,6 +119,10 @@ MainWindow::MainWindow()
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
if (m_startView) {
|
||||
m_workspace->removeView(m_startView);
|
||||
delete m_startView;
|
||||
}
|
||||
delete m_contextBar;
|
||||
delete m_miniEditor;
|
||||
|
||||
@ -190,6 +197,19 @@ void MainWindow::popTimeline()
|
||||
setTimelineVisibility(true);
|
||||
}
|
||||
|
||||
bool MainWindow::onProcessMessage(ui::Message* msg)
|
||||
{
|
||||
#if 0 // TODO Enable start view
|
||||
if (msg->type() == kOpenMessage) {
|
||||
m_startView = new StartView;
|
||||
m_workspace->addView(m_startView);
|
||||
m_tabsBar->selectTab(m_startView);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Window::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
void MainWindow::onSaveLayout(SaveLayoutEvent& ev)
|
||||
{
|
||||
Window::onSaveLayout(ev);
|
||||
@ -205,10 +225,17 @@ void MainWindow::onSaveLayout(SaveLayoutEvent& ev)
|
||||
// inform to the UIContext that the current view has changed.
|
||||
void MainWindow::onActiveViewChange()
|
||||
{
|
||||
if (DocumentView* docView = dynamic_cast<DocumentView*>(m_workspace->getActiveView()))
|
||||
if (DocumentView* docView = dynamic_cast<DocumentView*>(m_workspace->getActiveView())) {
|
||||
UIContext::instance()->setActiveView(docView);
|
||||
else
|
||||
|
||||
m_contextBar->setVisible(true);
|
||||
}
|
||||
else {
|
||||
UIContext::instance()->setActiveView(NULL);
|
||||
|
||||
m_contextBar->setVisible(false);
|
||||
}
|
||||
layout();
|
||||
}
|
||||
|
||||
void MainWindow::clickTab(Tabs* tabs, TabView* tabView, ui::MouseButtons buttons)
|
||||
@ -216,8 +243,13 @@ void MainWindow::clickTab(Tabs* tabs, TabView* tabView, ui::MouseButtons buttons
|
||||
if (!tabView)
|
||||
return;
|
||||
|
||||
DocumentView* docView = static_cast<DocumentView*>(tabView);
|
||||
Document* document = docView->getDocument();
|
||||
WorkspaceView* workspaceView = dynamic_cast<WorkspaceView*>(tabView);
|
||||
if (m_workspace->getActiveView() != workspaceView)
|
||||
m_workspace->setActiveView(workspaceView);
|
||||
|
||||
DocumentView* docView = dynamic_cast<DocumentView*>(workspaceView);
|
||||
if (!docView)
|
||||
return;
|
||||
|
||||
UIContext* context = UIContext::instance();
|
||||
context->setActiveView(docView);
|
||||
@ -242,8 +274,7 @@ void MainWindow::clickTab(Tabs* tabs, TabView* tabView, ui::MouseButtons buttons
|
||||
void MainWindow::mouseOverTab(Tabs* tabs, TabView* tabView)
|
||||
{
|
||||
// Note: tabView can be NULL
|
||||
if (tabView) {
|
||||
DocumentView* docView = static_cast<DocumentView*>(tabView);
|
||||
if (DocumentView* docView = dynamic_cast<DocumentView*>(tabView)) {
|
||||
Document* document = docView->getDocument();
|
||||
m_statusBar->setStatusText(250, "%s",
|
||||
document->getFilename().c_str());
|
||||
|
@ -32,6 +32,7 @@ namespace app {
|
||||
class ContextBar;
|
||||
class MainMenuBar;
|
||||
class MiniEditorWindow;
|
||||
class StartView;
|
||||
class StatusBar;
|
||||
class Tabs;
|
||||
class Timeline;
|
||||
@ -50,6 +51,7 @@ namespace app {
|
||||
Workspace* getWorkspace() { return m_workspace; }
|
||||
MiniEditorWindow* getMiniEditor() { return m_miniEditor; }
|
||||
|
||||
void start();
|
||||
void reloadMenus();
|
||||
|
||||
bool isAdvancedMode() const { return m_advancedMode; }
|
||||
@ -64,6 +66,7 @@ namespace app {
|
||||
void mouseOverTab(Tabs* tabs, TabView* tabView);
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(ui::Message* msg) OVERRIDE;
|
||||
void onSaveLayout(ui::SaveLayoutEvent& ev) OVERRIDE;
|
||||
void onActiveViewChange();
|
||||
|
||||
@ -82,6 +85,7 @@ namespace app {
|
||||
Timeline* m_timeline;
|
||||
Workspace* m_workspace;
|
||||
MiniEditorWindow* m_miniEditor;
|
||||
StartView* m_startView;
|
||||
};
|
||||
|
||||
}
|
||||
|
65
src/app/ui/start_view.cpp
Normal file
65
src/app/ui/start_view.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 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/start_view.h"
|
||||
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "ui/label.h"
|
||||
#include "ui/textbox.h"
|
||||
#include "ui/view.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
using namespace skin;
|
||||
|
||||
StartView::StartView()
|
||||
: Box(JI_VERTICAL)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
setBgColor(theme->getColor(ThemeColor::Workspace));
|
||||
|
||||
child_spacing = 8 * jguiscale();
|
||||
|
||||
addChild(new Label("Welcome to " PACKAGE " v" VERSION));
|
||||
}
|
||||
|
||||
StartView::~StartView()
|
||||
{
|
||||
}
|
||||
|
||||
std::string StartView::getTabText()
|
||||
{
|
||||
return "Start";
|
||||
}
|
||||
|
||||
WorkspaceView* StartView::cloneWorkspaceView()
|
||||
{
|
||||
return NULL; // This view cannot be cloned
|
||||
}
|
||||
|
||||
void StartView::onClonedFrom(WorkspaceView* from)
|
||||
{
|
||||
ASSERT(false); // Never called
|
||||
}
|
||||
|
||||
} // namespace app
|
50
src/app/ui/start_view.h
Normal file
50
src/app/ui/start_view.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* 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_START_VIEW_H_INCLUDED
|
||||
#define APP_UI_START_VIEW_H_INCLUDED
|
||||
|
||||
#include "app/ui/tabs.h"
|
||||
#include "app/ui/workspace_view.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "ui/box.h"
|
||||
|
||||
namespace ui {
|
||||
class View;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
class StartView : public ui::Box
|
||||
, public TabView
|
||||
, public WorkspaceView {
|
||||
public:
|
||||
StartView();
|
||||
~StartView();
|
||||
|
||||
// TabView implementation
|
||||
std::string getTabText() OVERRIDE;
|
||||
|
||||
// WorkspaceView implementation
|
||||
ui::Widget* getContentWidget() OVERRIDE { return this; }
|
||||
WorkspaceView* cloneWorkspaceView() OVERRIDE;
|
||||
void onClonedFrom(WorkspaceView* from) OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -148,8 +148,14 @@ void Tabs::removeTab(TabView* tabView)
|
||||
if (!tab)
|
||||
return;
|
||||
|
||||
if (m_hot == tab) m_hot = NULL;
|
||||
if (m_selected == tab) m_selected = NULL;
|
||||
if (m_hot == tab)
|
||||
m_hot = NULL;
|
||||
|
||||
if (m_selected == tab) {
|
||||
selectNextTab();
|
||||
if (m_selected == tab)
|
||||
m_selected = NULL;
|
||||
}
|
||||
|
||||
TabsListIterator it =
|
||||
std::find(m_list_of_tabs.begin(), m_list_of_tabs.end(), tab);
|
||||
|
@ -110,6 +110,13 @@ void Workspace::setActiveView(WorkspaceView* view)
|
||||
|
||||
void Workspace::splitView(WorkspaceView* view, int orientation)
|
||||
{
|
||||
// Try to clone the workspace view.
|
||||
WorkspaceView* newView = view->cloneWorkspaceView();
|
||||
if (newView == NULL)
|
||||
return;
|
||||
|
||||
// Get the part where the view-to-clone is located because we need
|
||||
// to split this part.
|
||||
WorkspacePart* viewPart =
|
||||
static_cast<WorkspacePart*>(view->getContentWidget()->getParent());
|
||||
|
||||
@ -130,9 +137,8 @@ void Workspace::splitView(WorkspaceView* view, int orientation)
|
||||
// The new part is the active one.
|
||||
m_activePart = newPart;
|
||||
|
||||
// Clone the workspace view, and add it to the active part (newPart)
|
||||
// Add the cloned view to the active part (newPart)
|
||||
// using Workspace::addView().
|
||||
WorkspaceView* newView = view->cloneWorkspaceView();
|
||||
addView(newView);
|
||||
setActiveView(newView);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user