diff options
author | Rider Linden <rider@lindenlab.com> | 2018-05-18 13:33:49 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2018-05-18 13:33:49 -0700 |
commit | 9dc8df35c0ae24ed8a1d8329c7b0ac0f71d239bf (patch) | |
tree | 24d7a43af758fb7de0fa8406cc729a6803b7ed54 | |
parent | 4c1a633c232880f4ac6e01807f1084e5d5c68b1e (diff) | |
parent | e4973e0f92b524e7f9c2d10745f4c5e3a8557284 (diff) |
Merge
-rw-r--r-- | indra/llui/llmultislider.cpp | 49 | ||||
-rw-r--r-- | indra/llui/llmultislider.h | 1 | ||||
-rw-r--r-- | indra/llui/llmultisliderctrl.cpp | 5 | ||||
-rw-r--r-- | indra/llui/llmultisliderctrl.h | 1 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.cpp | 975 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.h | 69 | ||||
-rw-r--r-- | indra/newview/llpanelenvironment.cpp | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml | 45 |
8 files changed, 365 insertions, 784 deletions
diff --git a/indra/llui/llmultislider.cpp b/indra/llui/llmultislider.cpp index 0aa3e17075..93045a6578 100644 --- a/indra/llui/llmultislider.cpp +++ b/indra/llui/llmultislider.cpp @@ -196,7 +196,11 @@ void LLMultiSlider::setValue(const LLSD& value) F32 LLMultiSlider::getSliderValue(const std::string& name) const { - return (F32)mValue[name].asReal(); + if (mValue.has(name)) + { + return (F32)mValue[name].asReal(); + } + return 0; } void LLMultiSlider::setCurSlider(const std::string& name) @@ -206,6 +210,11 @@ void LLMultiSlider::setCurSlider(const std::string& name) } } +void LLMultiSlider::resetCurSlider() +{ + mCurSlider = LLStringUtil::null; +} + const std::string& LLMultiSlider::addSlider() { return addSlider(mInitialValue); @@ -334,10 +343,15 @@ void LLMultiSlider::deleteSlider(const std::string& name) void LLMultiSlider::clear() { - while(mThumbRects.size() > 0) { + while(mThumbRects.size() > 0 && mValue.size() > 0) { deleteCurSlider(); } + if (mThumbRects.size() > 0 || mValue.size() > 0) + { + LL_WARNS() << "Failed to fully clear Multi slider" << LL_ENDL; + } + LLF32UICtrl::clear(); } @@ -416,20 +430,23 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask) } } - // Find the offset of the actual mouse location from the center of the thumb. - if (mThumbRects[mCurSlider].pointInRect(x,y)) + if (!mCurSlider.empty()) { - mMouseOffset = (mThumbRects[mCurSlider].mLeft + mThumbWidth/2) - x; - } - else - { - mMouseOffset = 0; - } + // Find the offset of the actual mouse location from the center of the thumb. + if (mThumbRects[mCurSlider].pointInRect(x,y)) + { + mMouseOffset = (mThumbRects[mCurSlider].mLeft + mThumbWidth/2) - x; + } + else + { + mMouseOffset = 0; + } - // Start dragging the thumb - // No handler needed for focus lost since this class has no state that depends on it. - gFocusMgr.setMouseCapture( this ); - mDragStartThumbRect = mThumbRects[mCurSlider]; + // Start dragging the thumb + // No handler needed for focus lost since this class has no state that depends on it. + gFocusMgr.setMouseCapture( this ); + mDragStartThumbRect = mThumbRects[mCurSlider]; + } } make_ui_sound("UISndClick"); @@ -546,7 +563,7 @@ void LLMultiSlider::draw() thumb_imagep->drawSolid(mDragStartThumbRect, mThumbCenterColor.get() % 0.3f); // draw the highlight - if (hasFocus()) + if (hasFocus() && !mCurSlider.empty()) { thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); } @@ -578,7 +595,7 @@ void LLMultiSlider::draw() else { // draw highlight - if (hasFocus()) + if (hasFocus() && !mCurSlider.empty()) { thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth()); } diff --git a/indra/llui/llmultislider.h b/indra/llui/llmultislider.h index 2b422e89c9..927063a5fd 100644 --- a/indra/llui/llmultislider.h +++ b/indra/llui/llmultislider.h @@ -76,6 +76,7 @@ public: const std::string& getCurSlider() const { return mCurSlider; } F32 getCurSliderValue() const { return getSliderValue(mCurSlider); } void setCurSlider(const std::string& name); + void resetCurSlider(); void setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mCurSlider, val, from_event); } /*virtual*/ void setValue(const LLSD& value); diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp index c460a08afc..a982d431b3 100644 --- a/indra/llui/llmultisliderctrl.cpp +++ b/indra/llui/llmultisliderctrl.cpp @@ -213,6 +213,11 @@ void LLMultiSliderCtrl::setCurSlider(const std::string& name) mCurValue = mMultiSlider->getCurSliderValue(); } +void LLMultiSliderCtrl::resetCurSlider() +{ + mMultiSlider->resetCurSlider(); +} + BOOL LLMultiSliderCtrl::setLabelArg( const std::string& key, const LLStringExplicit& text ) { BOOL res = FALSE; diff --git a/indra/llui/llmultisliderctrl.h b/indra/llui/llmultisliderctrl.h index b6a3542376..84378ff7b2 100644 --- a/indra/llui/llmultisliderctrl.h +++ b/indra/llui/llmultisliderctrl.h @@ -84,6 +84,7 @@ public: const std::string& getCurSlider() const { return mMultiSlider->getCurSlider(); } F32 getCurSliderValue() const { return mCurValue; } void setCurSlider(const std::string& name); + void resetCurSlider(); void setCurSliderValue(F32 val, BOOL from_event = false) { setSliderValue(mMultiSlider->getCurSlider(), val, from_event); } virtual void setMinValue(const LLSD& min_value) { setMinValue((F32)min_value.asReal()); } diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 222b530155..74cde2b0f7 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -44,10 +44,13 @@ // newview #include "llagent.h" +//#include "llflyoutcombobtnctrl.h" //Todo: get rid of this and LLSaveOutfitComboBtn, make a proper UI element/button/pannel instead #include "llregioninfomodel.h" #include "llviewerregion.h" #include "llpaneleditwater.h" #include "llpaneleditsky.h" +//#include "llsettingsvo.h" +//#include "llinventorymodel.h" #include "llenvironment.h" #include "lltrans.h" @@ -60,6 +63,14 @@ static const std::string track_tabs[] = { "sky4_track", }; +// For flyout +/*const std::string ACTION_SAVE("save_settings"); +const std::string ACTION_SAVEAS("save_as_new_settings"); +const std::string ACTION_APPLY_LOCAL("apply_local"); +const std::string ACTION_APPLY_PARCEL("apply_parcel"); +const std::string ACTION_APPLY_REGION("apply_region"); + +const std::string XML_FLYOUTMENU_FILE("menu_save_settings.xml");*/ //========================================================================= // **RIDER** @@ -71,50 +82,69 @@ const std::string LLFloaterFixedEnvironment::KEY_DAY_OFFSET("day_offset"); // **RIDER** -LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key): +LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key): LLFloater(key), mSaveButton(NULL), mCancelButton(NULL), + mUploadButton(NULL), mDayLength(0), mDayOffset(0), mCurrentTrack(4), mTimeSlider(NULL), mFramesSlider(NULL), + //mFlyoutControl(NULL), mCurrentTimeLabel(NULL), // **RIDER** mInventoryId(), mInventoryItem(nullptr) // **RIDER** -// , mTimeCtrl(NULL) -// , mMakeDefaultCheckBox(NULL) -// , { mCommitCallbackRegistrar.add("DayCycle.Track", boost::bind(&LLFloaterEditExtDayCycle::onTrackSelectionCallback, this, _2)); } +LLFloaterEditExtDayCycle::~LLFloaterEditExtDayCycle() +{ + // Todo: consider remaking mFlyoutControl into class that initializes intself with floater, + // completes at postbuild, e t c... + // (make it into actual button?, In such case XML_FLYOUTMENU_FILE will be specified in xml) + //delete mFlyoutControl; +} + +void LLFloaterEditExtDayCycle::openFloater(LLSettingsDay::ptr_t settings, S64Seconds daylength, S64Seconds dayoffset) +{ + mSavedDay = settings; + mEditDay = settings->buildClone(); + mDayLength = daylength; + mDayOffset = dayoffset; + LLFloater::openFloater(); +} + // virtual BOOL LLFloaterEditExtDayCycle::postBuild() { - getChild<LLButton>("add_frame")->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddTrack, this)); - getChild<LLButton>("delete_frame")->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onRemoveTrack, this)); getChild<LLLineEditor>("day_cycle_name")->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onCommitName, this, _1, _2), NULL); mSaveButton = getChild<LLButton>("save_btn", true); mCancelButton = getChild<LLButton>("cancel_btn", true); mUploadButton = getChild<LLButton>("upload_btn", true); + mAddFrameButton = getChild<LLButton>("add_frame", true); + mDeleteFrameButton = getChild<LLButton>("delete_frame", true); mTimeSlider = getChild<LLMultiSliderCtrl>("WLTimeSlider"); mFramesSlider = getChild<LLMultiSliderCtrl>("WLDayCycleFrames"); mSkyTabLayoutContainer = getChild<LLView>("frame_settings_sky", true); mWaterTabLayoutContainer = getChild<LLView>("frame_settings_water", true); mCurrentTimeLabel = getChild<LLTextBox>("current_time", true); - //initCallbacks(); + //mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE); + //mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); - mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnSave, this)); + mUploadButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnSave, this)); mCancelButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnCancel, this)); - mUploadButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onUpload, this)); + mUploadButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnUpload, this)); mTimeSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onTimeSliderMoved, this)); mFramesSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onFrameSliderCallback, this)); + mAddFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddTrack, this)); + mDeleteFrameButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onRemoveTrack, this)); mTimeSlider->addSlider(0); @@ -164,17 +194,32 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) const S32 max_elm = 5; if (mDayLength.value() != 0) { - F32Hours hrs; + S32Hours hrs; + S32Minutes minutes; + S64Seconds total; + //LLDate date; LLUIString formatted_label = getString("time_label"); for (int i = 0; i < max_elm; i++) { - // Todo: if possible, find a better way, both to get string and child names - hrs = ((mDayLength / (max_elm - 1)) * i) + mDayOffset; - formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value())); + total = ((mDayLength / (max_elm - 1)) * i) + mDayOffset; + hrs = total; + minutes = total - hrs; + + //date = LLDate(((mDayLength / (max_elm - 1)) * i) + mDayOffset); + //formatted_label.setArg("[TIME]", date.toHTTPDateString(std::string("%H:%M"))); + //formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value())); + + formatted_label.setArg("[HH]", llformat("%d", hrs.value())); + formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value()))); getChild<LLTextBox>("p" + llformat("%d", i), true)->setTextArg("[DSC]", formatted_label.getString()); } hrs = mDayOffset; - formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value())); + minutes = mDayOffset - hrs; + //formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value())); + //date = LLDate(mDayOffset); + //formatted_label.setArg("[TIME]", date.toHTTPDateString(std::string("%H:%M"))); + formatted_label.setArg("[HH]", llformat("%d", hrs.value())); + formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value()))); mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString()); } else @@ -185,13 +230,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) } mCurrentTimeLabel->setTextArg("[DSC]", std::string()); } - - //todo: add time slider setting - - /*list_name_id_t getSkyList() const; - list_name_id_t getWaterList() const; - - getChild<LLButton>("sky4_track", true)->setToggleState(true);*/ } void LLFloaterEditExtDayCycle::onClose(bool app_quitting) @@ -204,65 +242,6 @@ void LLFloaterEditExtDayCycle::onClose(bool app_quitting) } } - -void LLFloaterEditExtDayCycle::onUpload() -{ - LLSettingsVOBase::createInventoryItem( mEditDay ); - -#if 0 - LLSettingsVOBase::storeAsAsset(mEditDay); - - LLTransactionID tid; - tid.generate(); - LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - - const std::string filename = asset_id_to_filename(mAssetID, LL_PATH_CACHE); - if (!exportFile(filename)) - { - std::string buffer = llformat("Unable to save '%s' to wearable file.", mName.c_str()); - LL_WARNS() << buffer << LL_ENDL; - - LLSD args; - args["NAME"] = mName; - LLNotificationsUtil::add("CannotSaveWearableOutOfSpace", args); - return; - } - - if (gSavedSettings.getBOOL("LogWearableAssetSave")) - { - const std::string log_filename = asset_id_to_filename(mAssetID, LL_PATH_LOGS); - exportFile(log_filename); - } - - // save it out to database - if (gAssetStorage) - { - /* - std::string url = gAgent.getRegion()->getCapability("NewAgentInventory"); - if (!url.empty()) - { - LL_INFOS() << "Update Agent Inventory via capability" << LL_ENDL; - LLSD body; - body["folder_id"] = gInventory.findCategoryUUIDForType(LLFolderType::assetToFolderType(getAssetType())); - body["asset_type"] = LLAssetType::lookup(getAssetType()); - body["inventory_type"] = LLInventoryType::lookup(LLInventoryType::IT_WEARABLE); - body["name"] = getName(); - body["description"] = getDescription(); - LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, filename)); - } - else - { - } - */ - LLWearableSaveData* data = new LLWearableSaveData; - data->mType = mType; - gAssetStorage->storeAssetData(filename, mTransactionID, getAssetType(), - &LLViewerWearable::onSaveNewAssetComplete, - (void*)data); - } -#endif -} - void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility) { if (new_visibility) @@ -277,47 +256,123 @@ void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility) } } +/*void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data) +{ + std::string ctrl_action = ctrl->getName(); + + if (ctrl_action == ACTION_SAVE) + { + mSavedDay = mEditDay; + //doApplyUpdateInventory(); + } + else if (ctrl_action == ACTION_SAVEAS) + { + //doApplyCreateNewInventory(); + LLSettingsVOBase::createInventoryItem(mEditDay, NULL); + } + else if ((ctrl_action == ACTION_APPLY_LOCAL) || + (ctrl_action == ACTION_APPLY_PARCEL) || + (ctrl_action == ACTION_APPLY_REGION)) + { + //doApplyEnvironment(ctrl_action); + // Shouldn't be supported? + } + else + { + LL_WARNS("ENVIRONMENT") << "Unknown settings action '" << ctrl_action << "'" << LL_ENDL; + } + + if (!mCommitSignal.empty()) + mCommitSignal(mEditDay); + closeFloater(); + }*/ + void LLFloaterEditExtDayCycle::onBtnSave() { + mSavedDay = mEditDay; + + //no longer needed? if (!mCommitSignal.empty()) mCommitSignal(mEditDay); + closeFloater(); } void LLFloaterEditExtDayCycle::onBtnCancel() { - closeFloater(); + closeFloater(); +} + +void LLFloaterEditExtDayCycle::onBtnUpload() +{ + LLSettingsVOBase::createInventoryItem(mEditDay); + //closeFloater(); } void LLFloaterEditExtDayCycle::onAddTrack() { + // todo: 2.5% safety zone + std::string sldr_key = mFramesSlider->getCurSlider(); F32 frame = mTimeSlider->getCurSliderValue(); LLSettingsBase::ptr_t setting; - // todo: expand to generate from panels instead of using defaults - if (mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack).get() != NULL) //temp check? todo: disable button in such cases + if (mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack).get() != NULL) { return; } - if (mCurrentTrack == 0) + + if (mCurrentTrack == LLSettingsDay::TRACK_WATER) { - setting = LLSettingsVOWater::buildDefaultWater(); + if (mSliderKeyMap.empty()) + { + // No existing points, use defaults + setting = LLSettingsVOWater::buildDefaultWater(); + } + else + { + // clone existing element, since we are intentionally dropping slider on time selection, copy from tab panels + LLView* tab_container = mWaterTabLayoutContainer->getChild<LLView>("water_tabs"); //can't extract panels directly, since it is in 'tuple' + LLPanelSettingsWaterMainTab* panel = dynamic_cast<LLPanelSettingsWaterMainTab*>(tab_container->getChildView("water_panel")); + if (panel) + { + setting = panel->getWater()->buildClone(); + } + } mEditDay->setWaterAtKeyframe(std::dynamic_pointer_cast<LLSettingsWater>(setting), frame); } else { - setting = LLSettingsVOSky::buildDefaultSky(); + if (mSliderKeyMap.empty()) + { + // No existing points, use defaults + setting = LLSettingsVOSky::buildDefaultSky(); + } + else + { + // clone existing element, since we are intentionally dropping slider on time selection, copy from tab panels + LLView* tab_container = mSkyTabLayoutContainer->getChild<LLView>("sky_tabs"); //can't extract panels directly, since they are in 'tuple' + + LLPanelSettingsSky* panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("atmosphere_panel")); + if (panel) + { + setting = panel->getSky()->buildClone(); + } + } mEditDay->setSkyAtKeyframe(std::dynamic_pointer_cast<LLSettingsSky>(setting), frame, mCurrentTrack); } + addSliderFrame(frame, setting); updateTabs(); } void LLFloaterEditExtDayCycle::onRemoveTrack() { - F32 frame = mTimeSlider->getCurSliderValue(); - mEditDay->removeTrackKeyframe(mCurrentTrack, frame); + std::string sldr_key = mFramesSlider->getCurSlider(); + if (!sldr_key.empty()) + { + return; + } removeCurrentSliderFrame(); - //mFramesSlider->deleteCurSlider(); + updateButtons(); } void LLFloaterEditExtDayCycle::onCommitName(class LLLineEditor* caller, void* user_data) @@ -333,14 +388,14 @@ void LLFloaterEditExtDayCycle::onTrackSelectionCallback(const LLSD& user_data) void LLFloaterEditExtDayCycle::onFrameSliderCallback() { - if (mFramesSlider->getValue().size() == 0) + if (mSliderKeyMap.size() == 0) { mLastFrameSlider.clear(); return; } // make sure we have a slider const std::string& cur_sldr = mFramesSlider->getCurSlider(); - if (cur_sldr == "") + if (cur_sldr.empty()) { mLastFrameSlider.clear(); return; @@ -349,7 +404,7 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback() F32 new_frame = mFramesSlider->getCurSliderValue(); // todo: add safety checks, user shouldn't be capable of moving one frame over another or move missing frame keymap_t::iterator iter = mSliderKeyMap.find(cur_sldr); - if (iter != mSliderKeyMap.end() && /*temp? until disabling mechanics*/ mEditDay->getSettingsAtKeyframe(new_frame, mCurrentTrack).get() == NULL) + if (iter != mSliderKeyMap.end() && mEditDay->getSettingsAtKeyframe(new_frame, mCurrentTrack).get() == NULL) { LL_DEBUGS() << "Moving frame from " << iter->second.first << " to " << new_frame << LL_ENDL; if (mEditDay->moveTrackKeyframe(mCurrentTrack, iter->second.first, new_frame)) @@ -358,6 +413,8 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback() } } + mTimeSlider->setCurSliderValue(new_frame); + if (mLastFrameSlider != cur_sldr) { // technically should not be possible for both frame and slider to change @@ -365,29 +422,33 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback() mLastFrameSlider = cur_sldr; updateTabs(); } - // updateTrack(); - // reset last known position + else + { + updateButtons(); + updateTimeAndLabel(); + } } void LLFloaterEditExtDayCycle::onTimeSliderMoved() { - // Todo: safety checks - // Update label - F32 time = mTimeSlider->getCurSliderValue(); - mCurrentTimeLabel->setTextArg("[PRCNT]", llformat("%.0f", time * 100)); - if (mDayLength.value() != 0) - { - F32Hours hrs = (mDayLength * time) + mDayOffset; - LLUIString formatted_label = getString("time_label"); - formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value())); - mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString()); - } - else + mFramesSlider->resetCurSlider(); + + keymap_t::iterator iter = mSliderKeyMap.begin(); + keymap_t::iterator end_iter = mSliderKeyMap.end(); + F32 frame = mTimeSlider->getCurSliderValue(); + while (iter != end_iter) { - mCurrentTimeLabel->setTextArg("[DSC]", std::string()); + if (iter->second.first == frame) + { + mFramesSlider->setCurSlider(iter->first); + break; + } + iter++; } - //Todo: update something related to time/play? + // Todo: safety checks + updateTabs(); + //Todo: update something related to time/play/blending? } void LLFloaterEditExtDayCycle::selectTrack(U32 track_index) @@ -400,60 +461,78 @@ void LLFloaterEditExtDayCycle::selectTrack(U32 track_index) return; } - for (int i = 0; i < 5; i++) // yse max value + for (int i = 0; i < LLSettingsDay::TRACK_MAX; i++) // use max value { getChild<LLButton>(track_tabs[i], true)->setToggleState(false); } button->setToggleState(true); - bool show_water = mCurrentTrack == 0; + bool show_water = mCurrentTrack == LLSettingsDay::TRACK_WATER; mSkyTabLayoutContainer->setVisible(!show_water); mWaterTabLayoutContainer->setVisible(show_water); updateSlider(); } -void LLFloaterEditExtDayCycle::updateTabs() +void LLFloaterEditExtDayCycle::clearTabs() { - if (mCurrentTrack == 0) + // todo: instead init with defaults? + if (mCurrentTrack == LLSettingsDay::TRACK_WATER) { - updateWaterTabs(); + const LLSettingsWaterPtr_t p_water = LLSettingsWaterPtr_t(NULL); + updateWaterTabs(p_water); } else { - updateSkyTabs(); + const LLSettingsSkyPtr_t p_sky = LLSettingsSkyPtr_t(NULL); + updateSkyTabs(p_sky); } + updateButtons(); + updateTimeAndLabel(); } -void LLFloaterEditExtDayCycle::updateWaterTabs() +void LLFloaterEditExtDayCycle::updateTabs() { - // todo: substitute with mSliderKeyMap? - const LLSettingsWaterPtr_t p_water = mEditDay->getWaterAtKeyframe(mFramesSlider->getCurSliderValue()); + // TODO: either prevent user from editing existing settings or clone them to not affect saved frames + std::string sldr = mFramesSlider->getCurSlider(); + if (sldr.empty()) + { + // keep old settings for duplicating if there are any + // TODO: disable tabs to prevent editing without nulling settings + } + else if (mCurrentTrack == LLSettingsDay::TRACK_WATER) + { + const LLSettingsWaterPtr_t p_water = sldr.empty() ? LLSettingsWaterPtr_t(NULL) : mEditDay->getWaterAtKeyframe(mFramesSlider->getCurSliderValue()); + updateWaterTabs(p_water); + } + else + { + const LLSettingsSkyPtr_t p_sky = sldr.empty() ? LLSettingsSkyPtr_t(NULL) : mEditDay->getSkyAtKeyframe(mFramesSlider->getCurSliderValue(), mCurrentTrack); + updateSkyTabs(p_sky); + } + updateButtons(); + updateTimeAndLabel(); +} - // Compiler warnings from getChild about LLPanelSettingsWaterMainTab not being complete/missing params constructor... - // Todo: fix class to work with getChild()? - LLView* tab_container = mWaterTabLayoutContainer->getChild<LLView>("water_tabs"); //can't extract panels directly, since they are in 'tuple' +void LLFloaterEditExtDayCycle::updateWaterTabs(const LLSettingsWaterPtr_t &p_water) +{ + LLView* tab_container = mWaterTabLayoutContainer->getChild<LLView>("water_tabs"); //can't extract panels directly, since it is in 'tuple' LLPanelSettingsWaterMainTab* panel = dynamic_cast<LLPanelSettingsWaterMainTab*>(tab_container->getChildView("water_panel")); if (panel) { - panel->setWater(p_water); // todo: Null disables + panel->setWater(p_water); } } -void LLFloaterEditExtDayCycle::updateSkyTabs() +void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) { - // todo: substitute with mSliderKeyMap? - const LLSettingsSkyPtr_t p_sky = mEditDay->getSkyAtKeyframe(mFramesSlider->getCurSliderValue(), mCurrentTrack); - LLView* tab_container = mSkyTabLayoutContainer->getChild<LLView>("sky_tabs"); //can't extract panels directly, since they are in 'tuple' - // Compiler warnings from getChild about tabs... - // Todo: fix class LLPanelSettingsSky* panel; panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("atmosphere_panel")); if (panel) { - panel->setSky(p_sky); // todo: Null disables + panel->setSky(p_sky); } panel = dynamic_cast<LLPanelSettingsSky*>(tab_container->getChildView("clouds_panel")); if (panel) @@ -467,51 +546,107 @@ void LLFloaterEditExtDayCycle::updateSkyTabs() } } +void LLFloaterEditExtDayCycle::updateButtons() +{ + F32 frame = mTimeSlider->getCurSliderValue(); + LLSettingsBase::ptr_t settings = mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack); + mAddFrameButton->setEnabled(settings.get() == NULL ? TRUE : FALSE); + mDeleteFrameButton->setEnabled(mSliderKeyMap.size() > 0 ? TRUE : FALSE); +} + void LLFloaterEditExtDayCycle::updateSlider() { mFramesSlider->clear(); mSliderKeyMap.clear(); + std::string new_slider; + F32 frame = 0; LLSettingsDay::CycleTrack_t track = mEditDay->getCycleTrack(mCurrentTrack); - for (auto &frame : track) + for (auto &track_frame : track) + { + // multi slider distinguishes elements by key/name in string format + // store names to map to be able to recall dependencies + frame = track_frame.first; + new_slider = mFramesSlider->addSlider(frame); + mSliderKeyMap[new_slider] = framedata_t(frame, track_frame.second); + } + + mLastFrameSlider = new_slider; + + if (mSliderKeyMap.size() > 0) + { + mTimeSlider->setCurSliderValue(frame); + updateTabs(); + } + else + { + // disable panels + clearTabs(); + } +} + +void LLFloaterEditExtDayCycle::updateTimeAndLabel() +{ + F32 time = mTimeSlider->getCurSliderValue(); + mCurrentTimeLabel->setTextArg("[PRCNT]", llformat("%.0f", time * 100)); + if (mDayLength.value() != 0) + { + LLUIString formatted_label = getString("time_label"); + + //F32Hours hrs = (mDayLength * time) + mDayOffset; + //LLDate date((mDayLength * time) + mDayOffset); + //formatted_label.setArg("[TIME]", llformat("%.1f", hrs.value())); + //formatted_label.setArg("[TIME]", date.toHTTPDateString(std::string("%H:%M"))); + + S64Seconds total = (mDayLength * time) + mDayOffset; + S32Hours hrs = total; + S32Minutes minutes = total - hrs; + + formatted_label.setArg("[HH]", llformat("%d", hrs.value())); + formatted_label.setArg("[MM]", llformat("%d", abs(minutes.value()))); + mCurrentTimeLabel->setTextArg("[DSC]", formatted_label.getString()); + } + else { - addSliderFrame(frame.first, frame.second); + mCurrentTimeLabel->setTextArg("[DSC]", std::string()); } + + // Update blender here: } void LLFloaterEditExtDayCycle::addSliderFrame(const F32 frame, LLSettingsBase::ptr_t setting) { // multi slider distinguishes elements by key/name in string format - // store names to map to be able to recal dependencies + // store names to map to be able to recall dependencies std::string new_slider = mFramesSlider->addSlider(frame); mSliderKeyMap[new_slider] = framedata_t(frame, setting); mLastFrameSlider = new_slider; + mTimeSlider->setCurSliderValue(frame); updateTabs(); } void LLFloaterEditExtDayCycle::removeCurrentSliderFrame() { std::string sldr = mFramesSlider->getCurSlider(); + if (sldr.empty()) + { + return; + } mFramesSlider->deleteCurSlider(); keymap_t::iterator iter = mSliderKeyMap.find(sldr); if (iter != mSliderKeyMap.end()) { LL_DEBUGS() << "Removing frame from " << iter->second.first << LL_ENDL; mSliderKeyMap.erase(iter); + mEditDay->removeTrackKeyframe(mCurrentTrack, iter->second.first); } + mLastFrameSlider = mFramesSlider->getCurSlider(); + mTimeSlider->setCurSliderValue(mFramesSlider->getCurSliderValue()); updateTabs(); } -/*void LLFloaterEditExtDayCycle::updateTrack() -{ - LLMultiSliderCtrl* slider = getChild<LLMultiSliderCtrl>("WLDayCycleKeys"); - //mEditDay->getTrackKeyframes - - // todo make tracks named to allow movement -}*/ - //------------------------------------------------------------------------- LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSignal(LLFloaterEditExtDayCycle::edit_commit_signal_t::slot_type cb) @@ -594,565 +729,3 @@ void LLFloaterFixedEnvironment::syncronizeTabs() // **RIDER** -// -// virtual -// void LLFloaterEditExtDayCycle::draw() -// { -// syncTimeSlider(); -// LLFloater::draw(); -// } -// -// void LLFloaterEditExtDayCycle::initCallbacks(void) -// { -// #if 0 -// mDayCycleNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onDayCycleNameEdited, this), NULL); -// mDayCyclesCombo->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onDayCycleSelected, this)); -// mDayCyclesCombo->setTextEntryCallback(boost::bind(&LLFloaterEditExtDayCycle::onDayCycleNameEdited, this)); -// mTimeSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onTimeSliderMoved, this)); -// mKeysSlider->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onKeyTimeMoved, this)); -// mTimeCtrl->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onKeyTimeChanged, this)); -// mSkyPresetsCombo->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onKeyPresetChanged, this)); -// -// getChild<LLButton>("WLAddKey")->setClickedCallback(boost::bind(&LLFloaterEditExtDayCycle::onAddKey, this)); -// getChild<LLButton>("WLDeleteKey")->setClickedCallback(boost::bind(&LLFloaterEditExtDayCycle::onDeleteKey, this)); -// -// mSaveButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnSave, this)); -// mSaveButton->setRightMouseDownCallback(boost::bind(&LLFloaterEditExtDayCycle::dumpTrack, this)); -// getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnCancel, this)); -// -// // Connect to env manager events. -// LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); -// env_mgr.setRegionSettingsChangeCallback(boost::bind(&LLFloaterEditExtDayCycle::onRegionSettingsChange, this)); -// gAgent.addRegionChangedCallback(boost::bind(&LLFloaterEditExtDayCycle::onRegionChange, this)); -// env_mgr.setRegionSettingsAppliedCallback(boost::bind(&LLFloaterEditExtDayCycle::onRegionSettingsApplied, this, _1)); -// // Connect to day cycle manager events. -// LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLFloaterEditExtDayCycle::onDayCycleListChange, this)); -// -// // Connect to sky preset list changes. -// LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterEditExtDayCycle::onSkyPresetListChange, this)); -// -// -// // Connect to region info updates. -// LLRegionInfoModel::instance().setUpdateCallback(boost::bind(&LLFloaterEditExtDayCycle::onRegionInfoUpdate, this)); -// #endif -// } -// -// void LLFloaterEditExtDayCycle::syncTimeSlider() -// { -// #if 0 -// // set time -// mTimeSlider->setCurSliderValue((F32)LLWLParamManager::getInstance()->mAnimator.getDayTime() * sHoursPerDay); -// #endif -// } -// -// void LLFloaterEditExtDayCycle::loadTrack() -// { -// // clear the slider -// mKeysSlider->clear(); -// mSliderToKey.clear(); -// -// // add sliders -// -// LL_DEBUGS() << "Adding " << LLWLParamManager::getInstance()->mDay.mTimeMap.size() << " keys to slider" << LL_ENDL; -// -// LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; -// for (std::map<F32, LLWLParamKey>::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it) -// { -// addSliderKey(it->first * sHoursPerDay, it->second); -// } -// -// // set drop-down menu to match preset of currently-selected keyframe (one is automatically selected initially) -// const std::string& cur_sldr = mKeysSlider->getCurSlider(); -// if (strlen(cur_sldr.c_str()) > 0) // only do this if there is a curSldr, otherwise we put an invalid entry into the map -// { -// mSkyPresetsCombo->selectByValue(mSliderToKey[cur_sldr].keyframe.toStringVal()); -// } -// -// syncTimeSlider(); -// } -// -// void LLFloaterEditExtDayCycle::applyTrack() -// { -// #if 0 -// LL_DEBUGS() << "Applying track (" << mSliderToKey.size() << ")" << LL_ENDL; -// -// // if no keys, do nothing -// if (mSliderToKey.size() == 0) -// { -// LL_DEBUGS() << "No keys, not syncing" << LL_ENDL; -// return; -// } -// -// llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size()); -// -// // create a new animation track -// LLWLParamManager::getInstance()->mDay.clearKeyframes(); -// -// // add the keys one by one -// for (std::map<std::string, SliderKey>::iterator it = mSliderToKey.begin(); -// it != mSliderToKey.end(); ++it) -// { -// LLWLParamManager::getInstance()->mDay.addKeyframe(it->second.time / sHoursPerDay, -// it->second.keyframe); -// } -// -// // set the param manager's track to the new one -// LLWLParamManager::getInstance()->resetAnimator( -// mTimeSlider->getCurSliderValue() / sHoursPerDay, false); -// -// LLWLParamManager::getInstance()->mAnimator.update( -// LLWLParamManager::getInstance()->mCurParams); -// #endif -// } - -// void LLFloaterEditExtDayCycle::refreshDayCyclesList() -// { -// #if 0 -// llassert(isNewDay() == false); -// -// mDayCyclesCombo->removeall(); -// -// #if 0 // Disable editing existing day cycle until the workflow is clear enough. -// const LLSD& region_day = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); -// if (region_day.size() > 0) -// { -// LLWLParamKey key(getRegionName(), LLEnvKey::SCOPE_REGION); -// mDayCyclesCombo->add(key.name, key.toLLSD()); -// mDayCyclesCombo->addSeparator(); -// } -// #endif -// -// LLDayCycleManager::preset_name_list_t user_days, sys_days; -// LLDayCycleManager::instance().getPresetNames(user_days, sys_days); -// -// // Add user days. -// for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) -// { -// mDayCyclesCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); -// } -// -// if (user_days.size() > 0) -// { -// mDayCyclesCombo->addSeparator(); -// } -// -// // Add system days. -// for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) -// { -// mDayCyclesCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); -// } -// -// mDayCyclesCombo->setLabel(getString("combo_label")); -// #endif -// } -// -// -// -// void LLFloaterEditExtDayCycle::onKeyTimeChanged() -// { -// #if 0 -// // if no keys, skipped -// if (mSliderToKey.size() == 0) -// { -// return; -// } -// -// F32 time24 = mTimeCtrl->getTime24(); -// -// const std::string& cur_sldr = mKeysSlider->getCurSlider(); -// mKeysSlider->setCurSliderValue(time24, TRUE); -// F32 time = mKeysSlider->getCurSliderValue() / sHoursPerDay; -// -// // now set the key's time in the sliderToKey map -// LL_DEBUGS() << "Setting key time: " << time << LL_ENDL; -// mSliderToKey[cur_sldr].time = time; -// -// applyTrack(); -// #endif -// } -// -// -// void LLFloaterEditExtDayCycle::onAddKey() -// { -// #if 0 -// llassert_always(mSliderToKey.size() == mKeysSlider->getValue().size()); -// -// S32 max_sliders; -// LLEnvKey::EScope scope = LLEnvKey::SCOPE_LOCAL; // *TODO: editing region day cycle -// switch (scope) -// { -// case LLEnvKey::SCOPE_LOCAL: -// max_sliders = 20; // *HACK this should be LLWLPacketScrubber::MAX_LOCAL_KEY_FRAMES; -// break; -// case LLEnvKey::SCOPE_REGION: -// max_sliders = 12; // *HACK this should be LLWLPacketScrubber::MAX_REGION_KEY_FRAMES; -// break; -// default: -// max_sliders = (S32) mKeysSlider->getMaxValue(); -// break; -// } -// -// #if 0 -// if ((S32)mSliderToKey.size() >= max_sliders) -// { -// LLSD args; -// args["SCOPE"] = LLEnvManagerNew::getScopeString(scope); -// args["MAX"] = max_sliders; -// LLNotificationsUtil::add("DayCycleTooManyKeyframes", args, LLSD(), LLNotificationFunctorRegistry::instance().DONOTHING); -// return; -// } -// #endif -// -// // add the slider key -// std::string key_val = mSkyPresetsCombo->getSelectedValue().asString(); -// LLWLParamKey sky_params(key_val); -// llassert(!sky_params.name.empty()); -// -// F32 time = mTimeSlider->getCurSliderValue(); -// addSliderKey(time, sky_params); -// -// // apply the change to current day cycles -// applyTrack(); -// #endif -// } -// - -// #if 0 -// LLWLParamKey LLFloaterEditExtDayCycle::getSelectedDayCycle() -// { -// LLWLParamKey dc_key; -// -// if (mDayCycleNameEditor->getVisible()) -// { -// dc_key.name = mDayCycleNameEditor->getText(); -// dc_key.scope = LLEnvKey::SCOPE_LOCAL; -// } -// else -// { -// LLSD combo_val = mDayCyclesCombo->getValue(); -// -// if (!combo_val.isArray()) // manually typed text -// { -// dc_key.name = combo_val.asString(); -// dc_key.scope = LLEnvKey::SCOPE_LOCAL; -// } -// else -// { -// dc_key.fromLLSD(combo_val); -// } -// } -// -// return dc_key; -// } -// #endif -// -// bool LLFloaterEditExtDayCycle::isNewDay() const -// { -// return mKey.asString() == "new"; -// } -// -// void LLFloaterEditExtDayCycle::dumpTrack() -// { -// #if 0 -// LL_DEBUGS("Windlight") << "Dumping day cycle" << LL_ENDL; -// -// LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; -// for (std::map<F32, LLWLParamKey>::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it) -// { -// F32 time = it->first * 24.0f; -// S32 h = (S32) time; -// S32 m = (S32) ((time - h) * 60.0f); -// LL_DEBUGS("Windlight") << llformat("(%.3f) %02d:%02d", time, h, m) << " => " << it->second.name << LL_ENDL; -// } -// #endif -// } -// -// void LLFloaterEditExtDayCycle::enableEditing(bool enable) -// { -// mSkyPresetsCombo->setEnabled(enable); -// mTimeCtrl->setEnabled(enable); -// getChild<LLPanel>("day_cycle_slider_panel")->setCtrlsEnabled(enable); -// mSaveButton->setEnabled(enable); -// mMakeDefaultCheckBox->setEnabled(enable); -// } -// -// void LLFloaterEditExtDayCycle::reset() -// { -// #if 0 -// // clear the slider -// mKeysSlider->clear(); -// mSliderToKey.clear(); -// -// refreshSkyPresetsList(); -// -// if (isNewDay()) -// { -// mDayCycleNameEditor->setValue(LLSD()); -// F32 time = 0.5f * sHoursPerDay; -// mSaveButton->setEnabled(FALSE); // will be enabled as soon as users enters a name -// mTimeSlider->setCurSliderValue(time); -// -// addSliderKey(time, LLWLParamKey("Default", LLEnvKey::SCOPE_LOCAL)); -// onKeyTimeMoved(); // update the time control and sky sky combo -// -// applyTrack(); -// } -// else -// { -// refreshDayCyclesList(); -// -// // Disable controls until a day cycle to edit is selected. -// enableEditing(false); -// } -// #endif -// } -// -// void LLFloaterEditExtDayCycle::saveRegionDayCycle() -// { -// #if 0 -// LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); -// LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay; // the day cycle being edited -// -// // Get current day cycle and the sky preset it references. -// LLSD day_cycle = cur_dayp.asLLSD(); -// LLSD sky_map; -// cur_dayp.getSkyMap(sky_map); -// -// // Apply it to the region. -// LLEnvironmentSettings new_region_settings; -// new_region_settings.saveParams(day_cycle, sky_map, env_mgr.getRegionSettings().getWaterParams(), 0.0f); -// -// #if 1 -// LLEnvManagerNew::instance().setRegionSettings(new_region_settings); -// #else // Temporary disabled ability to upload new region settings from the Day Cycle Editor. -// if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings)) -// { -// LL_WARNS() << "Error applying region environment settings" << LL_ENDL; -// return; -// } -// -// setApplyProgress(true); -// #endif -// #endif -// } -// -// void LLFloaterEditExtDayCycle::setApplyProgress(bool started) -// { -// LLLoadingIndicator* indicator = getChild<LLLoadingIndicator>("progress_indicator"); -// -// indicator->setVisible(started); -// -// if (started) -// { -// indicator->start(); -// } -// else -// { -// indicator->stop(); -// } -// } -// -// bool LLFloaterEditExtDayCycle::getApplyProgress() const -// { -// return getChild<LLLoadingIndicator>("progress_indicator")->getVisible(); -// } -// -// void LLFloaterEditExtDayCycle::onDeleteKey() -// { -// #if 0 -// if (mSliderToKey.size() == 0) -// { -// return; -// } -// else if (mSliderToKey.size() == 1) -// { -// LLNotifications::instance().add("EnvCannotDeleteLastDayCycleKey", LLSD(), LLSD()); -// return; -// } -// -// // delete from map -// const std::string& sldr_name = mKeysSlider->getCurSlider(); -// std::map<std::string, SliderKey>::iterator mIt = mSliderToKey.find(sldr_name); -// mSliderToKey.erase(mIt); -// -// mKeysSlider->deleteCurSlider(); -// -// if (mSliderToKey.size() == 0) -// { -// return; -// } -// -// const std::string& name = mKeysSlider->getCurSlider(); -// mSkyPresetsCombo->selectByValue(mSliderToKey[name].keyframe.toStringVal()); -// F32 time24 = mSliderToKey[name].time; -// -// mTimeCtrl->setTime24(time24); -// -// applyTrack(); -// #endif -// } -// -// void LLFloaterEditExtDayCycle::onRegionSettingsChange() -// { -// #if 0 -// LL_DEBUGS("Windlight") << "Region settings changed" << LL_ENDL; -// -// if (getApplyProgress()) // our region settings have being applied -// { -// setApplyProgress(false); -// -// // Change preference if requested. -// if (mMakeDefaultCheckBox->getValue()) -// { -// LL_DEBUGS("Windlight") << "Changed environment preference to region settings" << LL_ENDL; -// LLEnvManagerNew::instance().setUseRegionSettings(true); -// } -// -// closeFloater(); -// } -// #endif -// } -// -// void LLFloaterEditExtDayCycle::onRegionChange() -// { -// #if 0 -// LL_DEBUGS("Windlight") << "Region changed" << LL_ENDL; -// -// // If we're editing the region day cycle -// if (getSelectedDayCycle().scope == LLEnvKey::SCOPE_REGION) -// { -// reset(); // undoes all unsaved changes -// } -// #endif -// } -// -// void LLFloaterEditExtDayCycle::onRegionSettingsApplied(bool success) -// { -// LL_DEBUGS("Windlight") << "Region settings applied: " << success << LL_ENDL; -// -// if (!success) -// { -// // stop progress indicator -// setApplyProgress(false); -// } -// } -// -// void LLFloaterEditExtDayCycle::onRegionInfoUpdate() -// { -// #if 0 -// LL_DEBUGS("Windlight") << "Region info updated" << LL_ENDL; -// bool can_edit = true; -// -// // If we've selected the region day cycle for editing. -// if (getSelectedDayCycle().scope == LLEnvKey::SCOPE_REGION) -// { -// // check whether we have the access -// can_edit = LLEnvManagerNew::canEditRegionSettings(); -// } -// -// enableEditing(can_edit); -// #endif -// } -// -// void LLFloaterEditExtDayCycle::onDayCycleNameEdited() -// { -// #if 0 -// // Disable saving a day cycle having empty name. -// LLWLParamKey key = getSelectedDayCycle(); -// mSaveButton->setEnabled(!key.name.empty()); -// #endif -// } -// -// void LLFloaterEditExtDayCycle::onDayCycleSelected() -// { -// #if 0 -// -// LLSD day_data; -// LLWLParamKey dc_key = getSelectedDayCycle(); -// bool can_edit = true; -// -// if (dc_key.scope == LLEnvKey::SCOPE_LOCAL) -// { -// if (!LLDayCycleManager::instance().getPreset(dc_key.name, day_data)) -// { -// LL_WARNS() << "No day cycle named " << dc_key.name << LL_ENDL; -// return; -// } -// } -// else -// { -// day_data = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); -// if (day_data.size() == 0) -// { -// LL_WARNS() << "Empty region day cycle" << LL_ENDL; -// llassert(day_data.size() > 0); -// return; -// } -// -// can_edit = LLEnvManagerNew::canEditRegionSettings(); -// } -// -// // We may need to add or remove region skies from the list. -// refreshSkyPresetsList(); -// -// F32 slider_time = mTimeSlider->getCurSliderValue() / sHoursPerDay; -// LLWLParamManager::instance().applyDayCycleParams(day_data, dc_key.scope, slider_time); -// loadTrack(); -// #endif -// enableEditing(false); -// } -// -// bool LLFloaterEditExtDayCycle::onSaveAnswer(const LLSD& notification, const LLSD& response) -// { -// S32 option = LLNotificationsUtil::getSelectedOption(notification, response); -// -// // If they choose save, do it. Otherwise, don't do anything -// if (option == 0) -// { -// onSaveConfirmed(); -// } -// -// return false; -// } -// -// void LLFloaterEditExtDayCycle::onSaveConfirmed() -// { -// #if 0 -// std::string name = getSelectedDayCycle().name; -// -// // Save preset. -// LLSD data = LLWLParamManager::instance().mDay.asLLSD(); -// LL_DEBUGS("Windlight") << "Saving day cycle " << name << ": " << data << LL_ENDL; -// LLDayCycleManager::instance().savePreset(name, data); -// -// // Change preference if requested. -// if (mMakeDefaultCheckBox->getValue()) -// { -// LL_DEBUGS("Windlight") << name << " is now the new preferred day cycle" << LL_ENDL; -// LLEnvManagerNew::instance().setUseDayCycle(name); -// } -// #endif -// closeFloater(); -// } -// -// void LLFloaterEditExtDayCycle::onDayCycleListChange() -// { -// if (!isNewDay()) -// { -// refreshDayCyclesList(); -// } -// } -// -// void LLFloaterEditExtDayCycle::onSkyPresetListChange() -// { -// refreshSkyPresetsList(); -// -// // Refresh sliders from the currently visible day cycle. -// loadTrack(); -// } -// -// static -// std::string LLFloaterEditExtDayCycle::getRegionName() -// { -// return gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); -// } diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index 3185644df9..3cc41e6248 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -37,6 +37,7 @@ class LLLineEditor; class LLMultiSliderCtrl; class LLTextBox; class LLTimeCtrl; +//class LLFlyoutComboBtnCtrl; typedef std::shared_ptr<LLSettingsBase> LLSettingsBasePtr_t; @@ -59,15 +60,14 @@ public: typedef boost::signals2::connection connection_t; LLFloaterEditExtDayCycle(const LLSD &key); + ~LLFloaterEditExtDayCycle(); + + void openFloater(LLSettingsDay::ptr_t settings, S64Seconds daylength = S64Seconds(0), S64Seconds dayoffset = S64Seconds(0)); BOOL postBuild(); - void onOpen(const LLSD& key); + void onOpen(const LLSD& key); void onClose(bool app_quitting); - - /*TEMP*/ - void onUpload(); - void onVisibilityChange(BOOL new_visibility); // /*virtual*/ void draw(); @@ -86,8 +86,10 @@ private: // // /// refresh the sky presets combobox +// void onButtonApply(LLUICtrl *ctrl, const LLSD &data); void onBtnSave(); void onBtnCancel(); + void onBtnUpload(); void onAddTrack(); void onRemoveTrack(); void onCommitName(class LLLineEditor* caller, void* user_data); @@ -96,13 +98,15 @@ private: void onFrameSliderCallback(); /// a frame moved or frame selection changed void selectTrack(U32 track_index); + void clearTabs(); void updateTabs(); - void updateSkyTabs(); - void updateWaterTabs(); + void updateWaterTabs(const LLSettingsWaterPtr_t &p_water); + void updateSkyTabs(const LLSettingsSkyPtr_t &p_sky); + void updateButtons(); void updateSlider(); //track to slider + void updateTimeAndLabel(); void addSliderFrame(const F32 frame, LLSettingsBase::ptr_t setting); void removeCurrentSliderFrame(); - //void updateTrack(); // slider->track, todo: better name // **RIDER** void loadInventoryItem(const LLUUID &inventoryId); @@ -114,41 +118,6 @@ private: // **RIDER** -// /// refresh the day cycle combobox -// void refreshDayCyclesList(); -// -// /// add a slider to the track -// -// void initCallbacks(); -// // LLWLParamKey getSelectedDayCycle(); -// bool isNewDay() const; -// void dumpTrack(); -// void enableEditing(bool enable); -// void reset(); -// void saveRegionDayCycle(); -// -// void setApplyProgress(bool started); -// bool getApplyProgress() const; -// -// void onKeyTimeChanged(); /// a key frame's time changed -// void onAddKey(); /// new key added on slider -// void onDeleteKey(); /// a key frame deleted -// -// void onRegionSettingsChange(); -// void onRegionChange(); -// void onRegionSettingsApplied(bool success); -// void onRegionInfoUpdate(); -// -// void onDayCycleNameEdited(); -// void onDayCycleSelected(); -// -// bool onSaveAnswer(const LLSD& notification, const LLSD& response); -// void onSaveConfirmed(); -// -// void onDayCycleListChange(); -// void onSkyPresetListChange(); -// -// static std::string getRegionName(); LLSettingsDay::ptr_t mEditDay; S64Seconds mDayLength; @@ -156,11 +125,11 @@ private: U32 mCurrentTrack; std::string mLastFrameSlider; - LLButton* mSaveButton; - LLButton* mCancelButton; + LLButton* mSaveButton; + LLButton* mCancelButton; LLButton* mUploadButton; - - edit_commit_signal_t mCommitSignal; + LLButton* mAddFrameButton; + LLButton* mDeleteFrameButton; LLMultiSliderCtrl* mTimeSlider; LLMultiSliderCtrl* mFramesSlider; @@ -174,10 +143,14 @@ private: LLEnvironment::EnvSelection_t mEditingEnv; // **RIDER** +// LLFlyoutComboBtnCtrl * mFlyoutControl; // not a View! + + edit_commit_signal_t mCommitSignal; + // map of sliders to parameters typedef std::pair<F32, LLSettingsBase::ptr_t> framedata_t; typedef std::map<std::string, framedata_t> keymap_t; - keymap_t mSliderKeyMap; + keymap_t mSliderKeyMap; //slider keys[old_frames], shadows mFramesSlider }; #endif // LL_LLFloaterEditExtDayCycle_H diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index ab1c7502bb..afbbbd424e 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -360,8 +360,8 @@ void LLPanelEnvironmentInfo::onBtnEdit() if (dayeditor) { - dayeditor->setEditCommitSignal(boost::bind(&LLPanelEnvironmentInfo::onEditiCommited, this, _1)); - dayeditor->openFloater(); + dayeditor->setEditCommitSignal(boost::bind(&LLPanelEnvironmentInfo::onEditiCommited, this, _1)); //Not needed? + dayeditor->openFloater(mEditingDayCycle, F32Hours(mDayLengthSlider->getValue().asReal()), F32Hours(mDayOffsetSlider->getValue().asReal())); } } diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index 3b63d0018c..bab902001f 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -15,7 +15,7 @@ <string name="hint_edit">To edit your day cycle, adjust the controls below and click "Save".</string> <!-- Todo: These 5 strings might be subjected to a change to get dynamic labels, consider using layout_stack to get dynamic width adjustment--> - <string name="time_label"> ([TIME] hr)</string> + <string name="time_label"> ([HH]:[MM])</string> <layout_stack name="test_stack" width="705" @@ -58,23 +58,19 @@ bevel_style="in" auto_resize="false" user_resize="true" - bg_alpha_color="red" height="150" min_height="0" - visible="true" - background_visible="true"> + visible="true"> <panel name="timeline_layers" border="false" follows="left|top" auto_resize="false" user_resize="true" - bg_alpha_color="yellow" height="150" width="110" top_pad="0" min_height="0" - visible="true" - background_visible="true"> + visible="true"> <button follows="left|top" height="23" @@ -161,43 +157,43 @@ name="p0" top_pad="5" value="0%[DSC]" - width="70" /> + width="80" /> <text follows="left|top|right" height="15" layout="topleft" - left_pad="49" + left_pad="39" name="p1" top_delta="0" value="25%[DSC]" - width="70" /> + width="80" /> <text follows="left|top|right" height="15" layout="topleft" - left_pad="49" + left_pad="39" name="p2" top_delta="0" value="50%[DSC]" - width="70" /> + width="80" /> <text follows="left|top|right" height="15" layout="topleft" - left_pad="49" + left_pad="39" name="p3" top_delta="0" value="75%[DSC]" - width="70" /> + width="80" /> <text follows="left|top|right" height="15" layout="topleft" - left_pad="49" + left_pad="39" name="p4" top_delta="0" value="100%[DSC]" - width="70" /> + width="80" /> <multi_slider can_edit_text="true" decimal_digits="0" @@ -490,7 +486,22 @@ layout="topleft" left_pad="10" name="upload_btn" - width="100" /> + width="100" /> + + <!--<button + follows="top|left" + height="23" + name="btn_flyout" + label="" + layout="topleft" + left_pad="-20" + top="0" + image_selected="SegmentedBtn_Right_Selected_Press" + image_unselected="SegmentedBtn_Right_Off" + image_pressed="SegmentedBtn_Right_Press" + image_pressed_selected="SegmentedBtn_Right_Selected_Press" + image_overlay="Arrow_Small_Up" + width="20"/>--> </layout_panel> </layout_stack> |