SL-10279 Finalize drag and drop support

master
andreykproductengine 2019-01-10 22:11:11 +02:00
parent c0f67e8d6a
commit 00d8caa359
9 changed files with 75 additions and 31 deletions

View File

@ -1200,7 +1200,7 @@ void LLEnvironment::updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_lengt
updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset, altitudes, cb);
}
void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_name, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb)
void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb)
{
if (!isExtendedEnvironmentEnabled())
{
@ -1209,7 +1209,7 @@ void LLEnvironment::updateRegion(const LLUUID &asset_id, std::string display_nam
return;
}
updateParcel(INVALID_PARCEL_ID, asset_id, display_name, day_length, day_offset, altitudes, cb);
updateParcel(INVALID_PARCEL_ID, asset_id, display_name, track_num, day_length, day_offset, altitudes, cb);
}
void LLEnvironment::updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb)
@ -1261,12 +1261,12 @@ void LLEnvironment::requestParcel(S32 parcel_id, environment_apply_fn cb)
[this, parcel_id, cb]() { coroRequestEnvironment(parcel_id, cb); });
}
void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb)
void LLEnvironment::updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb)
{
UpdateInfo::ptr_t updates(std::make_shared<UpdateInfo>(asset_id, display_name, day_length, day_offset, altitudes));
std::string coroname =
LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment",
[this, parcel_id, updates, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, updates, cb); });
[this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); });
}
void LLEnvironment::onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes)
@ -1309,13 +1309,18 @@ void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pw
updateParcel(parcel_id, pday, day_length, day_offset, altitudes, cb);
}
void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb)
void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 track_num, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb)
{
UpdateInfo::ptr_t updates(std::make_shared<UpdateInfo>(pday, day_length, day_offset, altitudes));
std::string coroname =
LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment",
[this, parcel_id, updates, cb]() { coroUpdateEnvironment(parcel_id, NO_TRACK, updates, cb); });
[this, parcel_id, track_num, updates, cb]() { coroUpdateEnvironment(parcel_id, track_num, updates, cb); });
}
void LLEnvironment::updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, LLEnvironment::altitudes_vect_t altitudes, environment_apply_fn cb)
{
updateParcel(parcel_id, pday, NO_TRACK, day_length, day_offset, altitudes, cb);
}

View File

@ -201,13 +201,14 @@ public:
connection_t setEnvironmentChanged(env_changed_fn cb) { return mSignalEnvChanged.connect(cb); }
void requestRegion(environment_apply_fn cb = environment_apply_fn());
void updateRegion(const LLUUID &asset_id, std::string display_name, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateRegion(const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateRegion(const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateRegion(const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateRegion(const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void resetRegion(environment_apply_fn cb = environment_apply_fn());
void requestParcel(S32 parcel_id, environment_apply_fn cb = environment_apply_fn());
void updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateParcel(S32 parcel_id, const LLUUID &asset_id, std::string display_name, S32 track_num, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 track_num, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t &psky, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());
void updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t &pwater, S32 day_length, S32 day_offset, altitudes_vect_t altitudes = altitudes_vect_t(), environment_apply_fn cb = environment_apply_fn());

View File

@ -1476,7 +1476,7 @@ void LLFloaterEditExtDayCycle::doApplyEnvironment(const std::string &where, cons
if (mInventoryItem && !isDirty())
{
LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), -1, -1);
LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1);
}
else
{
@ -1487,7 +1487,7 @@ void LLFloaterEditExtDayCycle::doApplyEnvironment(const std::string &where, cons
{
if (mInventoryItem && !isDirty())
{
LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), -1, -1);
LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1);
}
else
{

View File

@ -549,7 +549,7 @@ void LLFloaterFixedEnvironment::doApplyEnvironment(const std::string &where)
if (mInventoryItem && !isDirty())
{
LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), -1, -1);
LLEnvironment::instance().updateParcel(parcel->getLocalID(), mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1);
}
else if (mSettings->getSettingsType() == "sky")
{
@ -564,7 +564,7 @@ void LLFloaterFixedEnvironment::doApplyEnvironment(const std::string &where)
{
if (mInventoryItem && !isDirty())
{
LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), -1, -1);
LLEnvironment::instance().updateRegion(mInventoryItem->getAssetUUID(), mInventoryItem->getName(), LLEnvironment::NO_TRACK, -1, -1);
}
else if (mSettings->getSettingsType() == "sky")
{

View File

@ -324,7 +324,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context)
if (context == PARAMETER_REGION)
{
LLEnvironment::instance().updateRegion(asset_id, name, -1, -1);
LLEnvironment::instance().updateRegion(asset_id, name, LLEnvironment::NO_TRACK, -1, -1);
LLEnvironment::instance().setSharedEnvironment();
}
else if (context == PARAMETER_PARCEL)
@ -335,7 +335,7 @@ void LLFloaterMyEnvironment::onDoApply(const std::string &context)
LL_WARNS("ENVIRONMENT") << "Unable to determine parcel." << LL_ENDL;
return;
}
LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, -1, -1);
LLEnvironment::instance().updateParcel(parcel->getLocalID(), asset_id, name, LLEnvironment::NO_TRACK, -1, -1);
LLEnvironment::instance().setSharedEnvironment();
}
else if (context == PARAMETER_LOCAL)

