linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05807
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2970: don't move splitters when only clicking
------------------------------------------------------------
revno: 2970
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2012-06-29 21:22:25 +0200
message:
don't move splitters when only clicking
modified:
dwt/include/dwt/widgets/Splitter.h
dwt/src/widgets/Splitter.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 'dwt/include/dwt/widgets/Splitter.h'
--- dwt/include/dwt/widgets/Splitter.h 2012-01-13 20:55:20 +0000
+++ dwt/include/dwt/widgets/Splitter.h 2012-06-29 19:22:25 +0000
@@ -32,6 +32,8 @@
#ifndef DWT_SPLITTER_H
#define DWT_SPLITTER_H
+#include <boost/optional.hpp>
+
#include <dwt/forward.h>
#include "Control.h"
#include <dwt/Theme.h>
@@ -89,25 +91,16 @@
Theme theme;
double pos;
+ bool horizontal;
bool hovering;
- bool moving;
- bool horizontal;
+ boost::optional<Point> moving; // store the last point to only handle actual moves
void handlePainting(PaintCanvas& canvas);
- bool handleLButtonDown() {
- ::SetCapture(handle());
- moving = true;
- return true;
- }
-
+ bool handleLButtonDown(const MouseEvent& mouseEvent);
+ bool handleLButtonUp();
bool handleMouseMove(const MouseEvent& mouseEvent);
- bool handleLButtonUp() {
- ::ReleaseCapture();
- moving = false;
- return true;
- }
int thickness() { return ::GetSystemMetrics(horizontal ? SM_CYEDGE : SM_CXEDGE) + 2; }
};
@@ -121,9 +114,8 @@
inline Splitter::Splitter(Widget* parent) :
BaseType(parent, NormalDispatcher::newClass<ThisType>(0, 0, NULL)),
pos(0.5),
-hovering(false),
-moving(false),
-horizontal(false)
+horizontal(false),
+hovering(false)
{
}
=== modified file 'dwt/src/widgets/Splitter.cpp'
--- dwt/src/widgets/Splitter.cpp 2012-06-29 19:05:29 +0000
+++ dwt/src/widgets/Splitter.cpp 2012-06-29 19:22:25 +0000
@@ -49,7 +49,7 @@
theme.load(VSCLASS_WINDOW, this);
onPainting([this](PaintCanvas& canvas) { handlePainting(canvas); });
- onLeftMouseDown([this](const MouseEvent&) { return handleLButtonDown(); });
+ onLeftMouseDown([this](const MouseEvent& mouseEvent) { return handleLButtonDown(mouseEvent); });
onMouseMove([this](const MouseEvent& mouseEvent) { return handleMouseMove(mouseEvent); });
onLeftMouseUp([this](const MouseEvent&) { return handleLButtonUp(); });
@@ -92,6 +92,18 @@
}
}
+bool Splitter::handleLButtonDown(const MouseEvent& mouseEvent) {
+ ::SetCapture(handle());
+ moving = mouseEvent.pos.getPoint();
+ return true;
+}
+
+bool Splitter::handleLButtonUp() {
+ ::ReleaseCapture();
+ moving.reset();
+ return true;
+}
+
bool Splitter::handleMouseMove(const MouseEvent& mouseEvent) {
if(!hovering) {
hovering = true;
@@ -104,7 +116,8 @@
});
}
- if(moving && mouseEvent.ButtonPressed == MouseEvent::LEFT) {
+ if(moving && mouseEvent.ButtonPressed == MouseEvent::LEFT && mouseEvent.pos.getPoint() != moving) {
+ moving = mouseEvent.pos.getPoint();
ClientCoordinate cc(mouseEvent.pos, getParent());
double mpos = horizontal ? cc.y() : cc.x();
double size = horizontal ? getParent()->getClientSize().y : getParent()->getClientSize().x;