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

/indra/llui/llscrollcontainer.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 142 lines | 82 code | 22 blank | 38 comment | 0 complexity | 4668b0229179bc9e0eb5a66405ddc728 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llscrollcontainer.h
  3. * @brief LLScrollContainer class header file.
  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_LLSCROLLCONTAINER_H
  27. #define LL_LLSCROLLCONTAINER_H
  28. #include "lluictrl.h"
  29. #ifndef LL_V4COLOR_H
  30. #include "v4color.h"
  31. #endif
  32. #include "stdenums.h"
  33. #include "llcoord.h"
  34. #include "llscrollbar.h"
  35. class LLViewBorder;
  36. class LLUICtrlFactory;
  37. /*****************************************************************************
  38. *
  39. * A decorator view class meant to encapsulate a clipped region which is
  40. * scrollable. It automatically takes care of pixel perfect scrolling
  41. * and cliipping, as well as turning the scrollbars on or off based on
  42. * the width and height of the view you're scrolling.
  43. *
  44. *****************************************************************************/
  45. struct ScrollContainerRegistry : public LLChildRegistry<ScrollContainerRegistry>
  46. {};
  47. class LLScrollContainer : public LLUICtrl
  48. {
  49. public:
  50. // Note: vertical comes before horizontal because vertical
  51. // scrollbars have priority for mouse and keyboard events.
  52. enum SCROLL_ORIENTATION { VERTICAL, HORIZONTAL, SCROLLBAR_COUNT };
  53. struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
  54. {
  55. Optional<bool> is_opaque,
  56. reserve_scroll_corner,
  57. border_visible,
  58. hide_scrollbar;
  59. Optional<F32> min_auto_scroll_rate,
  60. max_auto_scroll_rate;
  61. Optional<LLUIColor> bg_color;
  62. Optional<LLScrollbar::callback_t> scroll_callback;
  63. Params();
  64. };
  65. // my valid children are stored in this registry
  66. typedef ScrollContainerRegistry child_registry_t;
  67. protected:
  68. LLScrollContainer(const Params&);
  69. friend class LLUICtrlFactory;
  70. public:
  71. virtual ~LLScrollContainer( void );
  72. virtual void setValue(const LLSD& value) { mInnerRect.setValue(value); }
  73. void setBorderVisible( BOOL b );
  74. void scrollToShowRect( const LLRect& rect, const LLRect& constraint);
  75. void scrollToShowRect( const LLRect& rect) { scrollToShowRect(rect, LLRect(0, mInnerRect.getHeight(), mInnerRect.getWidth(), 0)); }
  76. void setReserveScrollCorner( BOOL b ) { mReserveScrollCorner = b; }
  77. LLRect getVisibleContentRect();
  78. LLRect getContentWindowRect();
  79. const LLRect& getScrolledViewRect() const { return mScrolledView ? mScrolledView->getRect() : LLRect::null; }
  80. void pageUp(S32 overlap = 0);
  81. void pageDown(S32 overlap = 0);
  82. void goToTop();
  83. void goToBottom();
  84. bool isAtTop() { return mScrollbar[VERTICAL]->isAtBeginning(); }
  85. bool isAtBottom() { return mScrollbar[VERTICAL]->isAtEnd(); }
  86. S32 getBorderWidth() const;
  87. // LLView functionality
  88. virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
  89. virtual BOOL handleKeyHere(KEY key, MASK mask);
  90. virtual BOOL handleUnicodeCharHere(llwchar uni_char);
  91. virtual BOOL handleScrollWheel( S32 x, S32 y, S32 clicks );
  92. virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
  93. EDragAndDropType cargo_type,
  94. void* cargo_data,
  95. EAcceptance* accept,
  96. std::string& tooltip_msg);
  97. virtual void draw();
  98. virtual bool addChild(LLView* view, S32 tab_group = 0);
  99. bool autoScroll(S32 x, S32 y);
  100. private:
  101. // internal scrollbar handlers
  102. virtual void scrollHorizontal( S32 new_pos );
  103. virtual void scrollVertical( S32 new_pos );
  104. void updateScroll();
  105. void calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const;
  106. LLScrollbar* mScrollbar[SCROLLBAR_COUNT];
  107. LLView* mScrolledView;
  108. S32 mSize;
  109. BOOL mIsOpaque;
  110. LLUIColor mBackgroundColor;
  111. LLRect mInnerRect;
  112. LLViewBorder* mBorder;
  113. BOOL mReserveScrollCorner;
  114. BOOL mAutoScrolling;
  115. F32 mAutoScrollRate;
  116. F32 mMinAutoScrollRate;
  117. F32 mMaxAutoScrollRate;
  118. bool mHideScrollbar;
  119. };
  120. #endif // LL_LLSCROLLCONTAINER_H