Inital full retooling of appearance editor for multi-wearables. Also updated LLTabContainer to use standard commit and validate callback signals.

This commit is contained in:
Shyotl
2012-06-15 09:51:11 -05:00
parent 3796a216d2
commit 4c45e9a9d1
41 changed files with 717 additions and 682 deletions

View File

@@ -297,8 +297,7 @@ boost::signals2::connection LLButton::setHeldDownCallback(const CommitCallbackPa
boost::signals2::connection LLButton::setClickedCallback( const commit_signal_t::slot_type& cb )
{
if (!mCommitSignal) mCommitSignal = new commit_signal_t();
return mCommitSignal->connect(cb);
return LLUICtrl::setCommitCallback(cb);
}
boost::signals2::connection LLButton::setMouseDownCallback( const commit_signal_t::slot_type& cb )
{

View File

@@ -280,7 +280,7 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater,
}
//add the panel, add it to proper maps
mTabContainer->addTabPanel(floaterp, floaterp->getShortTitle(), FALSE, onTabSelected, this, 0, FALSE, insertion_point);
mTabContainer->addTabPanel(floaterp, floaterp->getShortTitle(), FALSE, 0, FALSE, insertion_point);
mFloaterDataMap[floaterp->getHandle()] = floater_data;
updateResizeLimits();
@@ -366,10 +366,10 @@ void LLMultiFloater::removeFloater(LLFloater* floaterp)
updateResizeLimits();
tabOpen((LLFloater*)mTabContainer->getCurrentPanel(), false);
tabOpen((LLFloater*)mTabContainer->getCurrentPanel());
}
void LLMultiFloater::tabOpen(LLFloater* opened_floater, bool from_click)
void LLMultiFloater::tabOpen(LLFloater* opened_floater)
{
// default implementation does nothing
}
@@ -464,12 +464,9 @@ void LLMultiFloater::setFloaterFlashing(LLFloater* floaterp, BOOL flashing)
mTabContainer->setTabPanelFlashing(floaterp, flashing);
}
//static
void LLMultiFloater::onTabSelected(void* userdata, bool from_click)
void LLMultiFloater::onTabSelected()
{
LLMultiFloater* floaterp = (LLMultiFloater*)userdata;
floaterp->tabOpen((LLFloater*)floaterp->mTabContainer->getCurrentPanel(), from_click);
tabOpen((LLFloater*)mTabContainer->getCurrentPanel());
}
void LLMultiFloater::setCanResize(BOOL can_resize)
@@ -499,6 +496,7 @@ BOOL LLMultiFloater::postBuild()
if (checkRequirements())
{
mTabContainer = getChild<LLTabContainer>("Preview Tabs");
mTabContainer->setCommitCallback(boost::bind(&LLMultiFloater::onTabSelected, this));
return TRUE;
}

View File

@@ -60,7 +60,7 @@ public:
virtual void showFloater(LLFloater* floaterp);
virtual void removeFloater(LLFloater* floaterp);
virtual void tabOpen(LLFloater* opened_floater, bool from_click);
virtual void tabOpen(LLFloater* opened_floater);
virtual void tabClose();
virtual BOOL selectFloater(LLFloater* floaterp);
@@ -74,7 +74,7 @@ public:
virtual void setFloaterFlashing(LLFloater* floaterp, BOOL flashing);
virtual BOOL closeAllFloaters(); //Returns FALSE if the floater could not be closed due to pending confirmation dialogs
void setTabContainer(LLTabContainer* tab_container) { if (!mTabContainer) mTabContainer = tab_container; }
static void onTabSelected(void* userdata, bool);
void onTabSelected();
virtual void updateResizeLimits();

View File

@@ -931,24 +931,6 @@ LLPanel *LLPanel::childGetVisibleTab(const std::string& id) const
return NULL;
}
void LLPanel::childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata, void (*on_precommit)(void*,bool))
{
LLTabContainer* child = getChild<LLTabContainer>(id);
if (child)
{
LLPanel *panel = child->getPanelByName(tabname);
if (panel)
{
child->setTabChangeCallback(panel, on_tab_clicked);
child->setTabUserData(panel, userdata);
if (on_precommit)
{
child->setTabPrecommitChangeCallback(panel, on_precommit);
}
}
}
}
void LLPanel::childSetKeystrokeCallback(const std::string& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data)
{
LLLineEditor* child = getChild<LLLineEditor>(id);

View File

@@ -198,7 +198,6 @@ public:
// LLTabContainer
void childShowTab(const std::string& id, const std::string& tabname, bool visible = true);
LLPanel *childGetVisibleTab(const std::string& id) const;
void childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata, void (*on_precommit)(void*,bool) = NULL);
// LLTextBox
void childSetWrappedText(const std::string& id, const std::string& text, bool visible = true);

