Changeset 8600

Show
Ignore:
Timestamp:
07/16/08 00:03:59
Author:
robert
Message:

Converted tabs to four spaces

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph/trunk/examples/osgwidgetaddremove/osgwidgetaddremove.cpp

    r8588 r8600  
    1212class ABCWidget: public osgWidget::Label { 
    1313public: 
    14        ABCWidget(const std::string& label): 
    15        osgWidget::Label("", label) { 
    16                setFont("fonts/Calibri1.ttf"); 
    17                setFontSize(20); 
    18                setCanFill(true); 
    19                setShadow(0.08f); 
    20                addSize(10.0f, 10.0f); 
    21        
     14    ABCWidget(const std::string& label): 
     15    osgWidget::Label("", label) { 
     16        setFont("fonts/Calibri1.ttf"); 
     17        setFontSize(20); 
     18        setCanFill(true); 
     19        setShadow(0.08f); 
     20        addSize(10.0f, 10.0f); 
     21   
    2222}; 
    2323 
    2424class Button: public osgWidget::Label { 
    2525public: 
    26        Button(const std::string& label): 
    27        osgWidget::Label("", label) { 
    28                setFont("fonts/Calibri1.ttf"); 
    29                setFontSize(30); 
    30                setColor(0.8f, 0.2f, 0.2f, 0.8f); 
    31                setCanFill(true); 
    32                setShadow(0.1f); 
    33                setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK); 
    34                addSize(20.0f, 20.0f); 
    35        
     26    Button(const std::string& label): 
     27    osgWidget::Label("", label) { 
     28        setFont("fonts/Calibri1.ttf"); 
     29        setFontSize(30); 
     30        setColor(0.8f, 0.2f, 0.2f, 0.8f); 
     31        setCanFill(true); 
     32        setShadow(0.1f); 
     33        setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK); 
     34        addSize(20.0f, 20.0f); 
     35   
    3636 
    37        // NOTE! I need to make it clearer than Push/Release can happen so fast that 
    38        // the changes you make aren't visible with your refresh rate. Throttling state 
    39        // changes and what-have-you on mousePush/mouseRelease/etc. is going to be 
    40        // annoying... 
     37    // NOTE! I need to make it clearer than Push/Release can happen so fast that 
     38    // the changes you make aren't visible with your refresh rate. Throttling state 
     39    // changes and what-have-you on mousePush/mouseRelease/etc. is going to be 
     40    // annoying... 
    4141 
    42        virtual bool mousePush(double, double, osgWidget::WindowManager*) { 
    43                addColor(0.2f, 0.2f, 0.2f, 0.0f); 
    44                  
    45                return true; 
    46        
     42    virtual bool mousePush(double, double, osgWidget::WindowManager*) { 
     43        addColor(0.2f, 0.2f, 0.2f, 0.0f); 
     44         
     45        return true; 
     46   
    4747 
    48        virtual bool mouseRelease(double, double, osgWidget::WindowManager*) { 
    49                addColor(-0.2f, -0.2f, -0.2f, 0.0f); 
    50                  
    51                return true; 
    52        
     48    virtual bool mouseRelease(double, double, osgWidget::WindowManager*) { 
     49        addColor(-0.2f, -0.2f, -0.2f, 0.0f); 
     50         
     51        return true; 
     52   
    5353}; 
    5454 
    5555class AddRemove: public osgWidget::Box { 
    56        osg::ref_ptr<osgWidget::Window> _win1; 
     56    osg::ref_ptr<osgWidget::Window> _win1; 
    5757 
    5858public: 
    59        AddRemove(): 
    60        osgWidget::Box ("buttons", osgWidget::Box::VERTICAL), 
    61        _win1          (new osgWidget::Box("win1", osgWidget::Box::VERTICAL)) { 
    62                addWidget(new Button("Add Widget")); 
    63                addWidget(new Button("Remove Widget")); 
     59    AddRemove(): 
     60    osgWidget::Box ("buttons", osgWidget::Box::VERTICAL), 
     61    _win1          (new osgWidget::Box("win1", osgWidget::Box::VERTICAL)) { 
     62        addWidget(new Button("Add Widget")); 
     63        addWidget(new Button("Remove Widget")); 
    6464 
    65                // Take special note here! Not only do the Button objects have their 
    66                // own overridden methods for changing the color, but they have attached 
    67                // callbacks for doing the work with local data. 
    68                getByName("Widget_1")->addCallback(osgWidget::Callback( 
    69                        &AddRemove::handlePressAdd, 
    70                        this, 
    71                        osgWidget::EVENT_MOUSE_PUSH 
    72                )); 
     65        // Take special note here! Not only do the Button objects have their 
     66        // own overridden methods for changing the color, but they have attached 
     67        // callbacks for doing the work with local data. 
     68        getByName("Widget_1")->addCallback(osgWidget::Callback( 
     69            &AddRemove::handlePressAdd, 
     70            this, 
     71            osgWidget::EVENT_MOUSE_PUSH 
     72        )); 
    7373 
    74                getByName("Widget_2")->addCallback(osgWidget::Callback( 
    75                        &AddRemove::handlePressRemove, 
    76                        this, 
    77                        osgWidget::EVENT_MOUSE_PUSH 
    78                )); 
    79        
     74        getByName("Widget_2")->addCallback(osgWidget::Callback( 
     75            &AddRemove::handlePressRemove, 
     76            this, 
     77            osgWidget::EVENT_MOUSE_PUSH 
     78        )); 
     79   
    8080 
    81        virtual void managed(osgWidget::WindowManager* wm) { 
    82                osgWidget::Box::managed(wm); 
     81    virtual void managed(osgWidget::WindowManager* wm) { 
     82        osgWidget::Box::managed(wm); 
    8383 
    84                _win1->setOrigin(250.0f, 0.0f); 
     84        _win1->setOrigin(250.0f, 0.0f); 
    8585 
    86                wm->addChild(_win1.get()); 
    87        
     86        wm->addChild(_win1.get()); 
     87   
    8888 
    89        bool handlePressAdd(osgWidget::Event& ev) { 
    90                static unsigned int num = 0; 
     89    bool handlePressAdd(osgWidget::Event& ev) { 
     90        static unsigned int num = 0; 
    9191 
    92                std::stringstream ss; 
     92        std::stringstream ss; 
    9393 
    94                ss << "a random widget " << num; 
     94        ss << "a random widget " << num; 
    9595 
    96                _win1->addWidget(new ABCWidget(ss.str())); 
    97                _win1->resize(); 
     96        _win1->addWidget(new ABCWidget(ss.str())); 
     97        _win1->resize(); 
    9898 
    99                num++; 
     99        num++; 
    100100 
    101                return true; 
    102        
     101        return true; 
     102   
    103103 
    104        bool handlePressRemove(osgWidget::Event& ev) { 
    105                // TODO: Temporary hack! 
    106                const osgWidget::Box::Vector& v = _win1->getObjects(); 
    107          
    108                if(!v.size()) return false; 
     104    bool handlePressRemove(osgWidget::Event& ev) { 
     105        // TODO: Temporary hack! 
     106        const osgWidget::Box::Vector& v = _win1->getObjects(); 
     107     
     108        if(!v.size()) return false; 
    109109 
    110                osgWidget::Widget* w = _win1->getObjects()[v.size() - 1].get(); 
     110        osgWidget::Widget* w = _win1->getObjects()[v.size() - 1].get(); 
    111111 
    112                _win1->removeWidget(w); 
    113                _win1->resize(); 
     112        _win1->removeWidget(w); 
     113        _win1->resize(); 
    114114 
    115                return true; 
    116        
     115        return true; 
     116   
    117117}; 
    118118 
    119119int main(int argc, char** argv) { 
    120        osgViewer::Viewer viewer; 
     120    osgViewer::Viewer viewer; 
    121121 
    122        osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
    123                &viewer, 
    124                1280.0f, 
    125                1024.0f, 
    126                MASK_2D 
    127        ); 
    128          
    129        osgWidget::Box* buttons = new AddRemove(); 
     122    osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
     123        &viewer, 
     124        1280.0f, 
     125        1024.0f, 
     126        MASK_2D 
     127    ); 
     128     
     129    osgWidget::Box* buttons = new AddRemove(); 
    130130 
    131        wm->addChild(buttons); 
     131    wm->addChild(buttons); 
    132132 
    133        return createExample(viewer, wm); 
     133    return createExample(viewer, wm); 
    134134} 
  • OpenSceneGraph/trunk/examples/osgwidgetframe/osgwidgetframe.cpp

    r8588 r8600  
    1010 
    1111int main(int argc, char** argv) { 
    12        osgViewer::Viewer viewer; 
     12    osgViewer::Viewer viewer; 
    1313 
    14        osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
    15                &viewer, 
    16                1280.0f, 
    17                1024.0f, 
    18                MASK_2D, 
    19                osgWidget::WindowManager::WM_PICK_DEBUG 
    20        ); 
    21          
    22        osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrame( 
    23                "frame", 
    24                32.0f, 
    25                32.0f, 
    26                300.0f, 
    27                300.0f 
    28        ); 
    29          
    30        osgWidget::Table* table  = new osgWidget::Table("table", 2, 2); 
    31        osgWidget::Box*   bottom = new osgWidget::Box("panel", osgWidget::Box::HORIZONTAL); 
     14    osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
     15        &viewer, 
     16        1280.0f, 
     17        1024.0f, 
     18        MASK_2D, 
     19        osgWidget::WindowManager::WM_PICK_DEBUG 
     20    ); 
     21     
     22    osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrame( 
     23        "frame", 
     24        32.0f, 
     25        32.0f, 
     26        300.0f, 
     27        300.0f 
     28    ); 
     29     
     30    osgWidget::Table* table  = new osgWidget::Table("table", 2, 2); 
     31    osgWidget::Box*   bottom = new osgWidget::Box("panel", osgWidget::Box::HORIZONTAL); 
    3232 
    33        table->addWidget(new osgWidget::Widget("red", 300.0f, 300.0f), 0, 0); 
    34        table->addWidget(new osgWidget::Widget("white", 300.0f, 300.0f), 0, 1); 
    35        table->addWidget(new osgWidget::Widget("yellow", 300.0f, 300.0f), 1, 0); 
    36        table->addWidget(new osgWidget::Widget("purple", 300.0f, 300.0f), 1, 1); 
    37        table->getByRowCol(0, 0)->setColor(1.0f, 0.0f, 0.0f, 1.0f); 
    38        table->getByRowCol(0, 1)->setColor(1.0f, 1.0f, 1.0f, 1.0f); 
    39        table->getByRowCol(1, 0)->setColor(1.0f, 1.0f, 0.0f, 1.0f); 
    40        table->getByRowCol(1, 1)->setColor(1.0f, 0.0f, 1.0f, 1.0f); 
    41        table->getByRowCol(0, 0)->setMinimumSize(100.0f, 100.0f); 
    42        table->getByRowCol(0, 1)->setMinimumSize(100.0f, 100.0f); 
    43        table->getByRowCol(1, 0)->setMinimumSize(100.0f, 100.0f); 
    44        table->getByRowCol(1, 1)->setMinimumSize(100.0f, 100.0f); 
     33    table->addWidget(new osgWidget::Widget("red", 300.0f, 300.0f), 0, 0); 
     34    table->addWidget(new osgWidget::Widget("white", 300.0f, 300.0f), 0, 1); 
     35    table->addWidget(new osgWidget::Widget("yellow", 300.0f, 300.0f), 1, 0); 
     36    table->addWidget(new osgWidget::Widget("purple", 300.0f, 300.0f), 1, 1); 
     37    table->getByRowCol(0, 0)->setColor(1.0f, 0.0f, 0.0f, 1.0f); 
     38    table->getByRowCol(0, 1)->setColor(1.0f, 1.0f, 1.0f, 1.0f); 
     39    table->getByRowCol(1, 0)->setColor(1.0f, 1.0f, 0.0f, 1.0f); 
     40    table->getByRowCol(1, 1)->setColor(1.0f, 0.0f, 1.0f, 1.0f); 
     41    table->getByRowCol(0, 0)->setMinimumSize(100.0f, 100.0f); 
     42    table->getByRowCol(0, 1)->setMinimumSize(100.0f, 100.0f); 
     43    table->getByRowCol(1, 0)->setMinimumSize(100.0f, 100.0f); 
     44    table->getByRowCol(1, 1)->setMinimumSize(100.0f, 100.0f); 
    4545 
    46        frame->setWindow(table); 
     46    frame->setWindow(table); 
    4747 
    48        // Give frame some nice textures. 
    49        // TODO: This has to be done after setWindow(); wtf? 
    50        frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f); 
     48    // Give frame some nice textures. 
     49    // TODO: This has to be done after setWindow(); wtf? 
     50    frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f); 
    5151 
    52        osgWidget::Widget* l = frame->getBorder(osgWidget::Frame::BORDER_LEFT); 
    53        osgWidget::Widget* r = frame->getBorder(osgWidget::Frame::BORDER_RIGHT); 
    54        osgWidget::Widget* t = frame->getBorder(osgWidget::Frame::BORDER_TOP); 
    55        osgWidget::Widget* b = frame->getBorder(osgWidget::Frame::BORDER_BOTTOM); 
     52    osgWidget::Widget* l = frame->getBorder(osgWidget::Frame::BORDER_LEFT); 
     53    osgWidget::Widget* r = frame->getBorder(osgWidget::Frame::BORDER_RIGHT); 
     54    osgWidget::Widget* t = frame->getBorder(osgWidget::Frame::BORDER_TOP); 
     55    osgWidget::Widget* b = frame->getBorder(osgWidget::Frame::BORDER_BOTTOM); 
    5656 
    57        l->setImage("../examples/osgwidgetframe/images/border-left.tga", true); 
    58        r->setImage("../examples/osgwidgetframe/images/border-right.tga", true); 
    59        t->setImage("../examples/osgwidgetframe/images/border-top.tga", true); 
    60        b->setImage("../examples/osgwidgetframe/images/border-bottom.tga", true); 
     57    l->setImage("../examples/osgwidgetframe/images/border-left.tga", true); 
     58    r->setImage("../examples/osgwidgetframe/images/border-right.tga", true); 
     59    t->setImage("../examples/osgwidgetframe/images/border-top.tga", true); 
     60    b->setImage("../examples/osgwidgetframe/images/border-bottom.tga", true); 
    6161 
    62        l->setTexCoordWrapVertical(); 
    63        r->setTexCoordWrapVertical(); 
    64        t->setTexCoordWrapHorizontal(); 
    65        b->setTexCoordWrapHorizontal(); 
     62    l->setTexCoordWrapVertical(); 
     63    r->setTexCoordWrapVertical(); 
     64    t->setTexCoordWrapHorizontal(); 
     65    b->setTexCoordWrapHorizontal(); 
    6666 
    67        // Create the bottom, XArt panel. 
    68        osgWidget::Widget* left   = new osgWidget::Widget("left", 512.0f, 256.0f); 
    69        osgWidget::Widget* center = new osgWidget::Widget("center", 256.0f, 256.0f); 
    70        osgWidget::Widget* right  = new osgWidget::Widget("right", 512.0f, 256.0f); 
     67    // Create the bottom, XArt panel. 
     68    osgWidget::Widget* left   = new osgWidget::Widget("left", 512.0f, 256.0f); 
     69    osgWidget::Widget* center = new osgWidget::Widget("center", 256.0f, 256.0f); 
     70    osgWidget::Widget* right  = new osgWidget::Widget("right", 512.0f, 256.0f); 
    7171 
    72        left->setImage("../examples/osgwidgetframe/images/panel-left.tga", true); 
    73        center->setImage("../examples/osgwidgetframe/images/panel-center.tga", true); 
    74        right->setImage("../examples/osgwidgetframe/images/panel-right.tga", true); 
     72    left->setImage("../examples/osgwidgetframe/images/panel-left.tga", true); 
     73    center->setImage("../examples/osgwidgetframe/images/panel-center.tga", true); 
     74    right->setImage("../examples/osgwidgetframe/images/panel-right.tga", true); 
    7575 
    76        center->setTexCoordWrapHorizontal(); 
     76    center->setTexCoordWrapHorizontal(); 
    7777 
    78        bottom->addWidget(left); 
    79        bottom->addWidget(center); 
    80        bottom->addWidget(right); 
    81        bottom->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f); 
    82        bottom->setOrigin(0.0f, 1024.0f - 256.0f); 
     78    bottom->addWidget(left); 
     79    bottom->addWidget(center); 
     80    bottom->addWidget(right); 
     81    bottom->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f); 
     82    bottom->setOrigin(0.0f, 1024.0f - 256.0f); 
    8383 
    84        // Add everything to the WindowManager. 
    85        wm->addChild(frame); 
    86        wm->addChild(bottom); 
     84    // Add everything to the WindowManager. 
     85    wm->addChild(frame); 
     86    wm->addChild(bottom); 
    8787 
    88        return osgWidget::createExample(viewer, wm); 
     88    return osgWidget::createExample(viewer, wm); 
    8989} 
  • OpenSceneGraph/trunk/examples/osgwidgetinput/osgwidgetinput.cpp

    r8588 r8600  
    1515 
    1616const char* INFO = 
    17        "Use the Input Wigets below to enter the X, Y, and Z position of a\n" 
    18        "sphere to be inserted into the scene. Once you've done this, use\n" 
    19        "the button below to add it!" 
     17    "Use the Input Wigets below to enter the X, Y, and Z position of a\n" 
     18    "sphere to be inserted into the scene. Once you've done this, use\n" 
     19    "the button below to add it!" 
    2020; 
    2121 
    2222void setupLabel(osgWidget::Label* label) { 
    23        label->setFontSize(16); 
    24        label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f); 
    25        // label->setFont("fonts/monospace.ttf"); 
    26        label->setFont("fonts/Calibri1.ttf"); 
    27        label->setPadding(2.0f); 
    28        label->setHeight(18.0f); 
    29        label->setCanFill(true); 
     23    label->setFontSize(16); 
     24    label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f); 
     25    // label->setFont("fonts/monospace.ttf"); 
     26    label->setFont("fonts/Calibri1.ttf"); 
     27    label->setPadding(2.0f); 
     28    label->setHeight(18.0f); 
     29    label->setCanFill(true); 
    3030} 
    3131 
    3232osgWidget::Input* createTableRow( 
    33        osgWidget::Table*  table, 
    34        unsigned int       rowNum, 
    35        const std::string& valName 
     33    osgWidget::Table*  table, 
     34    unsigned int       rowNum, 
     35    const std::string& valName 
    3636) { 
    37        std::stringstream ssLabel; 
    38        std::stringstream ssInput; 
     37    std::stringstream ssLabel; 
     38    std::stringstream ssInput; 
    3939 
    40        ssLabel << "Label_Row" << rowNum; 
    41        ssInput << "Input_Row" << rowNum; 
     40    ssLabel << "Label_Row" << rowNum; 
     41    ssInput << "Input_Row" << rowNum; 
    4242 
    43        osgWidget::Label* label = new osgWidget::Label(ssLabel.str(), valName); 
    44        osgWidget::Input* input = new osgWidget::Input(ssInput.str(), "", 20); 
     43    osgWidget::Label* label = new osgWidget::Label(ssLabel.str(), valName); 
     44    osgWidget::Input* input = new osgWidget::Input(ssInput.str(), "", 20); 
    4545 
    46        setupLabel(label); 
    47        setupLabel(input); 
     46    setupLabel(label); 
     47    setupLabel(input); 
    4848 
    49        label->setWidth(50.0f); 
    50        label->setColor(0.1f, 0.1f, 0.1f, 1.0f); 
     49    label->setWidth(50.0f); 
     50    label->setColor(0.1f, 0.1f, 0.1f, 1.0f); 
    5151 
    52        input->setWidth(150.0f); 
    53        input->setColor(0.4f, 0.4f, 0.4f, 1.0f); 
     52    input->setWidth(150.0f); 
     53    input->setColor(0.4f, 0.4f, 0.4f, 1.0f); 
    5454 
    55        table->addWidget(label, rowNum, 0); 
    56        table->addWidget(input, rowNum, 1); 
     55    table->addWidget(label, rowNum, 0); 
     56    table->addWidget(input, rowNum, 1); 
    5757 
    58        return input; 
     58    return input; 
    5959} 
    6060 
    6161osgWidget::Label* createLabel(const std::string& text) { 
    62        osgWidget::Label* label = new osgWidget::Label("", text); 
     62    osgWidget::Label* label = new osgWidget::Label("", text); 
    6363 
    64        setupLabel(label); 
     64    setupLabel(label); 
    6565 
    66        return label; 
     66    return label; 
    6767} 
    6868 
    6969class Button: public osgWidget::Label { 
    7070public: 
    71        typedef std::vector<osgWidget::Input*> Inputs; 
     71    typedef std::vector<osgWidget::Input*> Inputs; 
    7272 
    7373private: 
    74        Inputs _xyz; 
     74    Inputs _xyz; 
    7575 
    7676public: 
    77        Button(const std::string& text, const Inputs& inputs): 
    78        osgWidget::Label("", text), 
    79        _xyz(inputs) { 
    80                setupLabel(this); 
     77    Button(const std::string& text, const Inputs& inputs): 
     78    osgWidget::Label("", text), 
     79    _xyz(inputs) { 
     80        setupLabel(this); 
    8181 
    82                setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK); 
    83                setShadow(0.1f); 
    84                addHeight(4.0f); 
    85        
     82        setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK); 
     83        setShadow(0.1f); 
     84        addHeight(4.0f); 
     85   
    8686 
    87        bool mousePush(double, double, osgWidget::WindowManager*) { 
    88                osgWidget::warn() 
    89                        << "x: " << _xyz[0]->getLabel() << std::endl 
    90                        << "y: " << _xyz[1]->getLabel() << std::endl 
    91                        << "z: " << _xyz[2]->getLabel() << std::endl 
    92                
     87    bool mousePush(double, double, osgWidget::WindowManager*) { 
     88        osgWidget::warn() 
     89            << "x: " << _xyz[0]->getLabel() << std::endl 
     90            << "y: " << _xyz[1]->getLabel() << std::endl 
     91            << "z: " << _xyz[2]->getLabel() << std::endl 
     92       
    9393 
    94                return false; 
    95        
     94        return false; 
     95   
    9696}; 
    9797 
    9898// TODO: Testing our _parent/EmbeddedWindow stuff. 
    9999bool info(osgWidget::Event& ev) { 
    100        osgWidget::warn() << "MousePush @ Window: " << ev.getWindow()->getName() << std::endl; 
     100    osgWidget::warn() << "MousePush @ Window: " << ev.getWindow()->getName() << std::endl; 
    101101 
    102        return true; 
     102    return true; 
    103103} 
    104104 
    105105int main(int argc, char** argv) { 
    106        osgViewer::Viewer viewer; 
     106    osgViewer::Viewer viewer; 
    107107 
    108        osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
    109                &viewer, 
    110                1280.0f, 
    111                1024.0f, 
    112                MASK_2D, 
    113                osgWidget::WindowManager::WM_PICK_DEBUG 
    114        ); 
    115          
    116        osgWidget::Box*   box   = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL); 
    117        osgWidget::Table* table = new osgWidget::Table("table", 3, 2); 
    118        osgWidget::Box*   lbox1 = new osgWidget::Box("lbox1", osgWidget::Box::HORIZONTAL); 
    119        osgWidget::Box*   lbox2 = new osgWidget::Box("lbox2", osgWidget::Box::HORIZONTAL); 
    120        osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture( 
    121                "frame", 
    122                "osgWidget/theme.png", 
    123                64.0f, 
    124                64.0f, 
    125                16.0f, 
    126                16.0f, 
    127                100.0f, 
    128                100.0f 
    129        ); 
     108    osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
     109        &viewer, 
     110        1280.0f, 
     111        1024.0f, 
     112        MASK_2D, 
     113        osgWidget::WindowManager::WM_PICK_DEBUG 
     114    ); 
     115     
     116    osgWidget::Box*   box   = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL); 
     117    osgWidget::Table* table = new osgWidget::Table("table", 3, 2); 
     118    osgWidget::Box*   lbox1 = new osgWidget::Box("lbox1", osgWidget::Box::HORIZONTAL); 
     119    osgWidget::Box*   lbox2 = new osgWidget::Box("lbox2", osgWidget::Box::HORIZONTAL); 
     120    osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture( 
     121        "frame", 
     122        "osgWidget/theme.png", 
     123        64.0f, 
     124        64.0f, 
     125        16.0f, 
     126        16.0f, 
     127        100.0f, 
     128        100.0f 
     129    ); 
    130130 
    131        osgWidget::Input* x = createTableRow(table, 0, "X Position"); 
    132        osgWidget::Input* y = createTableRow(table, 1, "Y Position"); 
    133        osgWidget::Input* z = createTableRow(table, 2, "Z Position"); 
    134          
    135        Button::Inputs inputs; 
     131    osgWidget::Input* x = createTableRow(table, 0, "X Position"); 
     132    osgWidget::Input* y = createTableRow(table, 1, "Y Position"); 
     133    osgWidget::Input* z = createTableRow(table, 2, "Z Position"); 
     134     
     135    Button::Inputs inputs; 
    136136 
    137        inputs.push_back(x); 
    138        inputs.push_back(y); 
    139        inputs.push_back(z); 
     137    inputs.push_back(x); 
     138    inputs.push_back(y); 
     139    inputs.push_back(z); 
    140140 
    141        table->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH)); 
     141    table->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH)); 
    142142 
    143        lbox1->addWidget(createLabel(INFO)); 
    144        lbox2->addWidget(new Button("Add To Scene...", inputs)); 
     143    lbox1->addWidget(createLabel(INFO)); 
     144    lbox2->addWidget(new Button("Add To Scene...", inputs)); 
    145145 
    146        box->addWidget(lbox1->embed()); 
    147        box->addWidget(table->embed()); 
    148        box->addWidget(lbox2->embed()); 
    149        box->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH)); 
     146    box->addWidget(lbox1->embed()); 
     147    box->addWidget(table->embed()); 
     148    box->addWidget(lbox2->embed()); 
     149    box->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH)); 
    150150 
    151        frame->setWindow(box); 
    152        frame->getEmbeddedWindow()->setSize(box->getWidth(), box->getHeight()); 
    153        frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f); 
    154        frame->attachTabFocusCallback(); 
     151    frame->setWindow(box); 
     152    frame->getEmbeddedWindow()->setSize(box->getWidth(), box->getHeight()); 
     153    frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f); 
     154    frame->attachTabFocusCallback(); 
    155155 
    156        for(osgWidget::Frame::Iterator i = frame->begin(); i != frame->end(); i++) { 
    157                if(i->valid()) i->get()->setColor(0.5f, 0.7f, 1.0f, 1.0f); 
    158        
     156    for(osgWidget::Frame::Iterator i = frame->begin(); i != frame->end(); i++) { 
     157        if(i->valid()) i->get()->setColor(0.5f, 0.7f, 1.0f, 1.0f); 
     158   
    159159 
    160        wm->addChild(frame); 
     160    wm->addChild(frame); 
    161161 
    162        /* 
    163        // Print out our focus list, it should just have 3 widgets. 
    164        osgWidget::WidgetList wl; 
     162    /* 
     163    // Print out our focus list, it should just have 3 widgets. 
     164    osgWidget::WidgetList wl; 
    165165 
    166        box->getFocusList(wl); 
     166    box->getFocusList(wl); 
    167167 
    168        for(osgWidget::WidgetList::iterator i = wl.begin(); i != wl.end(); i++) { 
    169                osgWidget::warn() << i->get()->getName() << std::endl; 
    170        
    171        */ 
    172          
    173        lbox1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT); 
    174        lbox1->getBackground()->setColor(0.0f, 1.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT); 
    175        lbox1->getBackground()->setColor(0.0f, 0.0f, 1.0f, 1.0f, osgWidget::Widget::LOWER_RIGHT); 
    176        lbox1->getBackground()->setColor(1.0f, 1.0f, 1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT); 
    177        lbox1->setVisibilityMode(osgWidget::Window::VM_ENTIRE); 
    178        lbox1->update(); 
     168    for(osgWidget::WidgetList::iterator i = wl.begin(); i != wl.end(); i++) { 
     169        osgWidget::warn() << i->get()->getName() << std::endl; 
     170   
     171    */ 
     172     
     173    lbox1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT); 
     174    lbox1->getBackground()->setColor(0.0f, 1.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT); 
     175    lbox1->getBackground()->setColor(0.0f, 0.0f, 1.0f, 1.0f, osgWidget::Widget::LOWER_RIGHT); 
     176    lbox1->getBackground()->setColor(1.0f, 1.0f, 1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT); 
     177    lbox1->setVisibilityMode(osgWidget::Window::VM_ENTIRE); 
     178    lbox1->update(); 
    179179 
    180        int r = osgWidget::createExample(viewer, wm); 
     180    int r = osgWidget::createExample(viewer, wm); 
    181181 
    182        // osgWidget::writeWindowManagerNode(wm); 
    183        // osgDB::writeNodeFile(*box, "osgWidget.osg"); 
     182    // osgWidget::writeWindowManagerNode(wm); 
     183    // osgDB::writeNodeFile(*box, "osgWidget.osg"); 
    184184 
    185        return r; 
     185    return r; 
    186186} 
  • OpenSceneGraph/trunk/examples/osgwidgetlabel/osgwidgetlabel.cpp

    r8588 r8600  
    1111 
    1212const char* LABEL1 = 
    13        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed\n" 
    14        "do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n" 
    15        "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n" 
    16        "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in..." 
     13    "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed\n" 
     14    "do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n" 
     15    "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n" 
     16    "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in..." 
    1717; 
    1818 
    1919const char* LABEL2 =  
    20        "...reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\n" 
    21        "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in \n" 
    22        "culpa qui officia deserunt mollit anim id est laborum. BBBBB" 
     20    "...reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\n" 
     21    "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in \n" 
     22    "culpa qui officia deserunt mollit anim id est laborum. BBBBB" 
    2323; 
    2424 
    2525osgWidget::Label* createLabel(const std::string& l, unsigned int size=13) { 
    26        osgWidget::Label* label = new osgWidget::Label("", ""); 
     26    osgWidget::Label* label = new osgWidget::Label("", ""); 
    2727 
    28        label->setFont("fonts/arial.ttf"); 
    29        label->setFontSize(size); 
    30        label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f); 
    31        label->setLabel(l); 
     28    label->setFont("fonts/arial.ttf"); 
     29    label->setFontSize(size); 
     30    label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f); 
     31    label->setLabel(l); 
    3232 
    33        /* 
    34        text->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT); 
    35        text->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER); 
    36        text->setBackdropOffset(0.2f); 
    37        */ 
     33    /* 
     34    text->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT); 
     35    text->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER); 
     36    text->setBackdropOffset(0.2f); 
     37    */ 
    3838 
    39        return label; 
     39    return label; 
    4040} 
    4141 
    4242int main(int argc, char** argv) { 
    43        osgViewer::Viewer viewer; 
     43    osgViewer::Viewer viewer; 
    4444 
    45        osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
    46                &viewer, 
    47                1280.0f, 
    48                1024.0f, 
    49                MASK_2D, 
    50                osgWidget::WindowManager::WM_PICK_DEBUG | 
    51                osgWidget::WindowManager::WM_NO_INVERT_Y 
    52        ); 
    53          
    54        osgWidget::Box*   box    = new osgWidget::Box("HBOX", osgWidget::Box::HORIZONTAL); 
    55        osgWidget::Box*   vbox   = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL); 
    56        osgWidget::Label* label1 = createLabel(LABEL1); 
    57        osgWidget::Label* label2 = createLabel(LABEL2); 
     45    osgWidget::WindowManager* wm = new osgWidget::WindowManager( 
     46        &viewer, 
     47        1280.0f, 
     48        1024.0f, 
     49        MASK_2D, 
     50        osgWidget::WindowManager::WM_PICK_DEBUG | 
     51        osgWidget::WindowManager::WM_NO_INVERT_Y 
     52    ); 
     53     
     54    osgWidget::Box*   box    = new osgWidget::Box("HBOX", osgWidget::Box::HORIZONTAL); 
     55    osgWidget::Box*   vbox   = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL); 
     56    osgWidget::Label* label1 = createLabel(LABEL1); 
     57    osgWidget::Label* label2 = createLabel(LABEL2); 
    5858 
    59        // Setup the labels for horizontal box. 
    60        label1->setPadding(10.0f); 
    61        label2->setPadding(10.0f); 
     59    // Setup the labels for horizontal box. 
     60    label1->setPadding(10.0f); 
     61    label2->setPadding(10.0f); 
    6262 
    63        label1->addSize(21.0f, 22.0f); 
    64        label2->addSize(21.0f, 22.0f); 
     63    label1->addSize(21.0f, 22.0f); 
     64    label2->addSize(21.0f, 22.0f); 
    6565 
    66        label1->setColor(1.0f, 0.5f, 0.0f, 0.0f); 
    67        label2->setColor(1.0f, 0.5f, 0.0f, 0.0f); 
     66    label1->setColor(1.0f, 0.5f, 0.0f, 0.0f); 
     67    label2->setColor(1.0f, 0.5f, 0.0f, 0.0f); 
    6868 
    69        box->addWidget(label1); 
    70        box->addWidget(label2); 
    71        box->attachMoveCallback(); 
    72        box->attachScaleCallback(); 
    73        box->attachRotateCallback(); 
     69    box->addWidget(label1); 
     70    box->addWidget(label2); 
     71    box->attachMoveCallback(); 
     72    box->attachScaleCallback(); 
     73    box->attachRotateCallback(); 
    7474 
    75        // Setup the labels for the vertical box. 
    76        osgWidget::Label* label3 = createLabel("Label 3", 80); 
    77        osgWidget::Label* label4 = createLabel("Label 4", 60); 
    78        osgWidget::Label* label5 = createLabel("ABCDEFGHIJK", 93); 
     75    // Setup the labels for the vertical box. 
     76    osgWidget::Label* label3 = createLabel("Label 3", 80); 
     77    osgWidget::Label* label4 = createLabel("Label 4", 60); 
     78    osgWidget::Label* label5 = createLabel("ABCDEFGHIJK", 93); 
    7979 
    80        label3->setPadding(3.0f); 
    81        label4->setPadding(3.0f); 
    82        label5->setPadding(3.0f); 
     80    label3->setPadding(3.0f); 
     81    label4->setPadding(3.0f); 
     82    label5->setPadding(3.0f); 
    8383 
    84        label3->setColor(0.0f, 0.0f, 0.5f, 0.5f); 
    85        label4->setColor(0.0f, 0.0f, 0.5f, 0.5f); 
    86        label5->setColor(0.0f, 0.0f, 0.5f, 0.5f); 
    87          
    88        label5->setAlignHorizontal(osgWidget::Widget::HA_LEFT); 
    89        label5->setAlignVertical(osgWidget::Widget::VA_BOTTOM); 
     84    label3->setColor(0.0f, 0.0f, 0.5f, 0.5f); 
     85    label4->setColor(0.0f, 0.0f, 0.5f, 0.5f); 
     86    label5->setColor(0.0f, 0.0f, 0.5f, 0.5f); 
     87     
     88    label5->setAlignHorizontal(osgWidget::Widget::HA_LEFT); 
     89    label5->setAlignVertical(osgWidget::Widget::VA_BOTTOM); 
    9090 
    91        // Test our label copy construction... 
    92        osgWidget::Label* label6 = label5->cloneAs("label6"); 
     91    // Test our label copy construction... 
     92    osgWidget::Label* label6 = label5->cloneAs("label6"); 
    9393 
    94        label6->setLabel("abcdefghijklmnopqrs"); 
     94    label6->setLabel("abcdefghijklmnopqrs"); 
    9595 
    96        vbox->addWidget(label3); 
    97        vbox->addWidget(label4); 
    98        vbox->addWidget(label5); 
    99        vbox->addWidget(label6); 
    100        vbox->attachMoveCallback(); 
    101        vbox->attachScaleCallback(); 
     96    vbox->addWidget(label3); 
     97    vbox->addWidget(label4); 
     98    vbox->addWidget(label5); 
     99    vbox->addWidget(label6); 
     100    vbox->attachMoveCallback(); 
     101    vbox->attachScaleCallback(); 
    102102 
    103        vbox->resize(); 
     103    vbox->resize(); 
    104104 
    105        // vbox->setVisibilityMode(osgWidget::Window::VM_ENTIRE); 
    106        // vbox->setVisibleArea(50, 50, 500, 200); 
    107        // vbox->setAnchorVertical(osgWidget::Window::VA_TOP); 
    108        // vbox->setAnchorHorizontal(osgWidget::Window::HA_RIGHT); 
     105    // vbox->setVisibilityMode(osgWidget::Window::VM_ENTIRE); 
     106    // vbox->setVisibleArea(50, 50, 500, 200); 
     107    // vbox->setAnchorVertical(osgWidget::Window::VA_TOP); 
     108    // vbox->setAnchorHorizontal(osgWidget::Window::HA_RIGHT); 
    109109 
    110        // Test our label-in-window copy construction... 
    111        osgWidget::Box* clonedBox = box->cloneAs("HBOX-new"); 
    112          
    113        clonedBox->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.5f); 
     110    // Test our label-in-window copy construction... 
     111    osgWidget::Box* clonedBox = box->cloneAs("HBOX-new"); 
     112     
     113    clonedBox->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.5f); 
    114114 
    115        wm->addChild(box); 
    116        wm->addChild(vbox); 
    117        wm->addChild(clonedBox); 
     115    wm->addChild(box); 
     116    wm->addChild(vbox); 
     117    wm->addChild(clonedBox); 
    118118 
    119        return osgWidget::createExample(viewer, wm); 
     119    return osgWidget::createExample(viewer, wm); 
    120120} 
  • OpenSceneGraph/trunk/examples/osgwidgetmenu/osgwidgetmenu.cpp

    r8588 r8600  
    1616 
    1717struct ColorLabel: public osgWidget::Label { 
    18        ColorLabel(const char* label): 
    19        osgWidget::Label("", "") { 
    20                setFont("fonts/Calibri1.ttf"); 
    21                setFontSize(14); 
    22                setFontColor(1.0f, 1.0f, 1.0f, 1.0f); 
    23                setColor(0.3f, 0.3f, 0.3f, 1.0f); 
    24                addHeight(18.0f); 
    25                setCanFill(true); 
    26                setLabel(label); 
    27                setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE); 
    28        
     18    ColorLabel(const char* label): 
     19    osgWidget::Label("", "") { 
     20        setFont("fonts/Calibri1.ttf"); 
     21        setFontSize(14); 
     22        setFontColor(1.0f, 1.0f, 1.0f, 1.0f); 
     23        setColor(0.3f, 0.3f, 0.3f, 1.0f); 
     24        addHeight(18.0f); 
     25        setCanFill(true); 
     26        setLabel(label); 
     27        setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE); 
     28   
    2929 
    30        bool mousePush(double, double, osgWidget::WindowManager*) { 
    31                return true; 
    32        
     30    bool mousePush(double, double, osgWidget::WindowManager*) { 
     31        return true; 
     32   
    3333 
    34        bool mouseEnter(double, double, osgWidget::WindowManager*) { 
    35                setColor(0.6f, 0.6f, 0.6f, 1.0f); 
    36                  
    37                return true; 
    38        
     34    bool mouseEnter(double, double, osgWidget::WindowManager*) { 
     35        setColor(0.6f, 0.6f, 0.6f, 1.0f); 
     36         
     37        return true; 
     38   
    3939 
    40        bool mouseLeave(double, double, osgWidget::WindowManager*) { 
    41                setColor(0.3f, 0.3f, 0.3f, 1.0f); 
    42                  
    43                return true; 
    44        
     40    bool mouseLeave(double, double, osgWidget::WindowManager*) { 
     41        setColor(0.3f, 0.3f, 0.3f, 1.0f); 
     42