summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llui/llcommandmanager.cpp10
-rw-r--r--indra/llui/llcommandmanager.h2
-rw-r--r--indra/newview/lluilistener.cpp68
-rw-r--r--indra/newview/lluilistener.h6
-rw-r--r--indra/newview/scripts/lua/require/UI.lua30
5 files changed, 116 insertions, 0 deletions
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 270ec86e01..0c27e519dd 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -189,3 +189,13 @@ bool LLCommandManager::load()
return true;
}
+
+LLSD LLCommandManager::getCommandNames()
+{
+ LLSD cmd_names;
+ for (auto &it : mCommands)
+ {
+ cmd_names.append(it->name());
+ }
+ return cmd_names;
+ }
diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h
index 3b2586a5a1..cf2270e658 100644
--- a/indra/llui/llcommandmanager.h
+++ b/indra/llui/llcommandmanager.h
@@ -192,6 +192,8 @@ public:
LLCommand * getCommand(const LLCommandId& commandId);
LLCommand * getCommand(const std::string& name);
+ LLSD getCommandNames();
+
static bool load();
protected:
diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp
index b81859a764..6d1d5ac735 100644
--- a/indra/newview/lluilistener.cpp
+++ b/indra/newview/lluilistener.cpp
@@ -35,6 +35,7 @@
// external library headers
// other Linden headers
#include "llmenugl.h"
+#include "lltoolbarview.h"
#include "llui.h" // getRootView(), resolvePath()
#include "lluictrl.h"
#include "llerror.h"
@@ -97,6 +98,32 @@ LLUIListener::LLUIListener():
"Add menu separator to the [\"parent_menu\"] within the Top menu.",
&LLUIListener::addMenuSeparator,
llsd::map("parent_menu", LLSD(), "reply", LLSD()));
+
+ add("defaultToolbars",
+ "todo: defaultToolbars desc",
+ &LLUIListener::restoreDefaultToolbars);
+
+ add("clearToolbars",
+ "Clear all buttons off the toolbars",
+ &LLUIListener::clearAllToolbars);
+
+ add("addToolbarBtn",
+ "Add [\"btn_name\"] toolbar button to the [\"toolbar\"]\n"
+ "[1 (left toolbar), 2 (right toolbar), 3 (bottom toolbar)]\n"
+ "Position of the command in the original list can be specified as [\"rank\"]",
+ &LLUIListener::addToolbarBtn,
+ llsd::map("btn_name", LLSD(), "reply", LLSD()));
+
+ add("removeToolbarBtn",
+ "Remove [\"btn_name\"] toolbar button off the toolbar,\n"
+ "return [\"rank\"] (old position) of the command in the original list",
+ &LLUIListener::removeToolbarBtn,
+ llsd::map("btn_name", LLSD(), "reply", LLSD()));
+
+ add("getToolbarBtnNames",
+ "Return the table of Toolbar buttons names",
+ &LLUIListener::getToolbarBtnNames,
+ llsd::map("reply", LLSD()));
}
typedef LLUICtrl::CommitCallbackInfo cb_info;
@@ -280,3 +307,44 @@ void LLUIListener::addMenuSeparator(const LLSD&event) const
}
}
}
+
+void LLUIListener::restoreDefaultToolbars(const LLSD &event) const
+{
+ LLToolBarView::loadDefaultToolbars();
+}
+
+void LLUIListener::clearAllToolbars(const LLSD &event) const
+{
+ LLToolBarView::clearAllToolbars();
+}
+
+void LLUIListener::addToolbarBtn(const LLSD &event) const
+{
+ Response response(LLSD(), event);
+
+ typedef LLToolBarEnums::EToolBarLocation ToolBarLocation;
+ ToolBarLocation toolbar = ToolBarLocation::TOOLBAR_BOTTOM;
+ if (event.has("toolbar"))
+ {
+ toolbar = llclamp((ToolBarLocation)event["toolbar"].asInteger(), ToolBarLocation::TOOLBAR_NONE, ToolBarLocation::TOOLBAR_BOTTOM);
+ }
+ S32 rank = event.has("rank") ? event["rank"].asInteger() : - 1;
+ if(!gToolBarView->addCommand(event["btn_name"].asString(), toolbar, rank))
+ {
+ response.error(stringize("Toolbar button ", std::quoted(event["btn_name"].asString()), " was not found"));
+ }
+}
+
+void LLUIListener::removeToolbarBtn(const LLSD &event) const
+{
+ Response response(LLSD(), event);
+
+ S32 old_rank = LLToolBar::RANK_NONE;
+ gToolBarView->removeCommand(event["btn_name"].asString(), old_rank);
+ response["rank"] = old_rank;
+}
+
+void LLUIListener::getToolbarBtnNames(const LLSD &event) const
+{
+ Response response(llsd::map("cmd_names", LLCommandManager::instance().getCommandNames()), event);
+}
diff --git a/indra/newview/lluilistener.h b/indra/newview/lluilistener.h
index 671eb5f29b..f4bee00807 100644
--- a/indra/newview/lluilistener.h
+++ b/indra/newview/lluilistener.h
@@ -50,6 +50,12 @@ private:
void addMenuItem(const LLSD&event) const;
void addMenuSeparator(const LLSD&event) const;
+ void restoreDefaultToolbars(const LLSD &event) const;
+ void clearAllToolbars(const LLSD &event) const;
+ void addToolbarBtn(const LLSD &event) const;
+ void removeToolbarBtn(const LLSD &event) const;
+ void getToolbarBtnNames(const LLSD &event) const;
+
F64 mLastUntrustedThrottle {0};
F64 mLastMinThrottle {0};
};
diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua
index 06b49c6269..30b7189c3c 100644
--- a/indra/newview/scripts/lua/require/UI.lua
+++ b/indra/newview/scripts/lua/require/UI.lua
@@ -169,4 +169,34 @@ function UI.addMenuSeparator(...)
return leap.request('UI', args)
end
+-- ***************************************************************************
+-- Toolbar buttons
+-- ***************************************************************************
+-- Clears all buttons off the toolbars
+function UI.clearToolbars()
+ leap.send('UI', {op='clearToolbars'})
+end
+
+function UI.defaultToolbars()
+ leap.send('UI', {op='defaultToolbars'})
+end
+
+-- UI.addToolbarBtn{btn_name=btn_name
+-- [, toolbar= 3] -- 1 [TOOLBAR_LEFT], 2 [TOOLBAR_RIGHT], 3 [TOOLBAR_BOTTOM]
+-- [, rank=1]} -- position on the toolbar
+function UI.addToolbarBtn(...)
+ local args = mapargs('btn_name,toolbar,rank', ...)
+ args.op = 'addToolbarBtn'
+ return leap.request('UI', args)
+end
+
+-- Returns the rank(position) of the command in the original list
+function UI.removeToolbarBtn(btn_name)
+ return leap.request('UI', {op = 'removeToolbarBtn', btn_name=btn_name}).rank
+end
+
+function UI.getToolbarBtnNames()
+ return leap.request('UI', {op = 'getToolbarBtnNames'}).cmd_names
+end
+
return UI