|
From: <zou...@us...> - 2008-03-04 23:27:16
|
Revision: 1025
http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1025&view=rev
Author: zouzou123gen
Date: 2008-03-04 15:26:14 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
fix problems when tabs were added/removed during tab drag&drop
Modified Paths:
--------------
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h
dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2008-03-04 23:19:17 UTC (rev 1024)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2008-03-04 23:26:14 UTC (rev 1025)
@@ -97,7 +97,7 @@
Rectangle clientSize;
std::vector<IconPtr> icons;
int active;
- int dragging;
+ WidgetChildWindow* dragging;
SmartUtil::tstring tipText;
int findTab(WidgetChildWindow* w);
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-03-04 23:19:17 UTC (rev 1024)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-03-04 23:26:14 UTC (rev 1025)
@@ -19,7 +19,7 @@
toggleActive(false),
inTab(false),
active(-1),
- dragging(-1)
+ dragging(0)
{ }
void WidgetTabView::create(const Seed & cs) {
@@ -81,6 +81,9 @@
viewOrder.remove(w);
+ if(w == dragging)
+ dragging = 0;
+
int i = findTab(w);
if(i != -1) {
delete getTabInfo(i);
@@ -291,12 +294,12 @@
}
void WidgetTabView::handleLeftMouseDown(const MouseEventResult& mouseEventResult) {
- int i = tab->hitTest(mouseEventResult.pos);
- if(i != -1) {
+ TabInfo* ti = getTabInfo(tab->hitTest(mouseEventResult.pos));
+ if(ti) {
if(mouseEventResult.isShiftPressed)
- getTabInfo(i)->w->close();
+ ti->w->close();
else {
- dragging = i;
+ dragging = ti->w;
::SetCapture(tab->handle());
}
}
@@ -305,7 +308,13 @@
void WidgetTabView::handleLeftMouseUp(const MouseEventResult& mouseEventResult) {
::ReleaseCapture();
- if(dragging != -1) {
+ if(dragging) {
+ int dragPos = findTab(dragging);
+ dragging = 0;
+
+ if(dragPos == -1)
+ return;
+
int dropPos = tab->hitTest(mouseEventResult.pos);
if(dropPos == -1) {
@@ -313,30 +322,27 @@
dropPos = tab->size() - 1;
}
- if(dropPos == dragging) {
+ if(dropPos == dragPos) {
// the tab hasn't moved; handle the click
if(dropPos == active) {
if(toggleActive)
next();
} else
setActive(dropPos);
- dragging = -1;
return;
}
// save some information about the tab before we erase it
- TabInfo* ti = getTabInfo(dragging);
- int image = tab->getImage(dragging);
+ TabInfo* ti = getTabInfo(dragPos);
+ int image = tab->getImage(dragPos);
- tab->erase(dragging);
+ tab->erase(dragPos);
tab->addPage(formatTitle(ti->w->getText()), dropPos, reinterpret_cast<LPARAM>(ti), image);
active = tab->getSelectedIndex();
layout();
-
- dragging = -1;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|