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