Input::Input(const std::string& name, const std::string& label, unsigned int size): Label (name, label), _xoff (0.0f), _yoff (0.0f), _index (0), _size (0), _cursorIndex (0), _maxSize (size), _cursor (new Widget("cursor")) { _text->setAlignment(osgText::Text::LEFT_BOTTOM_BASE_LINE); _text->setKerningType(osgText::KERNING_NONE); // Make the cursor un-copyable. _cursor->setCanClone(false); _cursor->setDataVariance(osg::Object::DYNAMIC); _cursor->setColor(0.0f, 0.0f, 0.0f, 1.0f); setEventMask( // For showing/hiding the "cursor." EVENT_MASK_FOCUS | // For keypresses, obviously. EVENT_MASK_KEY | // For "click" focusing. EVENT_MOUSE_PUSH ); _offsets.resize(size, 0.0f); _text->getText().resize(size, ' '); _text->update(); }
void Frame::Border::parented(Window* /*window*/) { Frame* parent = dynamic_cast<Frame*>(getParent()); if(!parent) return; if(parent->canResize()) setEventMask(EVENT_MASK_MOUSE_DRAG); }
VNormalButton::VNormalButton(const std::string& name) :osgWidget::Label(name) { setColor(osgWidget::Color(1, 1, 1, 1)); setCanFill(true); setEventMask(osgWidget::EVENT_MOUSE_OVER | osgWidget::EVENT_MOUSE_LEAVE | osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MOUSE_RELEASE); }
Button(const std::string& text, const Inputs& inputs): osgWidget::Label("", text), _xyz(inputs) { setupLabel(this); setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK); setShadow(0.1f); addHeight(4.0f); }
VInfoTreeWindow::VInfoTreeWindow(osgWidget::WindowManager* wm, const std::string& name, osgWidget::point_type size) :osgWidget::Canvas(name) , _windowManager(wm) , _windowSize(size) { getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f); setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK | osgWidget::EVENT_MASK_MOUSE_MOVE); _showCallback = new InfoTreeCallback(this); addUpdateCallback(_showCallback); }
ColorLabel(const char* label): osgWidget::Label("", "") { setFont("fonts/Vera.ttf"); setFontSize(14); setFontColor(1.0f, 1.0f, 1.0f, 1.0f); setColor(0.3f, 0.3f, 0.3f, 1.0f); addHeight(18.0f); setCanFill(true); setLabel(label); setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE); }
ColorLabel(const char* label): osgWidget::Label(label, "") { setFont("fonts/VeraMono.ttf"); setFontSize(14); setFontColor(1.0f, 1.0f, 1.0f, 1.0f); setColor(0.3f, 0.3f, 0.3f, 1.0f); setPadding(2.0f); setCanFill(true); addSize(150.0f, 25.0f); setLabel(label); setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE); }
MenuButton::MenuButton(const char* label, std::tr1::function<void ()> callback) : osgWidget::Label("", ""), _callback(callback) { // styling setFont("fonts/times.ttf"); setFontSize(MENU_BUTTON_FONT_SIZE); setFontColor(MENU_BUTTON_FONT_COLOR); setLabel(label); setPadding(MENU_BUTTON_PADDING); setAlignHorizontal(osgWidget::Widget::HA_LEFT); // activate event handling for mouse clicks and moves setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE); }
Window::Window(const std::string& name): _parent (0), _wm (0), _index (0), _x (0.0f), _y (0.0f), _z (0.0f), _zRange (0.0f), _strata (STRATA_NONE), _vis (VM_FULL), _r (0.0f), _s (1.0f), _scaleDenom (100.0f), _vAnchor (VA_NONE), _hAnchor (HA_NONE) { _name = name.size() ? name : generateRandomName("Window"); // TODO: Fix the "bg" name. osg::Geode* geode = new osg::Geode(); Widget* bg = new Widget(name + "bg", 0.0f, 0.0f); bg->setLayer(Widget::LAYER_BG); bg->setColor(1.0f, 1.0f, 1.0f, 1.0f); _setParented(bg); geode->addDrawable(bg); addChild(geode); setDataVariance(osg::Object::DYNAMIC); setEventMask(EVENT_ALL); getOrCreateStateSet()->setAttributeAndModes( new osg::Scissor(0, 0, 0, 0), osg::StateAttribute::ON ); }
ColorWidget(): osgWidget::Widget("", 256.0f, 256.0f) { setEventMask(osgWidget::EVENT_ALL); }