View File

@@ -69,12 +69,33 @@ const S32 TABCNTRV_PAD = 0;
static LLRegisterWidget<LLTabContainer> r("tab_container");
// Structure used to map tab buttons to and from tab panels
class LLTabTuple
{
public:
LLTabTuple( LLTabContainer* c, LLPanel* p, LLButton* b, LLTextBox* placeholder = NULL)
:
mTabContainer(c),
mTabPanel(p),
mButton(b),
mOldState(FALSE),
mPlaceholderText(placeholder),
mPadding(0)
{}
LLTabContainer* mTabContainer;
LLPanel* mTabPanel;
LLButton* mButton;
BOOL mOldState;
LLTextBox* mPlaceholderText;
S32 mPadding;
};
LLTabContainer::LLTabContainer(const std::string& name, const LLRect& rect, TabPosition pos,
BOOL bordered, BOOL is_vertical )
:
LLPanel(name, rect, bordered),
mCurrentTabIdx(-1),
mNextTabIdx(-1),
mTabsHidden(FALSE),
mScrolled(FALSE),
mScrollPos(0),
@@ -221,10 +242,13 @@ void LLTabContainer::draw()
}
// Hide all the buttons
for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
if (getTabsHidden())
{
LLTabTuple* tuple = *iter;
tuple->mButton->setVisible( FALSE );
for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
{
LLTabTuple* tuple = *iter;
tuple->mButton->setVisible( FALSE );
}
}
LLPanel::draw();
@@ -320,7 +344,7 @@ void LLTabContainer::draw()
BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask )
{
BOOL handled = FALSE;
BOOL has_scroll_arrows = (getMaxScrollPos() > 0);
BOOL has_scroll_arrows = (getMaxScrollPos() > 0) && !getTabsHidden();
if (has_scroll_arrows)
{
@@ -355,7 +379,7 @@ BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask )
}
S32 tab_count = getTabCount();
if (tab_count > 0)
if (tab_count > 0 && !getTabsHidden())
{
LLTabTuple* firsttuple = getTab(0);
LLRect tab_rect;
@@ -379,7 +403,7 @@ BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask )
index = llclamp(index, 0, tab_count-1);
LLButton* tab_button = getTab(index)->mButton;
gFocusMgr.setMouseCapture(this);
gFocusMgr.setKeyboardFocus(tab_button);
tab_button->setFocus(TRUE);
}
}
return handled;
@@ -389,7 +413,7 @@ BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask )
BOOL LLTabContainer::handleHover( S32 x, S32 y, MASK mask )
{
BOOL handled = FALSE;
BOOL has_scroll_arrows = (getMaxScrollPos() > 0);
BOOL has_scroll_arrows = (getMaxScrollPos() > 0) && !getTabsHidden();
if (has_scroll_arrows)
{
@@ -431,7 +455,7 @@ BOOL LLTabContainer::handleHover( S32 x, S32 y, MASK mask )
BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask )
{
BOOL handled = FALSE;
BOOL has_scroll_arrows = (getMaxScrollPos() > 0);
BOOL has_scroll_arrows = (getMaxScrollPos() > 0) && !getTabsHidden();
if (has_scroll_arrows)
{
@@ -487,7 +511,7 @@ BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask )
BOOL LLTabContainer::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect )
{
BOOL handled = LLPanel::handleToolTip( x, y, msg, sticky_rect );
if (!handled && getTabCount() > 0)
if (!handled && getTabCount() > 0 && !getTabsHidden())
{
LLTabTuple* firsttuple = getTab(0);
@@ -523,12 +547,6 @@ BOOL LLTabContainer::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* stic
}
}
}
for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
{
LLTabTuple* tuple = *iter;
tuple->mButton->setVisible( FALSE );
}
}
return handled;
}
@@ -695,8 +713,6 @@ BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDrag
void LLTabContainer::addTabPanel(LLPanel* child,
const std::string& label,
BOOL select,
void (*on_tab_clicked)(void*, bool),
void* userdata,
S32 indent,
BOOL placeholder,
eInsertionPoint insertion_point)
@@ -722,20 +738,28 @@ void LLTabContainer::addTabPanel(LLPanel* child,
// Tab panel
S32 tab_panel_top;
S32 tab_panel_bottom;
if( getTabPosition() == LLTabContainer::TOP )
if (!getTabsHidden())
{
S32 tab_height = mIsVertical ? BTN_HEIGHT : TABCNTR_TAB_HEIGHT;
tab_panel_top = getRect().getHeight() - getTopBorderHeight() - (tab_height - TABCNTR_BUTTON_PANEL_OVERLAP);
tab_panel_bottom = LLPANEL_BORDER_WIDTH;
if( getTabPosition() == LLTabContainer::TOP )
{
S32 tab_height = mIsVertical ? BTN_HEIGHT : TABCNTR_TAB_HEIGHT;
tab_panel_top = getRect().getHeight() - getTopBorderHeight() - (tab_height - TABCNTR_BUTTON_PANEL_OVERLAP);
tab_panel_bottom = LLPANEL_BORDER_WIDTH;
}
else
{
tab_panel_top = getRect().getHeight() - getTopBorderHeight();
tab_panel_bottom = (TABCNTR_TAB_HEIGHT - TABCNTR_BUTTON_PANEL_OVERLAP); // Run to the edge, covering up the border
}
}
else
{
tab_panel_top = getRect().getHeight() - getTopBorderHeight();
tab_panel_bottom = (TABCNTR_TAB_HEIGHT - TABCNTR_BUTTON_PANEL_OVERLAP); // Run to the edge, covering up the border
//Scip tab button space if they are invisible(EXT - 576)
tab_panel_top = getRect().getHeight();
tab_panel_bottom = LLPANEL_BORDER_WIDTH;
}
LLRect tab_panel_rect;
if (mIsVertical)
if (!getTabsHidden() && mIsVertical)
{
tab_panel_rect = LLRect(mMinTabWidth + (LLPANEL_BORDER_WIDTH * 2) + TABCNTRV_PAD,
getRect().getHeight() - LLPANEL_BORDER_WIDTH,
@@ -854,7 +878,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
}
}
LLTabTuple* tuple = new LLTabTuple( this, child, btn, on_tab_clicked, userdata, textbox );
LLTabTuple* tuple = new LLTabTuple( this, child, btn, textbox );
insertTuple( tuple, insertion_point );
if (textbox)
@@ -883,7 +907,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
void LLTabContainer::addPlaceholder(LLPanel* child, const std::string& label)
{
addTabPanel(child, label, FALSE, NULL, NULL, 0, TRUE);
addTabPanel(child, label, FALSE, 0, TRUE);
}
void LLTabContainer::removeTabPanel(LLPanel* child)
@@ -1154,8 +1178,8 @@ BOOL LLTabContainer::selectTabPanel(LLPanel* child)
BOOL LLTabContainer::selectTab(S32 which)
{
if (which >= getTabCount()) return FALSE;
if (which < 0) return FALSE;
if (which >= getTabCount() || which < 0)
return FALSE;
//if( gFocusMgr.childHasKeyboardFocus( this ) )
//{
@@ -1167,28 +1191,26 @@ BOOL LLTabContainer::selectTab(S32 which)
{
return FALSE;
}
LLSD cbdata;
if (selected_tuple->mTabPanel)
cbdata = selected_tuple->mTabPanel->getName();
if (!selected_tuple->mPrecommitChangeCallback)
BOOL res = FALSE;
if( !mValidateSignal || (*mValidateSignal)( this, cbdata ) )
{
return setTab(which);
res = setTab(which);
if (res && mCommitSignal)
{
(*mCommitSignal)(this, cbdata);
}
}
mNextTabIdx = which;
selected_tuple->mPrecommitChangeCallback(selected_tuple->mUserData, false);
return TRUE;
return res;
}
BOOL LLTabContainer::setTab(S32 which)
{
if (which == -1)
{
if (mNextTabIdx == -1)
{
return FALSE;
}
which = mNextTabIdx;
mNextTabIdx = -1;
}
LLTabTuple* selected_tuple = getTab(which);
if (!selected_tuple)
@@ -1212,7 +1234,7 @@ BOOL LLTabContainer::setTab(S32 which)
// RN: this limits tab-stops to active button only, which would require arrow keys to switch tabs
tuple->mButton->setTabStop( is_selected );
if( is_selected && (mIsVertical || (getMaxScrollPos() > 0)))
if (is_selected)
{
// Make sure selected tab is within scroll region
if (mIsVertical)
@@ -1228,7 +1250,7 @@ BOOL LLTabContainer::setTab(S32 which)
is_visible = FALSE;
}
}
else
else if (getMaxScrollPos() > 0)
{
if( i < getScrollPos() )
{
@@ -1259,13 +1281,13 @@ BOOL LLTabContainer::setTab(S32 which)
}
is_visible = TRUE;
}
else
{
is_visible = TRUE;
}
}
i++;
}
if( selected_tuple->mOnChangeCallback )
{
selected_tuple->mOnChangeCallback( selected_tuple->mUserData, false );
}
}
if (mIsVertical && getCurrentPanelIndex() >= 0)
{
@@ -1368,33 +1390,6 @@ S32 LLTabContainer::getTopBorderHeight() const
return mTopBorderHeight;
}
void LLTabContainer::setTabChangeCallback(LLPanel* tab, void (*on_tab_clicked)(void*, bool))
{
LLTabTuple* tuplep = getTabByPanel(tab);
if (tuplep)
{
tuplep->mOnChangeCallback = on_tab_clicked;
}
}
void LLTabContainer::setTabPrecommitChangeCallback(LLPanel* tab, void (*on_precommit)(void*, bool))
{
LLTabTuple* tuplep = getTabByPanel(tab);
if (tuplep)
{
tuplep->mPrecommitChangeCallback = on_precommit;
}
}
void LLTabContainer::setTabUserData(LLPanel* tab, void* userdata)
{
LLTabTuple* tuplep = getTabByPanel(tab);
if (tuplep)
{
tuplep->mUserData = userdata;
}
}
void LLTabContainer::setRightTabBtnOffset(S32 offset)
{
mNextArrowBtn->translate( -offset - mRightTabBtnOffset, 0 );
@@ -1583,8 +1578,7 @@ LLView* LLTabContainer::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto
}
BOOL placeholder = FALSE;
child->getAttributeBOOL("placeholder", placeholder);
tab_container->addTabPanel(panelp, label, false,
NULL, NULL, 0, placeholder);
tab_container->addTabPanel(panelp, label, false, 0, placeholder);
}
}
@@ -1745,7 +1739,7 @@ void LLTabContainer::initButtons()
setDefaultTabGroup(1);
}
LLTabContainer::LLTabTuple* LLTabContainer::getTabByPanel(LLPanel* child)
LLTabTuple* LLTabContainer::getTabByPanel(LLPanel* child)
{
for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
{
@@ -1846,7 +1840,7 @@ void LLTabContainer::updateMaxScrollPos()
void LLTabContainer::commitHoveredButton(S32 x, S32 y)
{
if (hasMouseCapture())
if (!getTabsHidden() && hasMouseCapture())
{
for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
{

View File

@@ -36,6 +36,7 @@
#include "llpanel.h"
#include "lltextbox.h"
#include "llframetimer.h"
class LLTabTuple;
extern const S32 TABCNTR_HEADER_HEIGHT;
@@ -79,9 +80,7 @@ public:
void addTabPanel(LLPanel* child,
const std::string& label,
BOOL select = FALSE,
void (*on_tab_clicked)(void*, bool) = NULL,
void* userdata = NULL,
BOOL select = FALSE,
S32 indent = 0,
BOOL placeholder = FALSE,
eInsertionPoint insertion_point = END);
@@ -108,7 +107,6 @@ public:
BOOL selectTabPanel( LLPanel* child );
BOOL selectTab(S32 which);
BOOL selectTabByName(const std::string& title);
BOOL setTab(S32 which);
BOOL getTabPanelFlashing(LLPanel* child);
void setTabPanelFlashing(LLPanel* child, BOOL state);
@@ -118,10 +116,6 @@ public:
void setTopBorderHeight(S32 height);
S32 getTopBorderHeight() const;
void setTabChangeCallback(LLPanel* tab, void (*on_tab_clicked)(void*,bool));
void setTabPrecommitChangeCallback(LLPanel* tab, void (*on_precommit)(void*, bool));
void setTabUserData(LLPanel* tab, void* userdata);
void setRightTabBtnOffset( S32 offset );
void setPanelTitle(S32 index, const std::string& title);
@@ -146,39 +140,11 @@ public:
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
private:
// Structure used to map tab buttons to and from tab panels
struct LLTabTuple
{
LLTabTuple( LLTabContainer* c, LLPanel* p, LLButton* b,
void (*cb)(void*,bool), void* userdata, LLTextBox* placeholder = NULL,
void (*pcb)(void*,bool) = NULL)
:
mTabContainer(c),
mTabPanel(p),
mButton(b),
mOnChangeCallback( cb ),
mPrecommitChangeCallback( pcb ),
mUserData( userdata ),
mOldState(FALSE),
mPlaceholderText(placeholder),
mPadding(0)
{}
LLTabContainer* mTabContainer;
LLPanel* mTabPanel;
LLButton* mButton;
void (*mOnChangeCallback)(void*, bool);
void (*mPrecommitChangeCallback)(void*,bool); // Precommit callback gets called before tab is changed and
// can prevent it from being changed. onChangeCallback is called
// immediately after tab is actually changed - Nyx
void* mUserData;
BOOL mOldState;
LLTextBox* mPlaceholderText;
S32 mPadding;
};
void initButtons();
BOOL setTab(S32 which);
LLTabTuple* getTab(S32 index) { return mTabList[index]; }
LLTabTuple* getTabByPanel(LLPanel* child);
void insertTuple(LLTabTuple * tuple, eInsertionPoint insertion_point);