mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-16 10:20:50 +00:00
Add special animation when drop a tab into other Tabs
This commit is contained in:
parent
6a56e218f2
commit
76cc5185d8
@ -80,10 +80,13 @@ Tabs::~Tabs()
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
void Tabs::addTab(TabView* tabView, int pos)
|
||||
void Tabs::addTab(TabView* tabView, bool from_drop, int pos)
|
||||
{
|
||||
resetOldPositions();
|
||||
startAnimation(ANI_ADDING_TAB, ANI_ADDING_TAB_TICKS);
|
||||
if (!from_drop)
|
||||
startAnimation(ANI_ADDING_TAB, ANI_ADDING_TAB_TICKS);
|
||||
else
|
||||
startAnimation(ANI_REORDER_TABS, ANI_REORDER_TABS_TICKS);
|
||||
|
||||
TabPtr tab(new Tab(tabView));
|
||||
if (pos < 0)
|
||||
@ -92,9 +95,9 @@ void Tabs::addTab(TabView* tabView, int pos)
|
||||
m_list.insert(m_list.begin()+pos, tab);
|
||||
updateTabs();
|
||||
|
||||
tab->oldX = tab->x;
|
||||
tab->oldX = (from_drop ? m_dropNewPosX-tab->width/2: tab->x);
|
||||
tab->oldWidth = tab->width;
|
||||
tab->modified = false;
|
||||
tab->modified = (m_delegate ? m_delegate->onIsModified(this, tabView): false);
|
||||
}
|
||||
|
||||
void Tabs::removeTab(TabView* tabView, bool with_animation)
|
||||
|
@ -122,7 +122,7 @@ namespace app {
|
||||
|
||||
TabsDelegate* getDelegate() { return m_delegate; }
|
||||
|
||||
void addTab(TabView* tabView, int pos = -1);
|
||||
void addTab(TabView* tabView, bool from_drop, int pos = -1);
|
||||
void removeTab(TabView* tabView, bool with_animation);
|
||||
void updateTabs();
|
||||
|
||||
|
@ -60,7 +60,7 @@ void Workspace::setTabsBar(WorkspaceTabs* tabs)
|
||||
|
||||
void Workspace::addView(WorkspaceView* view, int pos)
|
||||
{
|
||||
addViewToPanel(&m_mainPanel, view, pos);
|
||||
addViewToPanel(&m_mainPanel, view, false, pos);
|
||||
}
|
||||
|
||||
void Workspace::removeView(WorkspaceView* view)
|
||||
@ -182,25 +182,28 @@ bool Workspace::dropViewAt(const gfx::Point& pos, WorkspaceView* view)
|
||||
WorkspaceTabs* tabs = getTabsAt(pos);
|
||||
WorkspacePanel* panel = getPanelAt(pos);
|
||||
|
||||
if (panel)
|
||||
if (panel) {
|
||||
// Create new panel
|
||||
return panel->dropViewAt(pos, getViewPanel(view), view);
|
||||
}
|
||||
else if (tabs && tabs != getViewPanel(view)->tabs()) {
|
||||
// Dock tab in other tabs
|
||||
WorkspacePanel* dropPanel = tabs->panel();
|
||||
ASSERT(dropPanel);
|
||||
|
||||
int pos = tabs->getDropTabIndex();
|
||||
|
||||
removeView(view);
|
||||
addViewToPanel(dropPanel, view, pos);
|
||||
addViewToPanel(dropPanel, view, true, pos);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void Workspace::addViewToPanel(WorkspacePanel* panel, WorkspaceView* view, int pos)
|
||||
void Workspace::addViewToPanel(WorkspacePanel* panel, WorkspaceView* view, bool from_drop, int pos)
|
||||
{
|
||||
panel->addView(view, pos);
|
||||
panel->addView(view, from_drop, pos);
|
||||
|
||||
m_activePanel = panel;
|
||||
m_views.push_back(view);
|
||||
|
@ -60,7 +60,7 @@ namespace app {
|
||||
void onResize(ui::ResizeEvent& ev) override;
|
||||
|
||||
private:
|
||||
void addViewToPanel(WorkspacePanel* panel, WorkspaceView* view, int pos);
|
||||
void addViewToPanel(WorkspacePanel* panel, WorkspaceView* view, bool from_drop, int pos);
|
||||
WorkspacePanel* getViewPanel(WorkspaceView* view);
|
||||
WorkspacePanel* getPanelAt(const gfx::Point& pos);
|
||||
WorkspaceTabs* getTabsAt(const gfx::Point& pos);
|
||||
|
@ -64,7 +64,7 @@ void WorkspacePanel::setTabsBar(WorkspaceTabs* tabs)
|
||||
m_tabs->setPanel(this);
|
||||
}
|
||||
|
||||
void WorkspacePanel::addView(WorkspaceView* view, int pos)
|
||||
void WorkspacePanel::addView(WorkspaceView* view, bool from_drop, int pos)
|
||||
{
|
||||
if (pos < 0)
|
||||
m_views.push_back(view);
|
||||
@ -72,7 +72,7 @@ void WorkspacePanel::addView(WorkspaceView* view, int pos)
|
||||
m_views.insert(m_views.begin()+pos, view);
|
||||
|
||||
if (m_tabs)
|
||||
m_tabs->addTab(dynamic_cast<TabView*>(view), pos);
|
||||
m_tabs->addTab(dynamic_cast<TabView*>(view), from_drop, pos);
|
||||
|
||||
// Insert the view content as a hidden widget.
|
||||
Widget* content = view->getContentWidget();
|
||||
@ -294,7 +294,7 @@ bool WorkspacePanel::dropViewAt(const gfx::Point& pos, WorkspacePanel* from, Wor
|
||||
break;
|
||||
}
|
||||
|
||||
newPanel->addView(view);
|
||||
newPanel->addView(view, true);
|
||||
parent->layout();
|
||||
return true;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace app {
|
||||
|
||||
bool isEmpty() const { return m_views.empty(); }
|
||||
|
||||
void addView(WorkspaceView* view, int pos = -1);
|
||||
void addView(WorkspaceView* view, bool from_drop, int pos = -1);
|
||||
void removeView(WorkspaceView* view);
|
||||
|
||||
WorkspaceView* activeView();
|
||||
|
Loading…
x
Reference in New Issue
Block a user