From b6ba9dd565b59e516571445e56f9dafe3bdf4061 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 22 May 2018 20:32:56 +0300 Subject: MAINT-8344 Day Cycle Editor (part 4, finalization) --- indra/newview/llfloatereditextdaycycle.cpp | 288 +++++++++++++-------- indra/newview/llfloatereditextdaycycle.h | 64 ++--- indra/newview/llfloaterfixedenvironment.cpp | 2 +- indra/newview/llfloaterfixedenvironment.h | 2 +- indra/newview/llflyoutcombobtn.cpp | 24 +- indra/newview/llflyoutcombobtn.h | 15 +- indra/newview/llpanelenvironment.cpp | 2 +- .../default/xui/en/floater_edit_ext_day_cycle.xml | 35 +-- 8 files changed, 254 insertions(+), 178 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index ad759d13ff..747a20bbbd 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -43,13 +43,11 @@ // newview #include "llagent.h" -//#include "llflyoutcombobtnctrl.h" //Todo: get rid of this and LLSaveOutfitComboBtn, make a proper UI element/button/pannel instead +#include "llflyoutcombobtn.h" //Todo: make a proper UI element/button/panel 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" @@ -63,26 +61,24 @@ static const std::string track_tabs[] = { }; // For flyout -/*const std::string ACTION_SAVE("save_settings"); +const std::string XML_FLYOUTMENU_FILE("menu_save_settings.xml"); +// From menu_save_settings.xml, consider moving into flyout since it should be supported by flyout either way +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");*/ - LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key): LLFloater(key), - mSaveButton(NULL), + mFlyoutControl(NULL), mCancelButton(NULL), - mUploadButton(NULL), mDayLength(0), mDayOffset(0), mCurrentTrack(4), mTimeSlider(NULL), mFramesSlider(NULL), - //mFlyoutControl(NULL), mCurrentTimeLabel(NULL) { mCommitCallbackRegistrar.add("DayCycle.Track", boost::bind(&LLFloaterEditExtDayCycle::onTrackSelectionCallback, this, _2)); @@ -90,15 +86,14 @@ LLFloaterEditExtDayCycle::LLFloaterEditExtDayCycle(const LLSD &key): 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; + // Todo: consider remaking mFlyoutControl into full view class that initializes intself with floater, + // complete with postbuild, e t c... + delete mFlyoutControl; } void LLFloaterEditExtDayCycle::openFloater(LLSettingsDay::ptr_t settings, S64Seconds daylength, S64Seconds dayoffset) { - mSavedDay = settings; + mOriginalDay = settings; mEditDay = settings->buildClone(); mDayLength = daylength; mDayOffset = dayoffset; @@ -110,9 +105,7 @@ BOOL LLFloaterEditExtDayCycle::postBuild() { getChild("day_cycle_name")->setKeystrokeCallback(boost::bind(&LLFloaterEditExtDayCycle::onCommitName, this, _1, _2), NULL); - mSaveButton = getChild("save_btn", true); mCancelButton = getChild("cancel_btn", true); - mUploadButton = getChild("upload_btn", true); mAddFrameButton = getChild("add_frame", true); mDeleteFrameButton = getChild("delete_frame", true); mTimeSlider = getChild("WLTimeSlider"); @@ -121,12 +114,10 @@ BOOL LLFloaterEditExtDayCycle::postBuild() mWaterTabLayoutContainer = getChild("frame_settings_water", true); mCurrentTimeLabel = getChild("current_time", true); - //mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE); - //mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); + mFlyoutControl = new LLFlyoutComboBtnCtrl(this, "save_btn", "btn_flyout", XML_FLYOUTMENU_FILE); + mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); - mUploadButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnSave, this)); mCancelButton->setCommitCallback(boost::bind(&LLFloaterEditExtDayCycle::onBtnCancel, 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)); @@ -147,8 +138,21 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) LL_WARNS() << "Uninitialized day settings, closing floater" << LL_ENDL; closeFloater(); } - LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); - LLEnvironment::instance().updateEnvironment(); + + // Save previous data + LLEnvironment::EnvSelection_t env = LLEnvironment::instance().getSelectedEnvironment(); + mSavedEnvironment = env; + if (mSavedEnvironment == LLEnvironment::ENV_EDIT) + { + // Flawed in case of multiple edits (if multiple edits are possible), also check onClose() + LL_WARNS() << "Opening up Day editor when already editing day!" << LL_ENDL; + } + mSavedDay = LLEnvironment::instance().getEnvironmentDay(env); + mSavedDayLength = LLEnvironment::instance().getEnvironmentDayLength(env); + mSavedDayOffset = LLEnvironment::instance().getEnvironmentDayOffset(env); + + // set environment for editing (display the one we are editing) + setEditingEnv(); LLLineEditor* name_field = getChild("day_cycle_name"); name_field->setText(mEditDay->getName()); @@ -163,7 +167,6 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) S32Hours hrs; S32Minutes minutes; S64Seconds total; - //LLDate date; LLUIString formatted_label = getString("time_label"); for (int i = 0; i < max_elm; i++) { @@ -171,19 +174,12 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) 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("p" + llformat("%d", i), true)->setTextArg("[DSC]", formatted_label.getString()); } hrs = mDayOffset; 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()); @@ -200,79 +196,82 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) void LLFloaterEditExtDayCycle::onClose(bool app_quitting) { - if (!app_quitting) // there's no point to change environment if we're quitting - { - /* TODO: don't restore this environment. We may have gotten here from land or region. */ - LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT); - LLEnvironment::instance().updateEnvironment(); - } + // there's no point to change environment if we're quitting + // or if we already restored environment + if (!app_quitting && LLEnvironment::instance().getSelectedEnvironment() == LLEnvironment::ENV_EDIT) + { + restoreSavedEnv(); + } } void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility) { if (new_visibility) { - LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditDay, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); - LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); + setEditingEnv(); } else { - /* TODO: don't restore this environment. We may have gotten here from land or region. */ - LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + restoreSavedEnv(); } } -/*void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data) +void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data) { std::string ctrl_action = ctrl->getName(); if (ctrl_action == ACTION_SAVE) { - mSavedDay = mEditDay; - //doApplyUpdateInventory(); + if (mSavedDay.get() != mOriginalDay.get()) + { + restoreSavedEnv(); + } + else + { + S64Seconds day_length = mDayLength.value() > 0 ? mDayLength : LLSettingsDay::DEFAULT_DAYLENGTH; + S64Seconds day_offset = mDayLength.value() > 0 ? mDayOffset : LLSettingsDay::DEFAULT_DAYOFFSET; + LLEnvironment::instance().setEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment, mEditDay, day_length, day_offset); + LLEnvironment::instance().setSelectedEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment); + LLEnvironment::instance().updateEnvironment(); + } + mOriginalDay = mEditDay; // to kill the pointer + + if (!mCommitSignal.empty()) + mCommitSignal(mEditDay); } 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? + LLSettingsVOBase::createInventoryItem(mEditDay); + restoreSavedEnv(); } else { - LL_WARNS("ENVIRONMENT") << "Unknown settings action '" << ctrl_action << "'" << LL_ENDL; - } - - if (!mCommitSignal.empty()) - mCommitSignal(mEditDay); - closeFloater(); - }*/ - -void LLFloaterEditExtDayCycle::onBtnSave() -{ - mSavedDay = mEditDay; + LLEnvironment::EnvSelection_t env(LLEnvironment::ENV_DEFAULT); + bool updateSimulator(ctrl_action != ACTION_APPLY_LOCAL); - //no longer needed? - if (!mCommitSignal.empty()) - mCommitSignal(mEditDay); + if (ctrl_action == ACTION_APPLY_LOCAL) + env = LLEnvironment::ENV_LOCAL; + else if (ctrl_action == ACTION_APPLY_PARCEL) + env = LLEnvironment::ENV_PARCEL; + else if (ctrl_action == ACTION_APPLY_REGION) + env = LLEnvironment::ENV_REGION; + else + { + LL_WARNS("ENVIRONMENT") << "Unknown apply '" << ctrl_action << "'" << LL_ENDL; + } + LLEnvironment::instance().setEnvironment(env, mEditDay); + if (updateSimulator) + { + LL_WARNS("ENVIRONMENT") << "Attempting to apply " << env << LL_ENDL; + } + } closeFloater(); } void LLFloaterEditExtDayCycle::onBtnCancel() { - closeFloater(); -} - -void LLFloaterEditExtDayCycle::onBtnUpload() -{ - LLSettingsVOBase::createInventoryItem(mEditDay); - //closeFloater(); + closeFloater(); // will restore env } void LLFloaterEditExtDayCycle::onAddTrack() @@ -368,14 +367,44 @@ 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 + // todo: add safety 2.5% checks keymap_t::iterator iter = mSliderKeyMap.find(cur_sldr); 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)) + if (gKeyboard->currentMask(TRUE) == MASK_SHIFT) + { + LL_DEBUGS() << "Copying frame from " << iter->second.mFrame << " to " << new_frame << LL_ENDL; + LLSettingsBase::ptr_t new_settings; + + // mEditDay still remembers old position, add copy at new position + if (mCurrentTrack == LLSettingsDay::TRACK_WATER) + { + LLSettingsWaterPtr_t water_ptr = std::dynamic_pointer_cast(iter->second.pSettings)->buildClone(); + mEditDay->setWaterAtKeyframe(water_ptr, new_frame); + new_settings = water_ptr; + } + else + { + LLSettingsSkyPtr_t sky_ptr = std::dynamic_pointer_cast(iter->second.pSettings)->buildClone(); + mEditDay->setSkyAtKeyframe(sky_ptr, new_frame, mCurrentTrack); + new_settings = sky_ptr; + } + + // mSliderKeyMap still remembers old position, for simplicity, just move it to be identical to slider + F32 old_frame = iter->second.mFrame; + iter->second.mFrame = new_frame; + // slider already moved old frame, create new one in old place + addSliderFrame(old_frame, new_settings, false /*because we are going to reselect new one*/); + // reselect new frame + mFramesSlider->setCurSlider(iter->first); + } + else { - iter->second.first = new_frame; + LL_DEBUGS() << "Moving frame from " << iter->second.mFrame << " to " << new_frame << LL_ENDL; + if (mEditDay->moveTrackKeyframe(mCurrentTrack, iter->second.mFrame, new_frame)) + { + iter->second.mFrame = new_frame; + } } } @@ -404,7 +433,7 @@ void LLFloaterEditExtDayCycle::onTimeSliderMoved() F32 frame = mTimeSlider->getCurSliderValue(); while (iter != end_iter) { - if (iter->second.first == frame) + if (iter->second.mFrame == frame) { mFramesSlider->setCurSlider(iter->first); break; @@ -412,14 +441,14 @@ void LLFloaterEditExtDayCycle::onTimeSliderMoved() iter++; } - // Todo: safety checks + // block or update tabs according to new selection updateTabs(); - //Todo: update something related to time/play/blending? + + // blending: } void LLFloaterEditExtDayCycle::selectTrack(U32 track_index) { - // todo: safety checks mCurrentTrack = track_index; LLButton* button = getChild(track_tabs[track_index], true); if (button->getToggleState()) @@ -442,7 +471,7 @@ void LLFloaterEditExtDayCycle::selectTrack(U32 track_index) void LLFloaterEditExtDayCycle::clearTabs() { - // todo: instead init with defaults? + // Note: If this doesn't look good, init panels with default settings. It might be better looking if (mCurrentTrack == LLSettingsDay::TRACK_WATER) { const LLSettingsWaterPtr_t p_water = LLSettingsWaterPtr_t(NULL); @@ -459,12 +488,12 @@ void LLFloaterEditExtDayCycle::clearTabs() void LLFloaterEditExtDayCycle::updateTabs() { - // 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 + // keep old settings if there are any for duplicating later, just disable panels + setWaterTabsEnabled(FALSE); + setSkyTabsEnabled(FALSE); } else if (mCurrentTrack == LLSettingsDay::TRACK_WATER) { @@ -512,6 +541,42 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) } } +void LLFloaterEditExtDayCycle::setWaterTabsEnabled(BOOL enable) +{ + LLView* tab_container = mWaterTabLayoutContainer->getChild("water_tabs"); //can't extract panels directly, since it is in 'tuple' + LLPanelSettingsWaterMainTab* panel = dynamic_cast(tab_container->getChildView("water_panel")); + if (panel) + { + panel->setEnabled(enable); + panel->setAllChildrenEnabled(enable); + } +} + +void LLFloaterEditExtDayCycle::setSkyTabsEnabled(BOOL enable) +{ + LLView* tab_container = mSkyTabLayoutContainer->getChild("sky_tabs"); //can't extract panels directly, since they are in 'tuple' + + LLPanelSettingsSky* panel; + panel = dynamic_cast(tab_container->getChildView("atmosphere_panel")); + if (panel) + { + panel->setEnabled(enable); + panel->setAllChildrenEnabled(enable); + } + panel = dynamic_cast(tab_container->getChildView("clouds_panel")); + if (panel) + { + panel->setEnabled(enable); + panel->setAllChildrenEnabled(enable); + } + panel = dynamic_cast(tab_container->getChildView("moon_panel")); + if (panel) + { + panel->setEnabled(enable); + panel->setAllChildrenEnabled(enable); + } +} + void LLFloaterEditExtDayCycle::updateButtons() { F32 frame = mTimeSlider->getCurSliderValue(); @@ -525,29 +590,24 @@ void LLFloaterEditExtDayCycle::updateSlider() mFramesSlider->clear(); mSliderKeyMap.clear(); - std::string new_slider; - F32 frame = 0; LLSettingsDay::CycleTrack_t track = mEditDay->getCycleTrack(mCurrentTrack); 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); + addSliderFrame(track_frame.first, track_frame.second, false); } - mLastFrameSlider = new_slider; - if (mSliderKeyMap.size() > 0) { - mTimeSlider->setCurSliderValue(frame); + // update positions + mLastFrameSlider = mFramesSlider->getCurSlider(); + mTimeSlider->setCurSliderValue(mFramesSlider->getCurSliderValue()); updateTabs(); } else { // disable panels clearTabs(); + mLastFrameSlider.clear(); } } @@ -559,11 +619,6 @@ void LLFloaterEditExtDayCycle::updateTimeAndLabel() { 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; @@ -580,16 +635,19 @@ void LLFloaterEditExtDayCycle::updateTimeAndLabel() // Update blender here: } -void LLFloaterEditExtDayCycle::addSliderFrame(const F32 frame, LLSettingsBase::ptr_t setting) +void LLFloaterEditExtDayCycle::addSliderFrame(const F32 frame, LLSettingsBase::ptr_t &setting, bool update_ui) { // multi slider distinguishes elements by key/name in string format // 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; + mSliderKeyMap[new_slider] = FrameData(frame, setting); - mTimeSlider->setCurSliderValue(frame); - updateTabs(); + if (update_ui) + { + mLastFrameSlider = new_slider; + mTimeSlider->setCurSliderValue(frame); + updateTabs(); + } } void LLFloaterEditExtDayCycle::removeCurrentSliderFrame() @@ -603,9 +661,9 @@ void LLFloaterEditExtDayCycle::removeCurrentSliderFrame() keymap_t::iterator iter = mSliderKeyMap.find(sldr); if (iter != mSliderKeyMap.end()) { - LL_DEBUGS() << "Removing frame from " << iter->second.first << LL_ENDL; + LL_DEBUGS() << "Removing frame from " << iter->second.mFrame << LL_ENDL; mSliderKeyMap.erase(iter); - mEditDay->removeTrackKeyframe(mCurrentTrack, iter->second.first); + mEditDay->removeTrackKeyframe(mCurrentTrack, iter->second.mFrame); } mLastFrameSlider = mFramesSlider->getCurSlider(); @@ -613,6 +671,22 @@ void LLFloaterEditExtDayCycle::removeCurrentSliderFrame() updateTabs(); } +void LLFloaterEditExtDayCycle::setEditingEnv() +{ + S64Seconds day_length = mDayLength.value() > 0 ? mDayLength : LLSettingsDay::DEFAULT_DAYLENGTH; + S64Seconds day_offset = mDayLength.value() > 0 ? mDayOffset : LLSettingsDay::DEFAULT_DAYOFFSET; + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditDay, day_length, day_offset); + LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT); + LLEnvironment::instance().updateEnvironment(); +} + +void LLFloaterEditExtDayCycle::restoreSavedEnv() +{ + //LLEnvironment::instance().setEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment, mSavedDay, mSavedDayLength, mSavedDayOffset); + LLEnvironment::instance().setSelectedEnvironment((LLEnvironment::EnvSelection_t)mSavedEnvironment); + LLEnvironment::instance().updateEnvironment(); +} + //------------------------------------------------------------------------- LLFloaterEditExtDayCycle::connection_t LLFloaterEditExtDayCycle::setEditCommitSignal(LLFloaterEditExtDayCycle::edit_commit_signal_t::slot_type cb) diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index 46b34de5c7..0b48b51b5d 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -33,11 +33,11 @@ class LLCheckBoxCtrl; class LLComboBox; +class LLFlyoutComboBtnCtrl; class LLLineEditor; class LLMultiSliderCtrl; class LLTextBox; class LLTimeCtrl; -//class LLFlyoutComboBtnCtrl; typedef std::shared_ptr LLSettingsBasePtr_t; @@ -52,66 +52,63 @@ public: typedef boost::signals2::signal edit_commit_signal_t; typedef boost::signals2::connection connection_t; - LLFloaterEditExtDayCycle(const LLSD &key); + 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 onClose(bool app_quitting); + void onClose(bool app_quitting); void onVisibilityChange(BOOL new_visibility); -// /*virtual*/ void draw(); connection_t setEditCommitSignal(edit_commit_signal_t::slot_type cb); private: -// /// sync the time slider with day cycle structure -// void syncTimeSlider(); -// -// // makes sure key slider has what's in day cycle -// void loadTrack(); -// -// /// makes sure day cycle data structure has what's in menu -// void applyTrack(); -// -// /// refresh the sky presets combobox - -// void onButtonApply(LLUICtrl *ctrl, const LLSD &data); - void onBtnSave(); + // flyout response/click + void onButtonApply(LLUICtrl *ctrl, const LLSD &data); void onBtnCancel(); - void onBtnUpload(); void onAddTrack(); void onRemoveTrack(); void onCommitName(class LLLineEditor* caller, void* user_data); void onTrackSelectionCallback(const LLSD& user_data); - void onTimeSliderMoved(); /// time slider moved - void onFrameSliderCallback(); /// a frame moved or frame selection changed + // time slider moved + void onTimeSliderMoved(); + // a frame moved or frame selection changed + void onFrameSliderCallback(); void selectTrack(U32 track_index); void clearTabs(); void updateTabs(); void updateWaterTabs(const LLSettingsWaterPtr_t &p_water); void updateSkyTabs(const LLSettingsSkyPtr_t &p_sky); + void setWaterTabsEnabled(BOOL enable); + void setSkyTabsEnabled(BOOL enable); void updateButtons(); void updateSlider(); //track to slider void updateTimeAndLabel(); - void addSliderFrame(const F32 frame, LLSettingsBase::ptr_t setting); + void addSliderFrame(const F32 frame, LLSettingsBase::ptr_t &setting, bool update_ui = true); void removeCurrentSliderFrame(); + void setEditingEnv(); + void restoreSavedEnv(); - LLSettingsDay::ptr_t mSavedDay; - LLSettingsDay::ptr_t mEditDay; + // data for restoring previous displayed environment + LLSettingsDay::ptr_t mSavedDay; // the one currently on screen + S32 mSavedEnvironment; + S64Seconds mSavedDayLength; + S64Seconds mSavedDayOffset; + + LLSettingsDay::ptr_t mEditDay; // edited copy + LLSettingsDay::ptr_t mOriginalDay; // the one we are editing S64Seconds mDayLength; S64Seconds mDayOffset; U32 mCurrentTrack; std::string mLastFrameSlider; - LLButton* mSaveButton; LLButton* mCancelButton; - LLButton* mUploadButton; LLButton* mAddFrameButton; LLButton* mDeleteFrameButton; @@ -121,14 +118,21 @@ private: LLView* mWaterTabLayoutContainer; LLTextBox* mCurrentTimeLabel; -// LLFlyoutComboBtnCtrl * mFlyoutControl; // not a View! + LLFlyoutComboBtnCtrl * mFlyoutControl; edit_commit_signal_t mCommitSignal; - // map of sliders to parameters - typedef std::pair framedata_t; - typedef std::map keymap_t; - keymap_t mSliderKeyMap; //slider keys[old_frames], shadows mFramesSlider + // For map of sliders to parameters + class FrameData + { + public: + FrameData() : mFrame(0) {}; + FrameData(F32 frame, LLSettingsBase::ptr_t settings) : mFrame(frame), pSettings(settings) {}; + F32 mFrame; + LLSettingsBase::ptr_t pSettings; + }; + typedef std::map keymap_t; + keymap_t mSliderKeyMap; //slider's keys vs old_frames&settings, shadows mFramesSlider }; #endif // LL_LLFloaterEditExtDayCycle_H diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index f03c8ba7d1..84d80bc32f 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -103,7 +103,7 @@ BOOL LLFloaterFixedEnvironment::postBuild() getChild(BUTTON_NAME_IMPORT)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonImport(); }); getChild(BUTTON_NAME_CANCEL)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonCancel(); }); - mFlyoutControl = new LLFlyoutComboBtn(this, BUTTON_NAME_COMMIT, BUTTON_NAME_FLYOUT, XML_FLYOUTMENU_FILE); + mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BUTTON_NAME_COMMIT, BUTTON_NAME_FLYOUT, XML_FLYOUTMENU_FILE); mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); return TRUE; diff --git a/indra/newview/llfloaterfixedenvironment.h b/indra/newview/llfloaterfixedenvironment.h index 782dc9e61c..0590a80e57 100644 --- a/indra/newview/llfloaterfixedenvironment.h +++ b/indra/newview/llfloaterfixedenvironment.h @@ -80,7 +80,7 @@ protected: bool canApplyRegion() const; bool canApplyParcel() const; - LLFlyoutComboBtn * mFlyoutControl; + LLFlyoutComboBtnCtrl * mFlyoutControl; LLUUID mInventoryId; LLInventoryItem * mInventoryItem; diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp index efe76b5653..a736fcafa3 100644 --- a/indra/newview/llflyoutcombobtn.cpp +++ b/indra/newview/llflyoutcombobtn.cpp @@ -1,5 +1,5 @@ /** - * @file llsaveoutfitcombobtn.cpp + * @file llflyoutcombobtn.cpp * @brief Represents outfit save/save as combo button. * * $LicenseInfo:firstyear=2010&license=viewerlgpl$ @@ -29,7 +29,7 @@ #include "llflyoutcombobtn.h" #include "llviewermenu.h" -LLFlyoutComboBtn::LLFlyoutComboBtn(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file) : +LLFlyoutComboBtnCtrl::LLFlyoutComboBtnCtrl(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file) : mParent(parent), mActionButton(action_button), mFlyoutButton(flyout_button) @@ -48,30 +48,30 @@ LLFlyoutComboBtn::LLFlyoutComboBtn(LLPanel* parent, const std::string &action_bu setSelectedItem(0); } -void LLFlyoutComboBtn::setAction(LLUICtrl::commit_callback_t cb) +void LLFlyoutComboBtnCtrl::setAction(LLUICtrl::commit_callback_t cb) { mActionSignal.connect(cb); } -U32 LLFlyoutComboBtn::getItemCount() +U32 LLFlyoutComboBtnCtrl::getItemCount() { return mFlyoutMenu->getItemCount(); } -void LLFlyoutComboBtn::setSelectedItem(S32 itemno) +void LLFlyoutComboBtnCtrl::setSelectedItem(S32 itemno) { LLMenuItemGL *pitem = mFlyoutMenu->getItem(itemno); setSelectedItem(pitem); } -void LLFlyoutComboBtn::setSelectedItem(const std::string &item) +void LLFlyoutComboBtnCtrl::setSelectedItem(const std::string &item) { LLMenuItemGL *pitem = mFlyoutMenu->getChild(item, false); setSelectedItem(pitem); } -void LLFlyoutComboBtn::setSelectedItem(LLMenuItemGL *pitem) +void LLFlyoutComboBtnCtrl::setSelectedItem(LLMenuItemGL *pitem) { if (!pitem) { @@ -86,7 +86,7 @@ void LLFlyoutComboBtn::setSelectedItem(LLMenuItemGL *pitem) action_button->setLabel(pitem->getLabel()); } -void LLFlyoutComboBtn::setMenuItemEnabled(const std::string& item, bool enabled) +void LLFlyoutComboBtnCtrl::setMenuItemEnabled(const std::string& item, bool enabled) { mFlyoutMenu->setItemEnabled(item, enabled); if (item == mSelectedName) @@ -95,12 +95,12 @@ void LLFlyoutComboBtn::setMenuItemEnabled(const std::string& item, bool enabled) } } -void LLFlyoutComboBtn::setShownBtnEnabled(bool enabled) +void LLFlyoutComboBtnCtrl::setShownBtnEnabled(bool enabled) { mParent->getChildView(mActionButton)->setEnabled(enabled); } -void LLFlyoutComboBtn::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) +void LLFlyoutComboBtnCtrl::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) { S32 x, y; LLUI::getMousePositionLocal(mParent, &x, &y); @@ -109,7 +109,7 @@ void LLFlyoutComboBtn::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) LLMenuGL::showPopup(mParent, mFlyoutMenu, x, y); } -void LLFlyoutComboBtn::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) +void LLFlyoutComboBtnCtrl::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) { LLMenuItemGL *pmenuitem = static_cast(ctrl); setSelectedItem(pmenuitem); @@ -117,7 +117,7 @@ void LLFlyoutComboBtn::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) onFlyoutAction(pmenuitem, data); } -void LLFlyoutComboBtn::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data) +void LLFlyoutComboBtnCtrl::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data) { LLMenuItemGL *pmenuitem = mFlyoutMenu->getChild(mSelectedName); diff --git a/indra/newview/llflyoutcombobtn.h b/indra/newview/llflyoutcombobtn.h index ebf7564422..517752d8db 100644 --- a/indra/newview/llflyoutcombobtn.h +++ b/indra/newview/llflyoutcombobtn.h @@ -24,8 +24,8 @@ * $/LicenseInfo$ */ -#ifndef LL_LLSAVECOMBOBTN_H -#define LL_LLSAVECOMBOBTN_H +#ifndef LL_LLFLYOUTCOMBOBTN_H +#define LL_LLFLYOUTCOMBOBTN_H /*TODO: Make this button generic */ @@ -33,14 +33,11 @@ class LLButton; #include "lltoggleablemenu.h" -/** - * Represents outfit Save/Save As combo button. - */ -class LLFlyoutComboBtn +class LLFlyoutComboBtnCtrl { - LOG_CLASS(LLFlyoutComboBtn); + LOG_CLASS(LLFlyoutComboBtnCtrl); public: - LLFlyoutComboBtn(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file); + LLFlyoutComboBtnCtrl(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file); void setMenuItemEnabled(const std::string &item, bool enabled); void setShownBtnEnabled(bool enabled); @@ -68,4 +65,4 @@ private: LLUICtrl::commit_signal_t mActionSignal; }; -#endif // LL_LLSAVEOUTFITCOMBOBTN_H +#endif // LL_LLFLYOUTCOMBOBTN_H diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index afbbbd424e..8e846fe6ef 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -360,7 +360,7 @@ void LLPanelEnvironmentInfo::onBtnEdit() if (dayeditor) { - dayeditor->setEditCommitSignal(boost::bind(&LLPanelEnvironmentInfo::onEditiCommited, this, _1)); //Not needed? + dayeditor->setEditCommitSignal(boost::bind(&LLPanelEnvironmentInfo::onEditiCommited, this, _1)); 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 bab902001f..ad11bded6a 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 @@ -470,6 +470,22 @@ top_pad="0" name="save_btn" width="100" /> + +