← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2352: simplify taskbar activation

 

------------------------------------------------------------
revno: 2352
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-12-19 13:02:38 +0100
message:
  simplify taskbar activation
modified:
  dwt/include/dwt/Taskbar.h
  dwt/include/dwt/widgets/TabView.h
  dwt/src/Taskbar.cpp
  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 'dwt/include/dwt/Taskbar.h'
--- dwt/include/dwt/Taskbar.h	2010-10-28 22:43:23 +0000
+++ dwt/include/dwt/Taskbar.h	2010-12-19 12:02:38 +0000
@@ -46,9 +46,7 @@
 	void initTaskbar(WindowPtr window_);
 
 protected:
-	typedef std::function<void (ContainerPtr)> ActivateF;
-	/// @param activateF_ function called when the user activates a tab using the taskbar.
-	explicit Taskbar(const ActivateF& activateF_);
+	Taskbar();
 	virtual ~Taskbar();
 
 	void addToTaskbar(ContainerPtr tab);
@@ -62,10 +60,11 @@
 private:
 	BitmapPtr getBitmap(ContainerPtr tab, LPARAM thumbnailSize);
 
+	/// function called when the user activates a tab using the taskbar.
+	virtual void setActive(ContainerPtr) = 0;
+
 	WindowPtr window;
 	std::unordered_map<ContainerPtr, ContainerPtr> tabs;
-
-	ActivateF activateF;
 };
 
 }

=== modified file 'dwt/include/dwt/widgets/TabView.h'
--- dwt/include/dwt/widgets/TabView.h	2010-10-28 22:43:23 +0000
+++ dwt/include/dwt/widgets/TabView.h	2010-12-19 12:02:38 +0000
@@ -106,7 +106,7 @@
 	void next(bool reverse = false);
 
 	ContainerPtr getActive() const;
-	void setActive(ContainerPtr w) { setActive(findTab(w)); }
+	void setActive(ContainerPtr w);
 
 	IconPtr getIcon(ContainerPtr w) const;
 	void setIcon(ContainerPtr w, const IconPtr& icon);

=== modified file 'dwt/src/Taskbar.cpp'
--- dwt/src/Taskbar.cpp	2010-12-12 23:10:36 +0000
+++ dwt/src/Taskbar.cpp	2010-12-19 12:02:38 +0000
@@ -54,10 +54,9 @@
 typedef HRESULT (WINAPI *t_DwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD);
 static t_DwmSetWindowAttribute DwmSetWindowAttribute;
 
-Taskbar::Taskbar(const ActivateF& activateF_) :
+Taskbar::Taskbar() :
 taskbar(0),
-window(0),
-activateF(activateF_)
+window(0)
 {
 }
 
@@ -143,8 +142,7 @@
 	// forward taskbar events that were sent to the proxy window to the actual tab window.
 	proxy->onActivate([this, tab](bool activate) {
 		if(activate) {
-			activateF(tab);
-			// imitate MFC...
+			setActive(tab);
 			::SetForegroundWindow(window->handle());
 			if(window->isIconic())
 				window->restore();

=== modified file 'dwt/src/widgets/TabView.cpp'
--- dwt/src/widgets/TabView.cpp	2010-12-08 16:54:29 +0000
+++ dwt/src/widgets/TabView.cpp	2010-12-19 12:02:38 +0000
@@ -60,7 +60,7 @@
 
 TabView::TabView(Widget* w) :
 BaseType(w, ChainingDispatcher::superClass<TabView>()),
-Taskbar([this](ContainerPtr tab) { setActive(tab); }),
+Taskbar(),
 tip(0),
 toggleActive(false),
 font(0),
@@ -280,6 +280,10 @@
 	return ret;
 }
 
+void TabView::setActive(ContainerPtr w) {
+	setActive(findTab(w));
+}
+
 void TabView::setActive(int i) {
 	if(i == -1)
 		return;
@@ -567,7 +571,7 @@
 		layout();
 
 		if(taskbar) {
-			moveOnTaskbar(getTabInfo(dropPos)->w, (dropPos < size() - 1) ? getTabInfo(dropPos + 1)->w : 0);
+			moveOnTaskbar(getTabInfo(dropPos)->w, (dropPos < static_cast<int>(size()) - 1) ? getTabInfo(dropPos + 1)->w : 0);
 		}
 	}