-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Sebastien,
Maybe look at osgwidgetmessagebox example, if i remember it does what
you want.
Cedric
Jean-Sébastien Guay wrote:
> Hello all, hello Jeremy,
>
> I'm using osgWidget for the first time, thinking of using it for a
> little addition I'm planning for OSG eventually, and just trying to
> get familiar with it. I have a few questions.
>
> First, here's my code:
>
> const unsigned int MASK_2D = 0xF0000000;
>
> // To be able to pass an osg::Vec4 to a
> // setColor(float, float, float, float) method
> #define mySetColor(obj, c) (obj->setColor(c.r(), c.g(), c.b(), c.a()))
>
> DebugHUD::DebugHUD(osgViewer::View* view)
> {
> osg::Vec4 titleBarColor(0, 0, 0.5, 0.5);
> osg::Vec4 backgroundColor(0.2, 0.2, 0.7, 0.5);
>
> osgWidget::point_type w =
> view->getCamera()->getViewport()->width();
> osgWidget::point_type h =
> view->getCamera()->getViewport()->height();
>
> m_windowManager = new osgWidget::WindowManager(view, w, h,
> MASK_2D);
>
> osgWidget::Frame* frame =
> osgWidget::Frame::createSimpleFrameFromTheme(
> "frameTheme",
> osgDB::readImageFile("osgWidget/theme-1.png"),
> 300.0f,
> 300.0f,
> osgWidget::Frame::FRAME_ALL
> );
> frame->setPosition(300,100,0);
>
> osgWidget::Table* table = new osgWidget::Table("table", 1, 1);
> osgWidget::Widget* center = new osgWidget::Widget("center",
> 300.0f, 300.0f);
> mySetColor(center, backgroundColor);
> center->setAlignVertical(osgWidget::Widget::VA_TOP); //
> Doesn't work
> table->addWidget(center, 0, 0);
> frame->setWindow(table);
>
> mySetColor(frame->getBackground(), osg::Vec4(1.0, 1.0, 1.0, 0.0));
>
> mySetColor(frame->getBorder(osgWidget::Frame::BORDER_TOP),
> titleBarColor);
>
> mySetColor(frame->getCorner(osgWidget::Frame::CORNER_UPPER_LEFT),
> titleBarColor);
>
> mySetColor(frame->getCorner(osgWidget::Frame::CORNER_UPPER_RIGHT),
> titleBarColor);
>
> mySetColor(frame->getBorder(osgWidget::Frame::BORDER_LEFT),
> backgroundColor);
> mySetColor(frame->getBorder(osgWidget::Frame::BORDER_RIGHT),
> backgroundColor);
> mySetColor(frame->getBorder(osgWidget::Frame::BORDER_BOTTOM),
> backgroundColor);
>
> mySetColor(frame->getCorner(osgWidget::Frame::CORNER_LOWER_LEFT),
> backgroundColor);
>
> mySetColor(frame->getCorner(osgWidget::Frame::CORNER_LOWER_RIGHT),
> backgroundColor);
>
> m_windowManager->addChild(frame);
>
> m_camera = m_windowManager->createParentOrthoCamera();
> m_windowManager->resizeAllWindows();
>
> view->getCamera()->addChild(m_camera.get());
> view->addEventHandler(new
> osgWidget::MouseHandler(m_windowManager.get()));
> view->addEventHandler(new
> osgWidget::KeyboardHandler(m_windowManager.get()));
> view->addEventHandler(new
> osgWidget::ResizeHandler(m_windowManager.get(), m_camera.get()));
> view->addEventHandler(new
> osgWidget::CameraSwitchHandler(m_windowManager.get(), m_camera.get()));
> }
>
> So, here are my questions.
>
> 1. The widget in the center is not the color I set it to. The alpha
> doesn't seem to be taken into account. I'd like my whole window to
> be a transparent blue (backgroundColor).
> 2. When I resize the frame to make it larger (dragging the
> bottom-right corner down and to the right for example), I'd like the
> widget in the center to resize itself to fit. Is that possible?
> Well, in fact if I could do without that widget it would be even
> better, but I want the center of the window to be transparent blue,
> and getBackground()->setColor() makes the color visible even on the
> corners of the window, which I don't want...
> 3. I want the widgets in my frame to stay at the top of the frame
> when it's resized. But even if I set my widget's vertical alignment
> to VA_TOP, it doesn't work (see the line with the "Doesn't work"
> comment above). Is that a bug or should I do something else to get
> what I want?
>
> BTW, to set the vertical alignment I would have expected to call
> setVerticalAlignment instead of setAlignVertical, any reason why
> it's named that way? setVerticalAlignment seems more natural.
>
> Other than that, it seems that osgWidget will allow me to do what I
> want and I'm enjoying working with it (though I'm only doing basic
> things right now...).
>
> Thanks in advance,
>
> J-S
- --
+33 (0) 6 63 20 03 56 Cedric Pinson mailto:[email protected]
http://www.plopbyte.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknonmMACgkQs6ZHzVQN0IiiSACfYwX5eK3dRwnp/JHRI7gnkQ8+
+vUAn2k2pfcH8NjRWs2HMmNsaX+jjRFh
=XxCD
-----END PGP SIGNATURE-----
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org