Re: [osg-users] Using osgWidget for the first time, some questions

2009-04-20 Thread Jean-Sébastien Guay

Hi again all,

One other comment I'd like to make about osgWidget. In the header files, 
most argument names are removed from method declarations, even 
constructors. If I were using a binary version of OSG, all I would have 
to go with would be the headers, so the argument names should be there, 
otherwise I can't know what the arguments are...


If I see

class OSGWIDGET_EXPORT Label: public Widget
{
public:

META_Object   (osgWidget, Label);

Label (const std::string = , const std::string = );
// ...

What are those two strings? One might be the text of the label, but 
which one, and what about the other one?


I can understand the desire to shut up warnings about unused arguments, 
but perhaps this is being too pro-active? :-)


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Using osgWidget for the first time, some questions

2009-04-17 Thread Jean-Sébastien Guay

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 = 0xF000;

// 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
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Using osgWidget for the first time, some questions

2009-04-17 Thread Cedric Pinson
-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 = 0xF000;

 // 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:morni...@plopbyte.net
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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Using osgWidget for the first time, some questions

2009-04-17 Thread Jean-Sébastien Guay

Hello Cedric,


Maybe look at osgwidgetmessagebox example, if i remember it does what
you want.


That showed me how to make the center widget auto-resize, yes. Thanks.

What about the other questions? (the color of the center widget not 
using the alpha, and the alignment of widgets to the top of the frame)


Thanks a lot,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org