diff options
Diffstat (limited to 'indra/newview/llpanelenvironment.cpp')
-rw-r--r-- | indra/newview/llpanelenvironment.cpp | 212 |
1 files changed, 118 insertions, 94 deletions
diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index a706e339ea..51e2c05070 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,61 @@ 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++) + { + mAltitudeDropTarget[idx] = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]); + mAltitudeLabels[idx] = findChild<LLTextBox>("txt_" + alt_prefixes[idx]); + mAltitudeEditor[idx] = findChild<LLLineEditor>("edt_invname_" + alt_prefixes[idx]); + mAltitudePanels[idx] = findChild<LLView>("pnl_" + alt_prefixes[idx]); + } + for (U32 idx = 0; idx < ALTITUDE_SLIDER_COUNT; idx++) { LLSettingsDropTarget* drop_target = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]); @@ -192,11 +227,12 @@ bool LLPanelEnvironmentInfo::postBuild() { drop_target->setPanel(this, alt_sliders[idx]); } + // set initial values to prevent [ALTITUDE] from displaying - updateAltLabel(alt_prefixes[idx], idx + 2, (F32)(idx * 1000)); + updateAltLabel(idx, idx + 2, (F32)(idx * 1000)); } - getChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[3])->setPanel(this, alt_prefixes[3]); - getChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[4])->setPanel(this, alt_prefixes[4]); + mAltitudeDropTarget[3]->setPanel(this, alt_prefixes[3]); + mAltitudeDropTarget[4]->setPanel(this, alt_prefixes[4]); return true; } @@ -262,8 +298,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,59 +309,58 @@ 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 { // Something is very very wrong LL_WARNS_ONCE("ENVPANEL") << "Failed to set up altitudes for parcel id " << getParcelId() << LL_ENDL; } - updateAltLabel(alt_prefixes[idx], idx + 2, altitude); + updateAltLabel(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 - updateAltLabel(alt_prefixes[4], 0, 0); // water + updateAltLabel(3, 1, 0); // ground + updateAltLabel(4, 0, 0); // water } @@ -455,77 +490,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 (mAltitudeDropTarget[idx]) { - drop_target->setDndEnabled(can_enable); + mAltitudeDropTarget[idx]->setDndEnabled(can_enable); } } @@ -542,24 +575,18 @@ void LLPanelEnvironmentInfo::clearDirtyFlag(U32 flag) mDirtyFlag &= ~flag; } -void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_prefix, U32 sky_index, F32 alt_value) +void LLPanelEnvironmentInfo::updateAltLabel(U32 alt_index, 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. S32 pos = (S32)((sld_range - sld_offset) * ((alt_value - 100) / (4000 - 100))); // get related views - LLTextBox* text = findChild<LLTextBox>("txt_" + alt_prefix); - LLLineEditor *field = findChild<LLLineEditor>("edt_invname_" + alt_prefix); - LLView *alt_panel = findChild<LLView>("pnl_" + alt_prefix); + LLTextBox* text = mAltitudeLabels[alt_index]; + LLLineEditor* field = mAltitudeEditor[alt_index]; + LLView* alt_panel = mAltitudePanels[alt_index]; if (text && (sky_index > 1)) { @@ -596,19 +623,16 @@ 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++) { - LLView* cmp_view = findChild<LLView>(alt_panels[i], true); + LLView* cmp_view = mAltitudePanels[i]; if (!cmp_view) return; LLRect cmp_rect = cmp_view->getRect(); S32 pos = 0; @@ -619,7 +643,7 @@ void LLPanelEnvironmentInfo::readjustAltLabels() { if (i != j) { - LLView* intr_view = findChild<LLView>(alt_panels[j], true); + LLView* intr_view = mAltitudePanels[j]; if (!intr_view) return; LLRect intr_rect = intr_view->getRect(); if (cmp_rect.mBottom >= intr_rect.mBottom) @@ -667,7 +691,7 @@ void LLPanelEnvironmentInfo::readjustAltLabels() { if (i != midle_ind) { - LLView* trn_view = findChild<LLView>(alt_panels[i], true); + LLView* trn_view = mAltitudePanels[i]; LLRect trn_rect = trn_view->getRect(); if (trn_rect.mBottom <= midle_rect.mTop && trn_rect.mBottom >= midle_rect.mBottom) @@ -787,7 +811,7 @@ void LLPanelEnvironmentInfo::onAltSliderCallback(LLUICtrl *cntrl, const LLSD &da } iter->second.mTrackIndex = new_index; - updateAltLabel(alt_prefixes[iter->second.mLabelIndex], iter->second.mTrackIndex, iter->second.mAltitude); + updateAltLabel(iter->second.mLabelIndex, iter->second.mTrackIndex, iter->second.mAltitude); iter++; } @@ -907,10 +931,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 +956,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()); } |