aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lluictrlfactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/lluictrlfactory.cpp')
-rw-r--r--linden/indra/llui/lluictrlfactory.cpp301
1 files changed, 18 insertions, 283 deletions
diff --git a/linden/indra/llui/lluictrlfactory.cpp b/linden/indra/llui/lluictrlfactory.cpp
index cfee76a..cc8135c 100644
--- a/linden/indra/llui/lluictrlfactory.cpp
+++ b/linden/indra/llui/lluictrlfactory.cpp
@@ -71,100 +71,6 @@
71 71
72const char XML_HEADER[] = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n"; 72const char XML_HEADER[] = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n";
73 73
74// *NOTE: If you add a new class derived from LLPanel, add a check for its
75// widget type to LLUICtrl::getParentPanel().
76// *NOTE: This MUST match EWidgetType in llui.h
77//static
78const LLString LLUICtrlFactory::sUICtrlNames[WIDGET_TYPE_COUNT] =
79{
80 LLString("view"), //WIDGET_TYPE_VIEW
81 LLString("root_view"), //WIDGET_TYPE_ROOT_VIEW
82 LLString("floater_view"), //WIDGET_TYPE_FLOATER_VIEW
83 LLString("button"), //WIDGET_TYPE_BUTTON
84 LLString("joystick_turn"), //WIDGET_TYPE_JOYSTICK_TURN
85 LLString("joystick_slide"), //WIDGET_TYPE_JOYSTICK_SLIDE
86 LLString("check_box"), //WIDGET_TYPE_CHECKBOX
87 LLString("color_swatch"), //WIDGET_TYPE_COLOR_SWATCH
88 LLString("combo_box"), //WIDGET_TYPE_COMBO_BOX
89 LLString("line_editor"), //WIDGET_TYPE_LINE_EDITOR
90 LLString("search_editor"), //WIDGET_TYPE_SEARCH_EDITOR
91 LLString("scroll_list"), //WIDGET_TYPE_SCROLL_LIST
92 LLString("name_list"), //WIDGET_TYPE_NAME_LIST
93 LLString("web_browser"), //WIDGET_TYPE_WEBBROWSER
94 LLString("slider"), //WIDGET_TYPE_SLIDER, actually LLSliderCtrl
95 LLString("slider_bar"), //WIDGET_TYPE_SLIDER_BAR, actually LLSlider
96 LLString("volume_slider"), //WIDGET_TYPE_VOLUME_SLIDER, actually LLSlider + "volume" param
97 LLString("multi_slider"), //WIDGET_TYPE_MULTI_SLIDER, actually LLMultiSliderCtrl
98 LLString("multi_slider_bar"), //WIDGET_TYPE_MULTI_SLIDER_BAR, actually LLMultiSlider
99 LLString("spinner"), //WIDGET_TYPE_SPINNER, actually LLSpinCtrl
100 LLString("text_editor"), //WIDGET_TYPE_TEXT_EDITOR
101 LLString("texture_picker"),//WIDGET_TYPE_TEXTURE_PICKER
102 LLString("text"), //WIDGET_TYPE_TEXT_BOX
103 LLString("pad"), //WIDGET_TYPE_PAD
104 LLString("radio_group"), //WIDGET_TYPE_RADIO_GROUP
105 LLString("icon"), //WIDGET_TYPE_ICON
106 LLString("locate"), //WIDGET_TYPE_LOCATE
107 LLString("view_border"), //WIDGET_TYPE_VIEW_BORDER
108 LLString("panel"), //WIDGET_TYPE_PANEL
109 LLString("menu"), //WIDGET_TYPE_MENU
110 LLString("pie_menu"), //WIDGET_TYPE_PIE_MENU
111 LLString("pie_menu_branch"), //WIDGET_TYPE_PIE_MENU_BRANCH
112 LLString("menu_item"), //WIDGET_TYPE_MENU_ITEM
113 LLString("menu_item_separator"), //WIDGET_TYPE_MENU_ITEM_SEPARATOR
114 LLString("menu_separator_vertical"), // WIDGET_TYPE_MENU_SEPARATOR_VERTICAL
115 LLString("menu_item_call"), // WIDGET_TYPE_MENU_ITEM_CALL
116 LLString("menu_item_check"),// WIDGET_TYPE_MENU_ITEM_CHECK
117 LLString("menu_item_branch"), // WIDGET_TYPE_MENU_ITEM_BRANCH
118 LLString("menu_item_branch_down"), //WIDGET_TYPE_MENU_ITEM_BRANCH_DOWN,
119 LLString("menu_item_blank"), //WIDGET_TYPE_MENU_ITEM_BLANK,
120 LLString("tearoff_menu"), //WIDGET_TYPE_TEAROFF_MENU
121 LLString("menu_bar"), //WIDGET_TYPE_MENU_BAR
122 LLString("tab_container"),//WIDGET_TYPE_TAB_CONTAINER
123 LLString("scroll_container"),//WIDGET_TYPE_SCROLL_CONTAINER
124 LLString("scrollbar"), //WIDGET_TYPE_SCROLLBAR
125 LLString("inventory_panel"), //WIDGET_TYPE_INVENTORY_PANEL
126 LLString("floater"), //WIDGET_TYPE_FLOATER
127 LLString("drag_handle_top"), //WIDGET_TYPE_DRAG_HANDLE_TOP
128 LLString("drag_handle_left"), //WIDGET_TYPE_DRAG_HANDLE_LEFT
129 LLString("resize_handle"), //WIDGET_TYPE_RESIZE_HANDLE
130 LLString("resize_bar"), //WIDGET_TYPE_RESIZE_BAR
131 LLString("name_editor"), //WIDGET_TYPE_NAME_EDITOR
132 LLString("multi_floater"), //WIDGET_TYPE_MULTI_FLOATER
133 LLString("media_remote"), //WIDGET_TYPE_MEDIA_REMOTE
134 LLString("folder_view"), //WIDGET_TYPE_FOLDER_VIEW
135 LLString("folder_item"), //WIDGET_TYPE_FOLDER_ITEM
136 LLString("folder"), //WIDGET_TYPE_FOLDER
137 LLString("stat_graph"), //WIDGET_TYPE_STAT_GRAPH
138 LLString("stat_view"), //WIDGET_TYPE_STAT_VIEW
139 LLString("stat_bar"), //WIDGET_TYPE_STAT_BAR
140 LLString("drop_target"), //WIDGET_TYPE_DROP_TARGET
141 LLString("texture_bar"), //WIDGET_TYPE_TEXTURE_BAR
142 LLString("tex_mem_bar"), //WIDGET_TYPE_TEX_MEM_BAR
143 LLString("snapshot_live_preview"), //WIDGET_TYPE_SNAPSHOT_LIVE_PREVIEW
144 LLString("status_bar"), //WIDGET_TYPE_STATUS_BAR
145 LLString("progress_view"), //WIDGET_TYPE_PROGRESS_VIEW
146 LLString("talk_view"), //WIDGET_TYPE_TALK_VIEW
147 LLString("overlay_bar"), //WIDGET_TYPE_OVERLAY_BAR
148 LLString("hud_view"), //WIDGET_TYPE_HUD_VIEW
149 LLString("hover_view"), //WIDGET_TYPE_HOVER_VIEW
150 LLString("morph_view"), //WIDGET_TYPE_MORPH_VIEW
151 LLString("net_map"), //WIDGET_TYPE_NET_MAP
152 LLString("permissions_view"), //WIDGET_TYPE_PERMISSIONS_VIEW
153 LLString("menu_holder"), //WIDGET_TYPE_MENU_HOLDER
154 LLString("debug_view"), //WIDGET_TYPE_DEBUG_VIEW
155 LLString("scrolling_panel_list"), //WIDGET_TYPE_SCROLLING_PANEL_LIST
156 LLString("audio_status"), //WIDGET_TYPE_AUDIO_STATUS
157 LLString("container_view"), //WIDGET_TYPE_CONTAINER_VIEW
158 LLString("console"), //WIDGET_TYPE_CONSOLE
159 LLString("fast_timer_view"), //WIDGET_TYPE_FAST_TIMER_VIEW
160 LLString("velocity_bar"), //WIDGET_TYPE_VELOCITY_BAR
161 LLString("texture_view"), //WIDGET_TYPE_TEXTURE_VIEW
162 LLString("memory_view"), //WIDGET_TYPE_MEMORY_VIEW
163 LLString("frame_stat_view"), //WIDGET_TYPE_FRAME_STAT_VIEW
164 LLString("layout_stack"), //WIDGET_TYPE_LAYOUT_STACK
165 LLString("DONT_CARE"), //WIDGET_TYPE_DONTCARE
166};
167
168const S32 HPAD = 4; 74const S32 HPAD = 4;
169const S32 VPAD = 4; 75const S32 VPAD = 4;
170const S32 FLOATER_H_MARGIN = 15; 76const S32 FLOATER_H_MARGIN = 15;
@@ -179,9 +85,6 @@ public:
179 LLUICtrlLocate() : LLUICtrl("locate", LLRect(0,0,0,0), FALSE, NULL, NULL) { setTabStop(FALSE); } 85 LLUICtrlLocate() : LLUICtrl("locate", LLRect(0,0,0,0), FALSE, NULL, NULL) { setTabStop(FALSE); }
180 virtual void draw() { } 86 virtual void draw() { }
181 87
182 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_LOCATE; }
183 virtual LLString getWidgetTag() const { return LL_UI_CTRL_LOCATE_TAG; }
184
185 static LLView *fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) 88 static LLView *fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
186 { 89 {
187 LLString name("pad"); 90 LLString name("pad");
@@ -194,39 +97,14 @@ public:
194 } 97 }
195}; 98};
196 99
100static LLRegisterWidget<LLUICtrlLocate> r1("locate");
101static LLRegisterWidget<LLUICtrlLocate> r2("pad");
102
197//----------------------------------------------------------------------------- 103//-----------------------------------------------------------------------------
198// LLUICtrlFactory() 104// LLUICtrlFactory()
199//----------------------------------------------------------------------------- 105//-----------------------------------------------------------------------------
200LLUICtrlFactory::LLUICtrlFactory() 106LLUICtrlFactory::LLUICtrlFactory()
201{ 107{
202 // Register controls
203 LLUICtrlCreator<LLButton>::registerCreator(LL_BUTTON_TAG, this);
204 LLUICtrlCreator<LLCheckBoxCtrl>::registerCreator(LL_CHECK_BOX_CTRL_TAG, this);
205 LLUICtrlCreator<LLComboBox>::registerCreator(LL_COMBO_BOX_TAG, this);
206 LLUICtrlCreator<LLFlyoutButton>::registerCreator(LL_FLYOUT_BUTTON_TAG, this);
207 LLUICtrlCreator<LLLineEditor>::registerCreator(LL_LINE_EDITOR_TAG, this);
208 LLUICtrlCreator<LLSearchEditor>::registerCreator(LL_SEARCH_EDITOR_TAG, this);
209 LLUICtrlCreator<LLScrollListCtrl>::registerCreator(LL_SCROLL_LIST_CTRL_TAG, this);
210 LLUICtrlCreator<LLSliderCtrl>::registerCreator(LL_SLIDER_CTRL_TAG, this);
211 LLUICtrlCreator<LLSlider>::registerCreator(LL_SLIDER_TAG, this);
212 LLUICtrlCreator<LLSlider>::registerCreator(LL_VOLUME_SLIDER_CTRL_TAG, this);
213 LLUICtrlCreator<LLMultiSliderCtrl>::registerCreator(LL_MULTI_SLIDER_CTRL_TAG, this);
214 LLUICtrlCreator<LLMultiSlider>::registerCreator(LL_MULTI_SLIDER_TAG, this);
215 LLUICtrlCreator<LLSpinCtrl>::registerCreator(LL_SPIN_CTRL_TAG, this);
216 LLUICtrlCreator<LLTextBox>::registerCreator(LL_TEXT_BOX_TAG, this);
217 LLUICtrlCreator<LLRadioGroup>::registerCreator(LL_RADIO_GROUP_TAG, this);
218 LLUICtrlCreator<LLIconCtrl>::registerCreator(LL_ICON_CTRL_TAG, this);
219 LLUICtrlCreator<LLUICtrlLocate>::registerCreator(LL_UI_CTRL_LOCATE_TAG, this);
220 LLUICtrlCreator<LLUICtrlLocate>::registerCreator(LL_PAD_TAG, this);
221 LLUICtrlCreator<LLViewBorder>::registerCreator(LL_VIEW_BORDER_TAG, this);
222 LLUICtrlCreator<LLTabContainer>::registerCreator(LL_TAB_CONTAINER_COMMON_TAG, this);
223 LLUICtrlCreator<LLScrollableContainerView>::registerCreator(LL_SCROLLABLE_CONTAINER_VIEW_TAG, this);
224 LLUICtrlCreator<LLPanel>::registerCreator(LL_PANEL_TAG, this);
225 LLUICtrlCreator<LLMenuGL>::registerCreator(LL_MENU_GL_TAG, this);
226 LLUICtrlCreator<LLMenuBarGL>::registerCreator(LL_MENU_BAR_GL_TAG, this);
227 LLUICtrlCreator<LLScrollingPanelList>::registerCreator(LL_SCROLLING_PANEL_LIST_TAG, this);
228 LLUICtrlCreator<LLLayoutStack>::registerCreator(LL_LAYOUT_STACK_TAG, this);
229
230 setupPaths(); 108 setupPaths();
231} 109}
232 110
@@ -548,43 +426,33 @@ void LLUICtrlFactory::rebuild()
548//----------------------------------------------------------------------------- 426//-----------------------------------------------------------------------------
549//----------------------------------------------------------------------------- 427//-----------------------------------------------------------------------------
550 428
551// static
552EWidgetType LLUICtrlFactory::getWidgetType(const LLString& ctrl_type)
553{
554 U32 ctrl_id;
555 for (ctrl_id = 0; ctrl_id < WIDGET_TYPE_COUNT; ctrl_id++)
556 {
557 if (sUICtrlNames[ctrl_id] == ctrl_type)
558 {
559 break;
560 }
561 }
562 return (EWidgetType) ctrl_id;
563}
564
565LLString LLUICtrlFactory::getWidgetType(EWidgetType ctrl_type)
566{
567 return sUICtrlNames[ctrl_type];
568}
569
570LLView *LLUICtrlFactory::createCtrlWidget(LLPanel *parent, LLXMLNodePtr node) 429LLView *LLUICtrlFactory::createCtrlWidget(LLPanel *parent, LLXMLNodePtr node)
571{ 430{
431 // panel for holding dummy widgets, so they have a parent for layout purposes, etc.
432 // does not manage lifetime of child widgets
433 static LLPanel dummy_panel;
434
572 LLString ctrl_type = node->getName()->mString; 435 LLString ctrl_type = node->getName()->mString;
573 LLString::toLower(ctrl_type); 436 LLString::toLower(ctrl_type);
574 437
575 creator_list_t::const_iterator it = mCreatorFunctions.find(ctrl_type); 438 LLWidgetClassRegistry::factory_func_t func = LLWidgetClassRegistry::getInstance()->getCreatorFunc(ctrl_type);
576 if (it == mCreatorFunctions.end()) 439
440 if (func == NULL)
577 { 441 {
578 llwarns << "Unknown control type " << ctrl_type << llendl; 442 llwarns << "Unknown control type " << ctrl_type << llendl;
579 return NULL; 443 return NULL;
580 } 444 }
581 445
582 LLView *ctrl = (*it->second)(node, parent, this); 446 if (parent == NULL)
447 {
448 parent = &dummy_panel;
449 }
450 LLView *ctrl = func(node, parent, this);
583 451
584 return ctrl; 452 return ctrl;
585} 453}
586 454
587void LLUICtrlFactory::createWidget(LLPanel *parent, LLXMLNodePtr node) 455LLView* LLUICtrlFactory::createWidget(LLPanel *parent, LLXMLNodePtr node)
588{ 456{
589 LLView* view = createCtrlWidget(parent, node); 457 LLView* view = createCtrlWidget(parent, node);
590 458
@@ -595,6 +463,8 @@ void LLUICtrlFactory::createWidget(LLPanel *parent, LLXMLNodePtr node)
595 { 463 {
596 parent->addChild(view, tab_group); 464 parent->addChild(view, tab_group);
597 } 465 }
466
467 return view;
598} 468}
599 469
600//----------------------------------------------------------------------------- 470//-----------------------------------------------------------------------------
@@ -648,138 +518,3 @@ BOOL LLUICtrlFactory::getAttributeColor(LLXMLNodePtr node, const LLString& name,
648 return res; 518 return res;
649} 519}
650 520
651//============================================================================
652
653LLButton* LLUICtrlFactory::getButtonByName(const LLPanel* panelp, const LLString& name)
654{
655 return panelp->getChild<LLButton>(name);
656}
657
658LLCheckBoxCtrl* LLUICtrlFactory::getCheckBoxByName(const LLPanel* panelp, const LLString& name)
659{
660 return panelp->getChild<LLCheckBoxCtrl>(name);
661}
662
663LLComboBox* LLUICtrlFactory::getComboBoxByName(const LLPanel* panelp, const LLString& name)
664{
665 return panelp->getChild<LLComboBox>(name);
666}
667
668LLIconCtrl* LLUICtrlFactory::getIconByName(const LLPanel* panelp, const LLString& name)
669{
670 return panelp->getChild<LLIconCtrl>(name);
671}
672
673LLLineEditor* LLUICtrlFactory::getLineEditorByName(const LLPanel* panelp, const LLString& name)
674{
675 return panelp->getChild<LLLineEditor>(name);
676}
677
678LLRadioGroup* LLUICtrlFactory::getRadioGroupByName(const LLPanel* panelp, const LLString& name)
679{
680 return panelp->getChild<LLRadioGroup>(name);
681}
682
683LLScrollListCtrl* LLUICtrlFactory::getScrollListByName(const LLPanel* panelp, const LLString& name)
684{
685 return panelp->getChild<LLScrollListCtrl>(name);
686}
687
688LLSliderCtrl* LLUICtrlFactory::getSliderByName(const LLPanel* panelp, const LLString& name)
689{
690 return panelp->getChild<LLSliderCtrl>(name);
691}
692
693LLSlider* LLUICtrlFactory::getSliderBarByName(const LLPanel* panelp, const LLString& name)
694{
695 return panelp->getChild<LLSlider>(name);
696}
697
698LLSpinCtrl* LLUICtrlFactory::getSpinnerByName(const LLPanel* panelp, const LLString& name)
699{
700 return panelp->getChild<LLSpinCtrl>(name);
701}
702
703LLTextBox* LLUICtrlFactory::getTextBoxByName(const LLPanel* panelp, const LLString& name)
704{
705 return panelp->getChild<LLTextBox>(name);
706}
707
708LLTextEditor* LLUICtrlFactory::getTextEditorByName(const LLPanel* panelp, const LLString& name)
709{
710 return panelp->getChild<LLTextEditor>(name);
711}
712
713LLTabContainer* LLUICtrlFactory::getTabContainerByName(const LLPanel* panelp, const LLString& name)
714{
715 return panelp->getChild<LLTabContainer>(name);
716}
717
718LLScrollableContainerView* LLUICtrlFactory::getScrollableContainerByName(const LLPanel* panelp, const LLString& name)
719{
720 return panelp->getChild<LLScrollableContainerView>(name);
721}
722
723LLPanel* LLUICtrlFactory::getPanelByName(const LLPanel* panelp, const LLString& name)
724{
725 return panelp->getChild<LLPanel>(name);
726}
727
728LLMenuItemCallGL* LLUICtrlFactory::getMenuItemCallByName(const LLPanel* panelp, const LLString& name)
729{
730 return panelp->getChild<LLMenuItemCallGL>(name);
731}
732
733LLScrollingPanelList* LLUICtrlFactory::getScrollingPanelList(const LLPanel* panelp, const LLString& name)
734{
735 return panelp->getChild<LLScrollingPanelList>(name);
736}
737
738LLMultiSliderCtrl* LLUICtrlFactory::getMultiSliderByName(const LLPanel* panelp, const LLString& name)
739{
740 return panelp->getChild<LLMultiSliderCtrl>(name);
741}
742
743LLMultiSlider* LLUICtrlFactory::getMultiSliderBarByName(const LLPanel* panelp, const LLString& name)
744{
745 return panelp->getChild<LLMultiSlider>(name);
746}
747
748
749LLCtrlListInterface* LLUICtrlFactory::getListInterfaceByName(const LLPanel* panelp, const LLString& name)
750{
751 LLView* viewp = panelp->getCtrlByNameAndType(name, WIDGET_TYPE_DONTCARE);
752 if (viewp && viewp->isCtrl())
753 {
754 return ((LLUICtrl*)viewp)->getListInterface();
755 }
756 return NULL;
757}
758
759LLCtrlSelectionInterface* LLUICtrlFactory::getSelectionInterfaceByName(const LLPanel* panelp, const LLString& name)
760{
761 LLView* viewp = panelp->getCtrlByNameAndType(name, WIDGET_TYPE_DONTCARE);
762 if (viewp && viewp->isCtrl())
763 {
764 return ((LLUICtrl*)viewp)->getSelectionInterface();
765 }
766 return NULL;
767}
768
769LLCtrlScrollInterface* LLUICtrlFactory::getScrollInterfaceByName(const LLPanel* panelp, const LLString& name)
770{
771 LLView* viewp = panelp->getCtrlByNameAndType(name, WIDGET_TYPE_DONTCARE);
772 if (viewp && viewp->isCtrl())
773 {
774 return ((LLUICtrl*)viewp)->getScrollInterface();
775 }
776 return NULL;
777}
778
779void LLUICtrlFactory::registerCreator(LLString ctrlname, creator_function_t function)
780{
781 LLString::toLower(ctrlname);
782 mCreatorFunctions[ctrlname] = function;
783}
784
785