PageRenderTime 22ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llslider.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 112 lines | 67 code | 19 blank | 26 comment | 0 complexity | 0d391358001a7eedc7ca00ef6b84c5e7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llslider.h
  3. * @brief A simple slider with no label.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLSLIDER_H
  27. #define LL_LLSLIDER_H
  28. #include "llf32uictrl.h"
  29. #include "v4color.h"
  30. #include "lluiimage.h"
  31. class LLSlider : public LLF32UICtrl
  32. {
  33. public:
  34. enum ORIENTATION { HORIZONTAL, VERTICAL };
  35. struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
  36. {
  37. Optional<std::string> orientation;
  38. Optional<LLUIColor> track_color,
  39. thumb_outline_color,
  40. thumb_center_color;
  41. Optional<LLUIImage*> thumb_image,
  42. thumb_image_pressed,
  43. thumb_image_disabled,
  44. track_image_horizontal,
  45. track_image_vertical,
  46. track_highlight_horizontal_image,
  47. track_highlight_vertical_image;
  48. Optional<CommitCallbackParam> mouse_down_callback,
  49. mouse_up_callback;
  50. Params();
  51. };
  52. protected:
  53. LLSlider(const Params&);
  54. friend class LLUICtrlFactory;
  55. public:
  56. virtual ~LLSlider();
  57. void setValue( F32 value, BOOL from_event = FALSE );
  58. // overrides for LLF32UICtrl methods
  59. virtual void setValue(const LLSD& value ) { setValue((F32)value.asReal(), TRUE); }
  60. virtual void setMinValue(const LLSD& min_value) { setMinValue((F32)min_value.asReal()); }
  61. virtual void setMaxValue(const LLSD& max_value) { setMaxValue((F32)max_value.asReal()); }
  62. virtual void setMinValue(F32 min_value) { LLF32UICtrl::setMinValue(min_value); updateThumbRect(); }
  63. virtual void setMaxValue(F32 max_value) { LLF32UICtrl::setMaxValue(max_value); updateThumbRect(); }
  64. boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
  65. boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb );
  66. virtual BOOL handleHover(S32 x, S32 y, MASK mask);
  67. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  68. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  69. virtual BOOL handleKeyHere(KEY key, MASK mask);
  70. virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
  71. virtual void draw();
  72. private:
  73. void setValueAndCommit(F32 value);
  74. void updateThumbRect();
  75. BOOL mVolumeSlider;
  76. S32 mMouseOffset;
  77. LLRect mDragStartThumbRect;
  78. LLPointer<LLUIImage> mThumbImage;
  79. LLPointer<LLUIImage> mThumbImagePressed;
  80. LLPointer<LLUIImage> mThumbImageDisabled;
  81. LLPointer<LLUIImage> mTrackImageHorizontal;
  82. LLPointer<LLUIImage> mTrackImageVertical;
  83. LLPointer<LLUIImage> mTrackHighlightHorizontalImage;
  84. LLPointer<LLUIImage> mTrackHighlightVerticalImage;
  85. const ORIENTATION mOrientation;
  86. LLRect mThumbRect;
  87. LLUIColor mTrackColor;
  88. LLUIColor mThumbOutlineColor;
  89. LLUIColor mThumbCenterColor;
  90. commit_signal_t* mMouseDownSignal;
  91. commit_signal_t* mMouseUpSignal;
  92. };
  93. #endif // LL_LLSLIDER_H