Exemplo n.º 1
0
// NOTE: THIS IS JUST A TEMPORARY HACK! :) This functionality will all eventually be
// encapsulate into another class in osgWidget proper.
bool scrollWindow(osgWidget::Event& ev) {
    // The first thing we need to do is make sure we have a Frame object...
    osgWidget::Frame* frame = dynamic_cast<osgWidget::Frame*>(ev.getWindow());

    if(!frame) return false;

    // And now we need to make sure our Frame has a valid internal EmbeddedWindow widget.
    osgWidget::Window::EmbeddedWindow* ew =
        dynamic_cast<osgWidget::Window::EmbeddedWindow*>(frame->getEmbeddedWindow())
    ;
        
    if(!ew) return false;
    
    // Lets get the visible area so that we can use it to make sure our scrolling action
    // is necessary in the first place.
    const osgWidget::Quad& va = ew->getWindow()->getVisibleArea();

    // The user wants to scroll up; make sure that the visible area's Y origin isn't already
    // at 0.0f, 0.0f.
    if(ev.getWindowManager()->isMouseScrollingUp() && va[1] != 0.0f)
        ew->getWindow()->addVisibleArea(0, -20)
    ;
    
    else if(va[1] <= (ew->getWindow()->getHeight() - ew->getHeight()))
        ew->getWindow()->addVisibleArea(0, 20)
    ;

    // We need to manually call update to make sure the visible area scissoring is done
    // properly.
    frame->update();

    return true;
}
Exemplo n.º 2
0
bool windowScrolled(osgWidget::Event& ev) {
    osgWidget::warn()
        << "scrolling up? " << ev.getWindowManager()->isMouseScrollingUp()
        << std::endl
    ;

    return true;
}