PageRenderTime 25ms CodeModel.GetById 14ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #include "linden_common.h"
  27. // file includes
  28. #include "llflyoutbutton.h"
  29. //static LLDefaultChildRegistry::Register<LLFlyoutButton> r2("flyout_button");
  30. const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24;
  31. LLFlyoutButton::LLFlyoutButton(const Params& p)
  32. : LLComboBox(p),
  33. mToggleState(FALSE),
  34. mActionButton(NULL)
  35. {
  36. // Always use text box
  37. // Text label button
  38. LLButton::Params bp(p.action_button);
  39. bp.name(p.label);
  40. bp.label(p.label);
  41. bp.rect.left(0).bottom(0).width(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH).height(getRect().getHeight());
  42. bp.click_callback.function(boost::bind(&LLFlyoutButton::onActionButtonClick, this, _2));
  43. bp.follows.flags(FOLLOWS_ALL);
  44. mActionButton = LLUICtrlFactory::create<LLButton>(bp);
  45. addChild(mActionButton);
  46. }
  47. void LLFlyoutButton::onActionButtonClick(const LLSD& data)
  48. {
  49. // remember last list selection?
  50. mList->deselect();
  51. onCommit();
  52. }
  53. void LLFlyoutButton::draw()
  54. {
  55. mActionButton->setToggleState(mToggleState);
  56. mButton->setToggleState(mToggleState);
  57. //FIXME: this should be an attribute of comboboxes, whether they have a distinct label or
  58. // the label reflects the last selected item, for now we have to manually remove the label
  59. setLabel(LLStringUtil::null);
  60. LLComboBox::draw();
  61. }
  62. void LLFlyoutButton::setToggleState(BOOL state)
  63. {
  64. mToggleState = state;
  65. }