From c85bcbd7de25f5aa252fd85d953341c5c79010fc Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 16 Aug 2022 18:27:13 +0200 Subject: [PATCH] FIRE-29425: User-selectable font and size for notecards --- indra/llui/lltextbase.cpp | 12 ++++++ indra/newview/app_settings/settings.xml | 22 ++++++++++ indra/newview/llpreviewnotecard.cpp | 31 +++++++++++++ indra/newview/llpreviewnotecard.h | 6 +++ indra/newview/llpreviewscript.cpp | 2 - indra/newview/llviewertexteditor.cpp | 10 ++++- .../default/xui/de/panel_preferences_UI.xml | 17 ++++++++ .../default/xui/en/panel_preferences_UI.xml | 43 +++++++++++++++++++ 8 files changed, 139 insertions(+), 4 deletions(-) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 4babd5028d..b74f2bf00a 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2454,6 +2454,18 @@ void LLTextBase::setFont(const LLFontGL* font) { mFont = font; mStyleDirty = true; + + // FIRE-29425: User-selectable font and size for notecards + for (auto segment : mSegments) + { + LLStyleConstSP style = segment->getStyle(); + LLStyleSP new_style(new LLStyle(*style)); + new_style->setFont(mFont); + LLStyleConstSP sp(new_style); + segment->setStyle(sp); + } + needsReflow(); + // } void LLTextBase::needsReflow(S32 index) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 8fa3b56a2e..f46e0cd086 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -25664,6 +25664,28 @@ Change of this parameter will affect the layout of buttons in notification toast Value Scripting + FSNotecardFontName + + Comment + The name of the font used for the notecard editor + Persist + 1 + Type + String + Value + SansSerif + + FSNotecardFontSize + + Comment + The size of the font used for the notecard editor + Persist + 1 + Type + String + Value + Medium + FSEnableRightclickOnTransparentObjects Comment diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index e6eedd76bf..280611329b 100644 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -76,6 +76,10 @@ LLPreviewNotecard::LLPreviewNotecard(const LLSD& key) //const LLUUID& item_id, // FIRE-24306: Retain cursor position when saving notecards ,mCursorPos(0) ,mScrollPos(0) + // FIRE-29425: User-selectable font and size for notecards + ,mFontNameChangedCallbackConnection() + ,mFontSizeChangedCallbackConnection() + // { const LLInventoryItem *item = getItem(); if (item) @@ -87,6 +91,17 @@ LLPreviewNotecard::LLPreviewNotecard(const LLSD& key) //const LLUUID& item_id, LLPreviewNotecard::~LLPreviewNotecard() { delete mLiveFile; + + // FIRE-29425: User-selectable font and size for notecards + if (mFontNameChangedCallbackConnection.connected()) + { + mFontNameChangedCallbackConnection.disconnect(); + } + if (mFontSizeChangedCallbackConnection.connected()) + { + mFontSizeChangedCallbackConnection.disconnect(); + } + // } BOOL LLPreviewNotecard::postBuild() @@ -118,6 +133,12 @@ BOOL LLPreviewNotecard::postBuild() } getChild("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); + // FIRE-29425: User-selectable font and size for notecards + mFontNameChangedCallbackConnection = gSavedSettings.getControl("FSNotecardFontName")->getSignal()->connect(boost::bind(&LLPreviewNotecard::onFontChanged, this)); + mFontSizeChangedCallbackConnection = gSavedSettings.getControl("FSNotecardFontSize")->getSignal()->connect(boost::bind(&LLPreviewNotecard::onFontChanged, this)); + onFontChanged(); + // + return LLPreview::postBuild(); } @@ -983,5 +1004,15 @@ void LLPreviewNotecard::checkCloseAfterSave() } // +// FIRE-29425: User-selectable font and size for notecards +void LLPreviewNotecard::onFontChanged() +{ + LLFontGL* font = LLFontGL::getFont(LLFontDescriptor(gSavedSettings.getString("FSNotecardFontName"), gSavedSettings.getString("FSNotecardFontSize"), LLFontGL::NORMAL)); + if (font) + { + mEditor->setFont(font); + } +} +// // EOF diff --git a/indra/newview/llpreviewnotecard.h b/indra/newview/llpreviewnotecard.h index 69d949da7c..09a61ea45f 100644 --- a/indra/newview/llpreviewnotecard.h +++ b/indra/newview/llpreviewnotecard.h @@ -129,6 +129,12 @@ protected: bool writeToFile(const std::string& filename); std::string getTmpFileName(); + // FIRE-29425: User-selectable font and size for notecards + boost::signals2::connection mFontNameChangedCallbackConnection; + boost::signals2::connection mFontSizeChangedCallbackConnection; + void onFontChanged(); + // + protected: LLViewerTextEditor* mEditor; LLButton* mSaveBtn; diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 0a081176ba..08176044dd 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -1839,11 +1839,9 @@ void LLScriptEdCore::onFontChanged() if (font) { mEditor->setFont(font); - mEditor->needsReflow(); if (mPostEditor) { mPostEditor->setFont(font); - mPostEditor->needsReflow(); } } } diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 18096a7f35..bfe83fe944 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -211,7 +211,9 @@ public: // [/SL:KB] { - mStyle = new LLStyle(LLStyle::Params().font(LLFontGL::getFontSansSerif())); + // FIRE-29425: User-selectable font and size for notecards + //mStyle = new LLStyle(LLStyle::Params().font(LLFontGL::getFontSansSerif())); + mStyle = new LLStyle(LLStyle::Params().font(mEditor.getFont())); mToolTip = inv_item->getName() + '\n' + inv_item->getDescription(); } @@ -328,11 +330,15 @@ public: // [/SL:KB] /*virtual*/ LLStyleConstSP getStyle() const { return mStyle; } + /*virtual*/ void setStyle(LLStyleConstSP style) { mStyle = style; } // FIRE-29425: User-selectable font and size for notecards private: LLUIImagePtr mImage; LLWString mLabel; - LLStyleSP mStyle; + // FIRE-29425: User-selectable font and size for notecards + //LLStyleSP mStyle; + LLStyleConstSP mStyle; + // std::string mToolTip; LLPointer mItem; LLTextEditor& mEditor; diff --git a/indra/newview/skins/default/xui/de/panel_preferences_UI.xml b/indra/newview/skins/default/xui/de/panel_preferences_UI.xml index d28f52b3fc..55ccfc05be 100644 --- a/indra/newview/skins/default/xui/de/panel_preferences_UI.xml +++ b/indra/newview/skins/default/xui/de/panel_preferences_UI.xml @@ -264,6 +264,23 @@ Standard 0. Größere Werte können nicht korrekt funktionieren. Pixel (Erfordert Neustart) [VIEWER_GENERATION]-Standard 20. Viewer 1-Standard 18. + + Schrift für Notizkarten: + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/en/panel_preferences_UI.xml b/indra/newview/skins/default/xui/en/panel_preferences_UI.xml index dc98ebf690..7d1166bcfe 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_UI.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_UI.xml @@ -1734,6 +1734,49 @@ Default 0. Larger values may not work well. [VIEWER_GENERATION] default 20. Viewer 1 default 18. + + Notecard Editor Font: + + + + + + + + + + + + + + + +