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/osgwidgettable/osgwidgettable.cpp

    r9289 r9370  
    1414 
    1515int main(int argc, char** argv) { 
    16         osgViewer::Viewer viewer; 
     16    osgViewer::Viewer viewer; 
    1717 
    18         osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
    19                 &viewer, 
    20                 1280.0f, 
    21                 1024.0f, 
    22                 MASK_2D, 
    23                 osgWidget::WindowManager::WM_PICK_DEBUG 
    24         ); 
    25          
    26         osgWidget::Table* table = new osgWidget::Table("table", 3, 3); 
     18    osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
     19        &viewer, 
     20        1280.0f, 
     21        1024.0f, 
     22        MASK_2D, 
     23        osgWidget::WindowManager::WM_PICK_DEBUG 
     24    ); 
     25     
     26    osgWidget::Table* table = new osgWidget::Table("table", 3, 3); 
    2727 
    28         // Here we create our "cells" manually, though it will often be convenient to 
    29         // do so algorithmically. Also, notice how we set the text name of each widget to 
    30         // correspond with it's "index" in the table. This is merely a convenience, which 
    31         // we use later... 
    32         table->addWidget(new osgWidget::Widget("0, 0", 100.0f, 25.0f), 0, 0); 
    33         table->addWidget(new osgWidget::Widget("0, 1", 100.0f, 25.0f), 0, 1); 
    34         table->addWidget(new osgWidget::Widget("0, 2", 100.0f, 75.0f), 0, 2); 
    35          
    36         table->addWidget(new osgWidget::Widget("1, 0", 200.0f, 45.0f), 1, 0); 
    37         table->addWidget(new osgWidget::Widget("1, 1", 200.0f, 45.0f), 1, 1); 
    38         table->addWidget(new osgWidget::Widget("1, 2", 200.0f, 45.0f), 1, 2); 
    39          
    40         table->addWidget(new osgWidget::Widget("2, 0", 300.0f, 65.0f), 2, 0); 
    41         table->addWidget(new osgWidget::Widget("2, 1", 300.0f, 65.0f), 2, 1); 
    42         table->addWidget(new osgWidget::Widget("2, 2", 300.0f, 65.0f), 2, 2); 
     28    // Here we create our "cells" manually, though it will often be convenient to 
     29    // do so algorithmically. Also, notice how we set the text name of each widget to 
     30    // correspond with it's "index" in the table. This is merely a convenience, which 
     31    // we use later... 
     32    table->addWidget(new osgWidget::Widget("0, 0", 100.0f, 25.0f), 0, 0); 
     33    table->addWidget(new osgWidget::Widget("0, 1", 100.0f, 25.0f), 0, 1); 
     34    table->addWidget(new osgWidget::Widget("0, 2", 100.0f, 75.0f), 0, 2); 
     35     
     36    table->addWidget(new osgWidget::Widget("1, 0", 200.0f, 45.0f), 1, 0); 
     37    table->addWidget(new osgWidget::Widget("1, 1", 200.0f, 45.0f), 1, 1); 
     38    table->addWidget(new osgWidget::Widget("1, 2", 200.0f, 45.0f), 1, 2); 
     39     
     40    table->addWidget(new osgWidget::Widget("2, 0", 300.0f, 65.0f), 2, 0); 
     41    table->addWidget(new osgWidget::Widget("2, 1", 300.0f, 65.0f), 2, 1); 
     42    table->addWidget(new osgWidget::Widget("2, 2", 300.0f, 65.0f), 2, 2); 
    4343 
    44         table->getBackground()->setColor(0.0f, 0.0f, 0.5f, 1.0f); 
    45         table->attachMoveCallback(); 
     44    table->getBackground()->setColor(0.0f, 0.0f, 0.5f, 1.0f); 
     45    table->attachMoveCallback(); 
    4646 
    47         // Use a hackish method of setting the spacing for all Widgets. 
    48         for(osgWidget::Table::Iterator i = table->begin(); i != table->end(); i++) 
    49                 i->get()->setPadding(1.0f) 
    50         ; 
     47    // Use a hackish method of setting the spacing for all Widgets. 
     48    for(osgWidget::Table::Iterator i = table->begin(); i != table->end(); i++) 
     49        i->get()->setPadding(1.0f) 
     50    ; 
    5151 
    52         // Now we fetch the very first 0, 0 Widget in the table using an awkward method. 
    53         // This is merely one way to fetch a Widget from a Window, there are many others. 
    54         // The osgWidget::Window::getByName interface will be very handy in scripting languages 
    55         // where users will want to retrieve handles to existing Windows using a useful 
    56         // textual name, such as "MainGUIParent" or something. 
    57         table->getByName("0, 0")->setAlignHorizontal(osgWidget::Widget::HA_LEFT); 
    58         table->getByName("0, 0")->setAlignVertical(osgWidget::Widget::VA_BOTTOM); 
    59         table->getByName("0, 0")->setPadLeft(50.0f); 
    60         table->getByName("0, 0")->setPadTop(3.0f); 
    61          
    62         // Change the colors a bit to differentiate this row from the others. 
    63         table->getByName("2, 0")->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT); 
    64         table->getByName("2, 1")->setColor(1.0f, 0.0f, 0.0f, 0.5f); 
    65         table->getByName("2, 2")->setColor(1.0f, 0.0f, 0.0f, 0.5f); 
     52    // Now we fetch the very first 0, 0 Widget in the table using an awkward method. 
     53    // This is merely one way to fetch a Widget from a Window, there are many others. 
     54    // The osgWidget::Window::getByName interface will be very handy in scripting languages 
     55    // where users will want to retrieve handles to existing Windows using a useful 
     56    // textual name, such as "MainGUIParent" or something. 
     57    table->getByName("0, 0")->setAlignHorizontal(osgWidget::Widget::HA_LEFT); 
     58    table->getByName("0, 0")->setAlignVertical(osgWidget::Widget::VA_BOTTOM); 
     59    table->getByName("0, 0")->setPadLeft(50.0f); 
     60    table->getByName("0, 0")->setPadTop(3.0f); 
     61     
     62    // Change the colors a bit to differentiate this row from the others. 
     63    table->getByName("2, 0")->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT); 
     64    table->getByName("2, 1")->setColor(1.0f, 0.0f, 0.0f, 0.5f); 
     65    table->getByName("2, 2")->setColor(1.0f, 0.0f, 0.0f, 0.5f); 
    6666 
    67         wm->addChild(table); 
     67    wm->addChild(table); 
    6868 
    69         return createExample(viewer, wm); 
     69    return createExample(viewer, wm); 
    7070}