Notecard Editor byte counter - automatically hide byte count on resize

Added callback method for the resize bars of the Notecard Editor floater.
Once the text overlaps the Save button, it will hide the  byte count textbox.
Works for both when the floater is manually resized or if the text becomes too long by typing and is going to overlap as well.
This commit is contained in:
minerjr
2026-07-19 22:27:08 -03:00
parent a6e409b020
commit b6307a278e
2 changed files with 40 additions and 0 deletions
+36
View File
@@ -166,6 +166,30 @@ bool LLPreviewNotecard::postBuild()
onFontChanged();
// </FS:Ansariel>
// <FS:mjr>
// Get the resize bars and add a resize listener to the onResizeFloater method.
LLResizeBar* resizebar_left = getChild<LLResizeBar>("resizebar_left");
if (resizebar_left)
{
resizebar_left->setResizeListener(boost::bind(&LLPreviewNotecard::onResizeFloater, this));
}
LLResizeBar* resizebar_right = getChild<LLResizeBar>("resizebar_right");
if (resizebar_right)
{
resizebar_right->setResizeListener(boost::bind(&LLPreviewNotecard::onResizeFloater, this));
}
LLResizeBar* resizebar_top = getChild<LLResizeBar>("resizebar_top");
if (resizebar_top)
{
resizebar_top->setResizeListener(boost::bind(&LLPreviewNotecard::onResizeFloater, this));
}
LLResizeBar* resizebar_bottom = getChild<LLResizeBar>("resizebar_bottom");
if (resizebar_bottom)
{
resizebar_bottom->setResizeListener(boost::bind(&LLPreviewNotecard::onResizeFloater, this));
}
// </FS:mjr>
return LLPreview::postBuild();
}
@@ -210,9 +234,21 @@ void LLPreviewNotecard::updateByteCounter()
ui_text.setArg("[MAX]", std::to_string(MAX_BYTES));
mByteCounter->setText(ui_text.getString());
// Update the visiblity state of the mByteCounter if there is not enough space.
onResizeFloater();
}
// </FS>
// <FS:mjr>
// Callback method for the resizebar so the byte counter can become invisible if overlapped by the buttons
void LLPreviewNotecard::onResizeFloater()
{
// Set the visiblity flag of the byte counter to true if the right side of the byte counter text is less then the left side of the save button.
S32 text_right = mByteCounter->getRect().mLeft + mByteCounter->getTextPixelWidth();
mByteCounter->setVisible(text_right < mSaveBtn->getRect().mLeft);
}
// </FS:mjr>
void LLPreviewNotecard::setEnabled(bool enabled)
{
if (mEditor)
+4
View File
@@ -132,6 +132,10 @@ protected:
boost::signals2::connection mFontSizeChangedCallbackConnection;
void onFontChanged();
// </FS:Ansariel>
// <FS:mjr>
// Callback method for the resizebar so the byte counter can become invisible if overlapped by the buttons
void onResizeFloater();
// </FS:mjr>
protected:
LLViewerTextEditor* mEditor = nullptr;