示例#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;
}
bool AnimtkViewerGUI::_buttonPush(osgWidget::Event& ev)
{
    if(!ev.getWidget()) return false;

    osgWidget::Label* l = static_cast<osgWidget::Label*>(_labelBox->getByName("label"));

    if(!l) return false;

    LabelFunctor* lf = dynamic_cast<LabelFunctor*>(l->getUpdateCallback());

    if(!lf) return false;

    // We're safe at this point, so begin processing.
    AnimtkViewerModelController& mc   = AnimtkViewerModelController::instance();
    std::string                  name = ev.getWidget()->getName();

    if(name == "play") mc.play();

    else if(name == "stop") mc.stop();

    else if(name == "next")
{
        mc.next();

        l->setFontColor(osg::Vec4(0.0f, 0.0f, 0.0f, 0.7f));
        l->setLabel(mc.getCurrentAnimationName());
        lf->setActive(true);
    }

    else if(name == "back")
{
        mc.previous();

        l->setFontColor(osg::Vec4(0.0f, 0.0f, 0.0f, 0.7f));
        l->setLabel(mc.getCurrentAnimationName());
        lf->setActive(true);
    }

    else if(name == "pause")
{
    }

    else if(name == "open")
{
        ListFunctor* lsf = dynamic_cast<ListFunctor*>(_listBox->getUpdateCallback());

        if(!lsf) return false;

        lsf->toggleShown();
    }

    else return false;

    return true;
}
示例#3
0
// Here we create (and later demonstrate) the use of a simple function callback.
bool windowClicked(osgWidget::Event& ev) {
    std::cout << "windowClicked: " << ev.getWindow()->getName() << std::endl;

    if(ev.getData()) {
        std::string* s = static_cast<std::string*>(ev.getData());

        std::cout << "This is data attached to the event: " << *s << std::endl;
    }

    return true;
}
bool overCallback(osgWidget::Event& ev) {
	if(!ev.getWidget()) return false;

	osgWidget::Widget* w = ev.getWidget();

	if(ev.type == osgWidget::EVENT_MOUSE_ENTER) w->setColor(1.0f, 1.0f, 1.0f, 1.0f);

	else if(ev.type == osgWidget::EVENT_MOUSE_LEAVE) w->setColor(1.0f, 1.0f, 1.0f, 0.0f);

	else return false;

	return true;
}
示例#5
0
bool colorWidgetEnter(osgWidget::Event& event) {
	event.getWidget()->addColor(0.5f, 0.2f, 0.3f, 0.0f);

	// osgWidget::warn() << "WIDGET mouseEnter " << event.getWidget()->getName() << std::endl;
	
	return true;
}
示例#6
0
bool widgetMouseOver(osgWidget::Event& event) {
	osgWidget::XYCoord xy = event.getWidget()->localXY(event.x, event.y);

	// osgWidget::warn() << "WIDGET mouseOver " << xy.x() << " - " << xy.y() << std::endl;

	return true;
}
示例#7
0
bool colorWidgetLeave(osgWidget::Event& event) {
	event.getWidget()->addColor(-0.5f, -0.2f, -0.3f, 0.0f);

	// osgWidget::warn() << "WIDGET mouseLeave" << std::endl;
	
	return true;
}
示例#8
0
bool changeTheme(osgWidget::Event& ev) {
    std::string theme;

    if(ev.key == osgGA::GUIEventAdapter::KEY_Right)
        theme = "osgWidget/theme-1.png"
    ;

    else if(ev.key == osgGA::GUIEventAdapter::KEY_Left)
        theme = "osgWidget/theme-2.png"
    ;

    else return false;

    osgWidget::Frame* frame = dynamic_cast<osgWidget::Frame*>(ev.getWindow());

    if(!frame) return false;

    // This is just one way to access all our Widgets; we could just as well have used:
    //
    // for(osgWidget::Frame::Iterator i = frame.begin(); i != frame.end() i++) {}
    //
    // ...and it have worked, too.
    for(unsigned int row = 0; row < 3; row++) {
        for(unsigned int col = 0; col < 3; col++) {
            frame->getByRowCol(row, col)->setImage(theme);
        }
    }

    return true;
}
示例#9
0
bool windowScrolled(osgWidget::Event& ev) {
    osgWidget::warn()
        << "scrolling up? " << ev.getWindowManager()->isMouseScrollingUp()
        << std::endl
    ;

    return true;
}
bool AnimtkViewerGUI::_listMouseHover(osgWidget::Event& ev)
{
    osgWidget::Label* l = dynamic_cast<osgWidget::Label*>(ev.getWidget());

    if(!l) return false;

    if(ev.type == osgWidget::EVENT_MOUSE_ENTER) l->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);

    else if(ev.type == osgWidget::EVENT_MOUSE_LEAVE) l->setFontColor(1.0f, 1.0f, 1.0f, 0.3f);

    else if(ev.type == osgWidget::EVENT_MOUSE_PUSH) {
        AnimtkViewerModelController::instance().playByName(ev.getWidget()->getName());
    }

    else return false;

    return true;
}
示例#11
0
    // NOTE: This whole thing is just a hack to demonstrate a concept. The real
    // implementation would need to be much cleaner.
    bool callbackTabPressed(osgWidget::Event& ev) {
        osgWidget::Canvas::Vector& objs = _windows->getObjects();

        for(unsigned int i = 0; i < objs.size(); i++) objs[i]->setLayer(
            osgWidget::Widget::LAYER_MIDDLE,
            i * 2
        );

        _windows->getByName(ev.getWidget()->getName())->setLayer(
            osgWidget::Widget::LAYER_MIDDLE,
            objs.size() * 2
        );

        _windows->resize();

        return true;
    }
    bool windowClicked(osgWidget::Event &ev)
    {
        std::cout << "Object::windowClicked " << ev.getWindow()->getName() << std::endl;

        return true;
    }
示例#13
0
// TODO: Testing our _parent/EmbeddedWindow stuff.
bool info(osgWidget::Event& ev) {
    osgWidget::warn() << "MousePush @ Window: " << ev.getWindow()->getName() << std::endl;

    return true;
}