Make it optional whether a dialog can be dragged or not.
This commit is contained in:
parent
34d23fe6f3
commit
0c61e0dae1
3 changed files with 10 additions and 2 deletions
|
@ -74,6 +74,7 @@ a simple, "hello world" dialog:
|
||||||
<width>150</width>
|
<width>150</width>
|
||||||
<height>100</height>
|
<height>100</height>
|
||||||
<modal>false</modal>
|
<modal>false</modal>
|
||||||
|
<draggable>true</draggable>
|
||||||
|
|
||||||
<text>
|
<text>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
|
@ -152,6 +153,8 @@ file, since the root element is named PropertyList.
|
||||||
modal - true if the dialog is modal (it blocks the rest of the
|
modal - true if the dialog is modal (it blocks the rest of the
|
||||||
program), false otherwise. The default is false.
|
program), false otherwise. The default is false.
|
||||||
|
|
||||||
|
draggable - false if the dialog is not draggable. The default is true.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
<PropertyList>
|
<PropertyList>
|
||||||
|
|
|
@ -15,6 +15,9 @@ int fgPopup::checkHit(int button, int updown, int x, int y)
|
||||||
{
|
{
|
||||||
int result = puPopup::checkHit(button, updown, x, y);
|
int result = puPopup::checkHit(button, updown, x, y);
|
||||||
|
|
||||||
|
if ( !_draggable)
|
||||||
|
return result;
|
||||||
|
|
||||||
// This is annoying. We would really want a true result from the
|
// This is annoying. We would really want a true result from the
|
||||||
// superclass to indicate "handled by child object", but all it
|
// superclass to indicate "handled by child object", but all it
|
||||||
// tells us is that the pointer is inside the dialog. So do the
|
// tells us is that the pointer is inside the dialog. So do the
|
||||||
|
@ -405,10 +408,11 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
|
||||||
|
|
||||||
if (type == "dialog") {
|
if (type == "dialog") {
|
||||||
puPopup * dialog;
|
puPopup * dialog;
|
||||||
|
bool draggable = props->getBoolValue("draggable", true);
|
||||||
if (props->getBoolValue("modal", false))
|
if (props->getBoolValue("modal", false))
|
||||||
dialog = new puDialogBox(x, y);
|
dialog = new puDialogBox(x, y);
|
||||||
else
|
else
|
||||||
dialog = new fgPopup(x, y);
|
dialog = new fgPopup(x, y, draggable);
|
||||||
setupGroup(dialog, props, width, height, color, true);
|
setupGroup(dialog, props, width, height, color, true);
|
||||||
return dialog;
|
return dialog;
|
||||||
} else if (type == "group") {
|
} else if (type == "group") {
|
||||||
|
|
|
@ -155,10 +155,11 @@ private:
|
||||||
//
|
//
|
||||||
class fgPopup : public puPopup {
|
class fgPopup : public puPopup {
|
||||||
public:
|
public:
|
||||||
fgPopup(int x, int y) : puPopup(x, y) { _dragging = false; }
|
fgPopup(int x, int y, bool d = true) : puPopup(x, y) { _dragging = false; _draggable = d;}
|
||||||
int checkHit(int b, int up, int x, int y);
|
int checkHit(int b, int up, int x, int y);
|
||||||
int getHitObjects(puObject *, int x, int y);
|
int getHitObjects(puObject *, int x, int y);
|
||||||
private:
|
private:
|
||||||
|
bool _draggable;
|
||||||
bool _dragging;
|
bool _dragging;
|
||||||
int _dX, _dY;
|
int _dX, _dY;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue