summaryrefslogtreecommitdiff
path: root/indra/llui/lllayoutstack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lllayoutstack.cpp')
-rw-r--r--indra/llui/lllayoutstack.cpp95
1 files changed, 56 insertions, 39 deletions
diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 13d6faa673..1c59938f90 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -61,7 +61,7 @@ LLLayoutPanel::LLLayoutPanel(const Params& p)
mMinDim(p.min_dim),
mAutoResize(p.auto_resize),
mUserResize(p.user_resize),
- mCollapsed(FALSE),
+ mCollapsed(false),
mCollapseAmt(0.f),
mVisibleAmt(1.f), // default to fully visible
mResizeBar(NULL),
@@ -86,10 +86,6 @@ void LLLayoutPanel::initFromParams(const Params& p)
LLLayoutPanel::~LLLayoutPanel()
{
- // probably not necessary, but...
- delete mResizeBar;
- mResizeBar = NULL;
-
gFocusMgr.removeKeyboardFocusWithoutCallback(this);
}
@@ -131,7 +127,7 @@ void LLLayoutPanel::setTargetDim(S32 value)
S32 LLLayoutPanel::getVisibleDim() const
{
- F32 min_dim = getRelevantMinDim();
+ F32 min_dim = (F32)getRelevantMinDim();
return ll_round(mVisibleAmt
* (min_dim
+ (((F32)mTargetDim - min_dim) * (1.f - mCollapseAmt))));
@@ -144,16 +140,14 @@ void LLLayoutPanel::setOrientation( LLView::EOrientation orientation )
? getRect().getWidth()
: getRect().getHeight()));
- if (mAutoResize == FALSE
- && mUserResize == TRUE
- && mMinDim == -1 )
+ if (!mAutoResize && mUserResize && mMinDim == -1)
{
setMinDim(layout_dim);
}
mTargetDim = llmax(layout_dim, getMinDim());
}
-void LLLayoutPanel::setVisible( BOOL visible )
+void LLLayoutPanel::setVisible( bool visible )
{
if (visible != getVisible())
{
@@ -166,11 +160,11 @@ void LLLayoutPanel::setVisible( BOOL visible )
LLPanel::setVisible(visible);
}
-void LLLayoutPanel::reshape( S32 width, S32 height, BOOL called_from_parent /*= TRUE*/ )
+void LLLayoutPanel::reshape( S32 width, S32 height, bool called_from_parent /*= true*/ )
{
if (width == getRect().getWidth() && height == getRect().getHeight() && !LLView::sForceReshape) return;
- if (!mIgnoreReshape && mAutoResize == false)
+ if (!mIgnoreReshape && !mAutoResize)
{
mTargetDim = (mOrientation == LLLayoutStack::HORIZONTAL) ? width : height;
LLLayoutStack* stackp = dynamic_cast<LLLayoutStack*>(getParent());
@@ -211,7 +205,7 @@ LLLayoutStack::Params::Params()
open_time_constant("open_time_constant", 0.02f),
close_time_constant("close_time_constant", 0.03f),
resize_bar_overlap("resize_bar_overlap", 1),
- border_size("border_size", LLCachedControl<S32>(*LLUI::getInstance()->mSettingGroups["config"], "UIResizeBarHeight", 0)),
+ border_size("border_size", LLUI::getInstance()->mSettingGroups["config"]->getS32("UIResizeBarHeight")),
show_drag_handle("show_drag_handle", false),
drag_handle_first_indent("drag_handle_first_indent", 0),
drag_handle_second_indent("drag_handle_second_indent", 0),
@@ -244,11 +238,9 @@ LLLayoutStack::LLLayoutStack(const LLLayoutStack::Params& p)
LLLayoutStack::~LLLayoutStack()
{
- e_panel_list_t panels = mPanels; // copy list of panel pointers
- mPanels.clear(); // clear so that removeChild() calls don't cause trouble
- std::for_each(panels.begin(), panels.end(), DeletePointer());
}
+// virtual
void LLLayoutStack::draw()
{
updateLayout();
@@ -286,8 +278,14 @@ void LLLayoutStack::draw()
}
}
+// virtual
void LLLayoutStack::deleteAllChildren()
{
+ for (LLLayoutPanel* p : mPanels)
+ {
+ p->mResizeBar = nullptr;
+ }
+
mPanels.clear();
LLView::deleteAllChildren();
@@ -297,29 +295,47 @@ void LLLayoutStack::deleteAllChildren()
mNeedsLayout = true;
}
+// virtual
void LLLayoutStack::removeChild(LLView* view)
{
- LLLayoutPanel* embedded_panelp = findEmbeddedPanel(dynamic_cast<LLPanel*>(view));
-
- if (embedded_panelp)
+ if (LLLayoutPanel* embedded_panelp = dynamic_cast<LLLayoutPanel*>(view))
{
- mPanels.erase(std::find(mPanels.begin(), mPanels.end(), embedded_panelp));
- LLView::removeChild(view);
- updateFractionalSizes();
- mNeedsLayout = true;
+ auto it = std::find(mPanels.begin(), mPanels.end(), embedded_panelp);
+ if (it != mPanels.end())
+ {
+ mPanels.erase(it);
+ }
+ if (embedded_panelp->mResizeBar)
+ {
+ LLView::removeChild(embedded_panelp->mResizeBar);
+ embedded_panelp->mResizeBar = nullptr;
+ }
}
- else
+ else if (LLResizeBar* resize_bar = dynamic_cast<LLResizeBar*>(view))
{
- LLView::removeChild(view);
+ for (LLLayoutPanel* p : mPanels)
+ {
+ if (p->mResizeBar == resize_bar)
+ {
+ p->mResizeBar = nullptr;
+ }
+ }
}
+
+ LLView::removeChild(view);
+
+ updateFractionalSizes();
+ mNeedsLayout = true;
}
-BOOL LLLayoutStack::postBuild()
+// virtual
+bool LLLayoutStack::postBuild()
{
updateLayout();
- return TRUE;
+ return true;
}
+// virtual
bool LLLayoutStack::addChild(LLView* child, S32 tab_group)
{
LLLayoutPanel* panelp = dynamic_cast<LLLayoutPanel*>(child);
@@ -330,7 +346,7 @@ bool LLLayoutStack::addChild(LLView* child, S32 tab_group)
createResizeBar(panelp);
mNeedsLayout = true;
}
- BOOL result = LLView::addChild(child, tab_group);
+ bool result = LLView::addChild(child, tab_group);
updateFractionalSizes();
return result;
@@ -344,11 +360,11 @@ void LLLayoutStack::addPanel(LLLayoutPanel* panel, EAnimate animate)
if (animate == ANIMATE)
{
panel->mVisibleAmt = 0.f;
- panel->setVisible(TRUE);
+ panel->setVisible(true);
}
}
-void LLLayoutStack::collapsePanel(LLPanel* panel, BOOL collapsed)
+void LLLayoutStack::collapsePanel(LLPanel* panel, bool collapsed)
{
LLLayoutPanel* panel_container = findEmbeddedPanel(panel);
if (!panel_container) return;
@@ -447,7 +463,7 @@ void LLLayoutStack::updateLayout()
for (LLLayoutPanel* panelp : mPanels)
{
- F32 panel_dim = llmax(panelp->getExpandedMinDim(), panelp->mTargetDim);
+ F32 panel_dim = (F32)llmax(panelp->getExpandedMinDim(), panelp->mTargetDim);
LLRect panel_rect;
if (mOrientation == HORIZONTAL)
@@ -467,7 +483,7 @@ void LLLayoutStack::updateLayout()
LLRect resize_bar_rect(panel_rect);
F32 panel_spacing = (F32)mPanelSpacing * panelp->getVisibleAmount();
- F32 panel_visible_dim = panelp->getVisibleDim();
+ F32 panel_visible_dim = (F32)panelp->getVisibleDim();
S32 panel_spacing_round = (S32)(ll_round(panel_spacing));
if (mOrientation == HORIZONTAL)
@@ -550,7 +566,7 @@ LLLayoutPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) const
return NULL;
}
-LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(const std::string& name) const
+LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(std::string_view name) const
{
LLLayoutPanel* result = NULL;
@@ -615,7 +631,7 @@ void LLLayoutStack::createResizeBar(LLLayoutPanel* panelp)
border_params.shadow_dark_color = LLUIColorTable::instance().getColor("ResizebarBorderDark");
addBorder(border_params);
- setBorderVisible(TRUE);
+ setBorderVisible(true);
LLImagePanel::Params image_panel;
mDragHandleImage = LLUI::getUIImage(LLResizeBar::RIGHT == mSide ? "Vertical Drag Handle" : "Horizontal Drag Handle");
@@ -628,7 +644,7 @@ void LLLayoutStack::createResizeBar(LLLayoutPanel* panelp)
//if (mShowDragHandle)
//{
- // setBackgroundVisible(TRUE);
+ // setBackgroundVisible(true);
// setTransparentColor(LLUIColorTable::instance().getColor("ResizebarBody"));
//}
@@ -985,7 +1001,8 @@ void LLLayoutStack::updatePanelRect( LLLayoutPanel* resized_panel, const LLRect&
//normalizeFractionalSizes();
}
-void LLLayoutStack::reshape(S32 width, S32 height, BOOL called_from_parent)
+// virtual
+void LLLayoutStack::reshape(S32 width, S32 height, bool called_from_parent)
{
mNeedsLayout = true;
LLView::reshape(width, height, called_from_parent);
@@ -998,7 +1015,7 @@ void LLLayoutStack::updateResizeBarLimits()
{
if (!visible_panelp->getVisible() || visible_panelp->mCollapsed)
{
- visible_panelp->mResizeBar->setVisible(FALSE);
+ visible_panelp->mResizeBar->setVisible(false);
continue;
}
@@ -1008,14 +1025,14 @@ void LLLayoutStack::updateResizeBarLimits()
&& (visible_panelp->mAutoResize || visible_panelp->mUserResize) // current panel is resizable
&& (previous_visible_panelp->mAutoResize || previous_visible_panelp->mUserResize)) // previous panel is resizable
{
- visible_panelp->mResizeBar->setVisible(TRUE);
+ visible_panelp->mResizeBar->setVisible(true);
S32 previous_panel_headroom = previous_visible_panelp->getVisibleDim() - previous_visible_panelp->getRelevantMinDim();
visible_panelp->mResizeBar->setResizeLimits(visible_panelp->getRelevantMinDim(),
visible_panelp->getVisibleDim() + previous_panel_headroom);
}
else
{
- visible_panelp->mResizeBar->setVisible(FALSE);
+ visible_panelp->mResizeBar->setVisible(false);
}
previous_visible_panelp = visible_panelp;