FIRE-29425: User-selectable font and size for notecards

meow-7.2.2
Ansariel 2022-08-16 18:27:13 +02:00
parent 095dff2db9
commit c85bcbd7de
8 changed files with 139 additions and 4 deletions

View File

@ -2454,6 +2454,18 @@ void LLTextBase::setFont(const LLFontGL* font)
{
mFont = font;
mStyleDirty = true;
// <FS:Ansariel> 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();
// </FS:Ansariel>
}
void LLTextBase::needsReflow(S32 index)

View File

@ -25664,6 +25664,28 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<string>Scripting</string>
</map>
<key>FSNotecardFontName</key>
<map>
<key>Comment</key>
<string>The name of the font used for the notecard editor</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>SansSerif</string>
</map>
<key>FSNotecardFontSize</key>
<map>
<key>Comment</key>
<string>The size of the font used for the notecard editor</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>Medium</string>
</map>
<key>FSEnableRightclickOnTransparentObjects</key>
<map>
<key>Comment</key>

View File

@ -76,6 +76,10 @@ LLPreviewNotecard::LLPreviewNotecard(const LLSD& key) //const LLUUID& item_id,
// <FS:Ansariel> FIRE-24306: Retain cursor position when saving notecards
,mCursorPos(0)
,mScrollPos(0)
// <FS:Ansariel> FIRE-29425: User-selectable font and size for notecards
,mFontNameChangedCallbackConnection()
,mFontSizeChangedCallbackConnection()
// </FS:Ansariel>
{
const LLInventoryItem *item = getItem();
if (item)
@ -87,6 +91,17 @@ LLPreviewNotecard::LLPreviewNotecard(const LLSD& key) //const LLUUID& item_id,
LLPreviewNotecard::~LLPreviewNotecard()
{
delete mLiveFile;
// <FS:Ansariel> FIRE-29425: User-selectable font and size for notecards
if (mFontNameChangedCallbackConnection.connected())
{
mFontNameChangedCallbackConnection.disconnect();
}
if (mFontSizeChangedCallbackConnection.connected())
{
mFontSizeChangedCallbackConnection.disconnect();
}
// </FS:Ansariel>
}
BOOL LLPreviewNotecard::postBuild()
@ -118,6 +133,12 @@ BOOL LLPreviewNotecard::postBuild()
}
getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
// <FS:Ansariel> 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();
// </FS:Ansariel>
return LLPreview::postBuild();
}
@ -983,5 +1004,15 @@ void LLPreviewNotecard::checkCloseAfterSave()
}
// </FS:Ansariel>
// <FS:Ansariel> 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);
}
}
// </FS:Ansariel>
// EOF

View File

@ -129,6 +129,12 @@ protected:
bool writeToFile(const std::string& filename);
std::string getTmpFileName();
// <FS:Ansariel> FIRE-29425: User-selectable font and size for notecards
boost::signals2::connection mFontNameChangedCallbackConnection;
boost::signals2::connection mFontSizeChangedCallbackConnection;
void onFontChanged();
// </FS:Ansariel>
protected:
LLViewerTextEditor* mEditor;
LLButton* mSaveBtn;

View File

@ -1839,11 +1839,9 @@ void LLScriptEdCore::onFontChanged()
if (font)
{
mEditor->setFont(font);
mEditor->needsReflow();
if (mPostEditor)
{
mPostEditor->setFont(font);
mPostEditor->needsReflow();
}
}
}

View File

@ -211,7 +211,9 @@ public:
// [/SL:KB]
{
mStyle = new LLStyle(LLStyle::Params().font(LLFontGL::getFontSansSerif()));
// <FS:Ansariel> 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; } // <FS:Ansariel> FIRE-29425: User-selectable font and size for notecards
private:
LLUIImagePtr mImage;
LLWString mLabel;
LLStyleSP mStyle;
// <FS:Ansariel> FIRE-29425: User-selectable font and size for notecards
//LLStyleSP mStyle;
LLStyleConstSP mStyle;
// </FS:Ansariel>
std::string mToolTip;
LLPointer<LLInventoryItem> mItem;
LLTextEditor& mEditor;

View File

@ -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.
</text>
<text name="text_box_notecard_font" width="125">
Schrift für Notizkarten:
</text>
<combo_box name="FSNotecardFontName" tool_tip="Name der Schrift, die für den Notizkarten-Editor verwendet wird">
<combo_item name="Sans Serif" label="Sans Serif"/>
<combo_item name="Monospace" label="Monospace"/>
<combo_item name="Scripting" label="Scripting"/>
<combo_item name="Cascadia" label="Cascadia Code"/>
</combo_box>
<combo_box name="FSNotecardFontSize" tool_tip="Größe der Schrift, die für den Notizkarten-Editor verwendet wird">
<combo_item name="Monospace" label="Monospace"/>
<combo_item name="Scripting" label="Scripting"/>
<combo_item name="Cascadia" label="Cascadia Code"/>
<combo_item name="Small" label="Klein"/>
<combo_item name="Medium" label="Mittel"/>
<combo_item name="Large" label="Groß"/>
</combo_box>
</panel>
</tab_container>
</panel>

View File

@ -1734,6 +1734,49 @@ Default 0. Larger values may not work well.
[VIEWER_GENERATION] default 20. Viewer 1 default 18.
</text>
<text
top_pad="10"
left="10"
follows="left|top"
name="text_box_notecard_font"
width="120">
Notecard Editor Font:
</text>
<combo_box
allow_text_entry="false"
top_delta="-5"
left_pad="5"
follows="left|top"
max_chars="20"
mouse_opaque="true"
name="FSNotecardFontName"
width="150"
control_name="FSNotecardFontName"
tool_tip="Name of the font used in the notecard editor">
<combo_item name="Sans Serif" value="SansSerif" label="Sans Serif"/>
<combo_item name="Monospace" value="Monospace" label="Monospace"/>
<combo_item name="Scripting" value="Scripting" label="Scripting"/>
<combo_item name="Cascadia" value="Cascadia" label="Cascadia Code"/>
</combo_box>
<combo_box
allow_text_entry="false"
top_delta="0"
left_pad="5"
follows="left|top"
max_chars="20"
mouse_opaque="true"
name="FSNotecardFontSize"
width="150"
control_name="FSNotecardFontSize"
tool_tip="Size of the font used in the notecard editor">
<combo_item name="Monospace" value="Monospace" label="Monospace"/>
<combo_item name="Scripting" value="Scripting" label="Scripting"/>
<combo_item name="Cascadia" value="Cascadia" label="Cascadia Code"/>
<combo_item name="Small" value="Small" label="Small"/>
<combo_item name="Medium" value="Medium" label="Medium"/>
<combo_item name="Large" value="Large" label="Large"/>
</combo_box>
<!-- not a live preview
<text
name="tooltip_textbox"