PageRenderTime 30ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llcolorswatch.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 122 lines | 78 code | 16 blank | 28 comment | 0 complexity | 73260c22f38d2bbfb3e08941acc68430 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llcolorswatch.h
  3. * @brief LLColorSwatch class definition
  4. *
  5. * $LicenseInfo:firstyear=2001&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_LLCOLORSWATCH_H
  27. #define LL_LLCOLORSWATCH_H
  28. #include "lluictrl.h"
  29. #include "v4color.h"
  30. #include "llfloater.h"
  31. #include "llviewertexture.h"
  32. #include "lltextbox.h"
  33. //
  34. // Classes
  35. //
  36. class LLColor4;
  37. class LLTextBox;
  38. class LLFloaterColorPicker;
  39. class LLViewerTexture;
  40. class LLColorSwatchCtrl
  41. : public LLUICtrl
  42. {
  43. public:
  44. typedef enum e_color_pick_op
  45. {
  46. COLOR_CHANGE,
  47. COLOR_SELECT,
  48. COLOR_CANCEL
  49. } EColorPickOp;
  50. struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
  51. {
  52. Optional<LLUIColor> color;
  53. Optional<bool> can_apply_immediately;
  54. Optional<LLUIImage*> alpha_background_image;
  55. Optional<commit_callback_t> cancel_callback;
  56. Optional<commit_callback_t> select_callback;
  57. Optional<LLUIColor> border_color;
  58. Optional<S32> label_width;
  59. Optional<S32> label_height;
  60. Optional<LLTextBox::Params> caption_text;
  61. Optional<LLViewBorder::Params> border;
  62. Params();
  63. };
  64. protected:
  65. LLColorSwatchCtrl(const Params& p);
  66. friend class LLUICtrlFactory;
  67. public:
  68. ~LLColorSwatchCtrl ();
  69. /*virtual*/ void setValue(const LLSD& value);
  70. /*virtual*/ LLSD getValue() const { return mColor.getValue(); }
  71. const LLColor4& get() { return mColor; }
  72. void set(const LLColor4& color, BOOL update_picker = FALSE, BOOL from_event = FALSE);
  73. void setOriginal(const LLColor4& color);
  74. void setValid(BOOL valid);
  75. void setLabel(const std::string& label);
  76. void setLabelWidth(S32 label_width) {mLabelWidth =label_width;}
  77. void setCanApplyImmediately(BOOL apply) { mCanApplyImmediately = apply; }
  78. void setOnCancelCallback(commit_callback_t cb) { mOnCancelCallback = cb; }
  79. void setOnSelectCallback(commit_callback_t cb) { mOnSelectCallback = cb; }
  80. void setFallbackImageName(const std::string& name) { mFallbackImageName = name; }
  81. void showPicker(BOOL take_focus);
  82. /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  83. /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  84. /*virtual*/ BOOL handleDoubleClick(S32 x,S32 y,MASK mask);
  85. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  86. /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char);
  87. /*virtual*/ void draw();
  88. /*virtual*/ void setEnabled( BOOL enabled );
  89. static void onColorChanged ( void* data, EColorPickOp pick_op = COLOR_CHANGE );
  90. void closeFloaterColorPicker();
  91. protected:
  92. BOOL mValid;
  93. LLColor4 mColor;
  94. LLUIColor mBorderColor;
  95. LLTextBox* mCaption;
  96. LLHandle<LLFloater> mPickerHandle;
  97. LLViewBorder* mBorder;
  98. BOOL mCanApplyImmediately;
  99. commit_callback_t mOnCancelCallback;
  100. commit_callback_t mOnSelectCallback;
  101. S32 mLabelWidth;
  102. S32 mLabelHeight;
  103. LLPointer<LLUIImage> mAlphaGradientImage;
  104. std::string mFallbackImageName;
  105. };
  106. #endif // LL_LLBUTTON_H