/indra/newview/llnavigationbar.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 153 lines · 91 code · 23 blank · 39 comment · 1 complexity · 6ee65e0fa972bf94cd29b5d0c3773882 MD5 · raw file

  1. /**
  2. * @file llnavigationbar.h
  3. * @brief Navigation bar definition
  4. *
  5. * $LicenseInfo:firstyear=2009&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_LLNAVIGATIONBAR_H
  27. #define LL_LLNAVIGATIONBAR_H
  28. #include "llpanel.h"
  29. #include "llbutton.h"
  30. class LLLocationInputCtrl;
  31. class LLMenuGL;
  32. class LLSearchEditor;
  33. class LLSearchComboBox;
  34. /**
  35. * This button is able to handle click-dragging mouse event.
  36. * It has appropriated signal for this event.
  37. * Dragging direction can be set from xml attribute called 'direction'
  38. *
  39. * *TODO: move to llui?
  40. */
  41. class LLPullButton: public LLButton
  42. {
  43. LOG_CLASS(LLPullButton);
  44. public:
  45. struct Params: public LLInitParam::Block<Params, LLButton::Params>
  46. {
  47. Optional<std::string> direction; // left, right, down, up
  48. Params()
  49. : direction("direction", "down")
  50. {
  51. }
  52. };
  53. /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  54. /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  55. /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
  56. boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb);
  57. protected:
  58. friend class LLUICtrlFactory;
  59. // convert string name into direction vector
  60. void setDirectionFromName(const std::string& name);
  61. LLPullButton(const LLPullButton::Params& params);
  62. commit_signal_t mClickDraggingSignal;
  63. LLVector2 mLastMouseDown;
  64. LLVector2 mDraggingDirection;
  65. };
  66. /**
  67. * Web browser-like navigation bar.
  68. */
  69. class LLNavigationBar
  70. : public LLPanel, public LLSingleton<LLNavigationBar>, private LLDestroyClass<LLNavigationBar>
  71. {
  72. LOG_CLASS(LLNavigationBar);
  73. friend class LLDestroyClass<LLNavigationBar>;
  74. public:
  75. LLNavigationBar();
  76. virtual ~LLNavigationBar();
  77. /*virtual*/ void draw();
  78. /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
  79. /*virtual*/ BOOL postBuild();
  80. /*virtual*/ void setVisible(BOOL visible);
  81. void handleLoginComplete();
  82. void clearHistoryCache();
  83. int getDefNavBarHeight();
  84. int getDefFavBarHeight();
  85. private:
  86. // the distance between navigation panel and favorites panel in pixels
  87. const static S32 FAVBAR_TOP_PADDING = 10;
  88. void rebuildTeleportHistoryMenu();
  89. void showTeleportHistoryMenu(LLUICtrl* btn_ctrl);
  90. void invokeSearch(std::string search_text);
  91. // callbacks
  92. void onTeleportHistoryMenuItemClicked(const LLSD& userdata);
  93. void onTeleportHistoryChanged();
  94. void onBackButtonClicked();
  95. void onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param);
  96. void onNavigationButtonHeldUp(LLButton* nav_button);
  97. void onForwardButtonClicked();
  98. void onHomeButtonClicked();
  99. void onLocationSelection();
  100. void onLocationPrearrange(const LLSD& data);
  101. void onTeleportFinished(const LLVector3d& global_agent_pos);
  102. void onTeleportFailed();
  103. void onRegionNameResponse(
  104. std::string typed_location,
  105. std::string region_name,
  106. LLVector3 local_coords,
  107. U64 region_handle, const std::string& url,
  108. const LLUUID& snapshot_id, bool teleport);
  109. static void destroyClass()
  110. {
  111. if (LLNavigationBar::instanceExists())
  112. {
  113. LLNavigationBar::getInstance()->setEnabled(FALSE);
  114. }
  115. }
  116. LLMenuGL* mTeleportHistoryMenu;
  117. LLPullButton* mBtnBack;
  118. LLPullButton* mBtnForward;
  119. LLButton* mBtnHome;
  120. LLLocationInputCtrl* mCmbLocation;
  121. LLRect mDefaultNbRect;
  122. LLRect mDefaultFpRect;
  123. boost::signals2::connection mTeleportFailedConnection;
  124. boost::signals2::connection mTeleportFinishConnection;
  125. boost::signals2::connection mHistoryMenuConnection;
  126. bool mPurgeTPHistoryItems;
  127. // if true, save location to location history when teleport finishes
  128. bool mSaveToLocationHistory;
  129. };
  130. #endif