Show
Ignore:
Timestamp:
12/16/08 21:29:00 (5 years ago)
Author:
robert
Message:

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).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgwidgetstyled/osgwidgetstyled.cpp

    r8588 r9370  
    1010 
    1111const std::string& STYLE1 = 
    12         "color 0 0 0 128\n" 
    13         "padding 5\n" 
     12    "color 0 0 0 128\n" 
     13    "padding 5\n" 
    1414; 
    1515 
    1616const std::string& STYLE2 = 
    17         "color 1.0 0.5 0.0\n" 
     17    "color 1.0 0.5 0.0\n" 
    1818; 
    1919 
    2020const std::string& STYLE3 = 
    21         "fill true\n" 
     21    "fill true\n" 
    2222; 
    2323 
    2424const std::string& STYLE4 = 
    25         "pos 100.0 100.0\n" 
    26         "size 600 600\n" 
     25    "pos 100.0 100.0\n" 
     26    "size 600 600\n" 
    2727; 
    2828 
     
    3131 
    3232class CustomStyle: public osgWidget::Style { 
    33         virtual bool applyStyle(osgWidget::Widget* w, osgWidget::Reader r) { 
    34                 CustomStyled* cs = dynamic_cast<CustomStyled*>(w); 
     33    virtual bool applyStyle(osgWidget::Widget* w, osgWidget::Reader r) { 
     34        CustomStyled* cs = dynamic_cast<CustomStyled*>(w); 
    3535 
    36                 if(!cs) return false; 
     36        if(!cs) return false; 
    3737 
    38                 osgWidget::warn() << "Here, okay." << std::endl; 
     38        osgWidget::warn() << "Here, okay." << std::endl; 
    3939 
    40                 return true; 
    41         } 
     40        return true; 
     41    } 
    4242}; 
    4343 
    4444int main(int argc, char** argv) { 
    45         osgViewer::Viewer viewer; 
     45    osgViewer::Viewer viewer; 
    4646 
    47         osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
    48                 &viewer, 
    49                 1280.0f, 
    50                 1024.0f, 
    51                 MASK_2D 
    52         ); 
     47    osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
     48        &viewer, 
     49        1280.0f, 
     50        1024.0f, 
     51        MASK_2D 
     52    ); 
    5353 
    54         osgWidget::Box* box = new osgWidget::Box("box", osgWidget::Box::VERTICAL); 
     54    osgWidget::Box* box = new osgWidget::Box("box", osgWidget::Box::VERTICAL); 
    5555 
    56         osgWidget::Widget* widget1 = new osgWidget::Widget("w1", 200.0f, 200.0f); 
    57         osgWidget::Widget* widget2 = new osgWidget::Widget("w2", 100.0f, 100.0f); 
    58         osgWidget::Widget* widget3 = new osgWidget::Widget("w3", 0.0f, 0.0f); 
    59         CustomStyled*      cs      = new CustomStyled(); 
     56    osgWidget::Widget* widget1 = new osgWidget::Widget("w1", 200.0f, 200.0f); 
     57    osgWidget::Widget* widget2 = new osgWidget::Widget("w2", 100.0f, 100.0f); 
     58    osgWidget::Widget* widget3 = new osgWidget::Widget("w3", 0.0f, 0.0f); 
     59    CustomStyled*      cs      = new CustomStyled(); 
    6060 
    61         // Yep. 
    62         wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style1", STYLE1)); 
    63         wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style2", STYLE2)); 
    64         wm->getStyleManager()->addStyle(new osgWidget::Style("spacer", STYLE3)); 
    65         wm->getStyleManager()->addStyle(new osgWidget::Style("window", STYLE4)); 
    66         // wm->getStyleManager()->addStyle(new CustomStyle("widget", "")); 
     61    // Yep. 
     62    wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style1", STYLE1)); 
     63    wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style2", STYLE2)); 
     64    wm->getStyleManager()->addStyle(new osgWidget::Style("spacer", STYLE3)); 
     65    wm->getStyleManager()->addStyle(new osgWidget::Style("window", STYLE4)); 
     66    // wm->getStyleManager()->addStyle(new CustomStyle("widget", "")); 
    6767 
    68         widget1->setStyle("widget.style1"); 
    69         widget2->setStyle("widget.style2"); 
    70         widget3->setStyle("spacer"); 
     68    widget1->setStyle("widget.style1"); 
     69    widget2->setStyle("widget.style2"); 
     70    widget3->setStyle("spacer"); 
    7171 
    72         box->setStyle("window"); 
     72    box->setStyle("window"); 
    7373 
    74         box->addWidget(widget1); 
    75         box->addWidget(widget2); 
    76         box->addWidget(widget3); 
     74    box->addWidget(widget1); 
     75    box->addWidget(widget2); 
     76    box->addWidget(widget3); 
    7777 
    78         wm->addChild(box); 
     78    wm->addChild(box); 
    7979 
    80         // box->resizePercent(0.0f, 100.0f); 
     80    // box->resizePercent(0.0f, 100.0f); 
    8181 
    82         return osgWidget::createExample(viewer, wm); 
     82    return osgWidget::createExample(viewer, wm); 
    8383}