/indra/llui/lldockablefloater.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 151 lines · 51 code · 25 blank · 75 comment · 2 complexity · b78eafd5f3c8e3268188f346a8d053ee MD5 · raw file

  1. /**
  2. * @file lldockablefloater.h
  3. * @brief Creates a panel of a specific kind for a toast.
  4. *
  5. * $LicenseInfo:firstyear=2003&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_DOCKABLEFLOATER_H
  27. #define LL_DOCKABLEFLOATER_H
  28. #include "llerror.h"
  29. #include "llfloater.h"
  30. #include "lldockcontrol.h"
  31. /**
  32. * Represents floater that can dock.
  33. * In case impossibility deriving from LLDockableFloater use LLDockControl.
  34. */
  35. class LLDockableFloater : public LLFloater
  36. {
  37. static const U32 UNDOCK_LEAP_HEIGHT = 12;
  38. static void init(LLDockableFloater* thiz);
  39. public:
  40. LOG_CLASS(LLDockableFloater);
  41. LLDockableFloater(LLDockControl* dockControl, const LLSD& key,
  42. const Params& params = getDefaultParams());
  43. /**
  44. * Constructor.
  45. * @param dockControl a pointer to the doc control instance
  46. * @param uniqueDocking - a flag defines is docking should work as tab(at one
  47. * moment only one docked floater can be shown), also this flag defines is dock
  48. * tongue should be used.
  49. * @params key a floater key.
  50. * @params params a floater parameters
  51. */
  52. LLDockableFloater(LLDockControl* dockControl, bool uniqueDocking,
  53. const LLSD& key, const Params& params = getDefaultParams());
  54. /**
  55. * Constructor.
  56. * @param dockControl a pointer to the doc control instance
  57. * @param uniqueDocking - a flag defines is docking should work as tab(at one
  58. * moment only one docked floater can be shown).
  59. * @praram useTongue - a flag defines is dock tongue should be used.
  60. * @params key a floater key.
  61. * @params params a floater parameters
  62. */
  63. LLDockableFloater(LLDockControl* dockControl, bool uniqueDocking,
  64. bool useTongue, const LLSD& key,
  65. const Params& params = getDefaultParams());
  66. virtual ~LLDockableFloater();
  67. static LLHandle<LLFloater> getInstanceHandle() { return sInstanceHandle; }
  68. static void toggleInstance(const LLSD& sdname);
  69. /**
  70. * If descendant class overrides postBuild() in order to perform specific
  71. * construction then it must still invoke its superclass' implementation.
  72. */
  73. /* virtula */BOOL postBuild();
  74. /* virtual */void setDocked(bool docked, bool pop_on_undock = true);
  75. /* virtual */void draw();
  76. /**
  77. * If descendant class overrides setVisible() then it must still invoke its
  78. * superclass' implementation.
  79. */
  80. /*virtual*/ void setVisible(BOOL visible);
  81. /**
  82. * If descendant class overrides setMinimized() then it must still invoke its
  83. * superclass' implementation.
  84. */
  85. /*virtual*/ void setMinimized(BOOL minimize);
  86. LLView * getDockWidget();
  87. virtual void onDockHidden();
  88. virtual void onDockShown();
  89. LLDockControl* getDockControl();
  90. /**
  91. * Returns true if screen channel should consider floater's size when drawing toasts.
  92. *
  93. * By default returns false.
  94. */
  95. virtual bool overlapsScreenChannel() { return mOverlapsScreenChannel && getVisible() && isDocked(); }
  96. virtual void setOverlapsScreenChannel(bool overlaps) { mOverlapsScreenChannel = overlaps; }
  97. bool getUniqueDocking() { return mUniqueDocking; }
  98. bool getUseTongue() { return mUseTongue; }
  99. void setUseTongue(bool use_tongue) { mUseTongue = use_tongue;}
  100. private:
  101. /**
  102. * Provides unique of dockable floater.
  103. * If dockable floater already exists it should be closed.
  104. */
  105. void resetInstance();
  106. protected:
  107. void setDockControl(LLDockControl* dockControl);
  108. const LLUIImagePtr& getDockTongue(LLDockControl::DocAt dock_side = LLDockControl::TOP);
  109. // Checks if docking should be forced.
  110. // It may be useful e.g. if floater created in mouselook mode (see EXT-5609)
  111. boost::function<BOOL ()> mIsDockedStateForcedCallback;
  112. private:
  113. std::auto_ptr<LLDockControl> mDockControl;
  114. LLUIImagePtr mDockTongue;
  115. static LLHandle<LLFloater> sInstanceHandle;
  116. /**
  117. * Provides possibility to define that dockable floaters can be docked
  118. * non exclusively.
  119. */
  120. bool mUniqueDocking;
  121. bool mUseTongue;
  122. bool mOverlapsScreenChannel;
  123. // Force docking when the floater is being shown for the first time.
  124. bool mForceDocking;
  125. };
  126. #endif /* LL_DOCKABLEFLOATER_H */