Commit 33018483 authored by bitplane's avatar bitplane

Added setDraggable and isDraggable to IGUIWindow, by Nox [2645227]

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2271 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b575eff0
Changes in 1.6
- Added IGUIWindow::setDraggable and IGUIWindow::isDraggable, by Nox
- Added SGI RGB file reader by Gary Conway, for loading Silicon Graphics .rgb, .rgba, .sgi, .int and .inta textures
- Renamed setResizeAble to setResizable
......
......@@ -31,6 +31,13 @@ namespace gui
//! Returns pointer to the maximize button
virtual IGUIButton* getMaximizeButton() const = 0;
//! Returns true if the window can be dragged with the mouse, false if not
virtual bool isDraggable() const = 0;
//! Sets whether the window can be dragged by the mouse
virtual void setDraggable(bool draggable) = 0;
};
......
......@@ -19,7 +19,7 @@ namespace gui
//! 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), IsDraggable(true)
{
#ifdef _DEBUG
setDebugName("CGUIWindow");
......@@ -160,7 +160,7 @@ bool CGUIWindow::OnEvent(const SEvent& event)
case EMIE_LMOUSE_PRESSED_DOWN:
DragStart.X = event.MouseInput.X;
DragStart.Y = event.MouseInput.Y;
Dragging = true;
Dragging = IsDraggable;
if (Parent)
Parent->bringToFront(this);
return true;
......@@ -258,6 +258,22 @@ IGUIButton* CGUIWindow::getMaximizeButton() const
return RestoreButton;
}
//! Returns true if the window is draggable, false if not
bool CGUIWindow::isDraggable() const
{
return IsDraggable;
}
//! Sets whether the window is draggable
void CGUIWindow::setDraggable(bool draggable)
{
IsDraggable = draggable;
if (Dragging && !IsDraggable)
Dragging = false;
}
} // end namespace gui
} // end namespace irr
......
......@@ -44,6 +44,12 @@ namespace gui
//! Returns pointer to the maximize button
virtual IGUIButton* getMaximizeButton() const;
//! Returns true if the window is draggable, false if not
virtual bool isDraggable() const;
//! Sets whether the window is draggable
virtual void setDraggable(bool draggable);
protected:
IGUIButton* CloseButton;
......@@ -51,7 +57,7 @@ namespace gui
IGUIButton* RestoreButton;
core::position2d<s32> DragStart;
bool Dragging;
bool Dragging, IsDraggable;
};
} // end namespace gui
......
......@@ -14,7 +14,7 @@ using namespace gui;
//! constructor
CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect<s32> rectangle, IGUIElement *parent)
: IGUIWindow(environment, parent, -1, rectangle),
Dragging(false), Resizing(false), SelectedElement(0),
Dragging(false), IsDraggable(true), Resizing(false), SelectedElement(0),
AttribEditor(0), OptionEditor(0), EnvEditor(0)
{
#ifdef _DEBUG
......@@ -202,7 +202,7 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
if (clickedElement == this)
{
Dragging = true;
Dragging = IsDraggable;
//Environment->setFocus(this);
if (Parent)
Parent->bringToFront(this);
......@@ -260,9 +260,23 @@ bool CGUIEditWindow::OnEvent(const SEvent &event)
return Parent ? Parent->OnEvent(event) : false;
}
bool CGUIEditWindow::isDraggable() const
{
return IsDraggable;
}
void CGUIEditWindow::setDraggable(bool draggable)
{
IsDraggable = draggable;
if (Dragging && !IsDraggable)
Dragging = false;
}
// we're supposed to supply these if we're creating an IGUIWindow
// but we don't need them so we'll just return null
IGUIButton* CGUIEditWindow::getCloseButton() const {return 0;}
IGUIButton* CGUIEditWindow::getMinimizeButton() const {return 0;}
IGUIButton* CGUIEditWindow::getMaximizeButton() const {return 0;}
......@@ -31,6 +31,12 @@ namespace gui
//! change selection
virtual void setSelectedElement(IGUIElement *sel);
//! get draggable
virtual bool isDraggable() const;
//! get draggable
virtual void setDraggable(bool draggable);
// not used
virtual IGUIButton* getCloseButton() const;
virtual IGUIButton* getMinimizeButton() const;
......@@ -48,6 +54,7 @@ namespace gui
// for dragging the window
bool Dragging;
bool IsDraggable;
bool Resizing;
core::position2d<s32> DragStart;
......
......@@ -16,7 +16,7 @@ namespace gui
CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id, IGUIElement *parent)
: IGUIWindow(environment, parent, id, core::rect<s32>(0,0,300,200)),
CloseButton(0), Panel(0), SelectedTexture(-1), Dragging(false)
CloseButton(0), Panel(0), SelectedTexture(-1), Dragging(false), IsDraggable(true)
{
#ifdef _DEBUG
setDebugName("CGUIWindow");
......@@ -215,7 +215,7 @@ bool CGUITextureCacheBrowser::OnEvent(const SEvent &event)
{
if (!Environment->hasFocus(this))
{
Dragging = true;
Dragging = IsDraggable;
//Environment->setFocus(this);
if (Parent)
Parent->bringToFront(this);
......@@ -307,5 +307,20 @@ void CGUITextureCacheBrowser::draw()
IGUIElement::draw();
}
bool CGUITextureCacheBrowser::isDraggable() const
{
return IsDraggable;
}
void CGUITextureCacheBrowser::setDraggable(bool draggable)
{
IsDraggable = draggable;
if (Dragging && !IsDraggable)
Dragging = false;
}
} // namespace gui
} // namespace irr
......@@ -49,6 +49,12 @@ namespace gui
//! Returns pointer to the maximize button
virtual IGUIButton* getMaximizeButton() const { return 0;}
//! get draggable
virtual bool isDraggable() const;
//! get draggable
virtual void setDraggable(bool draggable);
void setSelected(s32 index=-1);
private:
......@@ -62,6 +68,7 @@ namespace gui
CGUIPanel* Panel;
s32 SelectedTexture;
bool Dragging;
bool IsDraggable;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment