2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2024-09-05 04:37:24 +08:00
|
|
|
// Copyright (C) 2018-2024 Igara Studio S.A.
|
2018-06-06 00:11:29 +08:00
|
|
|
// Copyright (C) 2001-2018 David Capello
|
2015-02-12 23:16:25 +08:00
|
|
|
//
|
2016-08-27 04:02:58 +08:00
|
|
|
// This program is distributed under the terms of
|
|
|
|
// the End-User License Agreement for Aseprite.
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2013-01-21 05:40:37 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/workspace.h"
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2015-05-10 06:55:33 +08:00
|
|
|
#include "app/app.h"
|
|
|
|
#include "app/ui/input_chain.h"
|
2015-03-05 04:23:40 +08:00
|
|
|
#include "app/ui/skin/skin_theme.h"
|
2015-04-03 02:43:50 +08:00
|
|
|
#include "app/ui/workspace_tabs.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/workspace_view.h"
|
2015-03-05 04:23:40 +08:00
|
|
|
#include "base/remove_from_container.h"
|
2015-04-01 04:31:45 +08:00
|
|
|
#include "ui/paint_event.h"
|
|
|
|
#include "ui/resize_event.h"
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
using namespace app::skin;
|
|
|
|
using namespace ui;
|
2015-02-12 23:16:25 +08:00
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
// static
|
|
|
|
WidgetType Workspace::Type()
|
|
|
|
{
|
|
|
|
static WidgetType type = kGenericWidget;
|
|
|
|
if (type == kGenericWidget)
|
|
|
|
type = register_widget_type();
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2013-01-21 05:40:37 +08:00
|
|
|
Workspace::Workspace()
|
2015-04-01 04:31:45 +08:00
|
|
|
: Widget(Workspace::Type())
|
|
|
|
, m_mainPanel(WorkspacePanel::MAIN_PANEL)
|
|
|
|
, m_tabs(nullptr)
|
|
|
|
, m_activePanel(&m_mainPanel)
|
|
|
|
, m_dropPreviewPanel(nullptr)
|
2015-04-03 02:43:50 +08:00
|
|
|
, m_dropPreviewTabs(nullptr)
|
2013-01-21 05:40:37 +08:00
|
|
|
{
|
2018-12-13 21:48:12 +08:00
|
|
|
enableFlags(IGNORE_MOUSE);
|
2015-04-01 04:31:45 +08:00
|
|
|
addChild(&m_mainPanel);
|
2017-08-15 21:39:06 +08:00
|
|
|
|
|
|
|
InitTheme.connect(
|
|
|
|
[this]{
|
2022-02-19 06:01:46 +08:00
|
|
|
auto theme = SkinTheme::get(this);
|
2017-08-15 21:39:06 +08:00
|
|
|
setBgColor(theme->colors.workspace());
|
|
|
|
});
|
|
|
|
initTheme();
|
2013-01-21 05:40:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Workspace::~Workspace()
|
|
|
|
{
|
2013-03-28 08:19:35 +08:00
|
|
|
// No views at this point.
|
|
|
|
ASSERT(m_views.empty());
|
2013-01-21 05:40:37 +08:00
|
|
|
}
|
|
|
|
|
2015-04-03 02:43:50 +08:00
|
|
|
void Workspace::setTabsBar(WorkspaceTabs* tabs)
|
2015-03-28 04:26:04 +08:00
|
|
|
{
|
2015-04-01 04:31:45 +08:00
|
|
|
m_tabs = tabs;
|
|
|
|
m_mainPanel.setTabsBar(tabs);
|
2015-03-28 04:26:04 +08:00
|
|
|
}
|
|
|
|
|
2015-03-19 04:34:22 +08:00
|
|
|
void Workspace::addView(WorkspaceView* view, int pos)
|
2013-01-21 05:40:37 +08:00
|
|
|
{
|
2015-04-05 03:45:58 +08:00
|
|
|
addViewToPanel(&m_mainPanel, view, false, pos);
|
2013-01-21 05:40:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::removeView(WorkspaceView* view)
|
|
|
|
{
|
2019-05-22 02:14:06 +08:00
|
|
|
ASSERT(view);
|
2015-03-05 04:23:40 +08:00
|
|
|
base::remove_from_container(m_views, view);
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
WorkspacePanel* panel = getViewPanel(view);
|
|
|
|
ASSERT(panel);
|
|
|
|
if (panel)
|
|
|
|
panel->removeView(view);
|
2019-05-22 02:14:06 +08:00
|
|
|
|
|
|
|
view->onAfterRemoveView(this);
|
2013-03-28 08:19:35 +08:00
|
|
|
}
|
|
|
|
|
2016-06-09 00:27:36 +08:00
|
|
|
bool Workspace::closeView(WorkspaceView* view, bool quitting)
|
2015-02-23 08:18:53 +08:00
|
|
|
{
|
2016-06-09 00:27:36 +08:00
|
|
|
return view->onCloseView(this, quitting);
|
2015-02-23 08:18:53 +08:00
|
|
|
}
|
|
|
|
|
2014-07-29 11:53:24 +08:00
|
|
|
WorkspaceView* Workspace::activeView()
|
2013-03-28 08:19:35 +08:00
|
|
|
{
|
2015-04-01 04:31:45 +08:00
|
|
|
return (m_activePanel ? m_activePanel->activeView(): nullptr);
|
2013-01-21 05:40:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::setActiveView(WorkspaceView* view)
|
|
|
|
{
|
2015-04-01 04:31:45 +08:00
|
|
|
m_activePanel = getViewPanel(view);
|
|
|
|
ASSERT(m_activePanel);
|
|
|
|
if (!m_activePanel)
|
|
|
|
return;
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2024-11-12 22:35:23 +08:00
|
|
|
BeforeViewChanged();
|
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
m_activePanel->setActiveView(view);
|
2013-03-28 08:19:35 +08:00
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
ActiveViewChanged(); // Fire ActiveViewChanged event
|
|
|
|
}
|
2013-03-28 08:19:35 +08:00
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
void Workspace::setMainPanelAsActive()
|
|
|
|
{
|
2024-11-12 22:35:23 +08:00
|
|
|
BeforeViewChanged();
|
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
m_activePanel = &m_mainPanel;
|
2015-04-01 22:35:52 +08:00
|
|
|
|
|
|
|
removeDropViewPreview();
|
|
|
|
m_dropPreviewPanel = nullptr;
|
2015-04-03 03:02:24 +08:00
|
|
|
m_dropPreviewTabs = nullptr;
|
2015-04-01 22:35:52 +08:00
|
|
|
|
2013-03-28 08:19:35 +08:00
|
|
|
ActiveViewChanged(); // Fire ActiveViewChanged event
|
2013-01-21 05:40:37 +08:00
|
|
|
}
|
|
|
|
|
2015-04-17 20:49:49 +08:00
|
|
|
bool Workspace::canSelectOtherTab() const
|
|
|
|
{
|
|
|
|
return m_activePanel->tabs()->canSelectOtherTab();
|
|
|
|
}
|
|
|
|
|
2015-04-05 01:40:07 +08:00
|
|
|
void Workspace::selectNextTab()
|
|
|
|
{
|
|
|
|
m_activePanel->tabs()->selectNextTab();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::selectPreviousTab()
|
|
|
|
{
|
|
|
|
m_activePanel->tabs()->selectPreviousTab();
|
|
|
|
}
|
|
|
|
|
2015-04-06 23:22:20 +08:00
|
|
|
void Workspace::duplicateActiveView()
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
if (!view)
|
|
|
|
return;
|
|
|
|
|
|
|
|
WorkspaceView* clone = view->cloneWorkspaceView();
|
|
|
|
if (!clone)
|
|
|
|
return;
|
|
|
|
|
|
|
|
WorkspacePanel* panel = getViewPanel(view);
|
|
|
|
addViewToPanel(panel, clone, false, -1);
|
|
|
|
clone->onClonedFrom(view);
|
|
|
|
setActiveView(clone);
|
|
|
|
}
|
|
|
|
|
2015-05-05 02:52:00 +08:00
|
|
|
void Workspace::updateTabs()
|
|
|
|
{
|
2015-12-04 06:46:13 +08:00
|
|
|
WidgetsList children = this->children();
|
2015-05-05 02:52:00 +08:00
|
|
|
while (!children.empty()) {
|
|
|
|
Widget* child = children.back();
|
|
|
|
children.erase(--children.end());
|
|
|
|
|
2015-06-24 01:37:22 +08:00
|
|
|
if (child->type() == WorkspacePanel::Type())
|
2015-05-05 02:52:00 +08:00
|
|
|
static_cast<WorkspacePanel*>(child)->tabs()->updateTabs();
|
|
|
|
|
2015-12-04 06:46:13 +08:00
|
|
|
for (auto subchild : child->children())
|
2015-05-05 02:52:00 +08:00
|
|
|
children.push_back(subchild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-05 04:23:40 +08:00
|
|
|
void Workspace::onPaint(PaintEvent& ev)
|
2014-01-26 22:22:23 +08:00
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
ev.graphics()->fillRect(bgColor(), clientBounds());
|
2014-01-26 22:22:23 +08:00
|
|
|
}
|
|
|
|
|
2015-03-28 05:14:00 +08:00
|
|
|
void Workspace::onResize(ui::ResizeEvent& ev)
|
|
|
|
{
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
setBoundsQuietly(ev.bounds());
|
2015-03-28 05:14:00 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
gfx::Rect rc = childrenBounds();
|
2015-12-04 06:46:13 +08:00
|
|
|
for (auto child : children())
|
2015-03-28 05:45:36 +08:00
|
|
|
child->setBounds(rc);
|
2015-03-28 05:14:00 +08:00
|
|
|
}
|
|
|
|
|
2022-08-09 04:22:39 +08:00
|
|
|
DropViewPreviewResult Workspace::setDropViewPreview(
|
|
|
|
const gfx::Point& screenPos,
|
|
|
|
WorkspaceView* view,
|
|
|
|
WorkspaceTabs* tabs)
|
2015-03-28 05:14:00 +08:00
|
|
|
{
|
2015-04-03 02:43:50 +08:00
|
|
|
TabView* tabView = dynamic_cast<TabView*>(view);
|
|
|
|
WorkspaceTabs* newTabs = nullptr;
|
2022-08-09 04:22:39 +08:00
|
|
|
WorkspacePanel* panel = getPanelAt(screenPos);
|
2015-04-03 02:43:50 +08:00
|
|
|
if (!newTabs) {
|
2022-08-09 04:22:39 +08:00
|
|
|
newTabs = getTabsAt(screenPos);
|
2015-04-03 02:43:50 +08:00
|
|
|
// Drop preview is only to drop tabs from a different WorkspaceTabs.
|
|
|
|
if (newTabs == tabs)
|
|
|
|
newTabs = nullptr;
|
|
|
|
}
|
2015-03-28 05:14:00 +08:00
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
if (m_dropPreviewPanel && m_dropPreviewPanel != panel)
|
|
|
|
m_dropPreviewPanel->removeDropViewPreview();
|
2015-04-03 02:43:50 +08:00
|
|
|
if (m_dropPreviewTabs && m_dropPreviewTabs != newTabs)
|
|
|
|
m_dropPreviewTabs->removeDropViewPreview();
|
2015-03-28 06:42:18 +08:00
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
m_dropPreviewPanel = panel;
|
2015-04-03 02:43:50 +08:00
|
|
|
m_dropPreviewTabs = newTabs;
|
2015-03-28 06:42:18 +08:00
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
if (m_dropPreviewPanel)
|
2022-08-09 04:22:39 +08:00
|
|
|
m_dropPreviewPanel->setDropViewPreview(screenPos, view);
|
2015-04-03 02:43:50 +08:00
|
|
|
if (m_dropPreviewTabs)
|
2022-08-09 04:22:39 +08:00
|
|
|
m_dropPreviewTabs->setDropViewPreview(screenPos, tabView);
|
2015-04-05 03:25:57 +08:00
|
|
|
|
|
|
|
if (panel)
|
|
|
|
return DropViewPreviewResult::DROP_IN_PANEL;
|
|
|
|
else if (newTabs)
|
|
|
|
return DropViewPreviewResult::DROP_IN_TABS;
|
|
|
|
else
|
|
|
|
return DropViewPreviewResult::FLOATING;
|
2015-03-28 05:14:00 +08:00
|
|
|
}
|
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
void Workspace::removeDropViewPreview()
|
2015-03-28 06:42:18 +08:00
|
|
|
{
|
2015-04-05 01:53:27 +08:00
|
|
|
if (m_dropPreviewPanel) {
|
2015-04-01 04:31:45 +08:00
|
|
|
m_dropPreviewPanel->removeDropViewPreview();
|
2015-04-05 01:53:27 +08:00
|
|
|
m_dropPreviewPanel = nullptr;
|
|
|
|
}
|
2015-04-03 02:43:50 +08:00
|
|
|
|
2015-04-05 01:53:27 +08:00
|
|
|
if (m_dropPreviewTabs) {
|
2015-04-03 02:43:50 +08:00
|
|
|
m_dropPreviewTabs->removeDropViewPreview();
|
2015-04-05 01:53:27 +08:00
|
|
|
m_dropPreviewTabs = nullptr;
|
|
|
|
}
|
2015-03-28 06:42:18 +08:00
|
|
|
}
|
|
|
|
|
2022-08-09 04:22:39 +08:00
|
|
|
DropViewAtResult Workspace::dropViewAt(const gfx::Point& screenPos,
|
|
|
|
WorkspaceView* view,
|
|
|
|
const bool clone)
|
2015-03-28 05:14:00 +08:00
|
|
|
{
|
2022-08-09 04:22:39 +08:00
|
|
|
WorkspaceTabs* tabs = getTabsAt(screenPos);
|
|
|
|
WorkspacePanel* panel = getPanelAt(screenPos);
|
2015-04-05 01:53:27 +08:00
|
|
|
|
2015-04-05 03:45:58 +08:00
|
|
|
if (panel) {
|
|
|
|
// Create new panel
|
2022-08-09 04:22:39 +08:00
|
|
|
return panel->dropViewAt(screenPos, getViewPanel(view), view, clone);
|
2015-04-05 03:45:58 +08:00
|
|
|
}
|
2015-04-05 01:53:27 +08:00
|
|
|
else if (tabs && tabs != getViewPanel(view)->tabs()) {
|
2015-04-05 03:45:58 +08:00
|
|
|
// Dock tab in other tabs
|
2015-04-05 01:53:27 +08:00
|
|
|
WorkspacePanel* dropPanel = tabs->panel();
|
2015-04-03 02:43:50 +08:00
|
|
|
ASSERT(dropPanel);
|
|
|
|
|
2015-04-05 01:53:27 +08:00
|
|
|
int pos = tabs->getDropTabIndex();
|
2015-04-21 00:49:25 +08:00
|
|
|
DropViewAtResult result;
|
|
|
|
|
2015-04-21 21:24:42 +08:00
|
|
|
WorkspaceView* originalView = view;
|
2015-04-21 00:49:25 +08:00
|
|
|
if (clone) {
|
|
|
|
view = view->cloneWorkspaceView();
|
|
|
|
result = DropViewAtResult::CLONED_VIEW;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
removeView(view);
|
|
|
|
result = DropViewAtResult::MOVED_TO_OTHER_PANEL;
|
|
|
|
}
|
2015-04-03 02:43:50 +08:00
|
|
|
|
2015-04-05 03:45:58 +08:00
|
|
|
addViewToPanel(dropPanel, view, true, pos);
|
2015-04-21 21:24:42 +08:00
|
|
|
|
|
|
|
if (result == DropViewAtResult::CLONED_VIEW)
|
|
|
|
view->onClonedFrom(originalView);
|
|
|
|
|
2015-04-21 00:49:25 +08:00
|
|
|
return result;
|
2015-04-03 02:43:50 +08:00
|
|
|
}
|
|
|
|
else
|
2015-04-21 00:49:25 +08:00
|
|
|
return DropViewAtResult::NOTHING;
|
2015-04-03 02:43:50 +08:00
|
|
|
}
|
|
|
|
|
2015-04-05 03:45:58 +08:00
|
|
|
void Workspace::addViewToPanel(WorkspacePanel* panel, WorkspaceView* view, bool from_drop, int pos)
|
2015-04-03 02:43:50 +08:00
|
|
|
{
|
2015-04-05 03:45:58 +08:00
|
|
|
panel->addView(view, from_drop, pos);
|
2015-04-01 04:31:45 +08:00
|
|
|
|
2015-04-03 02:43:50 +08:00
|
|
|
m_activePanel = panel;
|
|
|
|
m_views.push_back(view);
|
|
|
|
|
|
|
|
setActiveView(view);
|
2015-04-21 21:24:42 +08:00
|
|
|
layout();
|
2015-03-28 05:14:00 +08:00
|
|
|
}
|
|
|
|
|
2015-04-01 04:31:45 +08:00
|
|
|
WorkspacePanel* Workspace::getViewPanel(WorkspaceView* view)
|
2015-03-28 05:45:36 +08:00
|
|
|
{
|
2015-04-01 04:31:45 +08:00
|
|
|
Widget* widget = view->getContentWidget();
|
|
|
|
while (widget) {
|
2015-06-24 01:37:22 +08:00
|
|
|
if (widget->type() == WorkspacePanel::Type())
|
2015-04-01 04:31:45 +08:00
|
|
|
return static_cast<WorkspacePanel*>(widget);
|
2015-03-28 05:45:36 +08:00
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
widget = widget->parent();
|
2015-04-01 04:31:45 +08:00
|
|
|
}
|
|
|
|
return nullptr;
|
2015-03-28 05:45:36 +08:00
|
|
|
}
|
|
|
|
|
2022-08-09 04:22:39 +08:00
|
|
|
WorkspacePanel* Workspace::getPanelAt(const gfx::Point& screenPos)
|
2015-03-28 05:45:36 +08:00
|
|
|
{
|
2022-08-09 04:22:39 +08:00
|
|
|
Widget* widget = manager()->pickFromScreenPos(screenPos);
|
2015-04-01 04:31:45 +08:00
|
|
|
while (widget) {
|
2015-06-24 01:37:22 +08:00
|
|
|
if (widget->type() == WorkspacePanel::Type())
|
2015-04-01 04:31:45 +08:00
|
|
|
return static_cast<WorkspacePanel*>(widget);
|
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
widget = widget->parent();
|
2015-04-01 04:31:45 +08:00
|
|
|
}
|
|
|
|
return nullptr;
|
2015-03-28 05:45:36 +08:00
|
|
|
}
|
|
|
|
|
2022-08-09 04:22:39 +08:00
|
|
|
WorkspaceTabs* Workspace::getTabsAt(const gfx::Point& screenPos)
|
2015-04-03 02:43:50 +08:00
|
|
|
{
|
2022-08-09 04:22:39 +08:00
|
|
|
Widget* widget = manager()->pickFromScreenPos(screenPos);
|
2015-04-03 02:43:50 +08:00
|
|
|
while (widget) {
|
2015-06-24 01:37:22 +08:00
|
|
|
if (widget->type() == Tabs::Type())
|
2015-04-03 02:43:50 +08:00
|
|
|
return static_cast<WorkspaceTabs*>(widget);
|
|
|
|
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
widget = widget->parent();
|
2015-04-03 02:43:50 +08:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-06-06 00:11:29 +08:00
|
|
|
void Workspace::onNewInputPriority(InputChainElement* newElement,
|
|
|
|
const ui::Message* msg)
|
2015-05-10 06:55:33 +08:00
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
2018-06-06 00:11:29 +08:00
|
|
|
activeElement->onNewInputPriority(newElement, msg);
|
2015-05-10 06:55:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::onCanCut(Context* ctx)
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
|
|
|
return activeElement->onCanCut(ctx);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::onCanCopy(Context* ctx)
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
|
|
|
return activeElement->onCanCopy(ctx);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::onCanPaste(Context* ctx)
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
|
|
|
return activeElement->onCanPaste(ctx);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::onCanClear(Context* ctx)
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
|
|
|
return activeElement->onCanClear(ctx);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::onCut(Context* ctx)
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
|
|
|
return activeElement->onCut(ctx);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::onCopy(Context* ctx)
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
|
|
|
return activeElement->onCopy(ctx);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-09-05 04:37:24 +08:00
|
|
|
bool Workspace::onPaste(Context* ctx,
|
|
|
|
const gfx::Point* position)
|
2015-05-10 06:55:33 +08:00
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
2024-09-05 04:37:24 +08:00
|
|
|
return activeElement->onPaste(ctx, position);
|
2015-05-10 06:55:33 +08:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::onClear(Context* ctx)
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
|
|
|
return activeElement->onClear(ctx);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::onCancel(Context* ctx)
|
|
|
|
{
|
|
|
|
WorkspaceView* view = activeView();
|
|
|
|
InputChainElement* activeElement = (view ? view->onGetInputChainElement(): nullptr);
|
|
|
|
if (activeElement)
|
|
|
|
activeElement->onCancel(ctx);
|
|
|
|
}
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
} // namespace app
|