PageRenderTime 33ms CodeModel.GetById 13ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llflyoutbutton.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 77 lines | 33 code | 12 blank | 32 comment | 0 complexity | 97abce9fd39b60f33e3ff9aca59fe931 MD5 | raw file
 1/** 
 2 * @file llflyoutbutton.cpp
 3 * @brief LLFlyoutButton base class
 4 *
 5 * $LicenseInfo:firstyear=2001&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
27#include "linden_common.h"
28
29// file includes
30#include "llflyoutbutton.h"
31
32//static LLDefaultChildRegistry::Register<LLFlyoutButton> r2("flyout_button");
33
34const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24;
35
36LLFlyoutButton::LLFlyoutButton(const Params& p)
37:	LLComboBox(p),
38	mToggleState(FALSE),
39	mActionButton(NULL)
40{
41	// Always use text box 
42	// Text label button
43	LLButton::Params bp(p.action_button);
44	bp.name(p.label);
45	bp.label(p.label);
46	bp.rect.left(0).bottom(0).width(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH).height(getRect().getHeight());
47	bp.click_callback.function(boost::bind(&LLFlyoutButton::onActionButtonClick, this, _2));
48	bp.follows.flags(FOLLOWS_ALL);
49
50	mActionButton = LLUICtrlFactory::create<LLButton>(bp);
51	addChild(mActionButton);
52}
53
54void LLFlyoutButton::onActionButtonClick(const LLSD& data)
55{
56	// remember last list selection?
57	mList->deselect();
58	onCommit();
59}
60
61void LLFlyoutButton::draw()
62{
63	mActionButton->setToggleState(mToggleState);
64	mButton->setToggleState(mToggleState);
65
66	//FIXME: this should be an attribute of comboboxes, whether they have a distinct label or
67	// the label reflects the last selected item, for now we have to manually remove the label
68	setLabel(LLStringUtil::null);
69	LLComboBox::draw();	
70}
71
72void LLFlyoutButton::setToggleState(BOOL state)
73{
74	mToggleState = state;
75}
76
77