Newer
Older
Steven Bennetts
committed
* @brief LLTabContainer class
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
Richard Nelson
committed
Richard Nelson
committed
Richard Nelson
committed
#include "lllocalcliprect.h"
#include "llrect.h"
#include "llresizehandle.h"
#include "lltextbox.h"
#include "llcriticaldamp.h"
#include "lluictrlfactory.h"
#include "llrender.h"
#include "llfloater.h"
Leyla Farazha
committed
#include "lltrans.h"
//----------------------------------------------------------------------------
// Implementation Notes:
// - Each tab points to a LLPanel (see LLTabTuple below)
// - When a tab is selected, the validation callback
// (LLUICtrl::mValidateSignal) is called
// - If the validation callback returns true (or none is provided),
// the tab is changed and the commit callback
// (LLUICtrl::mCommitSignal) is called
// - Callbacks pass the LLTabContainer as the control,
// and the NAME of the selected PANEL as the LLSD data
//----------------------------------------------------------------------------
const F32 SCROLL_DELAY_TIME = 0.5f;
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
void LLTabContainer::TabPositions::declareValues()
{
declare("top", LLTabContainer::TOP);
declare("bottom", LLTabContainer::BOTTOM);
declare("left", LLTabContainer::LEFT);
}
//----------------------------------------------------------------------------
// Structure used to map tab buttons to and from tab panels
class LLTabTuple
{
public:
LLTabTuple( LLTabContainer* c, LLPanel* p, LLButton* b, LLTextBox* placeholder = NULL)
:
mTabContainer(c),
mTabPanel(p),
mButton(b),
mOldState(FALSE),
mPlaceholderText(placeholder),
mPadding(0)
{}
LLTabContainer* mTabContainer;
LLPanel* mTabPanel;
LLButton* mButton;
BOOL mOldState;
LLTextBox* mPlaceholderText;
S32 mPadding;
};
//----------------------------------------------------------------------------
struct LLPlaceHolderPanel : public LLPanel
{
// create dummy param block to register with "placeholder" nane
struct Params : public LLPanel::Params{};
LLPlaceHolderPanel(const Params& p) : LLPanel(p)
{}
};
James Cook
committed
static LLDefaultChildRegistry::Register<LLPlaceHolderPanel> r1("placeholder");
static LLDefaultChildRegistry::Register<LLTabContainer> r2("tab_container");
LLTabContainer::TabParams::TabParams()
: tab_top_image_unselected("tab_top_image_unselected"),
tab_top_image_selected("tab_top_image_selected"),
tab_bottom_image_unselected("tab_bottom_image_unselected"),
tab_bottom_image_selected("tab_bottom_image_selected"),
tab_left_image_unselected("tab_left_image_unselected"),
tab_left_image_selected("tab_left_image_selected")
{}
LLTabContainer::Params::Params()
: tab_width("tab_width"),
tab_min_width("tab_min_width"),
tab_max_width("tab_max_width"),
tab_height("tab_height"),
tab_position("tab_position"),
hide_tabs("hide_tabs", false),
James Cook
committed
tab_padding_right("tab_padding_right"),
first_tab("first_tab"),
middle_tab("middle_tab"),
last_tab("last_tab")
{
name(std::string("tab_container"));
mouse_opaque = false;
}
LLTabContainer::LLTabContainer(const LLTabContainer::Params& p)
: LLPanel(p),
mTabsHidden(p.hide_tabs),
mScrolled(FALSE),
mScrollPos(0),
mScrollPosPixels(0),
mMaxScrollPos(0),
mTitleBox(NULL),
mTopBorderHeight(LLPANEL_BORDER_WIDTH),
Steven Bennetts
committed
mLockedTabCount(0),
mMinTabWidth(0),
mMaxTabWidth(p.tab_max_width),
mTabHeight(p.tab_height),
Steven Bennetts
committed
mPrevArrowBtn(NULL),
mNextArrowBtn(NULL),
mIsVertical( p.tab_position == LEFT ),
Steven Bennetts
committed
// Horizontal Specific
mJumpPrevArrowBtn(NULL),
mJumpNextArrowBtn(NULL),
mRightTabBtnOffset(p.tab_padding_right),
mTotalTabWidth(0),
mTabPosition(p.tab_position),
Leyla Farazha
committed
mFont(p.font),
mFirstTabParams(p.first_tab),
mMiddleTabParams(p.middle_tab),
mLastTabParams(p.last_tab)
{
static LLUICachedControl<S32> tabcntr_vert_tab_min_width ("UITabCntrVertTabMinWidth", 0);
mDragAndDropDelayTimer.stop();
if (p.tab_width.isProvided())
{
mMinTabWidth = p.tab_width;
}
else if (!mIsVertical)
Steven Bennetts
committed
{
mMinTabWidth = p.tab_min_width;
Steven Bennetts
committed
}
else
{
// *HACK: support default min width for legacy vertical
// tab containers
mMinTabWidth = tabcntr_vert_tab_min_width;
}
Steven Bennetts
committed
initButtons( );
Steven Bennetts
committed
LLTabContainer::~LLTabContainer()
{
std::for_each(mTabList.begin(), mTabList.end(), DeletePointer());
}
Steven Bennetts
committed
//virtual
void LLTabContainer::setValue(const LLSD& value)
Steven Bennetts
committed
selectTab((S32) value.asInteger());
}
//virtual
void LLTabContainer::reshape(S32 width, S32 height, BOOL called_from_parent)
Steven Bennetts
committed
LLPanel::reshape( width, height, called_from_parent );
updateMaxScrollPos();
Loading
Loading full blame...