From Cedric Pinson and Jeremey Moles, Changes to OpenSceneGraph-osgWidget-dev branch.
Notes from Robert Osfield, Merged changes to OpenSceneGraph-osgWidget-dev r9367 (prior to my botched attempt at merged svn/trunk into the branch).
This commit is contained in:
@@ -16,104 +16,104 @@ const unsigned int MASK_2D = 0xF0000000;
|
||||
const unsigned int MASK_3D = 0x0F000000;
|
||||
|
||||
struct ColorWidget: public osgWidget::Widget {
|
||||
ColorWidget():
|
||||
osgWidget::Widget("", 256.0f, 256.0f) {
|
||||
}
|
||||
ColorWidget():
|
||||
osgWidget::Widget("", 256.0f, 256.0f) {
|
||||
}
|
||||
|
||||
bool mouseEnter(double, double, osgWidget::WindowManager*) {
|
||||
addColor(-osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
|
||||
|
||||
// osgWidget::warn() << "enter: " << getColor() << std::endl;
|
||||
bool mouseEnter(double, double, osgWidget::WindowManager*) {
|
||||
addColor(-osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
|
||||
|
||||
// osgWidget::warn() << "enter: " << getColor() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseLeave(double, double, osgWidget::WindowManager*) {
|
||||
addColor(osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
|
||||
|
||||
// osgWidget::warn() << "leave: " << getColor() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool mouseLeave(double, double, osgWidget::WindowManager*) {
|
||||
addColor(osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
|
||||
|
||||
// osgWidget::warn() << "leave: " << getColor() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseOver(double x, double y, osgWidget::WindowManager*) {
|
||||
osgWidget::Color c = getImageColorAtPointerXY(x, y);
|
||||
bool mouseOver(double x, double y, osgWidget::WindowManager*) {
|
||||
osgWidget::Color c = getImageColorAtPointerXY(x, y);
|
||||
|
||||
if(c.a() < 0.001f) {
|
||||
// osgWidget::warn() << "Transparent Pixel: " << x << " " << y << std::endl;
|
||||
if(c.a() < 0.001f) {
|
||||
// osgWidget::warn() << "Transparent Pixel: " << x << " " << y << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool keyUp(int key, int keyMask, osgWidget::WindowManager*) {
|
||||
// osgWidget::warn() << "..." << key << " - " << keyMask << std::endl;
|
||||
bool keyUp(int key, int keyMask, osgWidget::WindowManager*) {
|
||||
// osgWidget::warn() << "..." << key << " - " << keyMask << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
osgWidget::Box* createBox(const std::string& name, osgWidget::Box::BoxType bt) {
|
||||
osgWidget::Box* box = new osgWidget::Box(name, bt, true);
|
||||
osgWidget::Widget* widget1 = new osgWidget::Widget(name + "_widget1", 100.0f, 100.0f);
|
||||
osgWidget::Widget* widget2 = new osgWidget::Widget(name + "_widget2", 100.0f, 100.0f);
|
||||
osgWidget::Widget* widget3 = new ColorWidget();
|
||||
osgWidget::Box* box = new osgWidget::Box(name, bt, true);
|
||||
osgWidget::Widget* widget1 = new osgWidget::Widget(name + "_widget1", 100.0f, 100.0f);
|
||||
osgWidget::Widget* widget2 = new osgWidget::Widget(name + "_widget2", 100.0f, 100.0f);
|
||||
osgWidget::Widget* widget3 = new ColorWidget();
|
||||
|
||||
widget1->setColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
widget2->setColor(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
widget1->setColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
widget2->setColor(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
|
||||
widget3->setImage("osgWidget/natascha.png");
|
||||
widget3->setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT);
|
||||
widget3->setTexCoord(1.0f, 0.0f, osgWidget::Widget::LOWER_RIGHT);
|
||||
widget3->setTexCoord(1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
|
||||
widget3->setTexCoord(0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
|
||||
widget3->setImage("osgWidget/natascha.png");
|
||||
widget3->setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT);
|
||||
widget3->setTexCoord(1.0f, 0.0f, osgWidget::Widget::LOWER_RIGHT);
|
||||
widget3->setTexCoord(1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
|
||||
widget3->setTexCoord(0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
|
||||
|
||||
box->addWidget(widget1);
|
||||
box->addWidget(widget2);
|
||||
box->addWidget(widget3);
|
||||
box->addWidget(widget1);
|
||||
box->addWidget(widget2);
|
||||
box->addWidget(widget3);
|
||||
|
||||
return box;
|
||||
return box;
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
wm->setPointerFocusMode(osgWidget::WindowManager::PFM_SLOPPY);
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG
|
||||
);
|
||||
|
||||
wm->setPointerFocusMode(osgWidget::WindowManager::PFM_SLOPPY);
|
||||
|
||||
osgWidget::Window* box1 = createBox("HBOX", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Window* box2 = createBox("VBOX", osgWidget::Box::VERTICAL);
|
||||
osgWidget::Window* box3 = createBox("HBOX2", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Window* box4 = createBox("VBOX2", osgWidget::Box::VERTICAL);
|
||||
osgWidget::Window* box1 = createBox("HBOX", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Window* box2 = createBox("VBOX", osgWidget::Box::VERTICAL);
|
||||
osgWidget::Window* box3 = createBox("HBOX2", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Window* box4 = createBox("VBOX2", osgWidget::Box::VERTICAL);
|
||||
|
||||
box1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 0.8f);
|
||||
box1->attachMoveCallback();
|
||||
box1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 0.8f);
|
||||
box1->attachMoveCallback();
|
||||
|
||||
box2->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.8f);
|
||||
box2->attachMoveCallback();
|
||||
box2->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.8f);
|
||||
box2->attachMoveCallback();
|
||||
|
||||
box3->getBackground()->setColor(0.0f, 0.0f, 1.0f, 0.8f);
|
||||
box3->attachMoveCallback();
|
||||
box3->getBackground()->setColor(0.0f, 0.0f, 1.0f, 0.8f);
|
||||
box3->attachMoveCallback();
|
||||
|
||||
wm->addChild(box1);
|
||||
wm->addChild(box2);
|
||||
wm->addChild(box3);
|
||||
wm->addChild(box4);
|
||||
wm->addChild(box1);
|
||||
wm->addChild(box2);
|
||||
wm->addChild(box3);
|
||||
wm->addChild(box4);
|
||||
|
||||
box4->hide();
|
||||
box4->hide();
|
||||
|
||||
osg::Node* model = osgDB::readNodeFile("spaceship.osg");
|
||||
osg::Node* model = osgDB::readNodeFile("spaceship.osg");
|
||||
|
||||
model->setNodeMask(MASK_3D);
|
||||
model->setNodeMask(MASK_3D);
|
||||
|
||||
return osgWidget::createExample(viewer, wm, model);
|
||||
return osgWidget::createExample(viewer, wm, model);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user