From 17c0da930f3acda8320a134e5e9cbd077b1f95c4 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Mon, 4 Mar 2019 18:12:02 -0500 Subject: [PATCH] Spawn the menu on button click TODO: Make a derived button that uses this showMenu function instead So we can finally have menu buttons like upstream --- indra/newview/llfloatermarketplacelistings.cpp | 13 +++++++++++++ indra/newview/llfloatermarketplacelistings.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/indra/newview/llfloatermarketplacelistings.cpp b/indra/newview/llfloatermarketplacelistings.cpp index 79ef2b70c..1a410847d 100644 --- a/indra/newview/llfloatermarketplacelistings.cpp +++ b/indra/newview/llfloatermarketplacelistings.cpp @@ -59,10 +59,23 @@ LLPanelMarketplaceListings::LLPanelMarketplaceListings() mEnableCallbackRegistrar.add("Marketplace.ViewSort.CheckItem", boost::bind(&LLPanelMarketplaceListings::onViewSortMenuItemCheck, this, _2)); } +LLPanelMarketplaceListings::~LLPanelMarketplaceListings() { delete mMenu; } + +void showMenu(LLView* button, LLMenuGL* menu) +{ + menu->buildDrawLabels(); + menu->updateParent(LLMenuGL::sMenuContainer); + const auto& rect = button->getRect(); + LLMenuGL::showPopup(button, menu, rect.mLeft, rect.mBottom); +} + BOOL LLPanelMarketplaceListings::postBuild() { childSetAction("add_btn", boost::bind(&LLPanelMarketplaceListings::onAddButtonClicked, this)); childSetAction("audit_btn", boost::bind(&LLPanelMarketplaceListings::onAuditButtonClicked, this)); + mMenu = LLUICtrlFactory::instance().buildMenu("menu_marketplace_view.xml", LLMenuGL::sMenuContainer); + auto sort = getChild("sort_btn"); + sort->setCommitCallback(boost::bind(showMenu, _1, mMenu)); mFilterEditor = getChild("filter_editor"); mFilterEditor->setCommitCallback(boost::bind(&LLPanelMarketplaceListings::onFilterEdit, this, _2)); diff --git a/indra/newview/llfloatermarketplacelistings.h b/indra/newview/llfloatermarketplacelistings.h index 451034d74..7df0c4976 100644 --- a/indra/newview/llfloatermarketplacelistings.h +++ b/indra/newview/llfloatermarketplacelistings.h @@ -51,6 +51,7 @@ class LLPanelMarketplaceListings : public LLPanel { public: LLPanelMarketplaceListings(); + ~LLPanelMarketplaceListings(); BOOL postBuild(); BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -79,6 +80,7 @@ private: LLFolderView* mRootFolder; LLButton* mAuditBtn; + class LLMenuGL* mMenu; LLFilterEditor* mFilterEditor; std::string mFilterSubString; bool mFilterListingFoldersOnly;