summaryrefslogtreecommitdiff
path: root/indra/newview/llchiclet.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llchiclet.h')
-rw-r--r--indra/newview/llchiclet.h584
1 files changed, 479 insertions, 105 deletions
diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h
index ceda61adea..e467ec012a 100644
--- a/indra/newview/llchiclet.h
+++ b/indra/newview/llchiclet.h
@@ -33,134 +33,333 @@
#ifndef LL_LLCHICLET_H
#define LL_LLCHICLET_H
+#include "llavatariconctrl.h"
#include "llpanel.h"
+#include "lltextbox.h"
+#include "lloutputmonitorctrl.h"
-class LLTextBox;
-class LLIconCtrl;
-class LLAvatarIconCtrl;
class LLVoiceControlPanel;
-class LLOutputMonitorCtrl;
+class LLMenuGL;
+/*
+ * Class for displaying amount of messages/notifications(unread).
+*/
+class LLChicletNotificationCounterCtrl : public LLTextBox
+{
+public:
+
+ struct Params : public LLInitParam::Block<Params, LLTextBox::Params>
+ {
+ Params()
+ {};
+ };
+
+ /*
+ * Sets number of notifications
+ */
+ virtual void setCounter(S32 counter);
+
+ /*
+ * Returns number of notifications
+ */
+ virtual S32 getCounter() const { return mCounter; }
+
+ /*
+ * Returns width, required to display amount of notifications in text form.
+ * Width is the only valid value.
+ */
+ /*virtual*/ LLRect getRequiredRect();
+
+ /*
+ * Sets number of notifications using LLSD
+ */
+ /*virtual*/ void setValue(const LLSD& value);
+
+ /*
+ * Returns number of notifications wrapped in LLSD
+ */
+ /*virtual*/ LLSD getValue() const;
+
+protected:
+
+ LLChicletNotificationCounterCtrl(const Params& p);
+ friend class LLUICtrlFactory;
+
+private:
+
+ S32 mCounter;
+ S32 mInitialWidth;
+};
+
+/*
+ * Class for displaying avatar's icon.
+*/
+class LLChicletAvatarIconCtrl : public LLAvatarIconCtrl
+{
+public:
+
+ struct Params : public LLInitParam::Block<Params, LLAvatarIconCtrl::Params>
+ {
+ Params()
+ {
+ draw_tooltip(FALSE);
+ mouse_opaque(FALSE);
+ };
+ };
+
+protected:
+
+ LLChicletAvatarIconCtrl(const Params& p);
+ friend class LLUICtrlFactory;
+};
+
+/*
+ * Class for displaying status of Voice Chat
+*/
+class LLChicletSpeakerCtrl : public LLIconCtrl
+{
+public:
+
+ struct Params : public LLInitParam::Block<Params, LLIconCtrl::Params>
+ {
+ Params(){};
+ };
+protected:
+
+ LLChicletSpeakerCtrl(const Params&p);
+ friend class LLUICtrlFactory;
+};
+
+/*
+ * Base class for all chiclets.
+ */
class LLChiclet : public LLUICtrl
{
public:
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
{
- Params(){};
+ Optional<bool> show_counter;
+
+ Params();
};
- virtual ~LLChiclet();
+ /*virtual*/ ~LLChiclet();
+
+ /*
+ * Associates chat session id with chiclet.
+ */
+ virtual void setSessionId(const LLUUID& session_id) { mSessionId = session_id; }
+ /*
+ * Returns associated chat session.
+ */
+ virtual const LLUUID& getSessionId() const { return mSessionId; }
+
+ /*
+ * Sets number of unread notifications.
+ */
virtual void setCounter(S32 counter) = 0;
+ /*
+ * Returns number of unread notifications.
+ */
virtual S32 getCounter() = 0;
- virtual void setShowCounter(bool show) {mShowCounter = show;};
+ /*
+ * Sets show counter state.
+ */
+ virtual void setShowCounter(bool show) { mShowCounter = show; }
+ /*
+ * Returns show counter state.
+ */
virtual bool getShowCounter() {return mShowCounter;};
- virtual boost::signals2::connection setLeftButtonClickCallback(
+ /*
+ * Connects chiclet clicked event with callback.
+ */
+ /*virtual*/ boost::signals2::connection setLeftButtonClickCallback(
const commit_callback_t& cb);
+ typedef boost::function<void (LLChiclet* ctrl, const LLSD& param)>
+ chiclet_size_changed_callback_t;
+
+ /*
+ * Connects chiclets size changed event with callback.
+ */
+ virtual boost::signals2::connection setChicletSizeChangedCallback(
+ const chiclet_size_changed_callback_t& cb);
+
+ /*
+ * Sets IM Session id using LLSD
+ */
+ /*virtual*/ LLSD getValue() const;
+
+ /*
+ * Returns IM Session id using LLSD
+ */
+ /*virtual*/ void setValue(const LLSD& value);
+
protected:
friend class LLUICtrlFactory;
LLChiclet(const Params& p);
- virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+ /*
+ * Notifies subscribers about click on chiclet.
+ */
+ /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+
+ /*
+ * Notifies subscribers about chiclet size changed event.
+ */
+ virtual void onChicletSizeChanged();
+
+private:
+
+ LLUUID mSessionId;
-protected:
- S32 mCounter;
bool mShowCounter;
+
+ typedef boost::signals2::signal<void (LLChiclet* ctrl, const LLSD& param)>
+ chiclet_size_changed_signal_t;
+
+ chiclet_size_changed_signal_t mChicletSizeChangedSignal;
};
+/*
+* Implements Instant Message chiclet.
+* IMChiclet displays avatar's icon, number of unread messages(optional)
+* and voice chat status(optional).
+*/
class LLIMChiclet : public LLChiclet
{
public:
- static LLChiclet* create(const LLUUID& im_session_id = LLUUID::null);
-
- void setCounter(S32);
-
- S32 getCounter() {return mCounter;};
-
- const LLUUID& getIMSessionId() const {return mIMSessionId;};
+ struct Params : public LLInitParam::Block<Params, LLChiclet::Params>
+ {
+ Optional<LLChicletAvatarIconCtrl::Params> avatar_icon;
- void setIMSessionId(const LLUUID& im_session_id) { mIMSessionId = im_session_id; }
- void setIMSessionName(const std::string& name);
- void setOtherParticipantId(const LLUUID& other_participant_id);
+ Optional<LLChicletNotificationCounterCtrl::Params> unread_notifications;
- void setShowSpeaker(bool show);
+ Optional<LLChicletSpeakerCtrl::Params> speaker;
- bool getShowSpeaker() {return mShowSpeaker;};
+ Optional<bool> show_speaker;
- enum SpeakerStatus
- {
- SPREAKER_ACTIVE,
- SPEAKER_IDLE
+ Params();
};
- void setSpeakerStatus(SpeakerStatus status);
-
- SpeakerStatus getSpeakerStatus() {return mSpeakerStatus;};
-
- ~LLIMChiclet();
+ /*virtual*/ ~LLIMChiclet();
+
+ /*
+ * Sets IM session name. This name will be displayed in chiclet tooltip.
+ */
+ virtual void setIMSessionName(const std::string& name);
+
+ /*
+ * Sets id of person/group user is chatting with.
+ */
+ virtual void setOtherParticipantId(const LLUUID& other_participant_id);
+
+ /*
+ * Shows/hides voice chat status control.
+ */
+ virtual void setShowSpeaker(bool show);
+
+ /*
+ * Returns voice chat status control visibility.
+ */
+ virtual bool getShowSpeaker() {return mShowSpeaker;};
+
+ /*
+ * Sets number of unread messages. Will update chiclet's width if number text
+ * exceeds size of counter and notify it's parent about size change.
+ */
+ /*virtual*/ void setCounter(S32);
+
+ /*
+ * Returns number of unread messages.
+ */
+ /*virtual*/ S32 getCounter() { return mCounterCtrl->getCounter(); }
+
+ /*
+ * Shows/hides number of unread messages.
+ */
+ /*virtual*/ void setShowCounter(bool show);
+
+ /*
+ * Draws border around chiclet.
+ */
+ /*virtual*/ void draw();
+
+ /*
+ * Returns rect, required to display chiclet.
+ * Width is the only valid value.
+ */
+ /*virtual*/ LLRect getRequiredRect();
protected:
- LLIMChiclet(const LLChiclet::Params& p);
- friend class LLUICtrlFactory;
- S32 calcCounterWidth();
+ LLIMChiclet(const Params& p);
+ friend class LLUICtrlFactory;
- //overrides
-public:
+ /*
+ * Creates chiclet popup menu. Will create P2P or Group IM Chat menu
+ * based on other participant's id.
+ */
+ virtual void createPopupMenu();
- void setShowCounter(bool show);
+ /*
+ * Processes clicks on chiclet popup menu.
+ */
+ virtual void onMenuItemClicked(const LLSD& user_data);
- void draw();
+ /*
+ * Enables/disables menus based on relationship with other participant.
+ */
+ virtual void updateMenuItems();
- LLRect getRequiredRect();
+ /*
+ * Displays popup menu.
+ */
+ /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
protected:
- LLAvatarIconCtrl* mAvatar;
- LLTextBox* mCounterText;
- LLIconCtrl* mSpeaker;
+ LLChicletAvatarIconCtrl* mAvatarCtrl;
+ LLChicletNotificationCounterCtrl* mCounterCtrl;
+ LLChicletSpeakerCtrl* mSpeakerCtrl;
+
+ LLMenuGL* mPopupMenu;
- LLUUID mIMSessionId;
bool mShowSpeaker;
- SpeakerStatus mSpeakerStatus;
};
+/*
+ * Implements notification chiclet. Used to display total amount of unread messages
+ * across all IM sessions, total amount of system notifications.
+*/
class LLNotificationChiclet : public LLChiclet
{
public:
struct Params : public LLInitParam::Block<Params, LLChiclet::Params>
{
- Optional<LLUIImage*>
- image_unselected,
- image_selected,
- image_hover_selected,
- image_hover_unselected,
- image_disabled_selected,
- image_disabled,
- image_overlay;
-
- Optional<S32>
- label_left;
+ Optional<LLButton::Params> button;
+
+ Optional<LLChicletNotificationCounterCtrl::Params> unread_notifications;
Params();
};
- static LLChiclet* create(const Params& p);
+ /*virtual*/ void setCounter(S32 counter);
- void setCounter(S32 counter);
+ /*virtual*/S32 getCounter() { return mCounterCtrl->getCounter(); }
- S32 getCounter() {return mCounter;};
+ /*virtual*/ void setShowCounter(bool show);
boost::signals2::connection setClickCallback(const commit_callback_t& cb);
- virtual ~ LLNotificationChiclet();
+ /*virtual*/ ~ LLNotificationChiclet();
protected:
LLNotificationChiclet(const Params& p);
@@ -168,112 +367,223 @@ protected:
protected:
LLButton* mButton;
- LLTextBox* mCounterText;
+ LLChicletNotificationCounterCtrl* mCounterCtrl;
};
+/*
+ * Storage class for all IM chiclets. Provides mechanism to display,
+ * scroll, create, remove chiclets.
+*/
class LLChicletPanel : public LLPanel
{
public:
struct Params : public LLInitParam::Block<Params, LLPanel::Params>
{
- Params(){};
- };
+ Optional<S32> chiclet_padding,
+ scrolling_offset;
- ~LLChicletPanel();
+ Optional<LLButton::Params> left_scroll_button,
+ right_scroll_button;
- LLChiclet* createChiclet(const LLUUID& im_session_id = LLUUID::null, S32 pos = 0);
+ Params();
+ };
- bool addChiclet(LLChiclet*, S32 pos);
+ virtual ~LLChicletPanel();
- LLChiclet* getChiclet(S32 pos);
+ /*
+ * Creates chiclet and adds it to chiclet list.
+ */
+ template<class T> T* createChiclet(const LLUUID& session_id = LLUUID::null, S32 index = 0);
- LLChiclet* findIMChiclet(const LLUUID& im_session_id);
+ /*
+ * Returns pointer to chiclet of specified type at specified index.
+ */
+ template<class T> T* getChiclet(S32 index);
- S32 getChicletCount() {return mChicletList.size();};
+ /*
+ * Returns pointer to LLChiclet at specified index.
+ */
+ LLChiclet* getChiclet(S32 index) { return getChiclet<LLChiclet>(index); }
- void removeChiclet(S32 pos);
+ /*
+ * Searches a chiclet using IM session id.
+ */
+ template<class T> T* findChiclet(const LLUUID& im_session_id);
- void removeChiclet(LLChiclet*);
-
- void removeIMChiclet(const LLUUID& im_session_id);
+ /*
+ * Returns number of hosted chiclets.
+ */
+ S32 getChicletCount() {return mChicletList.size();};
+ /*
+ * Returns index of chiclet in list.
+ */
+ S32 getChicletIndex(const LLChiclet* chiclet);
+
+ /*
+ * Removes chiclet by index.
+ */
+ void removeChiclet(S32 index);
+
+ /*
+ * Removes chiclet by pointer.
+ */
+ void removeChiclet(LLChiclet* chiclet);
+
+ /*
+ * Removes chiclet by IM session id.
+ */
+ void removeChiclet(const LLUUID& im_session_id);
+
+ /*
+ * Removes all chiclets.
+ */
void removeAll();
- void scrollLeft();
-
- void scrollRight();
-
- void onLeftScrollClick();
-
- void onRightScrollClick();
-
- boost::signals2::connection setChicletClickCallback(
+ boost::signals2::connection setChicletClickedCallback(
const commit_callback_t& cb);
- void onChicletClick(LLUICtrl*ctrl,const LLSD&param);
-
- //overrides
-public:
/*virtual*/ BOOL postBuild();
- void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE );
+ /*
+ * Reshapes controls and rearranges chiclets if needed.
+ */
+ /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE );
- void draw();
+ /*virtual*/ void draw();
protected:
LLChicletPanel(const Params&p);
friend class LLUICtrlFactory;
+ /*
+ * Adds chiclet to list and rearranges all chiclets.
+ */
+ bool addChiclet(LLChiclet*, S32 index);
+
+ /*
+ * Arranges chiclets.
+ */
void arrange();
+ /*
+ * Returns true if chiclets can be scrolled right.
+ */
bool canScrollRight();
+ /*
+ * Returns true if chiclets can be scrolled left.
+ */
bool canScrollLeft();
+ /*
+ * Shows or hides chiclet scroll buttons if chiclets can or can not be scrolled.
+ */
void showScrollButtonsIfNeeded();
- S32 getFirstVisibleChiclet();
+ /*
+ * Shifts chiclets left or right.
+ */
+ void shiftChiclets(S32 offset, S32 start_index = 0);
+
+ /*
+ * Removes gaps between first chiclet and scroll area left side,
+ * last chiclet and scroll area right side.
+ */
+ void trimChiclets();
+
+ /*
+ * Scrolls chiclets to right or left.
+ */
+ void scroll(S32 offset);
+
+ /*
+ * Verifies that chiclets can be scrolled left, then calls scroll()
+ */
+ void scrollLeft();
- void reshapeScrollArea(S32 delta_width);
+ /*
+ * Verifies that chiclets can be scrolled right, then calls scroll()
+ */
+ void scrollRight();
- enum ScrollDirection
- {
- SCROLL_LEFT = 1,
- SCROLL_RIGHT = -1
- };
+ /*
+ * Callback for left scroll button clicked
+ */
+ void onLeftScrollClick();
+
+ /*
+ * Callback for right scroll button clicked
+ */
+ void onRightScrollClick();
- void scroll(ScrollDirection direction);
+ /*
+ * Callback for mouse wheel scrolled, calls scrollRight() or scrollLeft()
+ */
+ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
+
+ /*
+ * Notifies subscribers about click on chiclet.
+ * Do not place any code here, instead subscribe on event (see setChicletClickedCallback).
+ */
+ void onChicletClick(LLUICtrl*ctrl,const LLSD&param);
+
+ /*
+ * Callback for chiclet size changed event, rearranges chiclets.
+ */
+ void onChicletSizeChanged(LLChiclet* ctrl, const LLSD& param);
typedef std::vector<LLChiclet*> chiclet_list_t;
+ /*
+ * Removes chiclet from scroll area and chiclet list.
+ */
void removeChiclet(chiclet_list_t::iterator it);
- BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
+ S32 getChicletPadding() { return mChicletPadding; }
+
+ S32 getScrollingOffset() { return mScrollingOffset; }
protected:
chiclet_list_t mChicletList;
- LLButton* mLeftScroll;
- LLButton* mRightScroll;
+ LLButton* mLeftScrollButton;
+ LLButton* mRightScrollButton;
LLPanel* mScrollArea;
-};
+ S32 mChicletPadding;
+ S32 mScrollingOffset;
+};
+/*
+ * Button displaying voice chat status. Displays voice chat options When clicked.
+*/
class LLTalkButton : public LLUICtrl
{
public:
- virtual ~LLTalkButton();
+ struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
+ {
+ Optional<LLButton::Params> speak_button,
+ show_button;
- void onClick_SpeakBtn();
- void onClick_ShowBtn();
+ Optional<LLOutputMonitorCtrl::Params> monitor;
- void draw();
+ Params();
+ };
+
+ /*virtual*/ ~LLTalkButton();
+
+ /*virtual*/ void draw();
protected:
friend class LLUICtrlFactory;
- LLTalkButton(const LLUICtrl::Params& p);
+ LLTalkButton(const Params& p);
+
+ void onClick_SpeakBtn();
+
+ void onClick_ShowBtn();
private:
LLButton* mSpeakBtn;
@@ -282,4 +592,68 @@ private:
LLOutputMonitorCtrl* mOutputMonitor;
};
+template<class T>
+T* LLChicletPanel::createChiclet(const LLUUID& session_id /*= LLUUID::null*/, S32 index /*= 0*/)
+{
+ typename T::Params params;
+ T* chiclet = LLUICtrlFactory::create<T>(params);
+ if(!chiclet)
+ {
+ llwarns << "Could not create chiclet" << llendl;
+ return NULL;
+ }
+ if(!addChiclet(chiclet, index))
+ {
+ delete chiclet;
+ llwarns << "Could not add chiclet to chiclet panel" << llendl;
+ return NULL;
+ }
+
+ chiclet->setSessionId(session_id);
+
+ return chiclet;
+}
+
+template<class T>
+T* LLChicletPanel::findChiclet(const LLUUID& im_session_id)
+{
+ if(im_session_id.isNull())
+ {
+ return NULL;
+ }
+
+ chiclet_list_t::const_iterator it = mChicletList.begin();
+ for( ; mChicletList.end() != it; ++it)
+ {
+ LLChiclet* chiclet = *it;
+
+ if(chiclet->getSessionId() == im_session_id)
+ {
+ T* result = dynamic_cast<T*>(chiclet);
+ if(!result && chiclet)
+ {
+ llwarns << "Found chiclet but of wrong type " << llendl;
+ }
+ return result;
+ }
+ }
+ return NULL;
+}
+
+template<class T> T* LLChicletPanel::getChiclet(S32 index)
+{
+ if(index < 0 || index >= getChicletCount())
+ {
+ return NULL;
+ }
+
+ LLChiclet* chiclet = mChicletList[index];
+ T*result = dynamic_cast<T*>(chiclet);
+ if(!result && chiclet)
+ {
+ llwarns << "Found chiclet but of wrong type " << llendl;
+ }
+ return result;
+}
+
#endif // LL_LLCHICLET_H