diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbutton.cpp | 5 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 101 | ||||
-rw-r--r-- | indra/llui/llmenugl.h | 7 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 15 | ||||
-rw-r--r-- | indra/llui/llview.cpp | 65 | ||||
-rw-r--r-- | indra/llui/llview.h | 22 |
6 files changed, 124 insertions, 91 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 8ae6dd2ea5..2bcc89b59f 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -778,8 +778,9 @@ void LLButton::setToggleState(BOOL b) { if( b != mToggleState ) { - setControlValue(b); // will fire LLControlVariable callbacks (if any) - mToggleState = b; // may or may not be redundant + mToggleState = b; + LLValueChangedEvent *evt = new LLValueChangedEvent(this, mToggleState); + fireEvent(evt, ""); } } diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 8c62a10f2b..00b4c37bb0 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -827,33 +827,57 @@ void LLMenuItemCallGL::setEnabledControl(LLString enabled_control, LLView *conte // Register new listener if (!enabled_control.empty()) { - LLControlVariable *control = context->findControl(enabled_control); - if (!control) + LLControlBase *control = context->findControl(enabled_control); + if (control) + { + LLSD state = control->registerListener(this, "ENABLED"); + setEnabled(state); + } + else { context->addBoolControl(enabled_control, getEnabled()); control = context->findControl(enabled_control); - llassert_always(control); + control->registerListener(this, "ENABLED"); } - control->getSignal()->connect(boost::bind(&LLView::controlListener, _1, getHandle(), std::string("enabled"))); - setEnabled(control->getValue()); } } -void LLMenuItemCallGL::setVisibleControl(LLString visible_control, LLView *context) +void LLMenuItemCallGL::setVisibleControl(LLString enabled_control, LLView *context) { // Register new listener - if (!visible_control.empty()) + if (!enabled_control.empty()) { - LLControlVariable *control = context->findControl(visible_control); - if (!control) + LLControlBase *control = context->findControl(enabled_control); + if (control) { - context->addBoolControl(visible_control, getVisible()); - control = context->findControl(visible_control); - llassert_always(control); + LLSD state = control->registerListener(this, "VISIBLE"); + setVisible(state); } - control->getSignal()->connect(boost::bind(&LLView::controlListener, _1, getHandle(), std::string("visible"))); - setVisible(control->getValue()); + else + { + context->addBoolControl(enabled_control, getEnabled()); + control = context->findControl(enabled_control); + control->registerListener(this, "VISIBLE"); + } + } +} + +// virtual +bool LLMenuItemCallGL::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) +{ + if (userdata.asString() == "ENABLED" && event->desc() == "value_changed") + { + LLSD state = event->getValue(); + setEnabled(state); + return TRUE; } + if (userdata.asString() == "VISIBLE" && event->desc() == "value_changed") + { + LLSD state = event->getValue(); + setVisible(state); + return TRUE; + } + return LLMenuItemGL::handleEvent(event, userdata); } // virtual @@ -976,35 +1000,44 @@ LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, setControlName(control_name, context); } -//virtual -void LLMenuItemCheckGL::setValue(const LLSD& value) -{ - mChecked = value.asBoolean(); - if(mChecked) - { - mDrawBoolLabel = BOOLEAN_TRUE_PREFIX; - } - else - { - mDrawBoolLabel.clear(); - } -} - void LLMenuItemCheckGL::setCheckedControl(LLString checked_control, LLView *context) { // Register new listener if (!checked_control.empty()) { - LLControlVariable *control = context->findControl(checked_control); - if (!control) + LLControlBase *control = context->findControl(checked_control); + if (control) + { + LLSD state = control->registerListener(this, "CHECKED"); + mChecked = state; + } + else { context->addBoolControl(checked_control, mChecked); control = context->findControl(checked_control); - llassert_always(control); + control->registerListener(this, "CHECKED"); + } + } +} + +// virtual +bool LLMenuItemCheckGL::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) +{ + if (userdata.asString() == "CHECKED" && event->desc() == "value_changed") + { + LLSD state = event->getValue(); + mChecked = state; + if(mChecked) + { + mDrawBoolLabel = BOOLEAN_TRUE_PREFIX; } - control->getSignal()->connect(boost::bind(&LLView::controlListener, _1, getHandle(), std::string("value"))); - mChecked = control->getValue(); + else + { + mDrawBoolLabel.clear(); + } + return TRUE; } + return LLMenuItemCallGL::handleEvent(event, userdata); } // virtual @@ -1913,7 +1946,7 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory { continue; } - LLControlVariable *control = parent->findControl(control_name); + LLControlBase *control = parent->findControl(control_name); if (!control) { parent->addBoolControl(control_name, FALSE); diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 33b226fd99..e9b80e562b 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -225,7 +225,7 @@ private: // calls a user defined callback. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLMenuItemCallGL : public LLMenuItemGL, public LLObservable +class LLMenuItemCallGL : public LLMenuItemGL { public: // normal constructor @@ -291,6 +291,7 @@ public: //virtual void draw(); + virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); private: menu_callback mCallback; @@ -340,7 +341,7 @@ public: void setCheckedControl(LLString checked_control, LLView *context); - virtual void setValue(const LLSD& value); + virtual void setValue(const LLSD& value) { mChecked = value.asBoolean(); } virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_CHECK; } virtual LLString getWidgetTag() const { return LL_MENU_ITEM_CHECK_GL_TAG; } @@ -349,6 +350,8 @@ public: // called to rebuild the draw label virtual void buildDrawLabel( void ); + virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); + private: check_callback mCheckCallback; BOOL mChecked; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 1e9442805f..aed7893df7 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1555,11 +1555,16 @@ void gl_segmented_rect_3d_tex_top(const LLVector2& border_scale, const LLVector3 gl_segmented_rect_3d_tex(border_scale, border_width, border_height, width_vec, height_vec, ROUNDED_RECT_TOP); } -bool handleShowXUINamesChanged(const LLSD& newvalue) +class LLShowXUINamesListener: public LLSimpleListener { - LLUI::sShowXUINames = newvalue.asBoolean(); - return true; -} + bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) + { + LLUI::sShowXUINames = (BOOL) event->getValue().asBoolean(); + return true; + } +}; +static LLShowXUINamesListener show_xui_names_listener; + void LLUI::initClass(LLControlGroup* config, LLControlGroup* colors, @@ -1579,7 +1584,7 @@ void LLUI::initClass(LLControlGroup* config, LLFontGL::sShadowColor = colors->getColor("ColorDropShadow"); LLUI::sShowXUINames = LLUI::sConfigGroup->getBOOL("ShowXUINames"); - LLUI::sConfigGroup->getControl("ShowXUINames")->getSignal()->connect(boost::bind(&handleShowXUINamesChanged, _1)); + LLUI::sConfigGroup->getControl("ShowXUINames")->addListener(&show_xui_names_listener); } void LLUI::cleanupClass() diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 269796e5de..0a37c03ac5 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -2426,7 +2426,16 @@ LLSimpleListener* LLView::getListenerByName(const LLString& callback_name) return callback; } -LLControlVariable *LLView::findControl(LLString name) +void LLView::addListenerToControl(LLEventDispatcher *dispatcher, const LLString& name, LLSD filter, LLSD userdata) +{ + LLSimpleListener* listener = getListenerByName(name); + if (listener) + { + dispatcher->addListener(listener, filter, userdata); + } +} + +LLControlBase *LLView::findControl(LLString name) { control_map_t::iterator itor = mFloaterControls.find(name); if (itor != mFloaterControls.end()) @@ -2782,15 +2791,9 @@ LLFontGL::StyleFlags LLView::selectFontStyle(LLXMLNodePtr node) return gl_font_style; } -bool LLView::setControlValue(const LLSD& value) +void LLView::setControlValue(const LLSD& value) { - LLString ctrlname = getControlName(); - if (!ctrlname.empty()) - { - LLUI::sConfigGroup->setValue(ctrlname, value); - return true; - } - return false; + LLUI::sConfigGroup->setValue(getControlName(), value); } //virtual @@ -2801,57 +2804,43 @@ void LLView::setControlName(const LLString& control_name, LLView *context) context = this; } + // Unregister from existing listeners if (!mControlName.empty()) { - llwarns << "setControlName called twice on same control!" << llendl; - mControlConnection.disconnect(); // disconnect current signal - mControlName.clear(); + clearDispatchers(); } - + // Register new listener if (!control_name.empty()) { - LLControlVariable *control = context->findControl(control_name); + LLControlBase *control = context->findControl(control_name); if (control) { mControlName = control_name; - mControlConnection = control->getSignal()->connect(boost::bind(&controlListener, _1, getHandle(), std::string("value"))); - setValue(control->getValue()); + LLSD state = control->registerListener(this, "DEFAULT"); + setValue(state); } } } -// static -bool LLView::controlListener(const LLSD& newvalue, LLHandle<LLView> handle, std::string type) +// virtual +bool LLView::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLView* view = handle.get(); - if (view) + if (userdata.asString() == "DEFAULT" && event->desc() == "value_changed") { - if (type == "value") - { - view->setValue(newvalue); - return true; - } - else if (type == "enabled") - { - view->setEnabled(newvalue.asBoolean()); - return true; - } - else if (type == "visible") - { - view->setVisible(newvalue.asBoolean()); - return true; - } + LLSD state = event->getValue(); + setValue(state); + return TRUE; } - return false; + return FALSE; } void LLView::addBoolControl(LLString name, bool initial_value) { - mFloaterControls[name] = new LLControlVariable(name, TYPE_BOOLEAN, initial_value, "Internal floater control"); + mFloaterControls[name] = new LLControl(name, TYPE_BOOLEAN, initial_value, "Internal floater control"); } -LLControlVariable *LLView::getControl(LLString name) +LLControlBase *LLView::getControl(LLString name) { control_map_t::iterator itor = mFloaterControls.find(name); if (itor != mFloaterControls.end()) diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 24a5eb4f89..c8556c7edc 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -65,6 +65,7 @@ const BOOL NOT_MOUSE_OPAQUE = FALSE; const U32 GL_NAME_UI_RESERVED = 2; + /* // virtual functions defined in LLView: @@ -149,7 +150,7 @@ virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent); * */ -class LLView : public LLMouseHandler, public LLMortician +class LLView : public LLMouseHandler, public LLMortician, public LLSimpleListenerObservable { public: @@ -293,6 +294,7 @@ public: LLHandle<LLView> getHandle() { mHandle.bind(this); return mHandle; } + U32 getFollows() const { return mReshapeFlags; } BOOL followsLeft() const { return mReshapeFlags & FOLLOWS_LEFT; } BOOL followsRight() const { return mReshapeFlags & FOLLOWS_RIGHT; } @@ -391,13 +393,13 @@ public: void addListenerToControl(LLEventDispatcher *observer, const LLString& name, LLSD filter, LLSD userdata); void addBoolControl(LLString name, bool initial_value); - LLControlVariable *getControl(LLString name); - LLControlVariable *findControl(LLString name); + LLControlBase *getControl(LLString name); + LLControlBase *findControl(LLString name); - bool setControlValue(const LLSD& value); + void setControlValue(const LLSD& value); virtual void setControlName(const LLString& control, LLView *context); virtual LLString getControlName() const { return mControlName; } -// virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); + virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); virtual void setValue(const LLSD& value); virtual LLSD getValue() const; @@ -492,12 +494,11 @@ protected: LLView* childrenHandleRightMouseDown(S32 x, S32 y, MASK mask); LLView* childrenHandleRightMouseUp(S32 x, S32 y, MASK mask); - static bool controlListener(const LLSD& newvalue, LLHandle<LLView> handle, std::string type); - - typedef std::map<LLString, LLControlVariable*> control_map_t; + typedef std::map<LLString, LLControlBase*> control_map_t; control_map_t mFloaterControls; virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const; + private: LLView* mParentView; child_list_t mChildList; @@ -536,8 +537,9 @@ private: dispatch_list_t mDispatchList; LLString mControlName; - boost::signals::connection mControlConnection; - + + +// Just debugging stuff? We should try to hide anything that's not. -MG public: static BOOL sDebugRects; // Draw debug rects behind everything. static BOOL sDebugKeys; |