From 888b39c283e53fd128778e70e231bcb6053de4b8 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 8 Jun 2011 13:14:15 -0700 Subject: EXP-865 PROGRESS -- Modify LLBadge to allow it to hang off of non-buttons Moved LLBadge use from LLButton into a separate LLBadgeOwner class. LLButton now derives from LLBadgeOwner which handles the bulk of the badge management. --- indra/llui/llbadgeowner.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 indra/llui/llbadgeowner.cpp (limited to 'indra/llui/llbadgeowner.cpp') diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp new file mode 100644 index 0000000000..c77cf21ae0 --- /dev/null +++ b/indra/llui/llbadgeowner.cpp @@ -0,0 +1,116 @@ +/** + * @file llbadgeowner.cpp + * @brief Class to manage badges attached to a UI control + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llbadgeowner.h" +#include "llpanel.h" + +// +// Classes +// + +LLBadgeOwner::LLBadgeOwner(LLHandle ctrlHandle) + : mBadge(NULL) + , mBadgeOwnerCtrl(ctrlHandle) +{ +} + +void LLBadgeOwner::initBadgeParams(const LLBadge::Params& p) +{ + if (!p.equals(LLUICtrlFactory::getDefaultParams())) + { + mBadge = createBadge(p); + } +} + +void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) +{ + if (mBadge == NULL) + { + mBadge = createBadge(LLUICtrlFactory::getDefaultParams()); + + addBadgeToParentPanel(); + } + + if (mBadge) + { + mBadge->setLabel(label); + + // + // Push the badge to the front so it renders on top + // + + LLUICtrl * parent = mBadge->getParentUICtrl(); + + if (parent) + { + parent->sendChildToFront(mBadge); + } + } +} + +void LLBadgeOwner::addBadgeToParentPanel() +{ + if (mBadge && mBadgeOwnerCtrl.get()) + { + // Find the appropriate parent panel for the badge + + LLUICtrl * owner_ctrl = mBadgeOwnerCtrl.get(); + LLUICtrl * parent = owner_ctrl->getParentUICtrl(); + + LLPanel * parentPanel = NULL; + + while (parent) + { + parentPanel = dynamic_cast(parent); + + if (parentPanel && parentPanel->acceptsBadge()) + { + break; + } + + parent = parent->getParentUICtrl(); + } + + if (parentPanel) + { + parentPanel->addChild(mBadge); + } + else + { + llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on ui control " << owner_ctrl->getName() << llendl; + } + } +} + +LLBadge* LLBadgeOwner::createBadge(const LLBadge::Params& p) +{ + LLBadge::Params badge_params(p); + badge_params.owner = mBadgeOwnerCtrl; + + return LLUICtrlFactory::create(badge_params); +} -- cgit v1.2.3 From def85f2778d9b69bc3fb0e89c1cef854a1c01886 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 9 Jun 2011 12:12:28 -0700 Subject: EXP-865 FIX -- Modify LLBadge to allow it to hang off of non-buttons LLBadgeOwner now only depends on LLView instead of LLUICtrl Sidebar Tab Buttons now can support badges Reviewed by Leyla --- indra/llui/llbadgeowner.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'indra/llui/llbadgeowner.cpp') diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp index c77cf21ae0..11f1463b9b 100644 --- a/indra/llui/llbadgeowner.cpp +++ b/indra/llui/llbadgeowner.cpp @@ -33,9 +33,9 @@ // Classes // -LLBadgeOwner::LLBadgeOwner(LLHandle ctrlHandle) +LLBadgeOwner::LLBadgeOwner(LLHandle< LLView > viewHandle) : mBadge(NULL) - , mBadgeOwnerCtrl(ctrlHandle) + , mBadgeOwnerView(viewHandle) { } @@ -64,7 +64,7 @@ void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) // Push the badge to the front so it renders on top // - LLUICtrl * parent = mBadge->getParentUICtrl(); + LLView * parent = mBadge->getParent(); if (parent) { @@ -75,34 +75,34 @@ void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) void LLBadgeOwner::addBadgeToParentPanel() { - if (mBadge && mBadgeOwnerCtrl.get()) + LLView * owner_view = mBadgeOwnerView.get(); + + if (mBadge && owner_view) { // Find the appropriate parent panel for the badge - LLUICtrl * owner_ctrl = mBadgeOwnerCtrl.get(); - LLUICtrl * parent = owner_ctrl->getParentUICtrl(); - - LLPanel * parentPanel = NULL; + LLView * parent = owner_view->getParent(); + LLPanel * parent_panel = NULL; while (parent) { - parentPanel = dynamic_cast(parent); + parent_panel = dynamic_cast(parent); - if (parentPanel && parentPanel->acceptsBadge()) + if (parent_panel && parent_panel->acceptsBadge()) { break; } - parent = parent->getParentUICtrl(); + parent = parent->getParent(); } - if (parentPanel) + if (parent_panel) { - parentPanel->addChild(mBadge); + parent_panel->addChild(mBadge); } else { - llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on ui control " << owner_ctrl->getName() << llendl; + llwarns << "Unable to find parent panel for badge " << mBadge->getName() << " on " << owner_view->getName() << llendl; } } } @@ -110,7 +110,7 @@ void LLBadgeOwner::addBadgeToParentPanel() LLBadge* LLBadgeOwner::createBadge(const LLBadge::Params& p) { LLBadge::Params badge_params(p); - badge_params.owner = mBadgeOwnerCtrl; + badge_params.owner = mBadgeOwnerView; return LLUICtrlFactory::create(badge_params); } -- cgit v1.2.3 From 3eeb14ee0abb5720e010d94eba52db09fa32237e Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 10 Jun 2011 16:20:30 -0700 Subject: EXP-856 FIX -- Inbox item count reflected as badge on inventory button * Modified badges to be parented to their owners if their owners have no parents * Modified side tray tab panels to create badges on side tab buttons when the xml specifies a badge. * Modified inbox to drive the badge value of the sidebar_inventory button. * Updated inbox and outbox sizes so scroll bars function as expected * Updated inventory_panel.xml to allow scroll tag to specify scroll bar properties, instead of just having them hardcoded. Reviewed by Richard --- indra/llui/llbadgeowner.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'indra/llui/llbadgeowner.cpp') diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp index 11f1463b9b..3d63fc7f60 100644 --- a/indra/llui/llbadgeowner.cpp +++ b/indra/llui/llbadgeowner.cpp @@ -79,26 +79,28 @@ void LLBadgeOwner::addBadgeToParentPanel() if (mBadge && owner_view) { - // Find the appropriate parent panel for the badge + // Badge parent is badge owner by default + LLView * badge_parent = owner_view; + // Find the appropriate parent for the badge LLView * parent = owner_view->getParent(); - LLPanel * parent_panel = NULL; while (parent) { - parent_panel = dynamic_cast(parent); + LLPanel * parent_panel = dynamic_cast(parent); if (parent_panel && parent_panel->acceptsBadge()) { + badge_parent = parent; break; } parent = parent->getParent(); } - if (parent_panel) + if (badge_parent) { - parent_panel->addChild(mBadge); + badge_parent->addChild(mBadge); } else { -- cgit v1.2.3 From 2f21ec48a222662351c9f8e7243673eb6a31b457 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 5 Jul 2011 12:32:12 -0700 Subject: EXP-860 FIX -- Display NEW for items added to inbox * Added createFolderView, createFolderViewFolder and createFolderViewItem virtuals to LLInventoryPanel so these can be overridden by a derived class for custom display. * Added new LLInboxInventoryPanel class that overrides createFolderViewFolder with a LLInboxFolderViewFolder for custom display with NEW tags. * LLInboxFolderViewFolder NEW tag is tied to the mFresh variable that currently has no logic attached to it, meaning it remains off all the time. Reviewed by Richard. --- indra/llui/llbadgeowner.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/llui/llbadgeowner.cpp') diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp index 3d63fc7f60..77f15567bf 100644 --- a/indra/llui/llbadgeowner.cpp +++ b/indra/llui/llbadgeowner.cpp @@ -73,6 +73,14 @@ void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) } } +void LLBadgeOwner::setBadgeVisibility(bool visible) +{ + if (mBadge) + { + mBadge->setVisible(visible); + } +} + void LLBadgeOwner::addBadgeToParentPanel() { LLView * owner_view = mBadgeOwnerView.get(); -- cgit v1.2.3