Converted tabs to four spaces

This commit is contained in:
Robert Osfield
2008-07-15 22:03:59 +00:00
parent e6c99b0434
commit 8fe0820bb8
8 changed files with 655 additions and 655 deletions

View File

@@ -14,173 +14,173 @@
const unsigned int MASK_2D = 0xF0000000;
const char* INFO =
"Use the Input Wigets below to enter the X, Y, and Z position of a\n"
"sphere to be inserted into the scene. Once you've done this, use\n"
"the button below to add it!"
"Use the Input Wigets below to enter the X, Y, and Z position of a\n"
"sphere to be inserted into the scene. Once you've done this, use\n"
"the button below to add it!"
;
void setupLabel(osgWidget::Label* label) {
label->setFontSize(16);
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
// label->setFont("fonts/monospace.ttf");
label->setFont("fonts/Calibri1.ttf");
label->setPadding(2.0f);
label->setHeight(18.0f);
label->setCanFill(true);
label->setFontSize(16);
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
// label->setFont("fonts/monospace.ttf");
label->setFont("fonts/Calibri1.ttf");
label->setPadding(2.0f);
label->setHeight(18.0f);
label->setCanFill(true);
}
osgWidget::Input* createTableRow(
osgWidget::Table* table,
unsigned int rowNum,
const std::string& valName
osgWidget::Table* table,
unsigned int rowNum,
const std::string& valName
) {
std::stringstream ssLabel;
std::stringstream ssInput;
std::stringstream ssLabel;
std::stringstream ssInput;
ssLabel << "Label_Row" << rowNum;
ssInput << "Input_Row" << rowNum;
ssLabel << "Label_Row" << rowNum;
ssInput << "Input_Row" << rowNum;
osgWidget::Label* label = new osgWidget::Label(ssLabel.str(), valName);
osgWidget::Input* input = new osgWidget::Input(ssInput.str(), "", 20);
osgWidget::Label* label = new osgWidget::Label(ssLabel.str(), valName);
osgWidget::Input* input = new osgWidget::Input(ssInput.str(), "", 20);
setupLabel(label);
setupLabel(input);
setupLabel(label);
setupLabel(input);
label->setWidth(50.0f);
label->setColor(0.1f, 0.1f, 0.1f, 1.0f);
label->setWidth(50.0f);
label->setColor(0.1f, 0.1f, 0.1f, 1.0f);
input->setWidth(150.0f);
input->setColor(0.4f, 0.4f, 0.4f, 1.0f);
input->setWidth(150.0f);
input->setColor(0.4f, 0.4f, 0.4f, 1.0f);
table->addWidget(label, rowNum, 0);
table->addWidget(input, rowNum, 1);
table->addWidget(label, rowNum, 0);
table->addWidget(input, rowNum, 1);
return input;
return input;
}
osgWidget::Label* createLabel(const std::string& text) {
osgWidget::Label* label = new osgWidget::Label("", text);
osgWidget::Label* label = new osgWidget::Label("", text);
setupLabel(label);
setupLabel(label);
return label;
return label;
}
class Button: public osgWidget::Label {
public:
typedef std::vector<osgWidget::Input*> Inputs;
typedef std::vector<osgWidget::Input*> Inputs;
private:
Inputs _xyz;
Inputs _xyz;
public:
Button(const std::string& text, const Inputs& inputs):
osgWidget::Label("", text),
_xyz(inputs) {
setupLabel(this);
Button(const std::string& text, const Inputs& inputs):
osgWidget::Label("", text),
_xyz(inputs) {
setupLabel(this);
setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK);
setShadow(0.1f);
addHeight(4.0f);
}
setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK);
setShadow(0.1f);
addHeight(4.0f);
}
bool mousePush(double, double, osgWidget::WindowManager*) {
osgWidget::warn()
<< "x: " << _xyz[0]->getLabel() << std::endl
<< "y: " << _xyz[1]->getLabel() << std::endl
<< "z: " << _xyz[2]->getLabel() << std::endl
;
bool mousePush(double, double, osgWidget::WindowManager*) {
osgWidget::warn()
<< "x: " << _xyz[0]->getLabel() << std::endl
<< "y: " << _xyz[1]->getLabel() << std::endl
<< "z: " << _xyz[2]->getLabel() << std::endl
;
return false;
}
return false;
}
};
// TODO: Testing our _parent/EmbeddedWindow stuff.
bool info(osgWidget::Event& ev) {
osgWidget::warn() << "MousePush @ Window: " << ev.getWindow()->getName() << std::endl;
osgWidget::warn() << "MousePush @ Window: " << ev.getWindow()->getName() << std::endl;
return true;
return true;
}
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG
);
osgWidget::Box* box = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
osgWidget::Table* table = new osgWidget::Table("table", 3, 2);
osgWidget::Box* lbox1 = new osgWidget::Box("lbox1", osgWidget::Box::HORIZONTAL);
osgWidget::Box* lbox2 = new osgWidget::Box("lbox2", osgWidget::Box::HORIZONTAL);
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture(
"frame",
"osgWidget/theme.png",
64.0f,
64.0f,
16.0f,
16.0f,
100.0f,
100.0f
);
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG
);
osgWidget::Box* box = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
osgWidget::Table* table = new osgWidget::Table("table", 3, 2);
osgWidget::Box* lbox1 = new osgWidget::Box("lbox1", osgWidget::Box::HORIZONTAL);
osgWidget::Box* lbox2 = new osgWidget::Box("lbox2", osgWidget::Box::HORIZONTAL);
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture(
"frame",
"osgWidget/theme.png",
64.0f,
64.0f,
16.0f,
16.0f,
100.0f,
100.0f
);
osgWidget::Input* x = createTableRow(table, 0, "X Position");
osgWidget::Input* y = createTableRow(table, 1, "Y Position");
osgWidget::Input* z = createTableRow(table, 2, "Z Position");
Button::Inputs inputs;
osgWidget::Input* x = createTableRow(table, 0, "X Position");
osgWidget::Input* y = createTableRow(table, 1, "Y Position");
osgWidget::Input* z = createTableRow(table, 2, "Z Position");
Button::Inputs inputs;
inputs.push_back(x);
inputs.push_back(y);
inputs.push_back(z);
inputs.push_back(x);
inputs.push_back(y);
inputs.push_back(z);
table->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));
table->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));
lbox1->addWidget(createLabel(INFO));
lbox2->addWidget(new Button("Add To Scene...", inputs));
lbox1->addWidget(createLabel(INFO));
lbox2->addWidget(new Button("Add To Scene...", inputs));
box->addWidget(lbox1->embed());
box->addWidget(table->embed());
box->addWidget(lbox2->embed());
box->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));
box->addWidget(lbox1->embed());
box->addWidget(table->embed());
box->addWidget(lbox2->embed());
box->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));
frame->setWindow(box);
frame->getEmbeddedWindow()->setSize(box->getWidth(), box->getHeight());
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
frame->attachTabFocusCallback();
frame->setWindow(box);
frame->getEmbeddedWindow()->setSize(box->getWidth(), box->getHeight());
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
frame->attachTabFocusCallback();
for(osgWidget::Frame::Iterator i = frame->begin(); i != frame->end(); i++) {
if(i->valid()) i->get()->setColor(0.5f, 0.7f, 1.0f, 1.0f);
}
for(osgWidget::Frame::Iterator i = frame->begin(); i != frame->end(); i++) {
if(i->valid()) i->get()->setColor(0.5f, 0.7f, 1.0f, 1.0f);
}
wm->addChild(frame);
wm->addChild(frame);
/*
// Print out our focus list, it should just have 3 widgets.
osgWidget::WidgetList wl;
/*
// Print out our focus list, it should just have 3 widgets.
osgWidget::WidgetList wl;
box->getFocusList(wl);
box->getFocusList(wl);
for(osgWidget::WidgetList::iterator i = wl.begin(); i != wl.end(); i++) {
osgWidget::warn() << i->get()->getName() << std::endl;
}
*/
lbox1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
lbox1->getBackground()->setColor(0.0f, 1.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT);
lbox1->getBackground()->setColor(0.0f, 0.0f, 1.0f, 1.0f, osgWidget::Widget::LOWER_RIGHT);
lbox1->getBackground()->setColor(1.0f, 1.0f, 1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
lbox1->setVisibilityMode(osgWidget::Window::VM_ENTIRE);
lbox1->update();
for(osgWidget::WidgetList::iterator i = wl.begin(); i != wl.end(); i++) {
osgWidget::warn() << i->get()->getName() << std::endl;
}
*/
lbox1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
lbox1->getBackground()->setColor(0.0f, 1.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT);
lbox1->getBackground()->setColor(0.0f, 0.0f, 1.0f, 1.0f, osgWidget::Widget::LOWER_RIGHT);
lbox1->getBackground()->setColor(1.0f, 1.0f, 1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
lbox1->setVisibilityMode(osgWidget::Window::VM_ENTIRE);
lbox1->update();
int r = osgWidget::createExample(viewer, wm);
int r = osgWidget::createExample(viewer, wm);
// osgWidget::writeWindowManagerNode(wm);
// osgDB::writeNodeFile(*box, "osgWidget.osg");
// osgWidget::writeWindowManagerNode(wm);
// osgDB::writeNodeFile(*box, "osgWidget.osg");
return r;
return r;
}