diff options
Diffstat (limited to 'linden/indra/newview/llvolumesliderctrl.cpp')
-rw-r--r-- | linden/indra/newview/llvolumesliderctrl.cpp | 193 |
1 files changed, 0 insertions, 193 deletions
diff --git a/linden/indra/newview/llvolumesliderctrl.cpp b/linden/indra/newview/llvolumesliderctrl.cpp deleted file mode 100644 index 54cfa30..0000000 --- a/linden/indra/newview/llvolumesliderctrl.cpp +++ /dev/null | |||
@@ -1,193 +0,0 @@ | |||
1 | /** | ||
2 | * @file llvolumesliderctrl.cpp | ||
3 | * @brief Horizontal volume slider. | ||
4 | * | ||
5 | * Copyright (c) 2004-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * Second Life Viewer Source Code | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #include "llviewerprecompiledheaders.h" | ||
30 | |||
31 | #include "llvolumesliderctrl.h" | ||
32 | |||
33 | #include "llfocusmgr.h" | ||
34 | |||
35 | #include "llui.h" | ||
36 | |||
37 | const F32 VOL_DEFAULT = 0.125f; | ||
38 | const F32 VOL_MIN = 0.f; | ||
39 | const F32 VOL_MAX = 0.5f; | ||
40 | const F32 VOL_INC = 0.01f; | ||
41 | |||
42 | LLVolumeSliderCtrl::LLVolumeSliderCtrl(const std::string& name, | ||
43 | const LLRect& rect, | ||
44 | void (*commit_callback)(LLUICtrl*, void*), | ||
45 | void* callback_data) | ||
46 | : | ||
47 | LLSlider(name, rect, commit_callback, callback_data, | ||
48 | VOL_DEFAULT, | ||
49 | VOL_MIN, | ||
50 | VOL_MAX, | ||
51 | VOL_INC) | ||
52 | { } | ||
53 | |||
54 | LLVolumeSliderCtrl::~LLVolumeSliderCtrl() | ||
55 | { } | ||
56 | |||
57 | // virtual | ||
58 | void LLVolumeSliderCtrl::draw() | ||
59 | { | ||
60 | if(!getVisible()) return; | ||
61 | |||
62 | F32 opacity = mEnabled ? 1.f : 0.3f; | ||
63 | |||
64 | // Track | ||
65 | LLRect track(0, mRect.getHeight(), mRect.getWidth(), 0); | ||
66 | |||
67 | track.mBottom += 3; | ||
68 | track.mTop -= 1; | ||
69 | track.mRight -= 1; | ||
70 | |||
71 | LLColor4 center_color = (mThumbCenterColor % opacity); | ||
72 | LLColor4 outline_color = (mThumbOutlineColor % opacity); | ||
73 | |||
74 | gl_triangle_2d(track.mLeft, track.mBottom, | ||
75 | track.mRight, track.mBottom, | ||
76 | track.mRight, track.mTop, | ||
77 | center_color, | ||
78 | TRUE); | ||
79 | gl_triangle_2d(track.mLeft, track.mBottom, | ||
80 | track.mRight, track.mBottom, | ||
81 | track.mRight, track.mTop, | ||
82 | outline_color, | ||
83 | FALSE); | ||
84 | |||
85 | if (hasMouseCapture()) | ||
86 | { | ||
87 | // Thumb | ||
88 | LLRect rect(mDragStartThumbRect); | ||
89 | gl_rect_2d( rect, outline_color ); | ||
90 | rect.stretch(-1); | ||
91 | gl_rect_2d( rect, mThumbCenterColor % 0.3f ); | ||
92 | |||
93 | // Thumb | ||
94 | if (gFocusMgr.childHasKeyboardFocus(this)) | ||
95 | { | ||
96 | LLRect thumb_rect = mThumbRect; | ||
97 | thumb_rect.stretch(llround(lerp(1.f, 3.f, gFocusMgr.getFocusFlashAmt()))); | ||
98 | gl_rect_2d(thumb_rect, gFocusMgr.getFocusColor()); | ||
99 | } | ||
100 | gl_rect_2d( mThumbRect, mThumbOutlineColor ); | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | LLRect rect(mThumbRect); | ||
105 | // Thumb | ||
106 | if (gFocusMgr.childHasKeyboardFocus(this)) | ||
107 | { | ||
108 | LLRect thumb_rect = mThumbRect; | ||
109 | thumb_rect.stretch(llround(lerp(1.f, 3.f, gFocusMgr.getFocusFlashAmt()))); | ||
110 | gl_rect_2d(thumb_rect, gFocusMgr.getFocusColor()); | ||
111 | } | ||
112 | |||
113 | // Thumb | ||
114 | gl_rect_2d(rect, outline_color); | ||
115 | rect.stretch(-1); | ||
116 | gl_rect_2d( rect, center_color); | ||
117 | } | ||
118 | |||
119 | LLUICtrl::draw(); | ||
120 | } | ||
121 | |||
122 | // virtual | ||
123 | LLXMLNodePtr LLVolumeSliderCtrl::getXML(bool save_children) const | ||
124 | { | ||
125 | LLXMLNodePtr node = LLUICtrl::getXML(); | ||
126 | |||
127 | LLString control_name = getControlName(); | ||
128 | if (!control_name.empty()) | ||
129 | { | ||
130 | node->createChild("control_name", TRUE)->setStringValue(control_name); | ||
131 | } | ||
132 | node->createChild("initial_val", TRUE)->setFloatValue(getInitialValue()); | ||
133 | node->createChild("min_val", TRUE)->setFloatValue(getMinValue()); | ||
134 | node->createChild("max_val", TRUE)->setFloatValue(getMaxValue()); | ||
135 | node->createChild("increment", TRUE)->setFloatValue(getIncrement()); | ||
136 | |||
137 | return node; | ||
138 | } | ||
139 | |||
140 | LLView* LLVolumeSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) | ||
141 | { LLString name("volume_slider"); | ||
142 | |||
143 | node->getAttributeString("name", name); | ||
144 | |||
145 | LLString label; | ||
146 | node->getAttributeString("label", label); | ||
147 | |||
148 | LLRect rect; | ||
149 | createRect(node, rect, parent, LLRect()); | ||
150 | |||
151 | LLFontGL* font = LLView::selectFont(node); | ||
152 | |||
153 | // HACK: Font might not be specified. | ||
154 | if (!font) | ||
155 | { | ||
156 | font = LLFontGL::sSansSerifSmall; | ||
157 | } | ||
158 | |||
159 | S32 label_width = font->getWidth(label) + 8; | ||
160 | node->getAttributeS32("label_width", label_width); | ||
161 | |||
162 | LLString control_name; | ||
163 | node->getAttributeString("control_name", control_name); | ||
164 | |||
165 | BOOL show_text = TRUE; | ||
166 | node->getAttributeBOOL("show_text", show_text); | ||
167 | |||
168 | BOOL can_edit_text = FALSE; | ||
169 | node->getAttributeBOOL("can_edit_text", can_edit_text); | ||
170 | |||
171 | F32 initial_value = 0.f; | ||
172 | node->getAttributeF32("initial_val", initial_value); | ||
173 | |||
174 | F32 min_value = 0.f; | ||
175 | node->getAttributeF32("min_val", min_value); | ||
176 | |||
177 | F32 max_value = 1.f; | ||
178 | node->getAttributeF32("max_val", max_value); | ||
179 | |||
180 | F32 increment = 0.1f; | ||
181 | node->getAttributeF32("increment", increment); | ||
182 | |||
183 | U32 precision = 3; | ||
184 | node->getAttributeU32("decimal_digits", precision); | ||
185 | |||
186 | |||
187 | LLVolumeSliderCtrl* slider = new LLVolumeSliderCtrl(name,rect,NULL,NULL); | ||
188 | |||
189 | slider->initFromXML(node, parent); | ||
190 | |||
191 | return slider; | ||
192 | } | ||
193 | |||