[feature request] Disabling dragging an IGUIWindow

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

[feature request] Disabling dragging an IGUIWindow

Post by Sylence »

Today I needed a window that could not be dragged using the mouse so I created this small patch and uploaded it to the tracker:

Code: Select all

Index: include/IGUIWindow.h
===================================================================
--- include/IGUIWindow.h	(Revision 2236)
+++ include/IGUIWindow.h	(Arbeitskopie)
@@ -31,6 +31,12 @@
 
 		//! Returns pointer to the maximize button
 		virtual IGUIButton* getMaximizeButton() const = 0;
+
+		//! Enables dragging for the window
+		virtual void setDraggingEnabled(bool enable) = 0;
+
+		//! Checks if the window can be dragged
+		virtual bool isDraggingEnabled() const = 0;
 	};
 
 
Index: source/Irrlicht/CGUIWindow.cpp
===================================================================
--- source/Irrlicht/CGUIWindow.cpp	(Revision 2236)
+++ source/Irrlicht/CGUIWindow.cpp	(Arbeitskopie)
@@ -19,7 +19,7 @@
 
 //! constructor
 CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
-: IGUIWindow(environment, parent, id, rectangle), Dragging(false)
+: IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDragginEnabled(true)
 {
 	#ifdef _DEBUG
 	setDebugName("CGUIWindow");
@@ -171,7 +171,7 @@
 				if ( !event.MouseInput.isLeftPressed() )
 					Dragging = false;
 
-				if (Dragging)
+				if (Dragging && IsDragginEnabled)
 				{
 					// gui window should not be dragged outside its parent
 					if (Parent &&
@@ -258,7 +258,17 @@
 	return RestoreButton;
 }
 
+void CGUIWindow::setDraggingEnabled( bool enable )
+{
+	IsDragginEnabled = enable;
+}
+
+bool CGUIWindow::isDraggingEnabled() const
+{
+	return IsDragginEnabled;
+}
 
+
 } // end namespace gui
 } // end namespace irr
 
Index: source/Irrlicht/CGUIWindow.h
===================================================================
--- source/Irrlicht/CGUIWindow.h	(Revision 2236)
+++ source/Irrlicht/CGUIWindow.h	(Arbeitskopie)
@@ -44,6 +44,12 @@
 		//! Returns pointer to the maximize button
 		virtual IGUIButton* getMaximizeButton() const;
 
+		//! Enables dragging for the window
+		virtual void setDraggingEnabled(bool enable);
+
+		//! Checks if the window can be dragged
+		virtual bool isDraggingEnabled() const;
+
 	protected:
 
 		IGUIButton* CloseButton;
@@ -52,6 +58,7 @@
 
 		core::position2d<s32> DragStart;
 		bool Dragging;
+		bool IsDragginEnabled;
 	};
 
 } // end namespace gui

https://sourceforge.net/tracker/index.p ... tid=540679
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

May be you should applay this attribute to the (de)serialisation too. But i like the idea :)
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Nice. Good idea too.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

Reviewed the patch and added the 2 missing methods. Do not know why they are missing in the patchfile. Changed the logic slightly (i guess it makes no real difference).

EDIT: i hope it will be added soon.
Post Reply