summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llui/llslider.cpp134
-rw-r--r--indra/llui/llslider.h21
-rw-r--r--indra/newview/llagent.cpp4
-rw-r--r--indra/newview/llfloatercamera.cpp92
-rw-r--r--indra/newview/llfloatercamera.h3
-rw-r--r--indra/newview/skins/default/xui/en/floater_camera.xml69
-rw-r--r--indra/newview/skins/default/xui/en/floater_test_slider.xml8
-rw-r--r--indra/newview/skins/default/xui/en/widgets/slider_bar.xml8
8 files changed, 275 insertions, 64 deletions
diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp
index f86776384a..da2fc7c68b 100644
--- a/indra/llui/llslider.cpp
+++ b/indra/llui/llslider.cpp
@@ -47,14 +47,17 @@ static LLDefaultChildRegistry::Register<LLSlider> r1("slider_bar");
// have ambigious template lookup problem
LLSlider::Params::Params()
-: track_color("track_color"),
+: orientation ("orientation", std::string ("horizontal")),
+ track_color("track_color"),
thumb_outline_color("thumb_outline_color"),
thumb_center_color("thumb_center_color"),
thumb_image("thumb_image"),
thumb_image_pressed("thumb_image_pressed"),
thumb_image_disabled("thumb_image_disabled"),
- track_image("track_image"),
- track_highlight_image("track_highlight_image"),
+ track_image_horizontal("track_image_horizontal"),
+ track_image_vertical("track_image_vertical"),
+ track_highlight_horizontal_image("track_highlight_horizontal_image"),
+ track_highlight_vertical_image("track_highlight_vertical_image"),
mouse_down_callback("mouse_down_callback"),
mouse_up_callback("mouse_up_callback")
{
@@ -64,14 +67,17 @@ LLSlider::Params::Params()
LLSlider::LLSlider(const LLSlider::Params& p)
: LLF32UICtrl(p),
mMouseOffset( 0 ),
+ mOrientation ((p.orientation() == "horizontal") ? HORIZONTAL : VERTICAL),
mTrackColor(p.track_color()),
mThumbOutlineColor(p.thumb_outline_color()),
mThumbCenterColor(p.thumb_center_color()),
mThumbImage(p.thumb_image),
mThumbImagePressed(p.thumb_image_pressed),
mThumbImageDisabled(p.thumb_image_disabled),
- mTrackImage(p.track_image),
- mTrackHighlightImage(p.track_highlight_image)
+ mTrackImageHorizontal(p.track_image_horizontal),
+ mTrackImageVertical(p.track_image_vertical),
+ mTrackHighlightHorizontalImage(p.track_highlight_horizontal_image),
+ mTrackHighlightVerticalImage(p.track_highlight_vertical_image)
{
mViewModel->setValue(p.initial_value);
updateThumbRect();
@@ -111,14 +117,29 @@ void LLSlider::updateThumbRect()
S32 thumb_width = mThumbImage ? mThumbImage->getWidth() : DEFAULT_THUMB_SIZE;
S32 thumb_height = mThumbImage ? mThumbImage->getHeight() : DEFAULT_THUMB_SIZE;
- S32 left_edge = (thumb_width / 2);
- S32 right_edge = getRect().getWidth() - (thumb_width / 2);
-
- S32 x = left_edge + S32( t * (right_edge - left_edge) );
- mThumbRect.mLeft = x - (thumb_width / 2);
- mThumbRect.mRight = mThumbRect.mLeft + thumb_width;
- mThumbRect.mBottom = getLocalRect().getCenterY() - (thumb_height / 2);
- mThumbRect.mTop = mThumbRect.mBottom + thumb_height;
+
+ if ( mOrientation == HORIZONTAL )
+ {
+ S32 left_edge = (thumb_width / 2);
+ S32 right_edge = getRect().getWidth() - (thumb_width / 2);
+
+ S32 x = left_edge + S32( t * (right_edge - left_edge) );
+ mThumbRect.mLeft = x - (thumb_width / 2);
+ mThumbRect.mRight = mThumbRect.mLeft + thumb_width;
+ mThumbRect.mBottom = getLocalRect().getCenterY() - (thumb_height / 2);
+ mThumbRect.mTop = mThumbRect.mBottom + thumb_height;
+ }
+ else
+ {
+ S32 top_edge = (thumb_height / 2);
+ S32 bottom_edge = getRect().getHeight() - (thumb_height / 2);
+
+ S32 y = top_edge + S32( t * (bottom_edge - top_edge) );
+ mThumbRect.mLeft = getLocalRect().getCenterX() - (thumb_width / 2);
+ mThumbRect.mRight = mThumbRect.mLeft + thumb_width;
+ mThumbRect.mBottom = y - (thumb_height / 2);
+ mThumbRect.mTop = mThumbRect.mBottom + thumb_height;
+ }
}
@@ -138,18 +159,32 @@ BOOL LLSlider::handleHover(S32 x, S32 y, MASK mask)
{
if( hasMouseCapture() )
{
- S32 thumb_half_width = mThumbImage->getWidth()/2;
- S32 left_edge = thumb_half_width;
- S32 right_edge = getRect().getWidth() - (thumb_half_width);
+ if ( mOrientation == HORIZONTAL )
+ {
+ S32 thumb_half_width = mThumbImage->getWidth()/2;
+ S32 left_edge = thumb_half_width;
+ S32 right_edge = getRect().getWidth() - (thumb_half_width);
- x += mMouseOffset;
- x = llclamp( x, left_edge, right_edge );
+ x += mMouseOffset;
+ x = llclamp( x, left_edge, right_edge );
- F32 t = F32(x - left_edge) / (right_edge - left_edge);
- setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue );
+ F32 t = F32(x - left_edge) / (right_edge - left_edge);
+ setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue );
+ }
+ else // mOrientation == VERTICAL
+ {
+ S32 thumb_half_height = mThumbImage->getHeight()/2;
+ S32 top_edge = thumb_half_height;
+ S32 bottom_edge = getRect().getHeight() - (thumb_half_height);
+
+ y += mMouseOffset;
+ y = llclamp(y, top_edge, bottom_edge);
+ F32 t = F32(y - top_edge) / (bottom_edge - top_edge);
+ setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue );
+ }
getWindow()->setCursor(UI_CURSOR_ARROW);
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl;
+ lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl;
}
else
{
@@ -198,7 +233,9 @@ BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask)
// Find the offset of the actual mouse location from the center of the thumb.
if (mThumbRect.pointInRect(x,y))
{
- mMouseOffset = (mThumbRect.mLeft + mThumbImage->getWidth()/2) - x;
+ mMouseOffset = (mOrientation == HORIZONTAL)
+ ? (mThumbRect.mLeft + mThumbImage->getWidth()/2) - x
+ : (mThumbRect.mBottom + mThumbImage->getHeight()/2) - y;
}
else
{
@@ -220,15 +257,12 @@ BOOL LLSlider::handleKeyHere(KEY key, MASK mask)
BOOL handled = FALSE;
switch(key)
{
- case KEY_UP:
case KEY_DOWN:
- // eat up and down keys to be consistent
- handled = TRUE;
- break;
case KEY_LEFT:
setValueAndCommit(getValueF32() - getIncrement());
handled = TRUE;
break;
+ case KEY_UP:
case KEY_RIGHT:
setValueAndCommit(getValueF32() + getIncrement());
handled = TRUE;
@@ -239,6 +273,17 @@ BOOL LLSlider::handleKeyHere(KEY key, MASK mask)
return handled;
}
+BOOL LLSlider::handleScrollWheel(S32 x, S32 y, S32 clicks)
+{
+ if ( mOrientation == VERTICAL )
+ {
+ F32 new_val = getValueF32() - clicks * getIncrement();
+ setValueAndCommit(new_val);
+ return TRUE;
+ }
+ return LLF32UICtrl::handleScrollWheel(x,y,clicks);
+}
+
void LLSlider::draw()
{
F32 alpha = getDrawContext().mAlpha;
@@ -252,13 +297,36 @@ void LLSlider::draw()
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
// Track
- LLRect track_rect(mThumbImage->getWidth() / 2,
- getLocalRect().getCenterY() + (mTrackImage->getHeight() / 2),
- getRect().getWidth() - mThumbImage->getWidth() / 2,
- getLocalRect().getCenterY() - (mTrackImage->getHeight() / 2) );
- LLRect highlight_rect(track_rect.mLeft, track_rect.mTop, mThumbRect.getCenterX(), track_rect.mBottom);
- mTrackImage->draw(track_rect, LLColor4::white % alpha);
- mTrackHighlightImage->draw(highlight_rect, LLColor4::white % alpha);
+ LLPointer<LLUIImage>& trackImage = ( mOrientation == HORIZONTAL )
+ ? mTrackImageHorizontal
+ : mTrackImageVertical;
+
+ LLPointer<LLUIImage>& trackHighlightImage = ( mOrientation == HORIZONTAL )
+ ? mTrackHighlightHorizontalImage
+ : mTrackHighlightVerticalImage;
+
+ LLRect track_rect;
+ LLRect highlight_rect;
+
+ if ( mOrientation == HORIZONTAL )
+ {
+ track_rect.set(mThumbImage->getWidth() / 2,
+ getLocalRect().getCenterY() + (trackImage->getHeight() / 2),
+ getRect().getWidth() - mThumbImage->getWidth() / 2,
+ getLocalRect().getCenterY() - (trackImage->getHeight() / 2) );
+ highlight_rect.set(track_rect.mLeft, track_rect.mTop, mThumbRect.getCenterX(), track_rect.mBottom);
+ }
+ else
+ {
+ track_rect.set(getLocalRect().getCenterX() - (trackImage->getWidth() / 2),
+ getRect().getHeight(),
+ getLocalRect().getCenterX() + (trackImage->getWidth() / 2),
+ 0);
+ highlight_rect.set(track_rect.mLeft, track_rect.mTop, track_rect.mRight, track_rect.mBottom);
+ }
+
+ trackImage->draw(track_rect, LLColor4::white % alpha);
+ trackHighlightImage->draw(highlight_rect, LLColor4::white % alpha);
// Thumb
if (hasFocus())
diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h
index e2a94e4d8c..6ab0ed7922 100644
--- a/indra/llui/llslider.h
+++ b/indra/llui/llslider.h
@@ -39,8 +39,12 @@
class LLSlider : public LLF32UICtrl
{
public:
+ enum ORIENTATION { HORIZONTAL, VERTICAL };
+
struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
{
+ Optional<std::string> orientation;
+
Optional<LLUIColor> track_color,
thumb_outline_color,
thumb_center_color;
@@ -48,8 +52,10 @@ public:
Optional<LLUIImage*> thumb_image,
thumb_image_pressed,
thumb_image_disabled,
- track_image,
- track_highlight_image;
+ track_image_horizontal,
+ track_image_vertical,
+ track_highlight_horizontal_image,
+ track_highlight_vertical_image;
Optional<CommitCallbackParam> mouse_down_callback,
mouse_up_callback;
@@ -77,6 +83,7 @@ public:
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleKeyHere(KEY key, MASK mask);
+ virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
virtual void draw();
private:
@@ -90,10 +97,14 @@ private:
LLPointer<LLUIImage> mThumbImage;
LLPointer<LLUIImage> mThumbImagePressed;
LLPointer<LLUIImage> mThumbImageDisabled;
- LLPointer<LLUIImage> mTrackImage;
- LLPointer<LLUIImage> mTrackHighlightImage;
+ LLPointer<LLUIImage> mTrackImageHorizontal;
+ LLPointer<LLUIImage> mTrackImageVertical;
+ LLPointer<LLUIImage> mTrackHighlightHorizontalImage;
+ LLPointer<LLUIImage> mTrackHighlightVerticalImage;
+
+ const ORIENTATION mOrientation;
- LLRect mThumbRect;
+ LLRect mThumbRect;
LLUIColor mTrackColor;
LLUIColor mThumbOutlineColor;
LLUIColor mThumbCenterColor;
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index d2c8558f0b..ca1688ad1f 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -3080,10 +3080,6 @@ void LLAgent::updateCamera()
mOrbitLeftKey > 0.f, // right
mOrbitDownKey > 0.f); // bottom
- camera_floater->mZoom->setToggleState(
- mOrbitInKey > 0.f, // top
- mOrbitOutKey > 0.f); // bottom
-
camera_floater->mTrack->setToggleState(
mPanLeftKey > 0.f, // left
mPanUpKey > 0.f, // top
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index d1317f7c36..92e958b32d 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -40,10 +40,12 @@
// Viewer includes
#include "lljoystickbutton.h"
#include "llviewercontrol.h"
+#include "llviewercamera.h"
#include "llbottomtray.h"
#include "llagent.h"
#include "lltoolmgr.h"
#include "lltoolfocus.h"
+#include "llslider.h"
// Constants
const F32 CAMERA_BUTTON_DELAY = 0.0f;
@@ -54,6 +56,93 @@ const F32 CAMERA_BUTTON_DELAY = 0.0f;
#define PRESETS "camera_presets"
#define CONTROLS "controls"
+// Zoom the camera in and out
+class LLPanelCameraZoom
+: public LLPanel
+{
+ LOG_CLASS(LLPanelCameraZoom);
+public:
+ LLPanelCameraZoom();
+
+ /* virtual */ BOOL postBuild();
+ /* virtual */ void onOpen(const LLSD& key);
+
+protected:
+ void onZoomPlusHeldDown();
+ void onZoomMinusHeldDown();
+ void onSliderValueChanged();
+
+private:
+ F32 mSavedSliderVal;
+ LLButton* mPlusBtn;
+ LLButton* mMinusBtn;
+ LLSlider* mSlider;
+};
+
+static LLRegisterPanelClassWrapper<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel");
+
+//-------------------------------------------------------------------------------
+// LLPanelCameraZoom
+//-------------------------------------------------------------------------------
+
+LLPanelCameraZoom::LLPanelCameraZoom()
+: mPlusBtn( NULL ),
+ mMinusBtn( NULL ),
+ mSlider( NULL ),
+ mSavedSliderVal(0.f)
+{
+ mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this));
+ mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this));
+ mCommitCallbackRegistrar.add("Slider.value_changed", boost::bind(&LLPanelCameraZoom::onSliderValueChanged, this));
+}
+
+BOOL LLPanelCameraZoom::postBuild()
+{
+ mPlusBtn = getChild <LLButton> ("zoom_plus_btn");
+ mMinusBtn = getChild <LLButton> ("zoom_minus_btn");
+ mSlider = getChild <LLSlider> ("zoom_slider");
+ mSlider->setMinValue(.0f);
+ mSlider->setMaxValue(8.f);
+ return LLPanel::postBuild();
+}
+
+void LLPanelCameraZoom::onOpen(const LLSD& key)
+{
+ LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - gAgent.calcFocusPositionTargetGlobal();
+ mSavedSliderVal = 8.f - (F32)to_focus.magVec(); // maximum minus current
+ mSlider->setValue( mSavedSliderVal );
+}
+
+void LLPanelCameraZoom::onZoomPlusHeldDown()
+{
+ F32 val = mSlider->getValueF32();
+ F32 inc = mSlider->getIncrement();
+ mSlider->setValue(val - inc);
+ // commit only if value changed
+ if (val != mSlider->getValueF32())
+ mSlider->onCommit();
+}
+
+void LLPanelCameraZoom::onZoomMinusHeldDown()
+{
+ F32 val = mSlider->getValueF32();
+ F32 inc = mSlider->getIncrement();
+ mSlider->setValue(val + inc);
+ // commit only if value changed
+ if (val != mSlider->getValueF32())
+ mSlider->onCommit();
+}
+
+void LLPanelCameraZoom::onSliderValueChanged()
+{
+ F32 val = mSlider->getValueF32();
+ F32 rate = val - mSavedSliderVal;
+
+ gAgent.unlockView();
+ gAgent.cameraOrbitIn(rate);
+
+ mSavedSliderVal = val;
+}
//
// Member functions
@@ -125,6 +214,7 @@ void LLFloaterCamera::onOpen(const LLSD& key)
anchor_panel, this,
getDockTongue(), LLDockControl::TOP));
+ mZoom->onOpen(key);
}
void LLFloaterCamera::onClose(bool app_quitting)
@@ -147,7 +237,7 @@ BOOL LLFloaterCamera::postBuild()
setIsChrome(TRUE);
mRotate = getChild<LLJoystickCameraRotate>(ORBIT);
- mZoom = getChild<LLJoystickCameraZoom>(ZOOM);
+ mZoom = getChild<LLPanelCameraZoom>(ZOOM);
mTrack = getChild<LLJoystickCameraTrack>(PAN);
assignButton2Mode(CAMERA_CTRL_MODE_ORBIT, "orbit_btn");
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index 583f279e62..4873a34e00 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -39,6 +39,7 @@ class LLJoystickCameraRotate;
class LLJoystickCameraZoom;
class LLJoystickCameraTrack;
class LLFloaterReg;
+class LLPanelCameraZoom;
enum ECameraControlMode
{
@@ -74,7 +75,7 @@ public:
virtual void onClose(bool app_quitting);
LLJoystickCameraRotate* mRotate;
- LLJoystickCameraZoom* mZoom;
+ LLPanelCameraZoom* mZoom;
LLJoystickCameraTrack* mTrack;
private:
diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml
index 5c09bc3a02..2af451400e 100644
--- a/indra/newview/skins/default/xui/en/floater_camera.xml
+++ b/indra/newview/skins/default/xui/en/floater_camera.xml
@@ -49,22 +49,57 @@
top="22"
visible="false"
width="78" />
- <!--TODO: replace with slider, + - images -->
- <joystick_zoom
- follows="top|left"
- height="78"
- image_unselected="ScrollThumb_Vert"
- layout="topleft"
- left="7"
- minus_image="ScrollThumb_Vert"
- name="zoom"
- plus_image="ScrollThumb_Vert"
- quadrant="left"
- scale_image="false"
- sound_flags="3"
- tool_tip="Zoom camera toward focus"
- top="22"
- width="20" />
+ <!--TODO: replace + - images -->
+ <panel
+ border="false"
+ class="camera_zoom_panel"
+ height="94"
+ layout="topleft"
+ left="7"
+ mouse_opaque="false"
+ name="zoom"
+ top="22"
+ width="18">
+ <button
+ follows="top|left"
+ height="18"
+ image_disabled="AddItem_Disabled"
+ image_selected="AddItem_Press"
+ image_unselected="AddItem_Off"
+ layout="topleft"
+ name="zoom_plus_btn"
+ width="18">
+ <commit_callback
+ function="Zoom.plus" />
+ <mouse_held_callback
+ function="Zoom.plus" />
+ </button>
+ <slider_bar
+ height="48"
+ layout="topleft"
+ name="zoom_slider"
+ orientation="vertical"
+ tool_tip="Zoom camera toward focus"
+ top_pad="0"
+ width="18">
+ <commit_callback function="Slider.value_changed"/>
+ </slider_bar>
+ <button
+ follows="top|left"
+ height="18"
+ image_disabled="AddItem_Disabled"
+ image_selected="AddItem_Press"
+ image_unselected="AddItem_Off"
+ layout="topleft"
+ name="zoom_minus_btn"
+ top_pad="0"
+ width="18">
+ <commit_callback
+ function="Zoom.minus" />
+ <mouse_held_callback
+ function="Zoom.minus" />
+ </button>
+ </panel>
<joystick_rotate
follows="top|left"
height="78"
@@ -80,7 +115,7 @@
tool_tip="Orbit camera around focus"
top="22"
width="78" />
- <panel
+ <panel
height="78"
layout="topleft"
left="36"
diff --git a/indra/newview/skins/default/xui/en/floater_test_slider.xml b/indra/newview/skins/default/xui/en/floater_test_slider.xml
index 57d8e686ce..86ff82e01f 100644
--- a/indra/newview/skins/default/xui/en/floater_test_slider.xml
+++ b/indra/newview/skins/default/xui/en/floater_test_slider.xml
@@ -57,6 +57,13 @@
width="200" />
<slider_bar
bottom="320"
+ height="100"
+ left="20"
+ name="slider_bar_vertical"
+ orientation="vertical"
+ width="20" />
+ <slider_bar
+ bottom="300"
height="20"
increment="1"
initial_value="2.0"
@@ -64,6 +71,7 @@
layout="topleft"
max_val="5"
min_val="1"
+ left_pad="20"
name="slider_bar"
width="300" />
<slider
diff --git a/indra/newview/skins/default/xui/en/widgets/slider_bar.xml b/indra/newview/skins/default/xui/en/widgets/slider_bar.xml
index bc1ca339a2..706c89f5ed 100644
--- a/indra/newview/skins/default/xui/en/widgets/slider_bar.xml
+++ b/indra/newview/skins/default/xui/en/widgets/slider_bar.xml
@@ -4,6 +4,8 @@
thumb_center_color="SliderThumbCenterColor"
thumb_image="SliderThumb_Off"
thumb_image_pressed="SliderThumb_Press"
- thumb_image_disabled="SliderThumb_Disabled"
- track_image="SliderTrack_Horiz"
- track_highlight_image="SliderTrack_Horiz" />
+ thumb_image_disabled="SliderThumb_Disabled"
+ track_image_horizontal="SliderTrack_Horiz"
+ track_image_vertical="SliderTrack_Vert"
+ track_highlight_horizontal_image="SliderTrack_Horiz"
+ track_highlight_vertical_image="SliderTrack_Vert" />