PageRenderTime 40ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/lldraghandle.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 139 lines | 87 code | 23 blank | 29 comment | 0 complexity | 1419b696af7e28141c30c18c3bd3effd MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lldraghandle.h
  3. * @brief LLDragHandle base class
  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. // A widget for dragging a view around the screen using the mouse.
  27. #ifndef LL_DRAGHANDLE_H
  28. #define LL_DRAGHANDLE_H
  29. #include "llview.h"
  30. #include "v4color.h"
  31. #include "llrect.h"
  32. #include "llcoord.h"
  33. class LLTextBox;
  34. class LLDragHandle : public LLView
  35. {
  36. public:
  37. struct Params
  38. : public LLInitParam::Block<Params, LLView::Params>
  39. {
  40. Optional<std::string> label;
  41. Optional<LLUIColor> drag_highlight_color;
  42. Optional<LLUIColor> drag_shadow_color;
  43. Params()
  44. : label("label"),
  45. drag_highlight_color("drag_highlight_color", LLUIColorTable::instance().getColor("DefaultHighlightLight")),
  46. drag_shadow_color("drag_shadow_color", LLUIColorTable::instance().getColor("DefaultShadowDark"))
  47. {
  48. changeDefault(mouse_opaque, true);
  49. changeDefault(follows.flags, FOLLOWS_ALL);
  50. }
  51. };
  52. void initFromParams(const Params&);
  53. virtual ~LLDragHandle();
  54. virtual void setValue(const LLSD& value);
  55. void setForeground(BOOL b) { mForeground = b; }
  56. BOOL getForeground() const { return mForeground; }
  57. void setMaxTitleWidth(S32 max_width) {mMaxTitleWidth = llmin(max_width, mMaxTitleWidth); }
  58. S32 getMaxTitleWidth() const { return mMaxTitleWidth; }
  59. void setButtonsRect(const LLRect& rect){ mButtonsRect = rect; }
  60. LLRect getButtonsRect() { return mButtonsRect; }
  61. void setTitleVisible(BOOL visible);
  62. virtual void setTitle( const std::string& title ) = 0;
  63. virtual std::string getTitle() const = 0;
  64. virtual BOOL handleHover(S32 x, S32 y, MASK mask);
  65. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  66. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  67. protected:
  68. LLDragHandle(const Params&);
  69. friend class LLUICtrlFactory;
  70. protected:
  71. LLTextBox* mTitleBox;
  72. private:
  73. LLRect mButtonsRect;
  74. S32 mDragLastScreenX;
  75. S32 mDragLastScreenY;
  76. S32 mLastMouseScreenX;
  77. S32 mLastMouseScreenY;
  78. LLCoordGL mLastMouseDir;
  79. LLUIColor mDragHighlightColor;
  80. LLUIColor mDragShadowColor;
  81. S32 mMaxTitleWidth;
  82. BOOL mForeground;
  83. // Pixels near the edge to snap floaters.
  84. static S32 sSnapMargin;
  85. };
  86. // Use this one for traditional top-of-window draggers
  87. class LLDragHandleTop
  88. : public LLDragHandle
  89. {
  90. protected:
  91. LLDragHandleTop(const Params& p) : LLDragHandle(p) {}
  92. friend class LLUICtrlFactory;
  93. public:
  94. virtual void setTitle( const std::string& title );
  95. virtual std::string getTitle() const;
  96. virtual void draw();
  97. virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
  98. private:
  99. void reshapeTitleBox();
  100. };
  101. // Use this for left-side, vertical text draggers
  102. class LLDragHandleLeft
  103. : public LLDragHandle
  104. {
  105. protected:
  106. LLDragHandleLeft(const Params& p) : LLDragHandle(p) {}
  107. friend class LLUICtrlFactory;
  108. public:
  109. virtual void setTitle( const std::string& title );
  110. virtual std::string getTitle() const;
  111. virtual void draw();
  112. virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
  113. };
  114. const S32 DRAG_HANDLE_HEIGHT = 16;
  115. const S32 DRAG_HANDLE_WIDTH = 16;
  116. #endif // LL_DRAGHANDLE_H