llchatbar.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * @file llchatbar.h
  3. * @brief LLChatBar class definition
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLCHATBAR_H
  33. #define LL_LLCHATBAR_H
  34. #include "llpanel.h"
  35. #include "llframetimer.h"
  36. #include "llchat.h"
  37. #include "llviewercontrol.h"
  38. class LLButton;
  39. class LLChatBarGestureObserver;
  40. class LLComboBox;
  41. class LLFlyoutButton;
  42. class LLFrameTimer;
  43. class LLLineEditor;
  44. class LLUICtrl;
  45. constexpr S32 CHAT_BAR_HEIGHT = 28;
  46. class LLChatBar final : public LLPanel
  47. {
  48. protected:
  49. LOG_CLASS(LLChatBar);
  50. public:
  51. LLChatBar(const std::string& name);
  52. LLChatBar(const std::string& name, const LLRect& rect);
  53. ~LLChatBar() override;
  54. bool postBuild() override;
  55. void reshape(S32 width, S32 height, bool called_from_parent) override;
  56. void refresh() override;
  57. bool handleKeyHere(KEY key, MASK mask) override;
  58. // Adjust buttons and input field for width
  59. void layout();
  60. void refreshGestures();
  61. // Move cursor into chat input field.
  62. void setKeyboardFocus(bool b);
  63. // Ignore arrow keys for chat bar
  64. void setIgnoreArrowKeys(bool b);
  65. bool hasTextEditor();
  66. bool inputEditorHasFocus();
  67. std::string getCurrentChat();
  68. // Since chat bar logic is reused for chat history gesture combo box might
  69. // not be a direct child
  70. void setGestureCombo(LLComboBox* combo);
  71. // Send a chat (after stripping /20foo channel chats). "animate" triggers
  72. // the nodding, whispering or shouting animations.
  73. void sendChatFromViewer(LLWString wtext, EChatType type, bool animate,
  74. bool lua_propagate = true);
  75. void sendChatFromViewer(const std::string& utf8text, EChatType type,
  76. bool animate, bool lua_propagate = true);
  77. // If input of the form "/20foo" or "/20 foo", returns "foo" and channel
  78. // 20. Otherwise returns input and channel 0.
  79. LLWString stripChannelNumber(const LLWString& mesg, S32* channel);
  80. static void startChat(const char* line);
  81. static void stopChat();
  82. static std::string getMatchingAvatarName(const std::string& match);
  83. private:
  84. void setVisible(bool visible) override;
  85. void sendChat(EChatType type);
  86. void updateChat();
  87. static void toggleChatHistory(void*);
  88. static void onClickSay(LLUICtrl*, void* userdata);
  89. static void onClickOpenTextEditor(void* userdata);
  90. static void onTabClick(void* userdata);
  91. static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata);
  92. static void onInputEditorScrolled(LLLineEditor* caller, void* userdata);
  93. static void onInputEditorFocusLost(LLFocusableElement* caller, void*);
  94. static void onInputEditorGainFocus(LLFocusableElement* caller, void*);
  95. static void onCommitGesture(LLUICtrl* ctrl, void* data);
  96. private:
  97. LLButton* mOpenTextEditorButton;
  98. LLButton* mHistoryButton;
  99. LLComboBox* mGestureCombo;
  100. LLFlyoutButton* mSayFlyoutButton;
  101. LLLineEditor* mInputEditor;
  102. LLFrameTimer mGestureLabelTimer;
  103. // Which non-zero channel did we last chat on?
  104. S32 mLastSpecialChatChannel;
  105. LLChatBarGestureObserver* mObserver;
  106. bool mSecondary;
  107. bool mIsBuilt;
  108. bool mHasScrolledOnce;
  109. bool mLastSwappedShortcuts;
  110. typedef std::set<std::string> av_names_list_t;
  111. static av_names_list_t sIgnoredNames;
  112. public:
  113. static bool sSwappedShortcuts;
  114. };
  115. extern LLChatBar* gChatBarp;
  116. #endif