PageRenderTime 38ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llsaveoutfitcombobtn.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 92 lines | 50 code | 13 blank | 29 comment | 3 complexity | fc33dfc41cfff60da60f513e8e5ed49e MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llsaveoutfitcombobtn.cpp
  3. * @brief Represents outfit save/save as combo button.
  4. *
  5. * $LicenseInfo:firstyear=2010&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 "llviewerprecompiledheaders.h"
  27. #include "llappearancemgr.h"
  28. #include "llpaneloutfitsinventory.h"
  29. #include "llsidepanelappearance.h"
  30. #include "llsaveoutfitcombobtn.h"
  31. #include "llviewermenu.h"
  32. static const std::string SAVE_BTN("save_btn");
  33. static const std::string SAVE_FLYOUT_BTN("save_flyout_btn");
  34. LLSaveOutfitComboBtn::LLSaveOutfitComboBtn(LLPanel* parent, bool saveAsDefaultAction):
  35. mParent(parent), mSaveAsDefaultAction(saveAsDefaultAction)
  36. {
  37. // register action mapping before creating menu
  38. LLUICtrl::CommitCallbackRegistry::ScopedRegistrar save_registar;
  39. save_registar.add("Outfit.Save.Action", boost::bind(
  40. &LLSaveOutfitComboBtn::saveOutfit, this, false));
  41. save_registar.add("Outfit.SaveAs.Action", boost::bind(
  42. &LLSaveOutfitComboBtn::saveOutfit, this, true));
  43. mParent->childSetAction(SAVE_BTN, boost::bind(&LLSaveOutfitComboBtn::saveOutfit, this, mSaveAsDefaultAction));
  44. mParent->childSetAction(SAVE_FLYOUT_BTN, boost::bind(&LLSaveOutfitComboBtn::showSaveMenu, this));
  45. mSaveMenu = LLUICtrlFactory::getInstance()->createFromFile<
  46. LLToggleableMenu> ("menu_save_outfit.xml", gMenuHolder,
  47. LLViewerMenuHolderGL::child_registry_t::instance());
  48. }
  49. void LLSaveOutfitComboBtn::showSaveMenu()
  50. {
  51. S32 x, y;
  52. LLUI::getMousePositionLocal(mParent, &x, &y);
  53. mSaveMenu->updateParent(LLMenuGL::sMenuContainer);
  54. LLMenuGL::showPopup(mParent, mSaveMenu, x, y);
  55. }
  56. void LLSaveOutfitComboBtn::saveOutfit(bool as_new)
  57. {
  58. if (!as_new && LLAppearanceMgr::getInstance()->updateBaseOutfit())
  59. {
  60. // we don't need to ask for an outfit name, and updateBaseOutfit() successfully saved.
  61. // If updateBaseOutfit fails, ask for an outfit name anyways
  62. return;
  63. }
  64. LLPanelOutfitsInventory* panel_outfits_inventory =
  65. LLPanelOutfitsInventory::findInstance();
  66. if (panel_outfits_inventory)
  67. {
  68. panel_outfits_inventory->onSave();
  69. }
  70. //*TODO how to get to know when base outfit is updated or new outfit is created?
  71. }
  72. void LLSaveOutfitComboBtn::setMenuItemEnabled(const std::string& item, bool enabled)
  73. {
  74. mSaveMenu->setItemEnabled("save_outfit", enabled);
  75. }
  76. void LLSaveOutfitComboBtn::setSaveBtnEnabled(bool enabled)
  77. {
  78. mParent->getChildView(SAVE_BTN)->setEnabled(enabled);
  79. }