Example #1
0
def createErrorMessage(themeMessage, themeButton, titleText, messageText, buttonText, font, fontSize):

    

    frame = osgWidget.Frame.createSimpleFrameFromTheme(
        "error",
        osgDB.readImageFile(themeMessage),
        300.0,
        50.0,
        osgWidget.Frame.FRAME_ALL
        )
    frame.getBackground().setColor(0.0, 0.0, 0.0, 0.0)

    labelText = createLabel(messageText, font, fontSize, osgWidget.Color(0,0,0,1))
    labelTitle = createLabel(titleText, font, fontSize+5, osgWidget.Color(0.4,0,0,1))

    box = osgWidget.Box("VBOX", osgWidget.Box.VERTICAL)

    buttonOK = createButtonOk(themeButton, buttonText, fontSize).embed()
    buttonOK.setColor(osgWidget.Color(0,0,0,0))
    buttonOK.setCanFill(False)

    box.addWidget(buttonOK)
    box.addWidget(labelText)
    box.addWidget(labelTitle)

    colorBack = frame.getEmbeddedWindow().getColor()
    box.getBackground().setColor(colorBack)

    frame.setWindow(box)

    box.resize()
    frame.resizeFrame(box.getWidth(), box.getHeight())
    return frame.release()
Example #2
0
def createButtonOk(theme, text, fontSize):

    
    frame = osgWidget.Frame.createSimpleFrameFromTheme(
        "ButtonOK",
        osgDB.readImageFile(theme),
        300.0, 
        50.0,
        osgWidget.Frame.FRAME_TEXTURE
        )
    frame.getBackground().setColor(0.0, 0.0, 0.0, 0.0)

    label = createLabel(text, "fonts/Vera.ttf", fontSize, osgWidget.Color(0,0,0,1))

    box = osgWidget.Box("HBOX", osgWidget.Box.HORIZONTAL)
    box.addWidget(label)
    box.resize()
    colorBack = frame.getEmbeddedWindow().getColor()
    box.getBackground().setColor(colorBack)
    frame.getEmbeddedWindow().setWindow(box)
    box.setVisibilityMode(osgWidget.Window.VM_ENTIRE)
    box.setEventMask(osgWidget.EVENT_NONE)

    frame.resizeFrame(box.getWidth(), box.getHeight())
    frame.resizeAdd(0, 0)

    event = EventOK(frame)
    frame.setUpdateCallback(event)
    frame.addCallback(event)


    return frame.release()
Example #3
0
def createLabel(string, font, size, color):



    
    label = osgWidget.Label("", "")
    label.setFont(font)
    label.setFontSize(size)
    label.setFontColor(color)
    label.setColor(osgWidget.Color(0,0,0,0))
    label.setLabel(string)
    label.setCanFill(True)
    return label
Example #4
0
    def apply(node):

        
        win = dynamic_cast<osgWidget.Window*>(node)

        if win : 
#            osgWidget.warn(), "I am in Window: ", win.getName()

            for (osgWidget.Window.Iterator it = win.begin() it  not = win.end() it++)
#                osgWidget.warn(), "   I am operating on Widget: ", it.getName()
                
#                 color = it.getColor()
#                 color[3] = color[3] *_alpha
                it.setColor(_color)
#                 color = win.getBackground().getColor()
#                 color[3] = color[3] *_alpha
                win.getBackground().setColor(osgWidget.Color(0,0,0,0))
Example #5
0
class ColorSetterVisitor (osg.NodeVisitor) :
_color = osgWidget.Color()
    ColorSetterVisitor(  osgWidget.Color color):osg.NodeVisitor(TRAVERSE_ALL_CHILDREN)  _color = color

    def apply(node):

        
        win = dynamic_cast<osgWidget.Window*>(node)

        if win : 
#            osgWidget.warn(), "I am in Window: ", win.getName()

            for (osgWidget.Window.Iterator it = win.begin() it  not = win.end() it++)
#                osgWidget.warn(), "   I am operating on Widget: ", it.getName()
                
#                 color = it.getColor()
#                 color[3] = color[3] *_alpha
                it.setColor(_color)
#                 color = win.getBackground().getColor()
#                 color[3] = color[3] *_alpha
                win.getBackground().setColor(osgWidget.Color(0,0,0,0))
        traverse(node)
#include <osg/io_utils>
#include <osgDB/ReadFile>
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Box>

MASK_2D = 0xF0000000
MASK_3D = 0x0F000000

class ColorWidget (osgWidget.Widget) :
ColorWidget():
    osgWidget.Widget("", 256.0, 256.0) 
        setEventMask(osgWidget.EVENT_ALL)

    bool mouseEnter(double, double,  osgWidget.WindowManager*) 
        addColor(-osgWidget.Color(0.4, 0.4, 0.4, 0.0))
        
        # osgWidget.warn(), "enter: ", getColor()

        return True

    bool mouseLeave(double, double,  osgWidget.WindowManager*) 
        addColor(osgWidget.Color(0.4, 0.4, 0.4, 0.0))
        
        # osgWidget.warn(), "leave: ", getColor()
        
        return True

    bool mouseOver(double x, double y,  osgWidget.WindowManager*) 
        
        c = getImageColorAtPointerXY(x, y)
Example #7
0
#                 color = win.getBackground().getColor()
#                 color[3] = color[3] *_alpha
                win.getBackground().setColor(osgWidget.Color(0,0,0,0))
        traverse(node)




struct EventOK : public osgWidget.Callback, osg.NodeCallback
    typedef osgAnimation.OutCubicMotion WidgetMotion
#    typedef osgAnimation.OutQuartMotion WidgetMotion
    _motionOver = WidgetMotion()
    _motionLeave = WidgetMotion()
    
    _lastUpdate = double()
    _defaultColor = osgWidget.Color()
    _overColor = osgWidget.Color()
    _over = bool()
    _frame = osgWidget.Frame()
    _width = float()
    _height = float()
    _matrix = osg.Matrix()
    EventOK(osgWidget.Frame* frame) : osgWidget.Callback(osgWidget.EVENT_ALL), _frame(frame) 
        _motionOver = WidgetMotion(0.0, 0.4)
        _motionLeave = WidgetMotion(0.0, 0.5)
        _defaultColor = _frame.getEmbeddedWindow().getColor()
        _overColor = osgWidget.Color(229.0/255.0,
                                      103.0/255.0,
                                      17.0/255,
                                      _defaultColor[3])
        _over  = False