diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lltextbase.cpp | 14 | ||||
-rw-r--r-- | indra/llui/lltextbase.h | 8 | ||||
-rw-r--r-- | indra/llui/lluiimage.cpp | 36 | ||||
-rw-r--r-- | indra/llui/lluiimage.h | 9 |
4 files changed, 56 insertions, 11 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index e0750968ae..2a9515171a 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2207,6 +2207,12 @@ LLNormalTextSegment::LLNormalTextSegment( const LLStyleSP& style, S32 start, S32 mEditor(editor) { mFontHeight = llceil(mStyle->getFont()->getLineHeight()); + + LLUIImagePtr image = mStyle->getImage(); + if (image.notNull()) + { + mImageLoadedConnection = image->addLoadedCallback(boost::bind(&LLTextBase::needsReflow, &mEditor)); + } } LLNormalTextSegment::LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible) @@ -2219,6 +2225,12 @@ LLNormalTextSegment::LLNormalTextSegment( const LLColor4& color, S32 start, S32 mFontHeight = llceil(mStyle->getFont()->getLineHeight()); } +LLNormalTextSegment::~LLNormalTextSegment() +{ + mImageLoadedConnection.disconnect(); +} + + F32 LLNormalTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect) { if( end - start > 0 ) @@ -2232,7 +2244,7 @@ F32 LLNormalTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selec // Center the image vertically S32 image_bottom = draw_rect.getCenterY() - (style_image_height/2); image->draw(draw_rect.mLeft, image_bottom, - style_image_width, style_image_height); + style_image_width, style_image_height, color); } return drawClippedSegment( getStart() + start, getStart() + end, selection_start, selection_end, draw_rect); diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index c60b040655..0138ca3704 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -136,7 +136,6 @@ public: // TODO: move into LLTextSegment? void createUrlContextMenu(S32 x, S32 y, const std::string &url); // create a popup context menu for the given Url - // Text accessors // TODO: add optional style parameter virtual void setText(const LLStringExplicit &utf8str , const LLStyle::Params& input_params = LLStyle::Params()); // uses default style @@ -148,6 +147,8 @@ public: LLWString getWText() const; void appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params = LLStyle::Params()); + // force reflow of text + void needsReflow() { mReflowNeeded = TRUE; } S32 getLength() const { return getWText().length(); } S32 getLineCount() const { return mLineInfoList.size(); } @@ -162,7 +163,6 @@ public: S32 getVPad() { return mVPad; } S32 getHPad() { return mHPad; } - S32 getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round ) const; LLRect getLocalRectFromDocIndex(S32 pos) const; LLRect getDocRectFromDocIndex(S32 pos) const; @@ -180,6 +180,7 @@ public: void changePage( S32 delta ); void changeLine( S32 delta ); + const LLFontGL* getDefaultFont() const { return mDefaultFont; } public: @@ -303,7 +304,6 @@ protected: // misc void updateRects(); - void needsReflow() { mReflowNeeded = TRUE; } void needsScroll() { mScrollNeeded = TRUE; } void replaceUrlLabel(const std::string &url, const std::string &label); @@ -426,6 +426,7 @@ class LLNormalTextSegment : public LLTextSegment public: LLNormalTextSegment( const LLStyleSP& style, S32 start, S32 end, LLTextBase& editor ); LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible = TRUE); + ~LLNormalTextSegment(); /*virtual*/ bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; /*virtual*/ S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const; @@ -457,6 +458,7 @@ protected: S32 mFontHeight; LLKeywordToken* mToken; std::string mTooltip; + boost::signals2::connection mImageLoadedConnection; }; class LLIndexSegment : public LLTextSegment diff --git a/indra/llui/lluiimage.cpp b/indra/llui/lluiimage.cpp index a8683e55c3..f941f391eb 100644 --- a/indra/llui/lluiimage.cpp +++ b/indra/llui/lluiimage.cpp @@ -39,18 +39,20 @@ #include "lluiimage.h" #include "llui.h" -LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image) : - mName(name), - mImage(image), - mScaleRegion(0.f, 1.f, 1.f, 0.f), - mClipRegion(0.f, 1.f, 1.f, 0.f), - mUniformScaling(TRUE), - mNoClip(TRUE) +LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image) +: mName(name), + mImage(image), + mScaleRegion(0.f, 1.f, 1.f, 0.f), + mClipRegion(0.f, 1.f, 1.f, 0.f), + mUniformScaling(TRUE), + mNoClip(TRUE), + mImageLoaded(NULL) { } LLUIImage::~LLUIImage() { + delete mImageLoaded; } void LLUIImage::setClipRegion(const LLRectf& region) @@ -138,6 +140,25 @@ S32 LLUIImage::getTextureHeight() const return mImage->getHeight(0); } +boost::signals2::connection LLUIImage::addLoadedCallback( const image_loaded_signal_t::slot_type& cb ) +{ + if (!mImageLoaded) + { + mImageLoaded = new image_loaded_signal_t(); + } + return mImageLoaded->connect(cb); +} + + +void LLUIImage::onImageLoaded() +{ + if (mImageLoaded) + { + (*mImageLoaded)(); + } +} + + namespace LLInitParam { LLUIImage* TypedParam<LLUIImage*>::getValueFromBlock() const @@ -170,3 +191,4 @@ namespace LLInitParam return (a == b); } } + diff --git a/indra/llui/lluiimage.h b/indra/llui/lluiimage.h index 9d734bcfdf..5fa9610ab2 100644 --- a/indra/llui/lluiimage.h +++ b/indra/llui/lluiimage.h @@ -39,6 +39,7 @@ #include "llrefcount.h" #include "llrect.h" #include <boost/function.hpp> +#include <boost/signals2.hpp> #include "llinitparam.h" #include "lltexture.h" @@ -47,6 +48,8 @@ extern const LLColor4 UI_VERTEX_COLOR; class LLUIImage : public LLRefCount { public: + typedef boost::signals2::signal<void (void)> image_loaded_signal_t; + LLUIImage(const std::string& name, LLPointer<LLTexture> image); virtual ~LLUIImage(); @@ -77,7 +80,13 @@ public: S32 getTextureWidth() const; S32 getTextureHeight() const; + boost::signals2::connection addLoadedCallback( const image_loaded_signal_t::slot_type& cb ); + + void onImageLoaded(); + protected: + image_loaded_signal_t* mImageLoaded; + std::string mName; LLRectf mScaleRegion; LLRectf mClipRegion; |