summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelenvironment.cpp
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-07-24 18:47:24 -0400
committerRye Mutt <rye@alchemyviewer.org>2024-07-25 08:45:53 -0400
commit70f332d02e687c2c3d4806ccda0e1dcd8bde1232 (patch)
treee3cacbedee73e8ee706c492268f488ebb80fc12f /indra/newview/llpanelenvironment.cpp
parent0a420e7d9ab54162a04472c756a3994b6597445d (diff)
Fix findChild during draw in the parcel/region environment panel
Diffstat (limited to 'indra/newview/llpanelenvironment.cpp')
-rw-r--r--indra/newview/llpanelenvironment.cpp180
1 files changed, 100 insertions, 80 deletions
diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp
index a706e339ea..0c8bbbf308 100644
--- a/indra/newview/llpanelenvironment.cpp
+++ b/indra/newview/llpanelenvironment.cpp
@@ -41,6 +41,7 @@
#include "llfloater.h"
#include "llfloaterreg.h"
#include "llfloatereditextdaycycle.h"
+#include "lliconctrl.h"
#include "llmultisliderctrl.h"
#include "llnotificationsutil.h"
#include "llsettingsvo.h"
@@ -109,10 +110,7 @@ const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_MASK(
LLPanelEnvironmentInfo::DIRTY_FLAG_DAYOFFSET |
LLPanelEnvironmentInfo::DIRTY_FLAG_ALTITUDES);
-const U32 ALTITUDE_SLIDER_COUNT = 3;
const F32 ALTITUDE_DEFAULT_HEIGHT_STEP = 1000;
-const U32 ALTITUDE_MARKERS_COUNT = 3;
-const U32 ALTITUDE_PREFIXERS_COUNT = 5;
const std::string slider_marker_base = "mark";
@@ -167,24 +165,58 @@ LLPanelEnvironmentInfo::~LLPanelEnvironmentInfo()
bool LLPanelEnvironmentInfo::postBuild()
{
+ mIconGround = getChild<LLIconCtrl>(ICN_GROUND);
+ mIconWater = getChild<LLIconCtrl>(ICN_WATER);
- getChild<LLUICtrl>(BTN_USEDEFAULT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnDefault(); });
- getChild<LLUICtrl>(BTN_SELECTINV)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnSelect(); });
- getChild<LLUICtrl>(BTN_EDIT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnEdit(); });
- getChild<LLUICtrl>(BTN_RST_ALTITUDES)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnRstAltitudes(); });
+ mPanelEnvAltitudes = getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES);
+ mPanelEnvConfig = getChild<LLUICtrl>(PNL_SETTINGS);
+ mPanelEnvButtons = getChild <LLUICtrl>(PNL_BUTTONS);
+ mPanelEnvDisabled = getChild<LLUICtrl>(PNL_DISABLED);
+ mPanelEnvRegionMsg = getChild<LLUICtrl>(PNL_REGION_MSG);
- getChild<LLUICtrl>(SLD_DAYLENGTH)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged((F32)value.asReal()); });
- getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
- getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setSliderEditorCommitCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
- getChild<LLUICtrl>(SLD_DAYOFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayOffsetChanged((F32)value.asReal()); });
- getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
- getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setSliderEditorCommitCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
+ mEnvironmentDisabledText = getChild<LLTextBox>(TXT_DISABLED);
+ mLabelApparentTime = getChild<LLTextBox>(LBL_TIMEOFDAY);
- getChild<LLMultiSliderCtrl>(SLD_ALTITUDES)->setCommitCallback([this](LLUICtrl *cntrl, const LLSD &value) { onAltSliderCallback(cntrl, value); });
- getChild<LLMultiSliderCtrl>(SLD_ALTITUDES)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onAltSliderMouseUp(); });
+ mBtnUseDefault = getChild<LLButton>(BTN_USEDEFAULT);
+ mBtnUseDefault->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnDefault(); });
+
+ mBtnSelectInv = getChild<LLButton>(BTN_SELECTINV);
+ mBtnSelectInv->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnSelect(); });
+
+ mBtnEdit = getChild<LLButton>(BTN_EDIT);
+ mBtnEdit->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnEdit(); });
+
+ mBtnResetAltitudes = getChild<LLButton>(BTN_RST_ALTITUDES);
+ mBtnResetAltitudes->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnRstAltitudes(); });
+
+ mCheckAllowOverride = getChild<LLCheckBoxCtrl>(CHK_ALLOWOVERRIDE);
+
+ mSliderDayLength = getChild<LLSliderCtrl>(SLD_DAYLENGTH);
+ mSliderDayLength->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged((F32)value.asReal()); });
+ mSliderDayLength->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
+ mSliderDayLength->setSliderEditorCommitCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
+
+ mSliderDayOffset = getChild<LLSliderCtrl>(SLD_DAYOFFSET);
+ mSliderDayOffset->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayOffsetChanged((F32)value.asReal()); });
+ mSliderDayOffset->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
+ mSliderDayOffset->setSliderEditorCommitCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); });
+
+ mMultiSliderAltitudes = getChild<LLMultiSliderCtrl>(SLD_ALTITUDES);
+ mMultiSliderAltitudes->setCommitCallback([this](LLUICtrl *cntrl, const LLSD &value) { onAltSliderCallback(cntrl, value); });
+ mMultiSliderAltitudes->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onAltSliderMouseUp(); });
mChangeMonitor = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32 version) { onEnvironmentChanged(env, version); });
+ for (U32 idx = 0; idx < ALTITUDE_MARKERS_COUNT; idx++)
+ {
+ mAltitudeMarkers[idx] = findChild<LLUICtrl>(slider_marker_base + llformat("%u", idx));
+ }
+
+ for (U32 idx = 0; idx < ALTITUDE_PREFIXERS_COUNT; idx++)
+ {
+ mAltitudePrefixers[idx] = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]);
+ }
+
for (U32 idx = 0; idx < ALTITUDE_SLIDER_COUNT; idx++)
{
LLSettingsDropTarget* drop_target = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]);
@@ -262,8 +294,8 @@ void LLPanelEnvironmentInfo::refresh()
if (dayoffset.value() > 12.0f)
dayoffset -= F32Hours(24.0);
- getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setValue(daylength.value());
- getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setValue(dayoffset.value());
+ mSliderDayLength->setValue(daylength.value());
+ mSliderDayOffset->setValue(dayoffset.value());
udpateApparentTimeOfDay();
@@ -273,40 +305,39 @@ void LLPanelEnvironmentInfo::refresh()
if (altitudes.size() > 0)
{
- LLMultiSliderCtrl *sld = getChild<LLMultiSliderCtrl>(SLD_ALTITUDES);
- sld->clear();
+ mMultiSliderAltitudes->clear();
for (S32 idx = 0; idx < ALTITUDE_SLIDER_COUNT; ++idx)
{
// make sure values are in range, server is supposed to validate them,
// but issues happen, try to fix values in such case
- F32 altitude = llclamp(altitudes[idx + 1], sld->getMinValue(), sld->getMaxValue());
- bool res = sld->addSlider(altitude, alt_sliders[idx]);
+ F32 altitude = llclamp(altitudes[idx + 1], mMultiSliderAltitudes->getMinValue(), mMultiSliderAltitudes->getMaxValue());
+ bool res = mMultiSliderAltitudes->addSlider(altitude, alt_sliders[idx]);
if (!res)
{
LL_WARNS_ONCE("ENVPANEL") << "Failed to validate altitude from server for parcel id" << getParcelId() << LL_ENDL;
// Find a spot to insert altitude.
// Assuming everything alright with slider, we should find new place in 11 steps top (step 25m, no overlap 100m)
- F32 alt_step = (altitude > (sld->getMaxValue() / 2)) ? -sld->getIncrement() : sld->getIncrement();
+ F32 alt_step = (altitude > (mMultiSliderAltitudes->getMaxValue() / 2)) ? -mMultiSliderAltitudes->getIncrement() : mMultiSliderAltitudes->getIncrement();
for (U32 i = 0; i < 30; i++)
{
altitude += alt_step;
- if (altitude > sld->getMaxValue())
+ if (altitude > mMultiSliderAltitudes->getMaxValue())
{
- altitude = sld->getMinValue();
+ altitude = mMultiSliderAltitudes->getMinValue();
}
- else if (altitude < sld->getMinValue())
+ else if (altitude < mMultiSliderAltitudes->getMinValue())
{
- altitude = sld->getMaxValue();
+ altitude = mMultiSliderAltitudes->getMaxValue();
}
- res = sld->addSlider(altitude, alt_sliders[idx]);
+ res = mMultiSliderAltitudes->addSlider(altitude, alt_sliders[idx]);
if (res) break;
}
}
if (res)
{
// slider has some auto correction that might have kicked in
- altitude = sld->getSliderValue(alt_sliders[idx]);
+ altitude = mMultiSliderAltitudes->getSliderValue(alt_sliders[idx]);
}
else
{
@@ -316,12 +347,12 @@ void LLPanelEnvironmentInfo::refresh()
updateAltLabel(alt_prefixes[idx], idx + 2, altitude);
mAltitudes[alt_sliders[idx]] = AltitudeData(idx + 2, idx, altitude);
}
- if (sld->getCurNumSliders() != ALTITUDE_SLIDER_COUNT)
+ if (mMultiSliderAltitudes->getCurNumSliders() != ALTITUDE_SLIDER_COUNT)
{
LL_WARNS("ENVPANEL") << "Failed to add altitude sliders!" << LL_ENDL;
}
readjustAltLabels();
- sld->resetCurSlider();
+ mMultiSliderAltitudes->resetCurSlider();
}
updateAltLabel(alt_prefixes[3], 1, 0); // ground
@@ -455,77 +486,75 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled)
if (mNoEnvironment || (!LLEnvironment::instance().isExtendedEnvironmentEnabled() && !isRegion()))
{
is_unavailable = true;
- getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_LEGACY));
+ mEnvironmentDisabledText->setText(getString(STR_LEGACY));
}
else if (mNoSelection)
{
is_unavailable = true;
- getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_NO_PARCEL));
+ mEnvironmentDisabledText->setText(getString(STR_NO_PARCEL));
}
else if (mCrossRegion)
{
is_unavailable = true;
- getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_CROSS_REGION));
+ mEnvironmentDisabledText->setText(getString(STR_CROSS_REGION));
}
else if (!isRegion() && !mAllowOverride)
{
is_unavailable = true;
- getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_DISALLOWED));
+ mEnvironmentDisabledText->setText(getString(STR_DISALLOWED));
}
else if (!is_bigenough)
{
is_unavailable = true;
- getChild<LLTextBox>(TXT_DISABLED)->setText(getString(STR_TOO_SMALL));
+ mEnvironmentDisabledText->setText(getString(STR_TOO_SMALL));
}
if (is_unavailable)
{
- getChild<LLUICtrl>(PNL_SETTINGS)->setVisible(false);
- getChild<LLUICtrl>(PNL_BUTTONS)->setVisible(false);
- getChild<LLUICtrl>(PNL_DISABLED)->setVisible(true);
- getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(false);
- getChild<LLUICtrl>(PNL_REGION_MSG)->setVisible(false);
+ mPanelEnvConfig->setVisible(false);
+ mPanelEnvButtons->setVisible(false);
+ mPanelEnvDisabled->setVisible(true);
+ mPanelEnvAltitudes->setVisible(false);
+ mPanelEnvRegionMsg->setVisible(false);
updateEditFloater(mCurrentEnvironment, false);
return false;
}
- getChild<LLUICtrl>(PNL_SETTINGS)->setVisible(true);
- getChild<LLUICtrl>(PNL_BUTTONS)->setVisible(true);
- getChild<LLUICtrl>(PNL_DISABLED)->setVisible(false);
- getChild<LLUICtrl>(PNL_REGION_MSG)->setVisible(isRegion());
+ mPanelEnvConfig->setVisible(true);
+ mPanelEnvButtons->setVisible(true);
+ mPanelEnvDisabled->setVisible(false);
+ mPanelEnvRegionMsg->setVisible(isRegion());
- getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(LLEnvironment::instance().isExtendedEnvironmentEnabled());
- getChild<LLUICtrl>(BTN_RST_ALTITUDES)->setVisible(isRegion());
+ mPanelEnvAltitudes->setVisible(LLEnvironment::instance().isExtendedEnvironmentEnabled());
+ mBtnResetAltitudes->setVisible(isRegion());
bool can_enable = enabled && !is_legacy && mCurrentEnvironment && (mCurEnvVersion != INVALID_PARCEL_ENVIRONMENT_VERSION);
- getChild<LLUICtrl>(BTN_SELECTINV)->setEnabled(can_enable);
- getChild<LLUICtrl>(BTN_USEDEFAULT)->setEnabled(can_enable);
- getChild<LLUICtrl>(BTN_EDIT)->setEnabled(can_enable);
- getChild<LLUICtrl>(SLD_DAYLENGTH)->setEnabled(can_enable);
- getChild<LLUICtrl>(SLD_DAYOFFSET)->setEnabled(can_enable);
- getChild<LLUICtrl>(SLD_ALTITUDES)->setEnabled(can_enable && isRegion());
- getChild<LLUICtrl>(ICN_GROUND)->setColor((can_enable && isRegion()) ? LLColor4::white : LLColor4::grey % 0.8f);
- getChild<LLUICtrl>(ICN_WATER)->setColor((can_enable && isRegion()) ? LLColor4::white : LLColor4::grey % 0.8f);
- getChild<LLUICtrl>(BTN_RST_ALTITUDES)->setEnabled(can_enable && isRegion());
- getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setEnabled(can_enable);
- getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setEnabled(can_enable && isRegion());
+ mBtnSelectInv->setEnabled(can_enable);
+ mBtnUseDefault->setEnabled(can_enable);
+ mBtnEdit->setEnabled(can_enable);
+ mSliderDayLength->setEnabled(can_enable);
+ mSliderDayOffset->setEnabled(can_enable);
+ mMultiSliderAltitudes->setEnabled(can_enable && isRegion());
+ mIconGround->setColor((can_enable && isRegion()) ? LLColor4::white : LLColor4::grey % 0.8f);
+ mIconWater->setColor((can_enable && isRegion()) ? LLColor4::white : LLColor4::grey % 0.8f);
+ mBtnResetAltitudes->setEnabled(can_enable && isRegion());
+ mPanelEnvAltitudes->setEnabled(can_enable);
+ mCheckAllowOverride->setEnabled(can_enable && isRegion());
for (U32 idx = 0; idx < ALTITUDE_MARKERS_COUNT; idx++)
{
- LLUICtrl* marker = findChild<LLUICtrl>(slider_marker_base + llformat("%u", idx));
- if (marker)
+ if (mAltitudeMarkers[idx])
{
static LLColor4 marker_color(0.75f, 0.75f, 0.75f, 1.f);
- marker->setColor((can_enable && isRegion()) ? marker_color : marker_color % 0.3f);
+ mAltitudeMarkers[idx]->setColor((can_enable && isRegion()) ? marker_color : marker_color % 0.3f);
}
}
for (U32 idx = 0; idx < ALTITUDE_PREFIXERS_COUNT; idx++)
{
- LLSettingsDropTarget* drop_target = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]);
- if (drop_target)
+ if (mAltitudePrefixers[idx])
{
- drop_target->setDndEnabled(can_enable);
+ mAltitudePrefixers[idx]->setDndEnabled(can_enable);
}
}
@@ -544,13 +573,7 @@ void LLPanelEnvironmentInfo::clearDirtyFlag(U32 flag)
void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_prefix, U32 sky_index, F32 alt_value)
{
- LLMultiSliderCtrl *sld = findChild<LLMultiSliderCtrl>(SLD_ALTITUDES);
- if (!sld)
- {
- LL_WARNS() << "Failed to find slider " << SLD_ALTITUDES << LL_ENDL;
- return;
- }
- LLRect sld_rect = sld->getRect();
+ LLRect sld_rect = mMultiSliderAltitudes->getRect();
S32 sld_range = sld_rect.getHeight();
S32 sld_bottom = sld_rect.mBottom;
S32 sld_offset = sld_rect.getWidth(); // Roughly identical to thumb's width in slider.
@@ -596,14 +619,11 @@ void LLPanelEnvironmentInfo::readjustAltLabels()
// Very simple "adjust after the fact" method
// Note: labels can be in any order
- LLMultiSliderCtrl *sld = findChild<LLMultiSliderCtrl>(SLD_ALTITUDES);
- if (!sld) return;
-
LLView* view_midle = NULL;
U32 midle_ind = 0;
S32 shift_up = 0;
S32 shift_down = 0;
- LLRect sld_rect = sld->getRect();
+ LLRect sld_rect = mMultiSliderAltitudes->getRect();
// Find the middle one
for (U32 i = 0; i < ALTITUDE_SLIDER_COUNT; i++)
@@ -907,10 +927,10 @@ void LLPanelEnvironmentInfo::udpateApparentTimeOfDay()
if ((!mCurrentEnvironment) || (mCurrentEnvironment->mDayLength.value() < 1.0) || (mCurrentEnvironment->mDayOffset.value() < 1.0))
{
- getChild<LLUICtrl>(LBL_TIMEOFDAY)->setVisible(false);
+ mLabelApparentTime->setVisible(false);
return;
}
- getChild<LLUICtrl>(LBL_TIMEOFDAY)->setVisible(true);
+ mLabelApparentTime->setVisible(true);
S32Seconds now((S32)LLDate::now().secondsSinceEpoch());
@@ -932,10 +952,10 @@ void LLPanelEnvironmentInfo::udpateApparentTimeOfDay()
std::string lblminute(((minutesofhour.value() < 10) ? "0" : "") + LLSD(minutesofhour.value()).asString());
- getChild<LLUICtrl>(LBL_TIMEOFDAY)->setTextArg("[HH]", LLSD(hourofday.value()).asString());
- getChild<LLUICtrl>(LBL_TIMEOFDAY)->setTextArg("[MM]", lblminute);
- getChild<LLUICtrl>(LBL_TIMEOFDAY)->setTextArg("[AP]", std::string(am_pm ? "PM" : "AM"));
- getChild<LLUICtrl>(LBL_TIMEOFDAY)->setTextArg("[PRC]", LLSD((S32)(100 * perc)).asString());
+ mLabelApparentTime->setTextArg("[HH]", LLSD(hourofday.value()).asString());
+ mLabelApparentTime->setTextArg("[MM]", lblminute);
+ mLabelApparentTime->setTextArg("[AP]", std::string(am_pm ? "PM" : "AM"));
+ mLabelApparentTime->setTextArg("[PRC]", LLSD((S32)(100 * perc)).asString());
}