mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-09 18:44:46 +00:00
Trigger "New Sprite" double clicking tabs background (fix #912)
This commit is contained in:
parent
331e09bdbf
commit
a674f5addb
@ -430,6 +430,34 @@ void MainWindow::onContextMenuTab(Tabs* tabs, TabView* tabView)
|
||||
view->onTabPopup(m_workspace);
|
||||
}
|
||||
|
||||
void MainWindow::onTabsContainerDoubleClicked(Tabs* tabs)
|
||||
{
|
||||
WorkspacePanel* mainPanel = m_workspace->mainPanel();
|
||||
WorkspaceView* oldActiveView = mainPanel->activeView();
|
||||
app::Document* oldDoc = static_cast<app::Document*>(UIContext::instance()->activeDocument());
|
||||
|
||||
Command* command = CommandsModule::instance()->getCommandByName(CommandId::NewFile);
|
||||
UIContext::instance()->executeCommand(command);
|
||||
|
||||
app::Document* newDoc = static_cast<app::Document*>(UIContext::instance()->activeDocument());
|
||||
if (newDoc != oldDoc) {
|
||||
WorkspacePanel* doubleClickedPanel =
|
||||
static_cast<WorkspaceTabs*>(tabs)->panel();
|
||||
|
||||
// TODO move this code to workspace?
|
||||
// Put the new sprite in the double-clicked tabs control
|
||||
if (doubleClickedPanel != mainPanel) {
|
||||
WorkspaceView* newView = m_workspace->activeView();
|
||||
m_workspace->removeView(newView);
|
||||
m_workspace->addViewToPanel(doubleClickedPanel, newView, false, -1);
|
||||
|
||||
// Re-activate the old view in the main panel
|
||||
mainPanel->setActiveView(oldActiveView);
|
||||
doubleClickedPanel->setActiveView(newView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onMouseOverTab(Tabs* tabs, TabView* tabView)
|
||||
{
|
||||
// Note: tabView can be NULL
|
||||
|
@ -89,6 +89,7 @@ namespace app {
|
||||
void onCloseTab(Tabs* tabs, TabView* tabView) override;
|
||||
void onCloneTab(Tabs* tabs, TabView* tabView, int pos) override;
|
||||
void onContextMenuTab(Tabs* tabs, TabView* tabView) override;
|
||||
void onTabsContainerDoubleClicked(Tabs* tabs) override;
|
||||
void onMouseOverTab(Tabs* tabs, TabView* tabView) override;
|
||||
DropViewPreviewResult onFloatingTab(Tabs* tabs, TabView* tabView, const gfx::Point& pos) override;
|
||||
void onDockingTab(Tabs* tabs, TabView* tabView) override;
|
||||
|
@ -440,6 +440,13 @@ bool Tabs::onProcessMessage(Message* msg)
|
||||
updateMouseCursor();
|
||||
return true;
|
||||
|
||||
case kDoubleClickMessage:
|
||||
// When we double-click outside tabs (!m_hot), we trigger the
|
||||
// double-click in tabs container to show the "New Sprite" dialog.
|
||||
if (!m_hot && m_delegate)
|
||||
m_delegate->onTabsContainerDoubleClicked(this);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return Widget::onProcessMessage(msg);
|
||||
|
@ -89,6 +89,9 @@ namespace app {
|
||||
// When the right-click is pressed in the tab.
|
||||
virtual void onContextMenuTab(Tabs* tabs, TabView* tabView) = 0;
|
||||
|
||||
// When the tab bar background is double-clicked.
|
||||
virtual void onTabsContainerDoubleClicked(Tabs* tabs) = 0;
|
||||
|
||||
// Called when the mouse is over a tab (the data can be null if the
|
||||
// mouse just leave all tabs)
|
||||
virtual void onMouseOverTab(Tabs* tabs, TabView* tabView) = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -71,6 +71,8 @@ namespace app {
|
||||
bool onClear(Context* ctx) override;
|
||||
void onCancel(Context* ctx) override;
|
||||
|
||||
WorkspacePanel* mainPanel() { return &m_mainPanel; }
|
||||
|
||||
obs::signal<void()> ActiveViewChanged;
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user