linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04728
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2660: Close tabs when releasing the mouse button
------------------------------------------------------------
revno: 2660
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2011-10-30 16:24:29 +0100
message:
Close tabs when releasing the mouse button
modified:
changelog.txt
dwt/include/dwt/widgets/TabView.h
dwt/src/widgets/TabView.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2011-10-28 19:29:51 +0000
+++ changelog.txt 2011-10-30 15:24:29 +0000
@@ -48,6 +48,7 @@
* [L#783516] ZLIF compression support (iceman50)
* Increase minimum download segment size from 64KiB to 256KiB (cologic)
* [L#874282] Fix the "Close disconnected hubs" command (poy)
+* [L#721102] Close tabs when releasing the mouse button (poy)
-- 0.782 2011-03-05 --
* Prevent a remote crash triggered via malformed user commands (poy)
=== modified file 'dwt/include/dwt/widgets/TabView.h'
--- dwt/include/dwt/widgets/TabView.h 2011-06-27 18:46:47 +0000
+++ dwt/include/dwt/widgets/TabView.h 2011-10-30 15:24:29 +0000
@@ -181,6 +181,7 @@
Rectangle clientSize;
ImageListPtr icons;
int active;
+ ContainerPtr middleClosing;
ContainerPtr dragging;
tstring tipText;
Rectangle closeRect;
@@ -201,6 +202,7 @@
bool handleLeftMouseUp(const MouseEvent& mouseEvent);
bool handleContextMenu(dwt::ScreenCoordinate pt);
bool handleMiddleMouseDown(const MouseEvent& mouseEvent);
+ bool handleMiddleMouseUp(const MouseEvent& mouseEvent);
bool handleXMouseUp(const MouseEvent& mouseEvent);
bool handleMouseMove(const MouseEvent& mouseEvent);
void handleMouseLeave();
=== modified file 'dwt/src/widgets/TabView.cpp'
--- dwt/src/widgets/TabView.cpp 2011-06-28 20:07:49 +0000
+++ dwt/src/widgets/TabView.cpp 2011-10-30 15:24:29 +0000
@@ -70,6 +70,7 @@
highlightClose(false),
closeAuthorized(false),
active(-1),
+middleClosing(0),
dragging(0)
{
}
@@ -126,6 +127,7 @@
onLeftMouseUp([this](const MouseEvent& me) { return handleLeftMouseUp(me); });
onContextMenu([this](const ScreenCoordinate& sc) { return handleContextMenu(sc); });
onMiddleMouseDown([this](const MouseEvent& me) { return handleMiddleMouseDown(me); });
+ onMiddleMouseUp([this](const MouseEvent& me) { return handleMiddleMouseUp(me); });
onXMouseUp([this](const MouseEvent& me) { return handleXMouseUp(me); });
if(cs.style & TCS_TOOLTIPS) {
@@ -200,6 +202,8 @@
viewOrder.remove(w);
+ if(w == middleClosing)
+ middleClosing = 0;
if(w == dragging)
dragging = 0;
@@ -511,17 +515,13 @@
bool TabView::handleLeftMouseDown(const MouseEvent& mouseEvent) {
TabInfo* ti = getTabInfo(hitTest(mouseEvent.pos));
if(ti) {
- if(mouseEvent.isShiftPressed)
- ti->w->close();
- else {
- dragging = ti->w;
- ::SetCapture(handle());
- if(hasStyle(TCS_OWNERDRAWFIXED)) {
- int index = findTab(dragging);
- if(index == active) {
- closeAuthorized = inCloseRect(mouseEvent.pos);
- redraw(index);
- }
+ dragging = ti->w;
+ ::SetCapture(handle());
+ if(hasStyle(TCS_OWNERDRAWFIXED)) {
+ int index = findTab(dragging);
+ if(index == active) {
+ closeAuthorized = inCloseRect(mouseEvent.pos);
+ redraw(index);
}
}
}
@@ -555,7 +555,7 @@
if(dropPos == dragPos) {
// the tab hasn't moved; handle the click
if(dropPos == active) {
- if(closeAuth && inCloseRect(mouseEvent.pos)) {
+ if(mouseEvent.isShiftPressed || (closeAuth && inCloseRect(mouseEvent.pos))) {
TabInfo* ti = getTabInfo(active);
if(ti)
ti->w->close();
@@ -617,8 +617,22 @@
bool TabView::handleMiddleMouseDown(const MouseEvent& mouseEvent) {
TabInfo* ti = getTabInfo(hitTest(mouseEvent.pos));
- if(ti)
- ti->w->close();
+ if(ti) {
+ middleClosing = ti->w;
+ ::SetCapture(handle());
+ }
+ return true;
+}
+
+bool TabView::handleMiddleMouseUp(const MouseEvent& mouseEvent) {
+ ::ReleaseCapture();
+ if(middleClosing) {
+ TabInfo* ti = getTabInfo(hitTest(mouseEvent.pos));
+ if(ti && ti->w == middleClosing) {
+ middleClosing->close();
+ }
+ middleClosing = 0;
+ }
return true;
}