Skip to content
Snippets Groups Projects
Commit 305b65f6 authored by Leslie Linden's avatar Leslie Linden
Browse files

EXP-1205 PROGRESS -- As a User, I want a toybox which will contain all buttons...

EXP-1205 PROGRESS -- As a User, I want a toybox which will contain all buttons that I can d&d into the toolbars
EXP-1210 FIX -- Implement new toybox floater window
EXP-1231 FIX -- Add menu option to toggle the toybox floater on and off

* Basic toybox floater implemented as its own class
* Toybox is available through "Me -> Toolbars..." menu option or ctrl-T shortcut
* Toolbars now have "side" type rather than simple orientation, as well as button
  state for "icons only" or "icons with text".

Reviewed by Richard
parent 8a846bd3
No related branches found
No related tags found
No related merge requests found
......@@ -32,23 +32,45 @@
//static LLDefaultChildRegistry::Register<LLToolBar> r1("toolbar");
namespace LLToolBarEnums
{
LLLayoutStack::ELayoutOrientation getOrientation(SideType sideType)
{
LLLayoutStack::ELayoutOrientation orientation = LLLayoutStack::HORIZONTAL;
if ((sideType == SIDE_LEFT) || (sideType == SIDE_RIGHT))
{
orientation = LLLayoutStack::VERTICAL;
}
return orientation;
}
}
LLToolBar::Params::Params()
: orientation("orientation"),
buttons("button")
: button_display_mode("button_display_mode"),
buttons("button"),
side("side")
{}
LLToolBar::LLToolBar(const Params& p)
: LLUICtrl(p),
mOrientation(p.orientation),
mButtonType(p.button_display_mode),
mSideType(p.side),
mStack(NULL)
{}
{
}
void LLToolBar::initFromParams(const LLToolBar::Params& p)
{
LLLayoutStack::ELayoutOrientation orientation = LLToolBarEnums::getOrientation(p.side);
LLLayoutStack::Params centering_stack_p;
centering_stack_p.rect = getLocalRect();
centering_stack_p.follows.flags = FOLLOWS_ALL;
centering_stack_p.orientation = p.orientation;
centering_stack_p.orientation = orientation;
centering_stack_p.name = "centering_stack";
LLLayoutPanel::Params border_panel_p;
......@@ -75,8 +97,8 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
LLLayoutStack::Params stack_p;
stack_p.rect = getLocalRect();
stack_p.name = "button_stack";
stack_p.orientation = p.orientation;
stack_p.follows.flags = (mOrientation == LLLayoutStack::HORIZONTAL)
stack_p.orientation = orientation;
stack_p.follows.flags = (orientation == LLLayoutStack::HORIZONTAL)
? (FOLLOWS_TOP|FOLLOWS_BOTTOM) // horizontal
: (FOLLOWS_LEFT|FOLLOWS_RIGHT); // vertical
......@@ -88,7 +110,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
// remove any offset from button
LLRect button_rect(button_p.rect);
if (mOrientation == LLLayoutStack::HORIZONTAL)
if (orientation == LLLayoutStack::HORIZONTAL)
{
button_rect.setOriginAndSize(0, 0, 0, getRect().getHeight());
}
......@@ -139,7 +161,7 @@ void LLToolBar::updateLayout()
max_height = llmax(button->getRect().getHeight(), max_height);
}
if (mOrientation == LLLayoutStack::HORIZONTAL)
if (LLToolBarEnums::getOrientation(mSideType) == LLLayoutStack::HORIZONTAL)
{
mStack->reshape(total_width, mStack->getParent()->getRect().getHeight());
}
......@@ -153,6 +175,24 @@ void LLToolBar::updateLayout()
void LLToolBar::draw()
{
//gl_rect_2d(getLocalRect(), LLColor4::blue, TRUE);
LLUICtrl::draw();
}
namespace LLInitParam
{
void TypeValues<LLToolBarEnums::ButtonType>::declareValues()
{
declare("icons_only", LLToolBarEnums::BTNTYPE_ICONS_ONLY);
declare("icons_with_text", LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT);
}
void TypeValues<LLToolBarEnums::SideType>::declareValues()
{
declare("none", LLToolBarEnums::SIDE_NONE);
declare("bottom", LLToolBarEnums::SIDE_BOTTOM);
declare("left", LLToolBarEnums::SIDE_LEFT);
declare("right", LLToolBarEnums::SIDE_RIGHT);
declare("top", LLToolBarEnums::SIDE_TOP);
}
}
......@@ -32,6 +32,7 @@
#include "lllayoutstack.h"
#include "llbutton.h"
class LLToolBarButton : public LLButton
{
public:
......@@ -40,9 +41,44 @@ class LLToolBarButton : public LLButton
};
LLToolBarButton(const Params& p) : LLButton(p) {}
};
namespace LLToolBarEnums
{
enum ButtonType
{
BTNTYPE_ICONS_ONLY = 0,
BTNTYPE_ICONS_WITH_TEXT,
};
enum SideType
{
SIDE_NONE = 0,
SIDE_BOTTOM,
SIDE_LEFT,
SIDE_RIGHT,
SIDE_TOP,
};
}
// NOTE: This needs to occur before Param block declaration for proper compilation.
namespace LLInitParam
{
template<>
struct TypeValues<LLToolBarEnums::ButtonType> : public TypeValuesHelper<LLToolBarEnums::ButtonType>
{
static void declareValues();
};
template<>
struct TypeValues<LLToolBarEnums::SideType> : public TypeValuesHelper<LLToolBarEnums::SideType>
{
static void declareValues();
};
}
class LLToolBar
: public LLUICtrl
{
......@@ -50,26 +86,29 @@ class LLToolBar
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
{
Mandatory<LLLayoutStack::ELayoutOrientation,
LLLayoutStack::OrientationNames> orientation;
Multiple<LLToolBarButton::Params> buttons;
Mandatory<LLToolBarEnums::ButtonType> button_display_mode;
Multiple<LLToolBarButton::Params> buttons;
Mandatory<LLToolBarEnums::SideType> side;
Params();
};
/*virtual*/ void draw();
// virtuals
void draw();
protected:
friend class LLUICtrlFactory;
LLToolBar(const Params&);
void initFromParams(const Params&);
void addButton(LLToolBarButton* buttonp);
void updateLayout();
private:
LLLayoutStack::ELayoutOrientation mOrientation;
LLLayoutStack* mStack;
std::list<LLToolBarButton*> mButtons;
std::list<LLToolBarButton*> mButtons;
LLToolBarEnums::ButtonType mButtonType;
LLToolBarEnums::SideType mSideType;
LLLayoutStack* mStack;
};
......
......@@ -237,6 +237,7 @@ set(viewer_SOURCE_FILES
llfloatertools.cpp
llfloatertopobjects.cpp
llfloatertos.cpp
llfloatertoybox.cpp
llfloateruipreview.cpp
llfloaterurlentry.cpp
llfloatervoiceeffect.cpp
......@@ -800,6 +801,7 @@ set(viewer_HEADER_FILES
llfloatertools.h
llfloatertopobjects.h
llfloatertos.h
llfloatertoybox.h
llfloateruipreview.h
llfloaterurlentry.h
llfloatervoiceeffect.h
......
/**
* @file llfloatertoybox.cpp
* @brief The toybox for flexibilizing the UI.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llfloatertoybox.h"
#include "llbutton.h"
#include "llpanel.h"
LLFloaterToybox::LLFloaterToybox(const LLSD& key)
: LLFloater(key)
, mBtnRestoreDefaults(NULL)
{
mCommitCallbackRegistrar.add("Toybox.RestoreDefaults", boost::bind(&LLFloaterToybox::onBtnRestoreDefaults, this));
}
LLFloaterToybox::~LLFloaterToybox()
{
}
BOOL LLFloaterToybox::postBuild()
{
center();
mBtnRestoreDefaults = getChild<LLButton>("btn_restore_defaults");
//
// Create Buttons
//
/*
LLToyboxButtons::load();
for (size_t i = 0; i < LLToyboxButtons::buttonCount(); i++)
{
LLToyboxButton * button = LLToyboxButtons::get(i);
// Panel opacity depends on whether or not button position is established
LLPanel * buttonPanel = createPanelForButton(button);
mToolBar->add(buttonPanel);
}
*/
return TRUE;
}
void LLFloaterToybox::onOpen(const LLSD& key)
{
}
BOOL LLFloaterToybox::canClose()
{
return TRUE;
}
void LLFloaterToybox::onClose(bool app_quitting)
{
}
void LLFloaterToybox::draw()
{
LLFloater::draw();
}
void LLFloaterToybox::onFocusReceived()
{
}
void LLFloaterToybox::onBtnRestoreDefaults()
{
}
// eof
/**
* @file llfloatertoybox.h
* @brief The toybox for flexibilizing the UI.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLFLOATERTOYBOX_H
#define LL_LLFLOATERTOYBOX_H
#include "llfloater.h"
class LLButton;
class LLFloaterToybox
: public LLFloater
{
public:
LLFloaterToybox(const LLSD& key);
virtual ~LLFloaterToybox();
// virtuals
BOOL postBuild();
void onOpen(const LLSD& key);
BOOL canClose();
void onClose(bool app_quitting);
void draw();
void onFocusReceived();
protected:
void onBtnRestoreDefaults();
public:
LLButton * mBtnRestoreDefaults;
};
#endif // LL_LLFLOATERTOYBOX_H
......@@ -103,6 +103,7 @@
#include "llfloatertools.h"
#include "llfloatertos.h"
#include "llfloatertopobjects.h"
#include "llfloatertoybox.h"
#include "llfloateruipreview.h"
#include "llfloatervoiceeffect.h"
#include "llfloaterwhitelistentry.h"
......@@ -255,6 +256,7 @@ void LLViewerFloaterReg::registerFloaters()
LLFloaterReg::add("test_text_editor", "floater_test_text_editor.xml", &LLFloaterReg::build<LLFloater>);
LLFloaterReg::add("test_widgets", "floater_test_widgets.xml", &LLFloaterReg::build<LLFloater>);
LLFloaterReg::add("top_objects", "floater_top_objects.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTopObjects>);
LLFloaterReg::add("toybox", "floater_toybox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterToybox>);
LLFloaterReg::add("reporter", "floater_report_abuse.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterReporter>);
LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterResetQueue>);
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
can_close="true"
can_dock="false"
can_minimize="false"
can_resize="false"
default_tab_group="1"
height="460"
help_topic="toybox"
layout="topleft"
legacy_header_height="18"
name="Toybox"
open_centered="true"
single_instance="true"
title="Customize toolbars"
width="658">
<text
follows="left|top"
font="SansSerifMedium"
halign="left"
height="20"
layout="topleft"
left="40"
length="1"
name="toybox label 1"
right="-40"
top="35"
type="string">
Add or remove buttons by dragging them to or from the toolbars.
</text>
<text
follows="left|top"
font="SansSerifMedium"
halign="left"
height="20"
layout="topleft"
left="40"
length="1"
name="toybox label 2"
right="-40"
top="55"
type="string">
Buttons will appear as shown or as icon-only depending on each toolbar's settings.
</text>
<toolbar
bottom="395"
left="40"
right="-40"
top="85">
</toolbar>
<button
follows="left|bottom"
height="23"
label="Restore defaults"
label_selected="Restore defaults"
layout="topleft"
left="40"
name="btn_restore_defaults"
top="415"
width="130">
<button.commit_callback function="Toybox.RestoreDefaults" />
</button>
</floater>
......@@ -13,7 +13,7 @@
tear_off="true"
name="File">
<menu_item_call
label="Preferences"
label="Preferences..."
name="Preferences..."
shortcut="control|P">
<menu_item_call.on_click
......
......@@ -9,14 +9,22 @@
name="Me"
tear_off="true">
<menu_item_call
label="Preferences"
label="Preferences..."
name="Preferences"
shortcut="control|P">
<menu_item_call.on_click
function="Floater.Show"
parameter="preferences" />
</menu_item_call>
<menu_item_call
<menu_item_call
label="Toolbars..."
name="Toolbars"
shortcut="control|T">
<menu_item_call.on_click
function="Floater.Toggle"
parameter="toybox" />
</menu_item_call>
<menu_item_call
label="My Dashboard"
name="Manage My Account">
<menu_item_call.on_click
......@@ -2855,7 +2863,7 @@
function="ToggleControl"
parameter="BottomPanelNew" />
</menu_item_check>-->
<menu_item_call
<menu_item_call
label="Media Browser Test"
name="Web Browser Test">
<menu_item_call.on_click
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment