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

/indra/llui/llmultisliderctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 152 lines | 91 code | 32 blank | 29 comment | 1 complexity | 28bac77ce100efe577c4742298fb0da7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llmultisliderctrl.h
  3. * @brief LLMultiSliderCtrl base class
  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_SLIDERCTRL_H
  27. #define LL_MULTI_SLIDERCTRL_H
  28. #include "llf32uictrl.h"
  29. #include "v4color.h"
  30. #include "llmultislider.h"
  31. #include "lltextbox.h"
  32. #include "llrect.h"
  33. //
  34. // Classes
  35. //
  36. class LLFontGL;
  37. class LLLineEditor;
  38. class LLSlider;
  39. class LLMultiSliderCtrl : public LLF32UICtrl
  40. {
  41. public:
  42. struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
  43. {
  44. Optional<S32> label_width,
  45. text_width;
  46. Optional<bool> show_text,
  47. can_edit_text;
  48. Optional<S32> decimal_digits;
  49. Optional<S32> max_sliders;
  50. Optional<bool> allow_overlap,
  51. draw_track,
  52. use_triangle;
  53. Optional<LLUIColor> text_color,
  54. text_disabled_color;
  55. Optional<CommitCallbackParam> mouse_down_callback,
  56. mouse_up_callback;
  57. Multiple<LLMultiSlider::SliderParams> sliders;
  58. Params();
  59. };
  60. protected:
  61. LLMultiSliderCtrl(const Params&);
  62. friend class LLUICtrlFactory;
  63. public:
  64. virtual ~LLMultiSliderCtrl();
  65. F32 getSliderValue(const std::string& name) const;
  66. void setSliderValue(const std::string& name, F32 v, BOOL from_event = FALSE);
  67. virtual void setValue(const LLSD& value );
  68. virtual LLSD getValue() const { return mMultiSlider->getValue(); }
  69. virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
  70. const std::string& getCurSlider() const { return mMultiSlider->getCurSlider(); }
  71. F32 getCurSliderValue() const { return mCurValue; }
  72. void setCurSlider(const std::string& name);
  73. void setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mMultiSlider->getCurSlider(), val, from_event); }
  74. virtual void setMinValue(const LLSD& min_value) { setMinValue((F32)min_value.asReal()); }
  75. virtual void setMaxValue(const LLSD& max_value) { setMaxValue((F32)max_value.asReal()); }
  76. BOOL isMouseHeldDown();
  77. virtual void setEnabled( BOOL b );
  78. virtual void clear();
  79. virtual void setPrecision(S32 precision);
  80. void setMinValue(F32 min_value) {mMultiSlider->setMinValue(min_value);}
  81. void setMaxValue(F32 max_value) {mMultiSlider->setMaxValue(max_value);}
  82. void setIncrement(F32 increment) {mMultiSlider->setIncrement(increment);}
  83. /// for adding and deleting sliders
  84. const std::string& addSlider();
  85. const std::string& addSlider(F32 val);
  86. void deleteSlider(const std::string& name);
  87. void deleteCurSlider() { deleteSlider(mMultiSlider->getCurSlider()); }
  88. F32 getMinValue() const { return mMultiSlider->getMinValue(); }
  89. F32 getMaxValue() const { return mMultiSlider->getMaxValue(); }
  90. void setLabel(const std::string& label) { if (mLabelBox) mLabelBox->setText(label); }
  91. void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; }
  92. void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; }
  93. boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb );
  94. boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb );
  95. virtual void onTabInto();
  96. virtual void setTentative(BOOL b); // marks value as tentative
  97. virtual void onCommit(); // mark not tentative, then commit
  98. virtual void setControlName(const std::string& control_name, LLView* context);
  99. static void onSliderCommit(LLUICtrl* caller, const LLSD& userdata);
  100. static void onEditorCommit(LLUICtrl* ctrl, const LLSD& userdata);
  101. static void onEditorGainFocus(LLFocusableElement* caller, void *userdata);
  102. static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
  103. private:
  104. void updateText();
  105. void reportInvalidData();
  106. private:
  107. const LLFontGL* mFont;
  108. BOOL mShowText;
  109. BOOL mCanEditText;
  110. S32 mPrecision;
  111. LLTextBox* mLabelBox;
  112. S32 mLabelWidth;
  113. F32 mCurValue;
  114. LLMultiSlider* mMultiSlider;
  115. LLLineEditor* mEditor;
  116. LLTextBox* mTextBox;
  117. LLUIColor mTextEnabledColor;
  118. LLUIColor mTextDisabledColor;
  119. };
  120. #endif // LL_MULTI_SLIDERCTRL_H