From ac865de287b2e740acd9f6a8724301146df73ccf Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 25 Jan 2019 22:02:16 +0200 Subject: SL-1945 Day Cycle Editor Copy Track --- indra/newview/lltrackpicker.cpp | 126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 indra/newview/lltrackpicker.cpp (limited to 'indra/newview/lltrackpicker.cpp') diff --git a/indra/newview/lltrackpicker.cpp b/indra/newview/lltrackpicker.cpp new file mode 100644 index 0000000000..07fdb5f476 --- /dev/null +++ b/indra/newview/lltrackpicker.cpp @@ -0,0 +1,126 @@ +/** +* @author AndreyK Productengine +* @brief LLTrackPicker class header file including related functions +* +* $LicenseInfo:firstyear=2018&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2018, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "lltrackpicker.h" + +#include "llradiogroup.h" +#include "llviewercontrol.h" + + +//========================================================================= +namespace +{ + const std::string FLOATER_DEFINITION_XML("floater_pick_track.xml"); + + const std::string BTN_SELECT("btn_select"); + const std::string BTN_CANCEL("btn_cancel"); + const std::string RDO_TRACK_SELECTION("track_selection"); + const std::string RDO_TRACK_PREFIX("radio_sky"); +} +//========================================================================= + +LLFloaterTrackPicker::LLFloaterTrackPicker(LLView * owner, const LLSD ¶ms) : + LLFloater(params), + mContextConeOpacity(0.0f), + mOwnerHandle() +{ + mOwnerHandle = owner->getHandle(); + buildFromFile(FLOATER_DEFINITION_XML); +} + +LLFloaterTrackPicker::~LLFloaterTrackPicker() +{ +} + +BOOL LLFloaterTrackPicker::postBuild() +{ + childSetAction(BTN_CANCEL, [this](LLUICtrl*, const LLSD& param){ onButtonCancel(); }); + childSetAction(BTN_SELECT, [this](LLUICtrl*, const LLSD& param){ onButtonSelect(); }); + return TRUE; +} + +void LLFloaterTrackPicker::onClose(bool app_quitting) +{ + if (app_quitting) + return; + + LLView *owner = mOwnerHandle.get(); + if (owner) + { + owner->setFocus(TRUE); + } +} + +void LLFloaterTrackPicker::showPicker(LLSD &args) +{ + LLSD::array_const_iterator iter; + LLSD::array_const_iterator end = args.endArray(); + + for (iter = args.beginArray(); iter != end; ++iter) + { + S32 track_id = (*iter)["id"].asInteger(); + bool can_enable = (*iter)["enabled"].asBoolean(); + LLView *view = getChild(RDO_TRACK_PREFIX + llformat("%d", track_id), true); + view->setEnabled(can_enable); + view->setLabelArg("[ALT]", (*iter).has("altitude") ? ((*iter)["altitude"].asString() + "m") : " "); + } + + openFloater(getKey()); + setFocus(TRUE); +} + +void LLFloaterTrackPicker::draw() +{ + LLView *owner = mOwnerHandle.get(); + static LLCachedControl max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, owner); + + LLFloater::draw(); +} + +void LLFloaterTrackPicker::onButtonCancel() +{ + closeFloater(); +} + +void LLFloaterTrackPicker::onButtonSelect() +{ + if (mCommitSignal) + { + (*mCommitSignal)(this, getChild(RDO_TRACK_SELECTION, true)->getSelectedValue()); + } + closeFloater(); +} + +void LLFloaterTrackPicker::onFocusLost() +{ + if (isInVisibleChain()) + { + closeFloater(); + } +} -- cgit v1.2.3 From fd13bdef98c169c518685a223482c922aed5db06 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 28 Jan 2019 18:32:47 +0200 Subject: SL-1945 Don't open floater if there is only one option to select from --- indra/newview/lltrackpicker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lltrackpicker.cpp') diff --git a/indra/newview/lltrackpicker.cpp b/indra/newview/lltrackpicker.cpp index 07fdb5f476..bc918f4bd7 100644 --- a/indra/newview/lltrackpicker.cpp +++ b/indra/newview/lltrackpicker.cpp @@ -76,7 +76,7 @@ void LLFloaterTrackPicker::onClose(bool app_quitting) } } -void LLFloaterTrackPicker::showPicker(LLSD &args) +void LLFloaterTrackPicker::showPicker(const LLSD &args) { LLSD::array_const_iterator iter; LLSD::array_const_iterator end = args.endArray(); -- cgit v1.2.3 From 645651813520c29c9f898ad531e0b3de65f33b67 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 25 Feb 2019 16:51:29 +0200 Subject: SL-1945 Autoselection and some crash fixing --- indra/newview/lltrackpicker.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/lltrackpicker.cpp') diff --git a/indra/newview/lltrackpicker.cpp b/indra/newview/lltrackpicker.cpp index bc918f4bd7..15bc591b37 100644 --- a/indra/newview/lltrackpicker.cpp +++ b/indra/newview/lltrackpicker.cpp @@ -81,13 +81,21 @@ void LLFloaterTrackPicker::showPicker(const LLSD &args) LLSD::array_const_iterator iter; LLSD::array_const_iterator end = args.endArray(); + bool select_item = true; for (iter = args.beginArray(); iter != end; ++iter) { S32 track_id = (*iter)["id"].asInteger(); bool can_enable = (*iter)["enabled"].asBoolean(); - LLView *view = getChild(RDO_TRACK_PREFIX + llformat("%d", track_id), true); + LLCheckBoxCtrl *view = getChild(RDO_TRACK_PREFIX + llformat("%d", track_id), true); view->setEnabled(can_enable); view->setLabelArg("[ALT]", (*iter).has("altitude") ? ((*iter)["altitude"].asString() + "m") : " "); + + // Mark first avaliable item as selected + if (can_enable && select_item) + { + select_item = false; + view->set(TRUE); + } } openFloater(getKey()); -- cgit v1.2.3 From 6b9b8a627f5923084bd5c519bd51801cbd3aa568 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Tue, 26 Feb 2019 15:51:33 +0200 Subject: SL-1945 Autoselection fix --- indra/newview/lltrackpicker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lltrackpicker.cpp') diff --git a/indra/newview/lltrackpicker.cpp b/indra/newview/lltrackpicker.cpp index 15bc591b37..fe6256a8a9 100644 --- a/indra/newview/lltrackpicker.cpp +++ b/indra/newview/lltrackpicker.cpp @@ -94,7 +94,7 @@ void LLFloaterTrackPicker::showPicker(const LLSD &args) if (can_enable && select_item) { select_item = false; - view->set(TRUE); + getChild(RDO_TRACK_SELECTION, true)->setSelectedByValue(LLSD(track_id), TRUE); } } -- cgit v1.2.3