mirror of
https://github.com/FirestormViewer/phoenix-firestorm.git
synced 2026-08-14 00:48:30 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user