property_list.cxx: in verbose mode (toggle with Ctrl-'.'-entry) also
show "secret" values, that is: values of nodes with children. These can be used like all normal (leaf) properties, but their values were until now only shown in writeProperties() dumps. Also show the number of attached listeners. Example: foo = 'bar' (string, AU, L3). dialog.cxx: add warning message for broken <format>s; cosmetics
This commit is contained in:
parent
ef3fb93056
commit
e88ba9a037
3 changed files with 88 additions and 87 deletions
|
@ -4,14 +4,11 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h> // atof()
|
|
||||||
|
|
||||||
#include <Input/input.hxx>
|
#include <Input/input.hxx>
|
||||||
#include <Scripting/NasalSys.hxx>
|
#include <Scripting/NasalSys.hxx>
|
||||||
|
|
||||||
#include "dialog.hxx"
|
#include "dialog.hxx"
|
||||||
#include "new_gui.hxx"
|
#include "new_gui.hxx"
|
||||||
|
|
||||||
#include "AirportList.hxx"
|
#include "AirportList.hxx"
|
||||||
#include "property_list.hxx"
|
#include "property_list.hxx"
|
||||||
#include "layout.hxx"
|
#include "layout.hxx"
|
||||||
|
@ -164,7 +161,7 @@ int fgPopup::checkKey(int key, int updown)
|
||||||
puObject *fgPopup::getKeyObject(puObject *object, int key)
|
puObject *fgPopup::getKeyObject(puObject *object, int key)
|
||||||
{
|
{
|
||||||
puObject *ret;
|
puObject *ret;
|
||||||
if(object->getType() & PUCLASS_GROUP)
|
if (object->getType() & PUCLASS_GROUP)
|
||||||
for (puObject *obj = ((puGroup *)object)->getFirstChild();
|
for (puObject *obj = ((puGroup *)object)->getFirstChild();
|
||||||
obj; obj = obj->getNextObject())
|
obj; obj = obj->getNextObject())
|
||||||
if ((ret = getKeyObject(obj, key)))
|
if ((ret = getKeyObject(obj, key)))
|
||||||
|
@ -180,7 +177,7 @@ puObject *fgPopup::getKeyObject(puObject *object, int key)
|
||||||
puObject *fgPopup::getActiveInputField(puObject *object)
|
puObject *fgPopup::getActiveInputField(puObject *object)
|
||||||
{
|
{
|
||||||
puObject *ret;
|
puObject *ret;
|
||||||
if(object->getType() & PUCLASS_GROUP)
|
if (object->getType() & PUCLASS_GROUP)
|
||||||
for (puObject *obj = ((puGroup *)object)->getFirstChild();
|
for (puObject *obj = ((puGroup *)object)->getFirstChild();
|
||||||
obj; obj = obj->getNextObject())
|
obj; obj = obj->getNextObject())
|
||||||
if ((ret = getActiveInputField(obj)))
|
if ((ret = getActiveInputField(obj)))
|
||||||
|
@ -199,7 +196,7 @@ 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)
|
if (!_draggable)
|
||||||
return result;
|
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
|
||||||
|
@ -208,12 +205,12 @@ int fgPopup::checkHit(int button, int updown, int x, int y)
|
||||||
// intersection test (again) to make sure we don't start a drag
|
// intersection test (again) to make sure we don't start a drag
|
||||||
// when inside controls.
|
// when inside controls.
|
||||||
|
|
||||||
if(updown == PU_DOWN && !_dragging) {
|
if (updown == PU_DOWN && !_dragging) {
|
||||||
if(!result)
|
if (!result)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int hit = getHitObjects(this, x, y);
|
int hit = getHitObjects(this, x, y);
|
||||||
if(hit & (PUCLASS_BUTTON|PUCLASS_ONESHOT|PUCLASS_INPUT))
|
if (hit & (PUCLASS_BUTTON|PUCLASS_ONESHOT|PUCLASS_INPUT))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
int px, py;
|
int px, py;
|
||||||
|
@ -221,7 +218,7 @@ int fgPopup::checkHit(int button, int updown, int x, int y)
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
_dX = px - x;
|
_dX = px - x;
|
||||||
_dY = py - y;
|
_dY = py - y;
|
||||||
} else if(updown == PU_DRAG && _dragging) {
|
} else if (updown == PU_DRAG && _dragging) {
|
||||||
setPosition(x + _dX, y + _dY);
|
setPosition(x + _dX, y + _dY);
|
||||||
} else {
|
} else {
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
|
@ -235,7 +232,7 @@ int fgPopup::getHitObjects(puObject *object, int x, int y)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int type = 0;
|
int type = 0;
|
||||||
if(object->getType() & PUCLASS_GROUP)
|
if (object->getType() & PUCLASS_GROUP)
|
||||||
for (puObject *obj = ((puGroup *)object)->getFirstChild();
|
for (puObject *obj = ((puGroup *)object)->getFirstChild();
|
||||||
obj; obj = obj->getNextObject())
|
obj; obj = obj->getNextObject())
|
||||||
type |= getHitObjects(obj, x, y);
|
type |= getHitObjects(obj, x, y);
|
||||||
|
@ -243,7 +240,7 @@ int fgPopup::getHitObjects(puObject *object, int x, int y)
|
||||||
int cx, cy, cw, ch;
|
int cx, cy, cw, ch;
|
||||||
object->getAbsolutePosition(&cx, &cy);
|
object->getAbsolutePosition(&cx, &cy);
|
||||||
object->getSize(&cw, &ch);
|
object->getSize(&cw, &ch);
|
||||||
if(x >= cx && x < cx + cw && y >= cy && y < cy + ch)
|
if (x >= cx && x < cx + cw && y >= cy && y < cy + ch)
|
||||||
type |= object->getType();
|
type |= object->getType();
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -288,11 +285,10 @@ copy_to_pui (SGPropertyNode * node, puObject * object)
|
||||||
// from properties.
|
// from properties.
|
||||||
if (object->getType() & PUCLASS_TEXT) {
|
if (object->getType() & PUCLASS_TEXT) {
|
||||||
GUIInfo *info = (GUIInfo *)object->getUserData();
|
GUIInfo *info = (GUIInfo *)object->getUserData();
|
||||||
if (info && info->fmt_string) {
|
if (info && info->fmt_string)
|
||||||
object->setLabel(info->format(node));
|
object->setLabel(info->format(node));
|
||||||
} else {
|
else
|
||||||
object->setLabel(node->getStringValue());
|
object->setLabel(node->getStringValue());
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,7 +734,7 @@ FGDialog::setupObject (puObject * object, SGPropertyNode * props)
|
||||||
|
|
||||||
PropertyObject* po = new PropertyObject(name, object, node);
|
PropertyObject* po = new PropertyObject(name, object, node);
|
||||||
_propertyObjects.push_back(po);
|
_propertyObjects.push_back(po);
|
||||||
if(props->getBoolValue("live"))
|
if (props->getBoolValue("live"))
|
||||||
_liveObjects.push_back(po);
|
_liveObjects.push_back(po);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,6 +773,9 @@ FGDialog::setupObject (puObject * object, SGPropertyNode * props)
|
||||||
info->text = new char[FORMAT_BUFSIZE + 1];
|
info->text = new char[FORMAT_BUFSIZE + 1];
|
||||||
info->fmt_string = new char[strlen(format) + 1];
|
info->fmt_string = new char[strlen(format) + 1];
|
||||||
strcpy(info->fmt_string, format);
|
strcpy(info->fmt_string, format);
|
||||||
|
} else {
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "DIALOG: invalid <format> '"
|
||||||
|
<< format << '\'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
#include STL_IOMANIP
|
#include STL_IOMANIP
|
||||||
#include STL_STRING
|
#include STL_STRING
|
||||||
SG_USING_STD(string);
|
SG_USING_STD(string);
|
||||||
|
@ -41,7 +42,6 @@ typedef string stdString; // puObject has a "string" member
|
||||||
static string getValueTypeString(const SGPropertyNode *node)
|
static string getValueTypeString(const SGPropertyNode *node)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
assert(node);
|
|
||||||
|
|
||||||
SGPropertyNode::Type type = node->getType();
|
SGPropertyNode::Type type = node->getType();
|
||||||
if (type == SGPropertyNode::UNSPECIFIED)
|
if (type == SGPropertyNode::UNSPECIFIED)
|
||||||
|
@ -67,7 +67,7 @@ static string getValueTypeString(const SGPropertyNode *node)
|
||||||
|
|
||||||
static void dumpProperties(const SGPropertyNode *node)
|
static void dumpProperties(const SGPropertyNode *node)
|
||||||
{
|
{
|
||||||
cout << node->getPath() << "/" << endl;
|
cout << node->getPath() << '/' << endl;
|
||||||
for (int i = 0; i < node->nChildren(); i++) {
|
for (int i = 0; i < node->nChildren(); i++) {
|
||||||
const SGPropertyNode *c = node->getChild(i);
|
const SGPropertyNode *c = node->getChild(i);
|
||||||
SGPropertyNode::Type type = c->getType();
|
SGPropertyNode::Type type = c->getType();
|
||||||
|
@ -149,7 +149,7 @@ PropertyList::PropertyList(int minx, int miny, int maxx, int maxy, SGPropertyNod
|
||||||
_return(0),
|
_return(0),
|
||||||
_entries(0),
|
_entries(0),
|
||||||
_num_entries(0),
|
_num_entries(0),
|
||||||
_flags(false)
|
_verbose(false)
|
||||||
|
|
||||||
{
|
{
|
||||||
_list_box->setUserData(this);
|
_list_box->setUserData(this);
|
||||||
|
@ -193,7 +193,7 @@ void PropertyList::handle_select(puObject *list_box)
|
||||||
if (prop_list->_dot_files && (selected < 2)) {
|
if (prop_list->_dot_files && (selected < 2)) {
|
||||||
if (!strcmp(src, ".")) {
|
if (!strcmp(src, ".")) {
|
||||||
if (mod_ctrl)
|
if (mod_ctrl)
|
||||||
prop_list->toggleFlags();
|
prop_list->toggleVerbosity();
|
||||||
else if (mod_shift)
|
else if (mod_shift)
|
||||||
dumpProperties(prop_list->_curr);
|
dumpProperties(prop_list->_curr);
|
||||||
|
|
||||||
|
@ -218,7 +218,6 @@ void PropertyList::handle_select(puObject *list_box)
|
||||||
selected -= 2;
|
selected -= 2;
|
||||||
|
|
||||||
SGPropertyNode_ptr child = prop_list->_children[selected].node;
|
SGPropertyNode_ptr child = prop_list->_children[selected].node;
|
||||||
assert(child);
|
|
||||||
|
|
||||||
// check if it's a directory
|
// check if it's a directory
|
||||||
if (child->nChildren()) {
|
if (child->nChildren()) {
|
||||||
|
@ -278,19 +277,11 @@ void PropertyList::update(bool restore_pos)
|
||||||
|
|
||||||
// Make lists of the children's names, values, etc.
|
// Make lists of the children's names, values, etc.
|
||||||
for (i = 0; i < _num_children; i++, pi++) {
|
for (i = 0; i < _num_children; i++, pi++) {
|
||||||
SGPropertyNode *child = _children[i].node;
|
_children[i].text = &_entries[pi];
|
||||||
|
_entries[pi] = 0; // make it deletable
|
||||||
if (child->nChildren() > 0) {
|
updateTextForEntry(_children[i]);
|
||||||
stdString name = stdString(child->getDisplayName(true)) + '/';
|
|
||||||
_entries[pi] = new char[name.size() + 1];
|
|
||||||
strcpy(_entries[pi], name.c_str());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
_entries[pi] = 0; // make it delete-able
|
|
||||||
updateTextForEntry(i);
|
|
||||||
_children[i].setListener(this);
|
_children[i].setListener(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_entries[_num_entries] = 0;
|
_entries[_num_entries] = 0;
|
||||||
|
|
||||||
|
@ -301,22 +292,28 @@ void PropertyList::update(bool restore_pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PropertyList::updateTextForEntry(int index)
|
void PropertyList::updateTextForEntry(NodeData& data)
|
||||||
{
|
{
|
||||||
assert((index >= 0) && (index < _num_children));
|
SGPropertyNode *node = data.node;
|
||||||
SGPropertyNode_ptr node = _children[index].node;
|
|
||||||
|
|
||||||
stdString name = node->getDisplayName(true);
|
stdString name = node->getDisplayName(true);
|
||||||
stdString type = getValueTypeString(node);
|
stdString type = getValueTypeString(node);
|
||||||
stdString value = node->getStringValue();
|
stdString value = node->getStringValue();
|
||||||
|
|
||||||
|
std::ostringstream line;
|
||||||
|
line << name;
|
||||||
|
|
||||||
|
int children = node->nChildren();
|
||||||
|
if (children)
|
||||||
|
line << '/';
|
||||||
|
|
||||||
|
if (!children || (_verbose && node->hasValue())) {
|
||||||
if (node->getType() == SGPropertyNode::STRING
|
if (node->getType() == SGPropertyNode::STRING
|
||||||
|| node->getType() == SGPropertyNode::UNSPECIFIED)
|
|| node->getType() == SGPropertyNode::UNSPECIFIED)
|
||||||
sanitize(value);
|
sanitize(value);
|
||||||
|
|
||||||
stdString line = name + " = '" + value + "' (" + type;
|
line << " = '" << value << "' (" << type;
|
||||||
|
|
||||||
if (_flags) {
|
if (_verbose) {
|
||||||
stdString ext;
|
stdString ext;
|
||||||
if (!node->getAttribute(SGPropertyNode::READ))
|
if (!node->getAttribute(SGPropertyNode::READ))
|
||||||
ext += 'r';
|
ext += 'r';
|
||||||
|
@ -332,21 +329,26 @@ void PropertyList::updateTextForEntry(int index)
|
||||||
ext += 'U';
|
ext += 'U';
|
||||||
if (node->isTied())
|
if (node->isTied())
|
||||||
ext += 'T';
|
ext += 'T';
|
||||||
if (ext.size())
|
|
||||||
line += ", " + ext;
|
if (!ext.empty())
|
||||||
|
line << ", " << ext;
|
||||||
|
|
||||||
|
int num = node->nListeners();
|
||||||
|
if (data.listener)
|
||||||
|
num--;
|
||||||
|
if (lst)
|
||||||
|
line << ", L" << num;
|
||||||
|
}
|
||||||
|
line << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
line += ')';
|
stdString out = line.str();
|
||||||
|
if (out.size() >= PUSTRING_MAX)
|
||||||
|
out.resize(PUSTRING_MAX - 1);
|
||||||
|
|
||||||
if (line.size() >= PUSTRING_MAX)
|
delete[] *data.text;
|
||||||
line.resize(PUSTRING_MAX - 1);
|
*data.text = new char[out.size() + 1];
|
||||||
|
strcpy(*data.text, out.c_str());
|
||||||
if (_dot_files)
|
|
||||||
index += 2;
|
|
||||||
|
|
||||||
delete[] _entries[index];
|
|
||||||
_entries[index] = new char[line.size() + 1];
|
|
||||||
strcpy(_entries[index], line.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,7 +356,7 @@ void PropertyList::valueChanged(SGPropertyNode *nd)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _num_children; i++)
|
for (int i = 0; i < _num_children; i++)
|
||||||
if (_children[i].node == nd) {
|
if (_children[i].node == nd) {
|
||||||
updateTextForEntry(i);
|
updateTextForEntry(_children[i]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
void setCurrent(SGPropertyNode *p);
|
void setCurrent(SGPropertyNode *p);
|
||||||
SGPropertyNode *getCurrent() const { return _curr; }
|
SGPropertyNode *getCurrent() const { return _curr; }
|
||||||
void publish(SGPropertyNode *p) { _return = p; invokeCallback(); }
|
void publish(SGPropertyNode *p) { _return = p; invokeCallback(); }
|
||||||
void toggleFlags() { _flags = !_flags; }
|
void toggleVerbosity() { _verbose = !_verbose; }
|
||||||
|
|
||||||
// overridden plib pui methods
|
// overridden plib pui methods
|
||||||
virtual char *getListStringValue() { return (char *)(_return ? _return->getPath(true) : ""); }
|
virtual char *getListStringValue() { return (char *)(_return ? _return->getPath(true) : ""); }
|
||||||
|
@ -50,21 +50,6 @@ public:
|
||||||
virtual void valueChanged(SGPropertyNode *node);
|
virtual void valueChanged(SGPropertyNode *node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// update the text string in the puList using the given node and
|
|
||||||
// updating the requested offset. The value of dotFiles is taken
|
|
||||||
// into account before the index is applied, i.e this should be
|
|
||||||
// an index into 'children'
|
|
||||||
void updateTextForEntry(int index);
|
|
||||||
void delete_arrays();
|
|
||||||
static void handle_select(puObject *b);
|
|
||||||
static int nodeNameCompare(const void *, const void *);
|
|
||||||
|
|
||||||
SGPropertyNode_ptr _curr;
|
|
||||||
SGPropertyNode_ptr _return;
|
|
||||||
|
|
||||||
char **_entries;
|
|
||||||
int _num_entries;
|
|
||||||
|
|
||||||
struct NodeData {
|
struct NodeData {
|
||||||
NodeData() : listener(0) {}
|
NodeData() : listener(0) {}
|
||||||
~NodeData() {
|
~NodeData() {
|
||||||
|
@ -76,12 +61,27 @@ private:
|
||||||
}
|
}
|
||||||
SGPropertyNode_ptr node;
|
SGPropertyNode_ptr node;
|
||||||
SGPropertyChangeListener *listener;
|
SGPropertyChangeListener *listener;
|
||||||
|
char **text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// update the text string in the puList using the given node and
|
||||||
|
// updating the requested offset.
|
||||||
|
void updateTextForEntry(NodeData&);
|
||||||
|
void delete_arrays();
|
||||||
|
static void handle_select(puObject *b);
|
||||||
|
static int nodeNameCompare(const void *, const void *);
|
||||||
|
|
||||||
|
SGPropertyNode_ptr _curr;
|
||||||
|
SGPropertyNode_ptr _return;
|
||||||
|
|
||||||
|
char **_entries;
|
||||||
|
int _num_entries;
|
||||||
|
|
||||||
NodeData *_children;
|
NodeData *_children;
|
||||||
int _num_children;
|
int _num_children;
|
||||||
|
|
||||||
bool _dot_files; // . and .. pseudo-dirs currently shown?
|
bool _dot_files; // . and .. pseudo-dirs currently shown?
|
||||||
bool _flags; // show SGPropertyNode flags
|
bool _verbose; // show SGPropertyNode flags
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue