diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 502c5b34bfb9587ab75a874c70a4e286fb4b3490..78a8ec4ef2e3b70bbe308f2cb9a1a5f4ed788f55 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -92,13 +92,13 @@ LLSnapshotModel::ESnapshotFormat LLFloaterSnapshot::Impl::getImageFormat(LLFloat LLSpinCtrl* LLFloaterSnapshot::Impl::getWidthSpinner(LLFloaterSnapshotBase* floater) { LLPanelSnapshot* active_panel = getActivePanel(floater); - return active_panel ? active_panel->getWidthSpinner() : nullptr; + return active_panel ? active_panel->getWidthSpinner() : floater->getChild<LLSpinCtrl>("snapshot_width"); } LLSpinCtrl* LLFloaterSnapshot::Impl::getHeightSpinner(LLFloaterSnapshotBase* floater) { LLPanelSnapshot* active_panel = getActivePanel(floater); - return active_panel ? active_panel->getHeightSpinner() : nullptr; + return active_panel ? active_panel->getHeightSpinner() : floater->getChild<LLSpinCtrl>("snapshot_height"); } void LLFloaterSnapshot::Impl::enableAspectRatioCheckbox(LLFloaterSnapshotBase* floater, BOOL enable) @@ -134,7 +134,7 @@ LLSnapshotLivePreview* LLFloaterSnapshotBase::ImplBase::getPreviewView() LLSnapshotModel::ESnapshotLayerType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSnapshotBase* floater) { LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; - LLSD value = floater->getLayerTypesCombo()->getValue(); + LLSD value = floater->getChild<LLUICtrl>("layer_types")->getValue(); const std::string id = value.asString(); if (id == "colors") type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; @@ -270,7 +270,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) LLSnapshotModel::ESnapshotLayerType layer_type = getLayerType(floater); floater->getChild<LLComboBox>("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat")); - floater->getLayerTypesCombo()->setEnabled(shot_type == LLSnapshotModel::SNAPSHOT_LOCAL); + floater->getChildView("layer_types")->setEnabled(shot_type == LLSnapshotModel::SNAPSHOT_LOCAL); LLPanelSnapshot* active_panel = getActivePanel(floater); if (active_panel) @@ -360,17 +360,17 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) { case LLSnapshotModel::SNAPSHOT_WEB: layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; - floater->getLayerTypesCombo()->setValue("colors"); + floater->getChild<LLUICtrl>("layer_types")->setValue("colors"); setResolution(floater, "profile_size_combo"); break; case LLSnapshotModel::SNAPSHOT_POSTCARD: layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; - floater->getLayerTypesCombo()->setValue("colors"); + floater->getChild<LLUICtrl>("layer_types")->setValue("colors"); setResolution(floater, "postcard_size_combo"); break; case LLSnapshotModel::SNAPSHOT_TEXTURE: layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR; - floater->getLayerTypesCombo()->setValue("colors"); + floater->getChild<LLUICtrl>("layer_types")->setValue("colors"); setResolution(floater, "texture_size_combo"); break; case LLSnapshotModel::SNAPSHOT_LOCAL: @@ -741,24 +741,20 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL previewp->getSize(width, height); - auto panel = getActivePanel(view); - if (panel) + // We use the height spinner here because we come here via the aspect ratio + // checkbox as well and we want height always changing to width by default. + // If we use the width spinner we would change width according to height by + // default, that is not what we want. + updateSpinners(view, previewp, width, height, !getHeightSpinner(view)->isDirty()); // may change width and height + + if(getWidthSpinner(view)->getValue().asInteger() != width || getHeightSpinner(view)->getValue().asInteger() != height) { - // We use the height spinner here because we come here via the aspect ratio - // checkbox as well and we want height always changing to width by default. - // If we use the width spinner we would change width according to height by - // default, that is not what we want. - updateSpinners(view, previewp, width, height, !getHeightSpinner(view)->isDirty()); // may change width and height - - if (getWidthSpinner(view)->getValue().asInteger() != width || getHeightSpinner(view)->getValue().asInteger() != height) + getWidthSpinner(view)->setValue(width); + getHeightSpinner(view)->setValue(height); + if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE) { - getWidthSpinner(view)->setValue(width); - getHeightSpinner(view)->setValue(height); - if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE) - { - getWidthSpinner(view)->setIncrement(width >> 1); - getHeightSpinner(view)->setIncrement(height >> 1); - } + getWidthSpinner(view)->setIncrement(width >> 1); + getHeightSpinner(view)->setIncrement(height >> 1); } } @@ -995,9 +991,8 @@ BOOL LLFloaterSnapshot::postBuild() ((Impl*)impl)->setAspectRatioCheckboxValue(this, gSavedSettings.getBOOL("KeepAspectForSnapshot")); childSetCommitCallback("layer_types", Impl::onCommitLayerTypes, this); - mLayerTypesCombo = getChild<LLUICtrl>("layer_types"); - mLayerTypesCombo->setValue("colors"); - mLayerTypesCombo->setEnabled(FALSE); + getChild<LLUICtrl>("layer_types")->setValue("colors"); + getChildView("layer_types")->setEnabled(FALSE); mFreezeFrameCheck = getChild<LLUICtrl>("freeze_frame_check"); mFreezeFrameCheck->setValue(gSavedSettings.getBOOL("UseFreezeFrame")); diff --git a/indra/newview/llfloatersnapshot.h b/indra/newview/llfloatersnapshot.h index 2a47ccc32df435d572346eacf5532feb37e00574..541931cfd5ca0e44f3e6816a9ee5439756269794 100644 --- a/indra/newview/llfloatersnapshot.h +++ b/indra/newview/llfloatersnapshot.h @@ -65,8 +65,6 @@ class LLFloaterSnapshotBase : public LLFloater void setFailureLabelPanelVisible(bool value) { if (mFailureLblPanel) mFailureLblPanel->setVisible(value); } void inventorySaveFailed(); - LLUICtrl* getLayerTypesCombo() { return mLayerTypesCombo; } - class ImplBase; friend class ImplBase; ImplBase* impl; @@ -75,7 +73,6 @@ class LLFloaterSnapshotBase : public LLFloater LLUICtrl* mThumbnailPlaceholder; LLUICtrl *mRefreshBtn, *mRefreshLabel; LLUICtrl *mSucceessLblPanel, *mFailureLblPanel; - LLUICtrl* mLayerTypesCombo = nullptr; LLUICtrl* mFreezeFrameCheck = nullptr; LLTextBox* m360Label = nullptr; }; @@ -176,7 +173,6 @@ class LLFloaterSnapshot final : public LLFloaterSnapshotBase class Impl; friend class Impl; - friend class LLFloaterSnapshotBase::ImplBase; }; ///---------------------------------------------------------------------------- @@ -185,7 +181,6 @@ class LLFloaterSnapshot final : public LLFloaterSnapshotBase class LLFloaterSnapshot::Impl final : public LLFloaterSnapshotBase::ImplBase { - friend class LLFloaterSnapshotBase; LOG_CLASS(LLFloaterSnapshot::Impl); public: Impl(LLFloaterSnapshotBase* floater) diff --git a/indra/newview/llpanelsnapshot.cpp b/indra/newview/llpanelsnapshot.cpp index 897b65d5178980e064b7f93d5966eaaff73da876..c8e9ed201408925c57bcf76ade6b4b3d350ae55f 100644 --- a/indra/newview/llpanelsnapshot.cpp +++ b/indra/newview/llpanelsnapshot.cpp @@ -65,13 +65,11 @@ BOOL LLPanelSnapshot::postBuild() getChild<LLUICtrl>(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onResolutionComboCommit, this, _1)); if (!getWidthSpinnerName().empty()) { - mWidthSpinner = getChild<LLSpinCtrl>(getWidthSpinnerName()); - mWidthSpinner->setCommitCallback(boost::bind(&LLPanelSnapshot::onCustomResolutionCommit, this)); + getChild<LLUICtrl>(getWidthSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onCustomResolutionCommit, this)); } if (!getHeightSpinnerName().empty()) { - mHeightSpinner = getChild<LLSpinCtrl>(getHeightSpinnerName()); - mHeightSpinner->setCommitCallback(boost::bind(&LLPanelSnapshot::onCustomResolutionCommit, this)); + getChild<LLUICtrl>(getHeightSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onCustomResolutionCommit, this)); } if (!getAspectRatioCBName().empty()) { @@ -114,25 +112,25 @@ void LLPanelSnapshot::enableControls(BOOL enable) LLSpinCtrl* LLPanelSnapshot::getWidthSpinner() { llassert(!getWidthSpinnerName().empty()); - return mWidthSpinner; + return getChild<LLSpinCtrl>(getWidthSpinnerName()); } LLSpinCtrl* LLPanelSnapshot::getHeightSpinner() { llassert(!getHeightSpinnerName().empty()); - return mHeightSpinner; + return getChild<LLSpinCtrl>(getHeightSpinnerName()); } S32 LLPanelSnapshot::getTypedPreviewWidth() const { llassert(!getWidthSpinnerName().empty()); - return mWidthSpinner->getValue().asInteger(); + return getChild<LLUICtrl>(getWidthSpinnerName())->getValue().asInteger(); } S32 LLPanelSnapshot::getTypedPreviewHeight() const { llassert(!getHeightSpinnerName().empty()); - return mHeightSpinner->getValue().asInteger(); + return getChild<LLUICtrl>(getHeightSpinnerName())->getValue().asInteger(); } void LLPanelSnapshot::enableAspectRatioCheckbox(BOOL enable) @@ -203,23 +201,28 @@ void LLPanelSnapshot::cancel() void LLPanelSnapshot::onCustomResolutionCommit() { LLSD info; + std::string widthSpinnerName = getWidthSpinnerName(); + std::string heightSpinnerName = getHeightSpinnerName(); + llassert(!widthSpinnerName.empty() && !heightSpinnerName.empty()); + LLSpinCtrl *widthSpinner = getChild<LLSpinCtrl>(widthSpinnerName); + LLSpinCtrl *heightSpinner = getChild<LLSpinCtrl>(heightSpinnerName); if (getName() == "panel_snapshot_inventory") { - S32 width = mWidthSpinner->getValue().asInteger(); + S32 width = widthSpinner->getValue().asInteger(); width = power_of_two(width, MAX_TEXTURE_SIZE); info["w"] = width; - mWidthSpinner->setIncrement(width >> 1); - mWidthSpinner->forceSetValue(width); - S32 height = mHeightSpinner->getValue().asInteger(); + widthSpinner->setIncrement(width >> 1); + widthSpinner->forceSetValue(width); + S32 height = heightSpinner->getValue().asInteger(); height = power_of_two(height, MAX_TEXTURE_SIZE); - mHeightSpinner->setIncrement(height >> 1); - mHeightSpinner->forceSetValue(height); + heightSpinner->setIncrement(height >> 1); + heightSpinner->forceSetValue(height); info["h"] = height; } else { - info["w"] = mWidthSpinner->getValue().asInteger(); - info["h"] = mHeightSpinner->getValue().asInteger(); + info["w"] = widthSpinner->getValue().asInteger(); + info["h"] = heightSpinner->getValue().asInteger(); } getParentByType<LLFloater>()->notify(LLSD().with("custom-res-change", info)); } diff --git a/indra/newview/llpanelsnapshot.h b/indra/newview/llpanelsnapshot.h index d7a0bfb1b76ca4021e12878f47d707be9429e7f8..55273797cc04e5a4948caf50a69b8fadb53892b0 100644 --- a/indra/newview/llpanelsnapshot.h +++ b/indra/newview/llpanelsnapshot.h @@ -74,9 +74,6 @@ class LLPanelSnapshot: public LLPanel void onKeepAspectRatioCommit(LLUICtrl* ctrl); LLFloaterSnapshotBase* mSnapshotFloater; - - LLSpinCtrl* mWidthSpinner = nullptr; - LLSpinCtrl* mHeightSpinner = nullptr; }; #endif // LL_LLPANELSNAPSHOT_H