← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2427: Highlight window splitters on mouse hover

 

------------------------------------------------------------
revno: 2427
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2011-02-19 18:02:21 +0100
message:
  Highlight window splitters on mouse hover
modified:
  changelog.txt
  dwt/include/dwt/aspects/AspectEraseBackground.h
  dwt/include/dwt/widgets/Splitter.h


--
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-02-12 17:03:41 +0000
+++ changelog.txt	2011-02-19 17:02:21 +0000
@@ -10,6 +10,7 @@
 * [L#704743] Fix hang on exit under WINE in active mode (cologic)
 * Add NAT-PMP for port mappings as an alternative to UPnP (poy)
 * [L#654483] Don't duplicate file list entries when re-downloading it (poy)
+* Highlight window splitters on mouse hover (poy)
 
 -- 0.781 2011-01-12 --
 * Add a dummy serial number to TLS certs to satisfy some parsers (poy)

=== modified file 'dwt/include/dwt/aspects/AspectEraseBackground.h'
--- dwt/include/dwt/aspects/AspectEraseBackground.h	2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/aspects/AspectEraseBackground.h	2011-02-19 17:02:21 +0000
@@ -55,15 +55,14 @@
 {
 	WidgetType& W() { return *static_cast<WidgetType*>(this); }
 
-	struct EraseBackgroundDispatcher : Dispatchers::Base<void (Canvas&)> {
-		typedef Dispatchers::Base<void (Canvas&)> BaseType;
+	struct EraseBackgroundDispatcher : Dispatchers::Base<bool (Canvas&)> {
+		typedef Dispatchers::Base<bool (Canvas&)> BaseType;
 		EraseBackgroundDispatcher(const F& f_) : BaseType(f_) { }
 
 		bool operator()(const MSG& msg, LRESULT& ret) const {
 			FreeCanvas canvas(reinterpret_cast<HDC>(msg.wParam));
-			f(canvas);
-			ret = 1;
-			return true;
+			ret = f(canvas);
+			return ret;
 		}
 	};
 
@@ -75,12 +74,13 @@
 	  * background property of the Widget.
 	  */
 	void onEraseBackground(const typename EraseBackgroundDispatcher::F& f) {
-		W().setCallback(Message( WM_ERASEBKGND ), EraseBackgroundDispatcher(f, &W() ) );
+		W().setCallback(Message(WM_ERASEBKGND), EraseBackgroundDispatcher(f));
 	}
 
 	void noEraseBackground() {
-		W().setCallback(Message( WM_ERASEBKGND ), &AspectEraseBackground<WidgetType>::noEraseDispatcher);
+		W().setCallback(Message(WM_ERASEBKGND), &AspectEraseBackground<WidgetType>::noEraseDispatcher);
 	}
+
 protected:
 	virtual ~AspectEraseBackground() { }
 

=== modified file 'dwt/include/dwt/widgets/Splitter.h'
--- dwt/include/dwt/widgets/Splitter.h	2011-01-18 18:39:48 +0000
+++ dwt/include/dwt/widgets/Splitter.h	2011-02-19 17:02:21 +0000
@@ -102,6 +102,7 @@
 
 	double pos;
 
+	bool hovering;
 	bool moving;
 
 	Rectangle rect;
@@ -109,6 +110,15 @@
 	Rectangle getSplitterRect();
 	void layout();
 
+	bool handleBg(Canvas& canvas) {
+		if(hovering) {
+			// safe to assume that the text color is different enough from the default background.
+			canvas.fill(Rectangle(getClientSize()), Brush(Brush::WindowText));
+			return true;
+		}
+		return false;
+	}
+
 	bool handleLButtonDown() {
 		::SetCapture(handle());
 		moving = true;
@@ -116,6 +126,15 @@
 	}
 
 	bool handleMouseMove(const MouseEvent& mouseEvent) {
+		if(!hovering) {
+			hovering = true;
+			redraw();
+			onMouseLeave([this] {
+				GCC_WTF->hovering = false;
+				GCC_WTF->redraw();
+			});
+		}
+
 		if(moving && mouseEvent.ButtonPressed == MouseEvent::LEFT) {
 			ClientCoordinate cc(mouseEvent.pos, getParent());
 			double distance = horizontal ? cc.y() : cc.x();
@@ -147,6 +166,7 @@
 first(0),
 second(0),
 pos(0.5),
+hovering(false),
 moving(false)
 {
 }
@@ -156,6 +176,8 @@
 	pos = cs.pos;
 	BaseType::create(cs);
 
+	onEraseBackground([this](Canvas& canvas) { return GCC_WTF->handleBg(canvas); });
+
 	onLeftMouseDown([this](const MouseEvent&) { return GCC_WTF->handleLButtonDown(); });
 	onMouseMove([this](const MouseEvent& mouseEvent) { return GCC_WTF->handleMouseMove(mouseEvent); });
 	onLeftMouseUp([this](const MouseEvent&) { return GCC_WTF->handleLButtonUp(); });
@@ -179,10 +201,10 @@
 	double splitterSize = ::GetSystemMetrics(horizontal ? SM_CYEDGE : SM_CXEDGE) + 2;
 	if(horizontal) {
 		rc.size.y = splitterSize;
-		rc.pos.y += pos * rect.height() - splitterSize / 2;
+		rc.pos.y += pos * rect.height() - splitterSize / 2.;
 	} else {
 		rc.size.x = splitterSize;
-		rc.pos.x += pos * rect.width() - splitterSize / 2;
+		rc.pos.x += pos * rect.width() - splitterSize / 2.;
 	}
 
 	return rc;