From a5261a5fa8fad810ecb5c260d92c3e771822bf58 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 23:46:23 +0100 Subject: Convert BOOL to bool in llui --- indra/llui/llpanel.h | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'indra/llui/llpanel.h') diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 8018365d3e..33883bf6a4 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -40,8 +40,8 @@ #include const S32 LLPANEL_BORDER_WIDTH = 1; -const BOOL BORDER_YES = TRUE; -const BOOL BORDER_NO = FALSE; +const bool BORDER_YES = true; +const bool BORDER_NO = false; class LLButton; class LLUIImage; @@ -107,20 +107,20 @@ protected: public: typedef std::vector ctrl_list_t; - BOOL buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams()); + bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams()); static LLPanel* createFactoryPanel(const std::string& name); /*virtual*/ ~LLPanel(); // LLView interface - /*virtual*/ BOOL isPanel() const; + /*virtual*/ bool isPanel() const; /*virtual*/ void draw(); - /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask ); - /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); + /*virtual*/ bool handleKeyHere( KEY key, MASK mask ); + /*virtual*/ void onVisibilityChange ( bool new_visibility ); // From LLFocusableElement - /*virtual*/ void setFocus( BOOL b ); + /*virtual*/ void setFocus( bool b ); // New virtuals virtual void refresh(); // called in setFocus() @@ -131,8 +131,8 @@ public: void addBorder( LLViewBorder::Params p); void addBorder(); void removeBorder(); - BOOL hasBorder() const { return mBorder != NULL; } - void setBorderVisible( BOOL b ); + bool hasBorder() const { return mBorder != NULL; } + void setBorderVisible( bool b ); void setBackgroundColor( const LLColor4& color ) { mBgOpaqueColor = color; } const LLColor4& getBackgroundColor() const { return mBgOpaqueColor; } @@ -144,10 +144,10 @@ public: LLPointer getTransparentImage() const { return mBgAlphaImage; } LLColor4 getBackgroundImageOverlay() { return mBgOpaqueImageOverlay; } LLColor4 getTransparentImageOverlay() { return mBgAlphaImageOverlay; } - void setBackgroundVisible( BOOL b ) { mBgVisible = b; } - BOOL isBackgroundVisible() const { return mBgVisible; } - void setBackgroundOpaque(BOOL b) { mBgOpaque = b; } - BOOL isBackgroundOpaque() const { return mBgOpaque; } + void setBackgroundVisible( bool b ) { mBgVisible = b; } + bool isBackgroundVisible() const { return mBgVisible; } + void setBackgroundOpaque(bool b) { mBgOpaque = b; } + bool isBackgroundOpaque() const { return mBgOpaque; } void setDefaultBtn(LLButton* btn = NULL); void setDefaultBtn(const std::string& id); void updateDefaultBtn(); @@ -156,7 +156,7 @@ public: void setHelpTopic(const std::string& help_topic) { mHelpTopic = help_topic; } std::string getHelpTopic() const { return mHelpTopic; } - void setCtrlsEnabled(BOOL b); + void setCtrlsEnabled(bool b); ctrl_list_t getCtrlList() const; LLHandle getHandle() const { return getDerivedHandle(); } @@ -167,7 +167,7 @@ public: EnableCallbackRegistry::ScopedRegistrar& getEnableCallbackRegistrar() { return mEnableCallbackRegistrar; } void initFromParams(const Params& p); - BOOL initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); + bool initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); bool hasString(const std::string& name); std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const; @@ -184,8 +184,8 @@ public: void childDisable(const std::string& name) { childSetEnabled(name, false); }; // LLUICtrl - void childSetFocus(const std::string& id, BOOL focus = TRUE); - BOOL childHasFocus(const std::string& id); + void childSetFocus(const std::string& id, bool focus = true); + bool childHasFocus(const std::string& id); // *TODO: Deprecate; for backwards compatability only: // Prefer getChild("foo")->setCommitCallback(boost:bind(...)), @@ -203,9 +203,9 @@ public: LLSD childGetValue(const std::string& id) const; // For setting text / label replacement params, e.g. "Hello [NAME]" - // Not implemented for all types, defaults to noop, returns FALSE if not applicaple - BOOL childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - BOOL childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + // Not implemented for all types, defaults to noop, returns false if not applicaple + bool childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + bool childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); // LLButton void childSetAction(const std::string& id, boost::function function, void* value); @@ -238,8 +238,8 @@ protected: std::string mXMLFilename; private: - BOOL mBgVisible; // any background at all? - BOOL mBgOpaque; // use opaque color or image + bool mBgVisible; // any background at all? + bool mBgOpaque; // use opaque color or image LLUIColor mBgOpaqueColor; LLUIColor mBgAlphaColor; LLUIColor mBgOpaqueImageOverlay; @@ -259,7 +259,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLPANEL_CPP extern template class LLPanel* LLView::getChild( - const std::string& name, BOOL recurse) const; + const std::string& name, bool recurse) const; #endif typedef boost::function LLPanelClassCreatorFunc; -- cgit v1.2.3 From a865d423974ea06dffa47798c81e98e7570b02ec Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Tue, 5 Mar 2024 17:03:11 +0100 Subject: viewer#819 Avoid reading the same XML file multiple times --- indra/llui/llpanel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llui/llpanel.h') diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 33883bf6a4..dd73a41132 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -107,7 +107,8 @@ protected: public: typedef std::vector ctrl_list_t; - bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams()); + bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params, bool cacheable = false); + bool buildFromFile(const std::string &filename, bool cacheable = false) { return buildFromFile(filename, getDefaultParams(), cacheable); } static LLPanel* createFactoryPanel(const std::string& name); -- cgit v1.2.3 From 2008f87f10d51a2f9372aa4a4d72e86ac94e1e81 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 13 May 2024 18:26:53 +0300 Subject: Revert "viewer#819 Avoid reading the same XML file multiple times" This reverts commit a865d423974ea06dffa47798c81e98e7570b02ec. Reason for revert: viewer#1420, reverting to not hold maint-A (is deepCopy not full?) --- indra/llui/llpanel.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llui/llpanel.h') diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index dd73a41132..33883bf6a4 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -107,8 +107,7 @@ protected: public: typedef std::vector ctrl_list_t; - bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params, bool cacheable = false); - bool buildFromFile(const std::string &filename, bool cacheable = false) { return buildFromFile(filename, getDefaultParams(), cacheable); } + bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams()); static LLPanel* createFactoryPanel(const std::string& name); -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/llui/llpanel.h | 636 +++++++++++++++++++++++++-------------------------- 1 file changed, 318 insertions(+), 318 deletions(-) (limited to 'indra/llui/llpanel.h') diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 1088af0e04..2be5573faf 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -1,318 +1,318 @@ -/** - * @file llpanel.h - * @author James Cook, Tom Yedwab - * @brief LLPanel base class - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLPANEL_H -#define LL_LLPANEL_H - - -#include "llcallbackmap.h" -#include "lluictrl.h" -#include "llviewborder.h" -#include "lluiimage.h" -#include "lluistring.h" -#include "v4color.h" -#include "llbadgeholder.h" -#include -#include - -const S32 LLPANEL_BORDER_WIDTH = 1; -const bool BORDER_YES = true; -const bool BORDER_NO = false; - -class LLButton; -class LLUIImage; - -/* - * General purpose concrete view base class. - * Transparent or opaque, - * With or without border, - * Can contain LLUICtrls. - */ -class LLPanel : public LLUICtrl, public LLBadgeHolder -{ -public: - struct LocalizedString : public LLInitParam::Block - { - Mandatory name; - Mandatory value; - - LocalizedString(); - }; - - struct Params - : public LLInitParam::Block - { - Optional has_border; - Optional border; - - Optional background_visible, - background_opaque; - - Optional bg_opaque_color, - bg_alpha_color, - bg_opaque_image_overlay, - bg_alpha_image_overlay; - // opaque image is for "panel in foreground" look - Optional bg_opaque_image, - bg_alpha_image; - - Optional min_width, - min_height; - - Optional filename; - Optional class_name; - Optional help_topic; - - Multiple strings; - - Optional visible_callback; - - Optional accepts_badge; - - Params(); - }; - -protected: - friend class LLUICtrlFactory; - // RN: for some reason you can't just use LLUICtrlFactory::getDefaultParams as a default argument in VC8 - static const LLPanel::Params& getDefaultParams(); - - // Panels can get constructed directly - LLPanel(const LLPanel::Params& params = getDefaultParams()); - -public: - typedef std::vector ctrl_list_t; - - bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams()); - - static LLPanel* createFactoryPanel(const std::string& name); - - /*virtual*/ ~LLPanel(); - - // LLView interface - /*virtual*/ bool isPanel() const; - /*virtual*/ void draw(); - /*virtual*/ bool handleKeyHere( KEY key, MASK mask ); - /*virtual*/ void onVisibilityChange ( bool new_visibility ); - - // From LLFocusableElement - /*virtual*/ void setFocus( bool b ); - - // New virtuals - virtual void refresh(); // called in setFocus() - virtual void clearCtrls(); // overridden in LLPanelObject and LLPanelVolume - - // Border controls - const LLViewBorder* getBorder() const { return mBorder; } - void addBorder( LLViewBorder::Params p); - void addBorder(); - void removeBorder(); - bool hasBorder() const { return mBorder != NULL; } - void setBorderVisible( bool b ); - - void setBackgroundColor( const LLColor4& color ) { mBgOpaqueColor = color; } - const LLColor4& getBackgroundColor() const { return mBgOpaqueColor; } - void setTransparentColor(const LLColor4& color) { mBgAlphaColor = color; } - const LLColor4& getTransparentColor() const { return mBgAlphaColor; } - void setBackgroundImage(LLUIImage* image) { mBgOpaqueImage = image; } - void setTransparentImage(LLUIImage* image) { mBgAlphaImage = image; } - LLPointer getBackgroundImage() const { return mBgOpaqueImage; } - LLPointer getTransparentImage() const { return mBgAlphaImage; } - LLColor4 getBackgroundImageOverlay() { return mBgOpaqueImageOverlay; } - LLColor4 getTransparentImageOverlay() { return mBgAlphaImageOverlay; } - void setBackgroundVisible( bool b ) { mBgVisible = b; } - bool isBackgroundVisible() const { return mBgVisible; } - void setBackgroundOpaque(bool b) { mBgOpaque = b; } - bool isBackgroundOpaque() const { return mBgOpaque; } - void setDefaultBtn(LLButton* btn = NULL); - void setDefaultBtn(const std::string& id); - void updateDefaultBtn(); - void setLabel(const LLStringExplicit& label) { mLabel = label; } - std::string getLabel() const { return mLabel; } - void setHelpTopic(const std::string& help_topic) { mHelpTopic = help_topic; } - std::string getHelpTopic() const { return mHelpTopic; } - - void setCtrlsEnabled(bool b); - ctrl_list_t getCtrlList() const; - - LLHandle getHandle() const { return getDerivedHandle(); } - - const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; } - - CommitCallbackRegistry::ScopedRegistrar& getCommitCallbackRegistrar() { return mCommitCallbackRegistrar; } - EnableCallbackRegistry::ScopedRegistrar& getEnableCallbackRegistrar() { return mEnableCallbackRegistrar; } - - void initFromParams(const Params& p); - bool initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); - - bool hasString(const std::string& name); - std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const; - std::string getString(const std::string& name) const; - - // ** Wrappers for setting child properties by name ** -TomY - // WARNING: These are deprecated, please use getChild("name")->doStuff() idiom instead - - // LLView - void childSetVisible(const std::string& name, bool visible); - - void childSetEnabled(const std::string& name, bool enabled); - void childEnable(const std::string& name) { childSetEnabled(name, true); } - void childDisable(const std::string& name) { childSetEnabled(name, false); }; - - // LLUICtrl - void childSetFocus(const std::string& id, bool focus = true); - bool childHasFocus(const std::string& id); - - // *TODO: Deprecate; for backwards compatability only: - // Prefer getChild("foo")->setCommitCallback(boost:bind(...)), - // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with - // a named callback and reference it in XML. - void childSetCommitCallback(const std::string& id, boost::function cb, void* data); - void childSetColor(const std::string& id, const LLColor4& color); - - LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; - LLCtrlListInterface* childGetListInterface(const std::string& id) const; - LLCtrlScrollInterface* childGetScrollInterface(const std::string& id) const; - - // This is the magic bullet for data-driven UI - void childSetValue(const std::string& id, LLSD value); - LLSD childGetValue(const std::string& id) const; - - // For setting text / label replacement params, e.g. "Hello [NAME]" - // Not implemented for all types, defaults to noop, returns false if not applicaple - bool childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - bool childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - - // LLButton - void childSetAction(const std::string& id, boost::function function, void* value); - void childSetAction(const std::string& id, const commit_signal_t::slot_type& function); - - static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL); - - //call onOpen to let panel know when it's about to be shown or activated - virtual void onOpen(const LLSD& key) {} - - void setXMLFilename(std::string filename) { mXMLFilename = filename; }; - std::string getXMLFilename() { return mXMLFilename; }; - - boost::signals2::connection setVisibleCallback( const commit_signal_t::slot_type& cb ); - -protected: - // Override to set not found list - LLButton* getDefaultButton() { return mDefaultBtn; } - LLCallbackMap::map_t mFactoryMap; - CommitCallbackRegistry::ScopedRegistrar mCommitCallbackRegistrar; - EnableCallbackRegistry::ScopedRegistrar mEnableCallbackRegistrar; - - commit_signal_t* mVisibleSignal; // Called when visibility changes, passes new visibility as LLSD() - - std::string mHelpTopic; // the name of this panel's help topic to display in the Help Viewer - typedef std::deque factory_stack_t; - static factory_stack_t sFactoryStack; - - // for setting the xml filename when building panel in context dependent cases - std::string mXMLFilename; - -private: - bool mBgVisible; // any background at all? - bool mBgOpaque; // use opaque color or image - LLUIColor mBgOpaqueColor; - LLUIColor mBgAlphaColor; - LLUIColor mBgOpaqueImageOverlay; - LLUIColor mBgAlphaImageOverlay; - LLPointer mBgOpaqueImage; // "panel in front" look - LLPointer mBgAlphaImage; // "panel in back" look - LLViewBorder* mBorder; - LLButton* mDefaultBtn; - LLUIString mLabel; - - typedef std::map ui_string_map_t; - ui_string_map_t mUIStrings; - - -}; // end class LLPanel - -// Build time optimization, generate once in .cpp file -#ifndef LLPANEL_CPP -extern template class LLPanel* LLView::getChild( - const std::string& name, bool recurse) const; -#endif - -typedef boost::function LLPanelClassCreatorFunc; - -// local static instance for registering a particular panel class - -class LLRegisterPanelClass -: public LLSingleton< LLRegisterPanelClass > -{ - LLSINGLETON_EMPTY_CTOR(LLRegisterPanelClass); -public: - // register with either the provided builder, or the generic templated builder - void addPanelClass(const std::string& tag,LLPanelClassCreatorFunc func) - { - mPanelClassesNames[tag] = func; - } - - LLPanel* createPanelClass(const std::string& tag) - { - param_name_map_t::iterator iT = mPanelClassesNames.find(tag); - if(iT == mPanelClassesNames.end()) - return 0; - return iT->second(); - } - template - static T* defaultPanelClassBuilder() - { - T* pT = new T(); - return pT; - } - -private: - typedef std::map< std::string, LLPanelClassCreatorFunc> param_name_map_t; - - param_name_map_t mPanelClassesNames; -}; - - -// local static instance for registering a particular panel class -template - class LLPanelInjector -{ -public: - // register with either the provided builder, or the generic templated builder - LLPanelInjector(const std::string& tag); -}; - - -template - LLPanelInjector::LLPanelInjector(const std::string& tag) -{ - LLRegisterPanelClass::instance().addPanelClass(tag,&LLRegisterPanelClass::defaultPanelClassBuilder); -} - - -#endif +/** + * @file llpanel.h + * @author James Cook, Tom Yedwab + * @brief LLPanel base class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLPANEL_H +#define LL_LLPANEL_H + + +#include "llcallbackmap.h" +#include "lluictrl.h" +#include "llviewborder.h" +#include "lluiimage.h" +#include "lluistring.h" +#include "v4color.h" +#include "llbadgeholder.h" +#include +#include + +const S32 LLPANEL_BORDER_WIDTH = 1; +const bool BORDER_YES = true; +const bool BORDER_NO = false; + +class LLButton; +class LLUIImage; + +/* + * General purpose concrete view base class. + * Transparent or opaque, + * With or without border, + * Can contain LLUICtrls. + */ +class LLPanel : public LLUICtrl, public LLBadgeHolder +{ +public: + struct LocalizedString : public LLInitParam::Block + { + Mandatory name; + Mandatory value; + + LocalizedString(); + }; + + struct Params + : public LLInitParam::Block + { + Optional has_border; + Optional border; + + Optional background_visible, + background_opaque; + + Optional bg_opaque_color, + bg_alpha_color, + bg_opaque_image_overlay, + bg_alpha_image_overlay; + // opaque image is for "panel in foreground" look + Optional bg_opaque_image, + bg_alpha_image; + + Optional min_width, + min_height; + + Optional filename; + Optional class_name; + Optional help_topic; + + Multiple strings; + + Optional visible_callback; + + Optional accepts_badge; + + Params(); + }; + +protected: + friend class LLUICtrlFactory; + // RN: for some reason you can't just use LLUICtrlFactory::getDefaultParams as a default argument in VC8 + static const LLPanel::Params& getDefaultParams(); + + // Panels can get constructed directly + LLPanel(const LLPanel::Params& params = getDefaultParams()); + +public: + typedef std::vector ctrl_list_t; + + bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams()); + + static LLPanel* createFactoryPanel(const std::string& name); + + /*virtual*/ ~LLPanel(); + + // LLView interface + /*virtual*/ bool isPanel() const; + /*virtual*/ void draw(); + /*virtual*/ bool handleKeyHere( KEY key, MASK mask ); + /*virtual*/ void onVisibilityChange ( bool new_visibility ); + + // From LLFocusableElement + /*virtual*/ void setFocus( bool b ); + + // New virtuals + virtual void refresh(); // called in setFocus() + virtual void clearCtrls(); // overridden in LLPanelObject and LLPanelVolume + + // Border controls + const LLViewBorder* getBorder() const { return mBorder; } + void addBorder( LLViewBorder::Params p); + void addBorder(); + void removeBorder(); + bool hasBorder() const { return mBorder != NULL; } + void setBorderVisible( bool b ); + + void setBackgroundColor( const LLColor4& color ) { mBgOpaqueColor = color; } + const LLColor4& getBackgroundColor() const { return mBgOpaqueColor; } + void setTransparentColor(const LLColor4& color) { mBgAlphaColor = color; } + const LLColor4& getTransparentColor() const { return mBgAlphaColor; } + void setBackgroundImage(LLUIImage* image) { mBgOpaqueImage = image; } + void setTransparentImage(LLUIImage* image) { mBgAlphaImage = image; } + LLPointer getBackgroundImage() const { return mBgOpaqueImage; } + LLPointer getTransparentImage() const { return mBgAlphaImage; } + LLColor4 getBackgroundImageOverlay() { return mBgOpaqueImageOverlay; } + LLColor4 getTransparentImageOverlay() { return mBgAlphaImageOverlay; } + void setBackgroundVisible( bool b ) { mBgVisible = b; } + bool isBackgroundVisible() const { return mBgVisible; } + void setBackgroundOpaque(bool b) { mBgOpaque = b; } + bool isBackgroundOpaque() const { return mBgOpaque; } + void setDefaultBtn(LLButton* btn = NULL); + void setDefaultBtn(const std::string& id); + void updateDefaultBtn(); + void setLabel(const LLStringExplicit& label) { mLabel = label; } + std::string getLabel() const { return mLabel; } + void setHelpTopic(const std::string& help_topic) { mHelpTopic = help_topic; } + std::string getHelpTopic() const { return mHelpTopic; } + + void setCtrlsEnabled(bool b); + ctrl_list_t getCtrlList() const; + + LLHandle getHandle() const { return getDerivedHandle(); } + + const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; } + + CommitCallbackRegistry::ScopedRegistrar& getCommitCallbackRegistrar() { return mCommitCallbackRegistrar; } + EnableCallbackRegistry::ScopedRegistrar& getEnableCallbackRegistrar() { return mEnableCallbackRegistrar; } + + void initFromParams(const Params& p); + bool initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); + + bool hasString(const std::string& name); + std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const; + std::string getString(const std::string& name) const; + + // ** Wrappers for setting child properties by name ** -TomY + // WARNING: These are deprecated, please use getChild("name")->doStuff() idiom instead + + // LLView + void childSetVisible(const std::string& name, bool visible); + + void childSetEnabled(const std::string& name, bool enabled); + void childEnable(const std::string& name) { childSetEnabled(name, true); } + void childDisable(const std::string& name) { childSetEnabled(name, false); }; + + // LLUICtrl + void childSetFocus(const std::string& id, bool focus = true); + bool childHasFocus(const std::string& id); + + // *TODO: Deprecate; for backwards compatability only: + // Prefer getChild("foo")->setCommitCallback(boost:bind(...)), + // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with + // a named callback and reference it in XML. + void childSetCommitCallback(const std::string& id, boost::function cb, void* data); + void childSetColor(const std::string& id, const LLColor4& color); + + LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; + LLCtrlListInterface* childGetListInterface(const std::string& id) const; + LLCtrlScrollInterface* childGetScrollInterface(const std::string& id) const; + + // This is the magic bullet for data-driven UI + void childSetValue(const std::string& id, LLSD value); + LLSD childGetValue(const std::string& id) const; + + // For setting text / label replacement params, e.g. "Hello [NAME]" + // Not implemented for all types, defaults to noop, returns false if not applicaple + bool childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + bool childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + + // LLButton + void childSetAction(const std::string& id, boost::function function, void* value); + void childSetAction(const std::string& id, const commit_signal_t::slot_type& function); + + static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL); + + //call onOpen to let panel know when it's about to be shown or activated + virtual void onOpen(const LLSD& key) {} + + void setXMLFilename(std::string filename) { mXMLFilename = filename; }; + std::string getXMLFilename() { return mXMLFilename; }; + + boost::signals2::connection setVisibleCallback( const commit_signal_t::slot_type& cb ); + +protected: + // Override to set not found list + LLButton* getDefaultButton() { return mDefaultBtn; } + LLCallbackMap::map_t mFactoryMap; + CommitCallbackRegistry::ScopedRegistrar mCommitCallbackRegistrar; + EnableCallbackRegistry::ScopedRegistrar mEnableCallbackRegistrar; + + commit_signal_t* mVisibleSignal; // Called when visibility changes, passes new visibility as LLSD() + + std::string mHelpTopic; // the name of this panel's help topic to display in the Help Viewer + typedef std::deque factory_stack_t; + static factory_stack_t sFactoryStack; + + // for setting the xml filename when building panel in context dependent cases + std::string mXMLFilename; + +private: + bool mBgVisible; // any background at all? + bool mBgOpaque; // use opaque color or image + LLUIColor mBgOpaqueColor; + LLUIColor mBgAlphaColor; + LLUIColor mBgOpaqueImageOverlay; + LLUIColor mBgAlphaImageOverlay; + LLPointer mBgOpaqueImage; // "panel in front" look + LLPointer mBgAlphaImage; // "panel in back" look + LLViewBorder* mBorder; + LLButton* mDefaultBtn; + LLUIString mLabel; + + typedef std::map ui_string_map_t; + ui_string_map_t mUIStrings; + + +}; // end class LLPanel + +// Build time optimization, generate once in .cpp file +#ifndef LLPANEL_CPP +extern template class LLPanel* LLView::getChild( + const std::string& name, bool recurse) const; +#endif + +typedef boost::function LLPanelClassCreatorFunc; + +// local static instance for registering a particular panel class + +class LLRegisterPanelClass +: public LLSingleton< LLRegisterPanelClass > +{ + LLSINGLETON_EMPTY_CTOR(LLRegisterPanelClass); +public: + // register with either the provided builder, or the generic templated builder + void addPanelClass(const std::string& tag,LLPanelClassCreatorFunc func) + { + mPanelClassesNames[tag] = func; + } + + LLPanel* createPanelClass(const std::string& tag) + { + param_name_map_t::iterator iT = mPanelClassesNames.find(tag); + if(iT == mPanelClassesNames.end()) + return 0; + return iT->second(); + } + template + static T* defaultPanelClassBuilder() + { + T* pT = new T(); + return pT; + } + +private: + typedef std::map< std::string, LLPanelClassCreatorFunc> param_name_map_t; + + param_name_map_t mPanelClassesNames; +}; + + +// local static instance for registering a particular panel class +template + class LLPanelInjector +{ +public: + // register with either the provided builder, or the generic templated builder + LLPanelInjector(const std::string& tag); +}; + + +template + LLPanelInjector::LLPanelInjector(const std::string& tag) +{ + LLRegisterPanelClass::instance().addPanelClass(tag,&LLRegisterPanelClass::defaultPanelClassBuilder); +} + + +#endif -- cgit v1.2.3