PageRenderTime 120ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llmultislider.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 128 lines | 82 code | 21 blank | 25 comment | 0 complexity | 4efd92902ed34a51b98ba6675095d6de MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llmultislider.h
  3. * @brief A simple multislider
  4. *
  5. * $LicenseInfo:firstyear=2007&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_MULTI_SLIDER_H
  27. #define LL_MULTI_SLIDER_H
  28. #include "llf32uictrl.h"
  29. #include "v4color.h"
  30. class LLUICtrlFactory;
  31. class LLMultiSlider : public LLF32UICtrl
  32. {
  33. public:
  34. struct SliderParams : public LLInitParam::Block<SliderParams>
  35. {
  36. Optional<std::string> name;
  37. Mandatory<F32> value;
  38. SliderParams();
  39. };
  40. struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
  41. {
  42. Optional<S32> max_sliders;
  43. Optional<bool> allow_overlap,
  44. draw_track,
  45. use_triangle;
  46. Optional<LLUIColor> track_color,
  47. thumb_disabled_color,
  48. thumb_outline_color,
  49. thumb_center_color,
  50. thumb_center_selected_color,
  51. triangle_color;
  52. Optional<CommitCallbackParam> mouse_down_callback,
  53. mouse_up_callback;
  54. Optional<S32> thumb_width;
  55. Multiple<SliderParams> sliders;
  56. Params();
  57. };
  58. protected:
  59. LLMultiSlider(const Params&);
  60. friend class LLUICtrlFactory;
  61. public:
  62. virtual ~LLMultiSlider();
  63. void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE);
  64. F32 getSliderValue(const std::string& name) const;
  65. const std::string& getCurSlider() const { return mCurSlider; }
  66. F32 getCurSliderValue() const { return getSliderValue(mCurSlider); }
  67. void setCurSlider(const std::string& name);
  68. void setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mCurSlider, val, from_event); }
  69. /*virtual*/ void setValue(const LLSD& value);
  70. /*virtual*/ LLSD getValue() const { return mValue; }
  71. boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
  72. boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb );
  73. bool findUnusedValue(F32& initVal);
  74. const std::string& addSlider();
  75. const std::string& addSlider(F32 val);
  76. void addSlider(F32 val, const std::string& name);
  77. void deleteSlider(const std::string& name);
  78. void deleteCurSlider() { deleteSlider(mCurSlider); }
  79. void clear();
  80. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  81. /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  82. /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  83. /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
  84. /*virtual*/ void draw();
  85. protected:
  86. LLSD mValue;
  87. std::string mCurSlider;
  88. static S32 mNameCounter;
  89. S32 mMaxNumSliders;
  90. BOOL mAllowOverlap;
  91. BOOL mDrawTrack;
  92. BOOL mUseTriangle; /// hacked in toggle to use a triangle
  93. S32 mMouseOffset;
  94. LLRect mDragStartThumbRect;
  95. S32 mThumbWidth;
  96. std::map<std::string, LLRect>
  97. mThumbRects;
  98. LLUIColor mTrackColor;
  99. LLUIColor mThumbOutlineColor;
  100. LLUIColor mThumbCenterColor;
  101. LLUIColor mThumbCenterSelectedColor;
  102. LLUIColor mDisabledThumbColor;
  103. LLUIColor mTriangleColor;
  104. commit_signal_t* mMouseDownSignal;
  105. commit_signal_t* mMouseUpSignal;
  106. };
  107. #endif // LL_MULTI_SLIDER_H