View File

@ -6959,7 +6959,7 @@ void LLSettingsBridge::performAction(LLInventoryModel* model, std::string action
S32 parcel_id = parcel->getLocalID();
LL_WARNS("LAPRAS") << "Applying asset ID " << asset_id << " to parcel " << parcel_id << LL_ENDL;
LLEnvironment::instance().updateParcel(parcel_id, asset_id, name, -1, -1);
LLEnvironment::instance().updateParcel(parcel_id, asset_id, name, LLEnvironment::NO_TRACK, -1, -1);
LLEnvironment::instance().setSharedEnvironment();
}
else

View File

@ -109,6 +109,7 @@ const U32 LLPanelEnvironmentInfo::DIRTY_FLAG_MASK(
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";
@ -179,7 +180,16 @@ BOOL LLPanelEnvironmentInfo::postBuild()
mChangeMonitor = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32 version) { onEnvironmentChanged(env, version); });
getChild<LLSettingsDropTarget>(SDT_DROP_TARGET)->setPanel(this);
for (U32 idx = 0; idx < ALTITUDE_SLIDER_COUNT; idx++)
{
LLSettingsDropTarget* drop_target = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]);
if (drop_target)
{
drop_target->setPanel(this, alt_sliders[idx]);
}
}
getChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[3])->setPanel(this, alt_prefixes[3]);
getChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[4])->setPanel(this, alt_prefixes[4]);
return TRUE;
}
@ -260,7 +270,7 @@ void LLPanelEnvironmentInfo::refresh()
{
sld->addSlider(altitudes[idx + 1], alt_sliders[idx]);
updateAltLabel(alt_prefixes[idx], idx + 2, altitudes[idx + 1]);
mAltitudes[alt_sliders[idx]] = AltitudeData(idx+1, idx, altitudes[idx+1]);
mAltitudes[alt_sliders[idx]] = AltitudeData(idx+2, idx, altitudes[idx+1]);
}
if (sld->getCurNumSliders() != ALTITUDE_SLIDER_COUNT)
{
@ -460,7 +470,14 @@ bool LLPanelEnvironmentInfo::setControlsEnabled(bool enabled)
}
}
getChild<LLSettingsDropTarget>(SDT_DROP_TARGET)->setDndEnabled(enabled && !is_legacy);
for (U32 idx = 0; idx < ALTITUDE_PREFIXERS_COUNT; idx++)
{
LLSettingsDropTarget* drop_target = findChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[idx]);
if (drop_target)
{
drop_target->setDndEnabled(enabled && !is_legacy);
}
}
return true;
}
@ -621,7 +638,7 @@ void LLPanelEnvironmentInfo::onAltSliderCallback(LLUICtrl *cntrl, const LLSD &da
while (iter != end)
{
iter2 = mAltitudes.begin();
new_index = 1;
new_index = 2;
while (iter2 != end)
{
if (iter->second.mAltitude > iter2->second.mAltitude)
@ -630,9 +647,9 @@ void LLPanelEnvironmentInfo::onAltSliderCallback(LLUICtrl *cntrl, const LLSD &da
}
iter2++;
}
iter->second.mAltitudeIndex = new_index;
iter->second.mTrackIndex = new_index;
updateAltLabel(alt_prefixes[iter->second.mLabelIndex], iter->second.mAltitudeIndex + 1, iter->second.mAltitude);
updateAltLabel(alt_prefixes[iter->second.mLabelIndex], iter->second.mTrackIndex, iter->second.mAltitude);
iter++;
}
@ -771,7 +788,24 @@ void LLPanelEnvironmentInfo::onIdlePlay(void *data)
((LLPanelEnvironmentInfo *)data)->udpateApparentTimeOfDay();
}
void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id)
void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, std::string source)
{
if (source == alt_prefixes[4])
{
onPickerCommitted(item_id, 0);
}
else if (source == alt_prefixes[3])
{
onPickerCommitted(item_id, 1);
}
else
{
onPickerCommitted(item_id, mAltitudes[source].mTrackIndex);
}
}
void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, S32 track_num)
{
LLInventoryItem *itemp = gInventory.getItem(item_id);
if (itemp)
@ -779,7 +813,8 @@ void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id)
LLHandle<LLPanel> that_h = getHandle();
LLEnvironment::instance().updateParcel(getParcelId(), itemp->getAssetUUID(),
itemp->getName(),
itemp->getName(),
track_num,
-1, -1, LLEnvironment::altitudes_vect_t(),
[that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); });
}
@ -946,7 +981,8 @@ BOOL LLSettingsDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
*accept = ACCEPT_YES_COPY_SINGLE;
if (drop)
{
mEnvironmentInfoPanel->onPickerCommitted(item_id);
// might be better to use name of the element
mEnvironmentInfoPanel->onPickerCommitted(item_id, mTrack);
}
}
}

View File

@ -123,7 +123,8 @@ protected:
void udpateApparentTimeOfDay();
void onPickerCommitted(LLUUID item_id);
void onPickerCommitted(LLUUID item_id, std::string source);
void onPickerCommitted(LLUUID item_id, S32 track_num = LLEnvironment::NO_TRACK);
void onEditCommitted(LLSettingsDay::ptr_t newday);
void onDayLenOffsetMouseUp();
@ -154,13 +155,13 @@ protected:
{
public:
AltitudeData() :
mAltitudeIndex(0), mLabelIndex(0), mAltitude(0)
mTrackIndex(0), mLabelIndex(0), mAltitude(0)
{}
AltitudeData(U32 altitude_index, U32 label_index, F32 altitude) :
mAltitudeIndex(altitude_index), mLabelIndex(label_index), mAltitude(altitude)
AltitudeData(U32 track_index, U32 label_index, F32 altitude) :
mTrackIndex(track_index), mLabelIndex(label_index), mAltitude(altitude)
{}
U32 mAltitudeIndex;
U32 mTrackIndex;
U32 mLabelIndex;
F32 mAltitude;
};
@ -211,11 +212,12 @@ public:
void* cargo_data,
EAcceptance* accept,
std::string& tooltip_msg);
void setPanel(LLPanelEnvironmentInfo* panel) { mEnvironmentInfoPanel = panel; };
void setPanel(LLPanelEnvironmentInfo* panel, std::string track) { mEnvironmentInfoPanel = panel; mTrack = track; };
void setDndEnabled(bool dnd_enabled) { mDndEnabled = dnd_enabled; };
protected:
LLPanelEnvironmentInfo* mEnvironmentInfoPanel;
std::string mTrack;
bool mDndEnabled;
};
#endif // LL_LLPANELENVIRONMENT_H

View File

@ -263,7 +263,7 @@
left_delta="0"
follows="top|left"
layout="topleft"
name="sdt_alt2"
name="sdt_alt1"
tool_tip="Drag a setting from Inventory onto this target box to select it as current sky."
width="155" />
</panel>