diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-09-02 13:46:13 +0300 |
---|---|---|
committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2024-09-04 10:16:46 +0300 |
commit | 57ab1a410f9cb3534bb403e034743505758579d8 (patch) | |
tree | aa7077841e6027d1efaf2c358c635e9cea83e8f2 /indra/llui | |
parent | 5c64e5e13d9a75cac510aac3128fc6ee780ab243 (diff) |
viewer#2411 A bit more coverage for font buffer
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbadge.cpp | 25 | ||||
-rw-r--r-- | indra/llui/llbadge.h | 3 | ||||
-rw-r--r-- | indra/llui/llbutton.cpp | 14 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 13 | ||||
-rw-r--r-- | indra/llui/llscrolllistcell.cpp | 60 | ||||
-rw-r--r-- | indra/llui/llscrolllistcell.h | 27 |
6 files changed, 82 insertions, 60 deletions
diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index 399f79ad2e..48489db615 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -27,6 +27,8 @@ #define LLBADGE_CPP #include "llbadge.h" +#include "llfontgl.h" +#include "llfontvertexbuffer.h" #include "llscrollcontainer.h" #include "lluictrlfactory.h" @@ -103,6 +105,7 @@ LLBadge::LLBadge(const LLBadge::Params& p) , mPaddingVert(p.padding_vert) , mParentScroller(NULL) , mDrawAtParentTop(false) + , mFontBuffer(false) { if (mImage.isNull()) { @@ -351,17 +354,17 @@ void LLBadge::draw() // // Draw the label // - - mGLFont->render(mLabel.getWString(), - badge_label_begin_offset, - badge_center_x + mLabelOffsetHoriz, - badge_center_y + mLabelOffsetVert, - mLabelColor % alpha, - LLFontGL::HCENTER, LLFontGL::VCENTER, // centered around the position - LLFontGL::NORMAL, // normal text (not bold, italics, etc.) - LLFontGL::DROP_SHADOW_SOFT, - badge_char_length, badge_pixel_length, - right_position_out, do_not_use_ellipses); + mFontBuffer.render(mGLFont, + mLabel.getWString(), + badge_label_begin_offset, + badge_center_x + mLabelOffsetHoriz, + badge_center_y + mLabelOffsetVert, + mLabelColor % alpha, + LLFontGL::HCENTER, LLFontGL::VCENTER, // centered around the position + LLFontGL::NORMAL, // normal text (not bold, italics, etc.) + LLFontGL::DROP_SHADOW_SOFT, + badge_char_length, badge_pixel_length, + right_position_out, do_not_use_ellipses); } } } diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index 77fe76f0da..636e2c9ded 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -34,12 +34,14 @@ #include "llstring.h" #include "lluiimage.h" #include "llview.h" +#include "llfontvertexbuffer.h" // // Declarations // class LLFontGL; +class LLFontVertexBuffer; class LLScrollContainer; class LLUICtrlFactory; @@ -144,6 +146,7 @@ private: LLUIColor mBorderColor; const LLFontGL* mGLFont; + LLFontVertexBuffer mFontBuffer; LLPointer< LLUIImage > mImage; LLUIColor mImageColor; diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index a9f1c10256..d4e5d501db 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -43,6 +43,8 @@ #include "llfloater.h" #include "llfloaterreg.h" #include "llfocusmgr.h" +#include "llfontgl.h" +#include "llfontvertexbuffer.h" #include "llwindow.h" #include "llnotificationsutil.h" #include "llrender.h" @@ -438,18 +440,6 @@ void LLButton::reshape(S32 width, S32 height, bool called_from_parent) } } -void LLButton::translate(S32 x, S32 y) -{ - LLUICtrl::translate(x, y); - mFontBuffer.reset(); -} - -void LLButton::setRect(const LLRect& rect) -{ - LLUICtrl::setRect(rect); - mFontBuffer.reset(); -} - void LLButton::dirtyRect() { LLUICtrl::dirtyRect(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 74ed922510..23a3a05e65 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -34,8 +34,6 @@ #include "lluictrl.h" #include "v4color.h" #include "llframetimer.h" -#include "llfontgl.h" -#include "llfontvertexbuffer.h" #include "lluiimage.h" #include "lluistring.h" @@ -56,6 +54,8 @@ S32 round_up(S32 grid, S32 value); class LLUICtrlFactory; +class LLFontGL; +class LLFontVertexBuffer; // // Classes @@ -170,8 +170,6 @@ public: void onVisibilityChange(bool visible) override; void reshape(S32 width, S32 height, bool called_from_parent = true) override; - void translate(S32 x, S32 y) override; - void setRect(const LLRect& rect) override; void dirtyRect() override; virtual void onMouseLeave(S32 x, S32 y, MASK mask) override; @@ -307,9 +305,6 @@ protected: commit_signal_t* mMouseUpSignal; commit_signal_t* mHeldDownSignal; - const LLFontGL* mGLFont; - LLFontVertexBuffer mFontBuffer; - S32 mMouseDownFrame; S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback F32 mHeldDownDelay; // seconds, after which held-down callbacks get called @@ -392,6 +387,10 @@ protected: bool mForceFlashing; // Stick flashing color even if button is pressed bool mHandleRightMouse; +private: + const LLFontGL* mGLFont; + LLFontVertexBuffer mFontBuffer; + protected: virtual std::string _getSearchText() const { diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp index 7ef2e54429..8b998971b6 100644 --- a/indra/llui/llscrolllistcell.cpp +++ b/indra/llui/llscrolllistcell.cpp @@ -30,6 +30,7 @@ #include "llscrolllistcell.h" #include "llcheckboxctrl.h" +#include "llfontvertexbuffer.h" #include "llui.h" // LLUIImage #include "lluictrlfactory.h" @@ -156,7 +157,7 @@ S32 LLScrollListIcon::getWidth() const } -void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) { if (mIcon) { @@ -236,7 +237,7 @@ S32 LLScrollListBar::getWidth() const } -void LLScrollListBar::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListBar::draw(const LLColor4& color, const LLColor4& highlight_color) { S32 bar_width = getWidth() - mLeftPad - mRightPad; S32 left = (S32)(bar_width - bar_width * mRatio); @@ -255,6 +256,7 @@ LLScrollListText::LLScrollListText(const LLScrollListCell::Params& p) mText(p.label.isProvided() ? p.label() : p.value().asString()), mAltText(p.alt_value().asString()), mFont(p.font), + mFontBuffer(false), mColor(p.color), mUseColor(p.color.isProvided()), mFontAlignment(p.font_halign), @@ -308,6 +310,19 @@ bool LLScrollListText::needsToolTip() const return mFont->getWidth(mText.getWString().c_str()) > getWidth(); } +void LLScrollListText::setTextWidth(S32 value) +{ + mTextWidth = value; + mFontBuffer.reset(); +} + +void LLScrollListText::setWidth(S32 width) +{ + LLScrollListCell::setWidth(width); + mTextWidth = width; + mFontBuffer.reset(); +} + //virtual bool LLScrollListText::getVisible() const { @@ -341,6 +356,7 @@ void LLScrollListText::setColor(const LLColor4& color) void LLScrollListText::setText(const LLStringExplicit& text) { mText = text; + mFontBuffer.reset(); } void LLScrollListText::setFontStyle(const U8 font_style) @@ -348,6 +364,13 @@ void LLScrollListText::setFontStyle(const U8 font_style) LLFontDescriptor new_desc(mFont->getFontDesc()); new_desc.setStyle(font_style); mFont = LLFontGL::getFont(new_desc); + mFontBuffer.reset(); +} + +void LLScrollListText::setAlignment(LLFontGL::HAlign align) +{ + mFontAlignment = align; + mFontBuffer.reset(); } //virtual @@ -375,7 +398,7 @@ const LLSD LLScrollListText::getAltValue() const } -void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color) { LLColor4 display_color; if (mUseColor) @@ -426,17 +449,18 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col start_x = (F32)getWidth() * 0.5f; break; } - mFont->render(mText.getWString(), 0, - start_x, 0.f, - display_color, - mFontAlignment, - LLFontGL::BOTTOM, - 0, - LLFontGL::NO_SHADOW, - string_chars, - getTextWidth(), - &right_x, - true); + mFontBuffer.render(mFont, + mText.getWString(), 0, + start_x, 0.f, + display_color, + mFontAlignment, + LLFontGL::BOTTOM, + 0, + LLFontGL::NO_SHADOW, + string_chars, + getTextWidth(), + &right_x, + true); } // @@ -475,7 +499,7 @@ LLScrollListCheck::~LLScrollListCheck() mCheckBox = NULL; } -void LLScrollListCheck::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListCheck::draw(const LLColor4& color, const LLColor4& highlight_color) { mCheckBox->draw(); } @@ -592,7 +616,7 @@ void LLScrollListIconText::setWidth(S32 width) } -void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight_color) { LLColor4 display_color; if (mUseColor) @@ -650,7 +674,9 @@ void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight start_icon_x = (S32)(center - (((F32)icon_space + mFont->getWidth(mText.getWString().c_str())) * 0.5f)); break; } - mFont->render(mText.getWString(), 0, + mFontBuffer.render( + mFont, + mText.getWString(), 0, start_text_x, 0.f, display_color, mFontAlignment, diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h index c5d785ae52..e7ff5c8424 100644 --- a/indra/llui/llscrolllistcell.h +++ b/indra/llui/llscrolllistcell.h @@ -29,6 +29,7 @@ #define LLSCROLLLISTCELL_H #include "llfontgl.h" // HAlign +#include "llfontvertexbuffer.h" // HAlign #include "llpointer.h" // LLPointer<> #include "lluistring.h" #include "v4color.h" @@ -96,7 +97,7 @@ public: LLScrollListCell(const LLScrollListCell::Params&); virtual ~LLScrollListCell() {}; - virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const {}; // truncate to given width, if possible + virtual void draw(const LLColor4& color, const LLColor4& highlight_color) {}; // truncate to given width, if possible virtual S32 getWidth() const {return mWidth;} virtual S32 getContentWidth() const { return 0; } virtual S32 getHeight() const { return 0; } @@ -127,7 +128,7 @@ class LLScrollListSpacer : public LLScrollListCell public: LLScrollListSpacer(const LLScrollListCell::Params& p) : LLScrollListCell(p) {} /*virtual*/ ~LLScrollListSpacer() {}; - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const {} + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) {} }; /* @@ -139,7 +140,7 @@ public: LLScrollListText(const LLScrollListCell::Params&); /*virtual*/ ~LLScrollListText(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ S32 getContentWidth() const; /*virtual*/ S32 getHeight() const; /*virtual*/ void setValue(const LLSD& value); @@ -155,18 +156,20 @@ public: /*virtual*/ bool needsToolTip() const; S32 getTextWidth() const { return mTextWidth;} - void setTextWidth(S32 value) { mTextWidth = value;} - virtual void setWidth(S32 width) { LLScrollListCell::setWidth(width); mTextWidth = width; } + void setTextWidth(S32 value); + virtual void setWidth(S32 width); void setText(const LLStringExplicit& text); void setFontStyle(const U8 font_style); - void setAlignment(LLFontGL::HAlign align) { mFontAlignment = align; } + void setAlignment(LLFontGL::HAlign align); protected: + LLUIString mText; LLUIString mAltText; S32 mTextWidth; const LLFontGL* mFont; + LLFontVertexBuffer mFontBuffer; LLColor4 mColor; LLColor4 mHighlightColor; U8 mUseColor; @@ -188,7 +191,7 @@ class LLScrollListIcon : public LLScrollListCell public: LLScrollListIcon(const LLScrollListCell::Params& p); /*virtual*/ ~LLScrollListIcon(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ S32 getWidth() const; /*virtual*/ S32 getHeight() const; /*virtual*/ const LLSD getValue() const; @@ -207,7 +210,7 @@ class LLScrollListBar : public LLScrollListCell public: LLScrollListBar(const LLScrollListCell::Params& p); /*virtual*/ ~LLScrollListBar(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ S32 getWidth() const; /*virtual*/ S32 getHeight() const; /*virtual*/ const LLSD getValue() const; @@ -229,7 +232,7 @@ class LLScrollListCheck : public LLScrollListCell public: LLScrollListCheck( const LLScrollListCell::Params&); /*virtual*/ ~LLScrollListCheck(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ S32 getHeight() const { return 0; } /*virtual*/ const LLSD getValue() const; /*virtual*/ void setValue(const LLSD& value); @@ -264,13 +267,11 @@ class LLScrollListIconText : public LLScrollListText public: LLScrollListIconText(const LLScrollListCell::Params& p); /*virtual*/ ~LLScrollListIconText(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ const LLSD getValue() const; /*virtual*/ void setValue(const LLSD& value); - - S32 getIconWidth() const; - /*virtual*/ void setWidth(S32 width);/* { LLScrollListCell::setWidth(width); mTextWidth = width - ; }*/ + /*virtual*/ void setWidth(S32 width); private: LLPointer<LLUIImage> mIcon; |