Huge renderer update (WIP). Still plenty to do, especially pertaining to UI.
-Nametag bubble visbility is oddly inconsistent. May vanish with future planned UI merges... -VBOs are PAINFULLY slow on ATI hardware. This repos self-compiled davep/shining-fixes branch, so I'll leave the ball in LL's court for now regarding that.
This commit is contained in:
@@ -68,6 +68,7 @@ set(llui_SOURCE_FILES
|
||||
llui.cpp
|
||||
lluictrl.cpp
|
||||
lluictrlfactory.cpp
|
||||
lluiimage.cpp
|
||||
lluistring.cpp
|
||||
lluitrans.cpp
|
||||
llundo.cpp
|
||||
@@ -92,6 +93,7 @@ set(llui_HEADER_FILES
|
||||
llfloater.h
|
||||
llfocusmgr.h
|
||||
llfunctorregistry.h
|
||||
llhandle.h
|
||||
llhtmlhelp.h
|
||||
lliconctrl.h
|
||||
llkeywords.h
|
||||
@@ -129,6 +131,7 @@ set(llui_HEADER_FILES
|
||||
lluictrl.h
|
||||
lluifwd.h
|
||||
llui.h
|
||||
lluiimage.h
|
||||
lluistring.h
|
||||
lluitrans.h
|
||||
lluixmltags.h
|
||||
|
||||
@@ -423,7 +423,7 @@ void LLButton::draw()
|
||||
// Unselected image assignments
|
||||
S32 local_mouse_x;
|
||||
S32 local_mouse_y;
|
||||
LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y);
|
||||
LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
|
||||
|
||||
BOOL pressed = pressed_by_keyboard
|
||||
|| (hasMouseCapture() && pointInView(local_mouse_x, local_mouse_y))
|
||||
@@ -688,7 +688,7 @@ void LLButton::draw()
|
||||
x = text_right;
|
||||
break;
|
||||
case LLFontGL::HCENTER:
|
||||
x = getRect().getWidth() / 2;
|
||||
x = text_left + (text_width / 2);
|
||||
break;
|
||||
case LLFontGL::LEFT:
|
||||
default:
|
||||
@@ -704,10 +704,13 @@ void LLButton::draw()
|
||||
x++;
|
||||
}
|
||||
|
||||
mGLFont->render(label, 0, (F32)x, (F32)(LLBUTTON_V_PAD + y_offset),
|
||||
mGLFont->render(label, 0,
|
||||
(F32)x,
|
||||
(F32)(LLBUTTON_V_PAD + y_offset),
|
||||
label_color,
|
||||
mHAlign, LLFontGL::BOTTOM,
|
||||
mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NORMAL,
|
||||
LLFontGL::NORMAL,
|
||||
mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NO_SHADOW,
|
||||
U32_MAX, text_width,
|
||||
NULL, FALSE, FALSE);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "v4color.h"
|
||||
#include "llframetimer.h"
|
||||
#include "llfontgl.h"
|
||||
#include "llimage.h"
|
||||
#include "lluiimage.h"
|
||||
#include "lluistring.h"
|
||||
|
||||
//
|
||||
|
||||
@@ -117,7 +117,7 @@ void LLDragHandleTop::setTitle(const std::string& title)
|
||||
const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
|
||||
LLTextBox* titlebox = new LLTextBox( std::string("Drag Handle Title"), getRect(), trimmed_title, font );
|
||||
titlebox->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT);
|
||||
titlebox->setFontStyle(LLFontGL::DROP_SHADOW_SOFT);
|
||||
titlebox->setFontShadow(LLFontGL::DROP_SHADOW_SOFT);
|
||||
|
||||
setTitleBox(titlebox);
|
||||
reshapeTitleBox();
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "llstring.h"
|
||||
#include "llframetimer.h"
|
||||
#include "llui.h"
|
||||
#include "llhandle.h"
|
||||
|
||||
class LLUICtrl;
|
||||
class LLMouseHandler;
|
||||
|
||||
164
indra/llui/llhandle.h
Normal file
164
indra/llui/llhandle.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* @file llhandle.h
|
||||
* @brief "Handle" to an object (usually a floater) whose lifetime you don't
|
||||
* control.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
#ifndef LLHANDLE_H
|
||||
#define LLHANDLE_H
|
||||
|
||||
#include "llpointer.h"
|
||||
|
||||
template <typename T>
|
||||
class LLTombStone : public LLRefCount
|
||||
{
|
||||
public:
|
||||
LLTombStone(T* target = NULL) : mTarget(target) {}
|
||||
|
||||
void setTarget(T* target) { mTarget = target; }
|
||||
T* getTarget() const { return mTarget; }
|
||||
private:
|
||||
T* mTarget;
|
||||
};
|
||||
|
||||
// LLHandles are used to refer to objects whose lifetime you do not control or influence.
|
||||
// Calling get() on a handle will return a pointer to the referenced object or NULL,
|
||||
// if the object no longer exists. Note that during the lifetime of the returned pointer,
|
||||
// you are assuming that the object will not be deleted by any action you perform,
|
||||
// or any other thread, as normal when using pointers, so avoid using that pointer outside of
|
||||
// the local code block.
|
||||
//
|
||||
// https://wiki.lindenlab.com/mediawiki/index.php?title=LLHandle&oldid=79669
|
||||
|
||||
template <typename T>
|
||||
class LLHandle
|
||||
{
|
||||
public:
|
||||
LLHandle() : mTombStone(getDefaultTombStone()) {}
|
||||
const LLHandle<T>& operator =(const LLHandle<T>& other)
|
||||
{
|
||||
mTombStone = other.mTombStone;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool isDead() const
|
||||
{
|
||||
return mTombStone->getTarget() == NULL;
|
||||
}
|
||||
|
||||
void markDead()
|
||||
{
|
||||
mTombStone = getDefaultTombStone();
|
||||
}
|
||||
|
||||
T* get() const
|
||||
{
|
||||
return mTombStone->getTarget();
|
||||
}
|
||||
|
||||
friend bool operator== (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
|
||||
{
|
||||
return lhs.mTombStone == rhs.mTombStone;
|
||||
}
|
||||
friend bool operator!= (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
friend bool operator< (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
|
||||
{
|
||||
return lhs.mTombStone < rhs.mTombStone;
|
||||
}
|
||||
friend bool operator> (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
|
||||
{
|
||||
return lhs.mTombStone > rhs.mTombStone;
|
||||
}
|
||||
|
||||
protected:
|
||||
LLPointer<LLTombStone<T> > mTombStone;
|
||||
|
||||
private:
|
||||
static LLPointer<LLTombStone<T> >& getDefaultTombStone()
|
||||
{
|
||||
static LLPointer<LLTombStone<T> > sDefaultTombStone = new LLTombStone<T>;
|
||||
return sDefaultTombStone;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class LLRootHandle : public LLHandle<T>
|
||||
{
|
||||
public:
|
||||
LLRootHandle(T* object) { bind(object); }
|
||||
LLRootHandle() {};
|
||||
~LLRootHandle() { unbind(); }
|
||||
|
||||
// this is redundant, since a LLRootHandle *is* an LLHandle
|
||||
LLHandle<T> getHandle() { return LLHandle<T>(*this); }
|
||||
|
||||
void bind(T* object)
|
||||
{
|
||||
// unbind existing tombstone
|
||||
if (LLHandle<T>::mTombStone.notNull())
|
||||
{
|
||||
if (LLHandle<T>::mTombStone->getTarget() == object) return;
|
||||
LLHandle<T>::mTombStone->setTarget(NULL);
|
||||
}
|
||||
// tombstone reference counted, so no paired delete
|
||||
LLHandle<T>::mTombStone = new LLTombStone<T>(object);
|
||||
}
|
||||
|
||||
void unbind()
|
||||
{
|
||||
LLHandle<T>::mTombStone->setTarget(NULL);
|
||||
}
|
||||
|
||||
//don't allow copying of root handles, since there should only be one
|
||||
private:
|
||||
LLRootHandle(const LLRootHandle& other) {};
|
||||
};
|
||||
|
||||
// Use this as a mixin for simple classes that need handles and when you don't
|
||||
// want handles at multiple points of the inheritance hierarchy
|
||||
template <typename T>
|
||||
class LLHandleProvider
|
||||
{
|
||||
protected:
|
||||
typedef LLHandle<T> handle_type_t;
|
||||
LLHandleProvider()
|
||||
{
|
||||
// provided here to enforce T deriving from LLHandleProvider<T>
|
||||
}
|
||||
|
||||
LLHandle<T> getHandle()
|
||||
{
|
||||
// perform lazy binding to avoid small tombstone allocations for handle
|
||||
// providers whose handles are never referenced
|
||||
mHandle.bind(static_cast<T*>(this));
|
||||
return mHandle;
|
||||
}
|
||||
|
||||
private:
|
||||
LLRootHandle<T> mHandle;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1964,6 +1964,7 @@ void LLLineEditor::draw()
|
||||
text_color,
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM,
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
select_left - mScrollHPos,
|
||||
mMaxHPixels - llround(rendered_pixels_right),
|
||||
&rendered_pixels_right);
|
||||
@@ -1983,6 +1984,7 @@ void LLLineEditor::draw()
|
||||
LLColor4( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], 1 ),
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM,
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
select_right - mScrollHPos - rendered_text,
|
||||
mMaxHPixels - llround(rendered_pixels_right),
|
||||
&rendered_pixels_right);
|
||||
@@ -1997,6 +1999,7 @@ void LLLineEditor::draw()
|
||||
text_color,
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM,
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX,
|
||||
mMaxHPixels - llround(rendered_pixels_right),
|
||||
&rendered_pixels_right);
|
||||
@@ -2010,6 +2013,7 @@ void LLLineEditor::draw()
|
||||
text_color,
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM,
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX,
|
||||
mMaxHPixels - llround(rendered_pixels_right),
|
||||
&rendered_pixels_right);
|
||||
@@ -2050,6 +2054,7 @@ void LLLineEditor::draw()
|
||||
LLColor4( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], 1 ),
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM,
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
1);
|
||||
}
|
||||
|
||||
@@ -2075,6 +2080,7 @@ void LLLineEditor::draw()
|
||||
LLFontGL::LEFT,
|
||||
LLFontGL::BOTTOM,
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX,
|
||||
mMaxHPixels - llround(rendered_pixels_right),
|
||||
&rendered_pixels_right, FALSE);
|
||||
@@ -2099,6 +2105,7 @@ void LLLineEditor::draw()
|
||||
LLFontGL::LEFT,
|
||||
LLFontGL::BOTTOM,
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX,
|
||||
mMaxHPixels - llround(rendered_pixels_right),
|
||||
&rendered_pixels_right, FALSE);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
#include "lleditmenuhandler.h"
|
||||
#include "lluictrl.h"
|
||||
#include "lluiimage.h"
|
||||
#include "lluistring.h"
|
||||
#include "llviewborder.h"
|
||||
|
||||
|
||||
@@ -447,10 +447,10 @@ void LLMenuItemGL::draw( void )
|
||||
|
||||
LLColor4 color;
|
||||
|
||||
U8 font_style = mStyle;
|
||||
LLFontGL::ShadowType font_shadow = LLFontGL::NO_SHADOW;
|
||||
if (getEnabled() && !mDrawTextDisabled )
|
||||
{
|
||||
font_style |= LLFontGL::DROP_SHADOW_SOFT;
|
||||
font_shadow = LLFontGL::DROP_SHADOW_SOFT;
|
||||
}
|
||||
|
||||
if ( getEnabled() && getHighlight() )
|
||||
@@ -470,26 +470,26 @@ void LLMenuItemGL::draw( void )
|
||||
if (mBriefItem)
|
||||
{
|
||||
mFont->render( mLabel, 0, BRIEF_PAD_PIXELS / 2, 0, color,
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM, font_style );
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM, mStyle );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !mDrawBoolLabel.empty() )
|
||||
{
|
||||
mFont->render( mDrawBoolLabel.getWString(), 0, (F32)LEFT_PAD_PIXELS, ((F32)MENU_ITEM_PADDING / 2.f) + 1.f, color,
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM, font_style, S32_MAX, S32_MAX, NULL, FALSE );
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM, mStyle, font_shadow, S32_MAX, S32_MAX, NULL, FALSE );
|
||||
}
|
||||
mFont->render( mLabel.getWString(), 0, (F32)LEFT_PLAIN_PIXELS, ((F32)MENU_ITEM_PADDING / 2.f) + 1.f, color,
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM, font_style, S32_MAX, S32_MAX, NULL, FALSE );
|
||||
LLFontGL::LEFT, LLFontGL::BOTTOM, mStyle, font_shadow, S32_MAX, S32_MAX, NULL, FALSE );
|
||||
if( !mDrawAccelLabel.empty() )
|
||||
{
|
||||
mFont->render( mDrawAccelLabel.getWString(), 0, (F32)getRect().mRight - (F32)RIGHT_PLAIN_PIXELS, ((F32)MENU_ITEM_PADDING / 2.f) + 1.f, color,
|
||||
LLFontGL::RIGHT, LLFontGL::BOTTOM, font_style, S32_MAX, S32_MAX, NULL, FALSE );
|
||||
LLFontGL::RIGHT, LLFontGL::BOTTOM, mStyle, font_shadow, S32_MAX, S32_MAX, NULL, FALSE );
|
||||
}
|
||||
if( !mDrawBranchLabel.empty() )
|
||||
{
|
||||
mFont->render( mDrawBranchLabel.getWString(), 0, (F32)getRect().mRight - (F32)RIGHT_PAD_PIXELS, ((F32)MENU_ITEM_PADDING / 2.f) + 1.f, color,
|
||||
LLFontGL::RIGHT, LLFontGL::BOTTOM, font_style, S32_MAX, S32_MAX, NULL, FALSE );
|
||||
LLFontGL::RIGHT, LLFontGL::BOTTOM, mStyle, font_shadow, S32_MAX, S32_MAX, NULL, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1638,10 +1638,10 @@ void LLMenuItemBranchDownGL::draw( void )
|
||||
gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0 );
|
||||
}
|
||||
|
||||
U8 font_style = getFontStyle();
|
||||
LLFontGL::ShadowType font_shadow = LLFontGL::NO_SHADOW;
|
||||
if (getEnabled() && !getDrawTextDisabled() )
|
||||
{
|
||||
font_style |= LLFontGL::DROP_SHADOW_SOFT;
|
||||
font_shadow = LLFontGL::DROP_SHADOW_SOFT;
|
||||
}
|
||||
|
||||
LLColor4 color;
|
||||
@@ -1658,7 +1658,7 @@ void LLMenuItemBranchDownGL::draw( void )
|
||||
color = getDisabledColor();
|
||||
}
|
||||
getFont()->render( mLabel.getWString(), 0, (F32)getRect().getWidth() / 2.f, (F32)LABEL_BOTTOM_PAD_PIXELS, color,
|
||||
LLFontGL::HCENTER, LLFontGL::BOTTOM, font_style );
|
||||
LLFontGL::HCENTER, LLFontGL::BOTTOM, getFontStyle(), font_shadow );
|
||||
|
||||
|
||||
// underline navigation key only when keyboard navigation has been initiated
|
||||
@@ -3858,7 +3858,7 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down)
|
||||
center.mX = (getRect().mLeft + getRect().mRight) / 2;
|
||||
center.mY = (getRect().mTop + getRect().mBottom) / 2;
|
||||
|
||||
LLUI::setCursorPositionLocal(getParent(), center.mX, center.mY);
|
||||
LLUI::setMousePositionLocal(getParent(), center.mX, center.mY);
|
||||
}
|
||||
|
||||
// *FIX: what happens when mouse buttons reversed?
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "llfocusmgr.h"
|
||||
#include "llkeyboard.h" // for the MASK constants
|
||||
#include "llcontrol.h"
|
||||
#include "llimagegl.h"
|
||||
#include "lluiimage.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "lltextbox.h"
|
||||
#include "lluictrl.h"
|
||||
#include "lluictrlfactory.h"
|
||||
#include "lluiimage.h"
|
||||
#include "llviewborder.h"
|
||||
#include "llbutton.h"
|
||||
#include "llnotificationsutil.h"
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "lluictrl.h"
|
||||
#include "llbutton.h"
|
||||
#include "lllineeditor.h"
|
||||
#include "lluiimage.h"
|
||||
#include "llviewborder.h"
|
||||
#include "lluistring.h"
|
||||
#include "v4color.h"
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "llgl.h"
|
||||
#include "llui.h"
|
||||
#include "llfontgl.h"
|
||||
#include "llimagegl.h"
|
||||
#include "lluiimage.h"
|
||||
#include "lltimer.h"
|
||||
#include "llglheaders.h"
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "llview.h"
|
||||
#include "llframetimer.h"
|
||||
#include "lluiimage.h"
|
||||
|
||||
class LLProgressBar
|
||||
: public LLView
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "llradiogroup.h"
|
||||
#include "indra_constants.h"
|
||||
|
||||
#include "lluiimage.h"
|
||||
#include "llviewborder.h"
|
||||
#include "llcontrol.h"
|
||||
#include "llui.h"
|
||||
|
||||
@@ -495,7 +495,7 @@ void LLScrollbar::draw()
|
||||
|
||||
S32 local_mouse_x;
|
||||
S32 local_mouse_y;
|
||||
LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y);
|
||||
LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
|
||||
BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this;
|
||||
BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y));
|
||||
if (hovered)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "llscrollbar.h"
|
||||
#include "llui.h"
|
||||
#include "llkeyboard.h"
|
||||
#include "lluiimage.h"
|
||||
#include "llviewborder.h"
|
||||
#include "llfocusmgr.h"
|
||||
#include "llframetimer.h"
|
||||
|
||||
@@ -445,6 +445,7 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
|
||||
mFontAlignment,
|
||||
LLFontGL::BOTTOM,
|
||||
mFontStyle,
|
||||
LLFontGL::NO_SHADOW,
|
||||
string_chars,
|
||||
getWidth(),
|
||||
&right_x,
|
||||
@@ -3741,7 +3742,7 @@ void LLColumnHeader::draw()
|
||||
// Unselected image assignments
|
||||
S32 local_mouse_x;
|
||||
S32 local_mouse_y;
|
||||
LLUI::getCursorPositionLocal(mButton, &local_mouse_x, &local_mouse_y);
|
||||
LLUI::getMousePositionLocal(mButton, &local_mouse_x, &local_mouse_y);
|
||||
|
||||
BOOL pressed = pressed_by_keyboard
|
||||
|| (mButton->hasMouseCapture() && mButton->pointInView(local_mouse_x, local_mouse_y))
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "llfocusmgr.h"
|
||||
#include "llkeyboard.h" // for the MASK constants
|
||||
#include "llcontrol.h"
|
||||
#include "llimagegl.h"
|
||||
#include "lluiimage.h"
|
||||
|
||||
static LLRegisterWidget<LLSlider> r1("slider_bar");
|
||||
static LLRegisterWidget<LLSlider> r2("volume_slider");
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "lluictrl.h"
|
||||
#include "v4color.h"
|
||||
|
||||
#include "lluiimage.h"
|
||||
|
||||
class LLSlider : public LLUICtrl
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "llresmgr.h"
|
||||
#include "llfont.h"
|
||||
#include "llui.h"
|
||||
#include "lluiimage.h"
|
||||
|
||||
class LLStyle : public LLRefCount
|
||||
{
|
||||
@@ -109,7 +110,7 @@ private:
|
||||
std::string mFontName;
|
||||
LLFONT_ID mFontID;
|
||||
std::string mLink;
|
||||
LLUIImagePtr mImagep;
|
||||
LLPointer<LLUIImage> mImagep;
|
||||
BOOL mIsEmbeddedItem;
|
||||
};
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ void LLTextBox::initDefaults()
|
||||
mHasHover = FALSE;
|
||||
mBackgroundVisible = FALSE;
|
||||
mBorderVisible = FALSE;
|
||||
mFontStyle = LLFontGL::DROP_SHADOW_SOFT;
|
||||
mFontStyle = 0;
|
||||
mFontShadow = LLFontGL::DROP_SHADOW_SOFT;
|
||||
mBorderDropShadowVisible = FALSE;
|
||||
mUseEllipses = FALSE;
|
||||
mLineSpacing = 0;
|
||||
@@ -217,7 +218,7 @@ void LLTextBox::setWrappedText(const LLStringExplicit& in_text, F32 max_width)
|
||||
{
|
||||
LLWString run(wtext, cur, runLen);
|
||||
LLWString::size_type useLen =
|
||||
mFontGL->maxDrawableChars(run.c_str(), max_width, runLen, TRUE);
|
||||
mFontGL->maxDrawableChars(run.c_str(), max_width, runLen, LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);
|
||||
|
||||
final_wtext.append(wtext, cur, useLen);
|
||||
cur += useLen;
|
||||
@@ -355,6 +356,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color )
|
||||
mFontGL->render(mText.getWString(), 0, (F32)x, (F32)y, color,
|
||||
mHAlign, mVAlign,
|
||||
mFontStyle,
|
||||
mFontShadow,
|
||||
S32_MAX, getRect().getWidth(), NULL, TRUE, mUseEllipses);
|
||||
}
|
||||
else
|
||||
@@ -367,6 +369,7 @@ void LLTextBox::drawText( S32 x, S32 y, const LLColor4& color )
|
||||
mFontGL->render(mText.getWString(), cur_pos, (F32)x, (F32)y, color,
|
||||
mHAlign, mVAlign,
|
||||
mFontStyle,
|
||||
mFontShadow,
|
||||
line_length, getRect().getWidth(), NULL, TRUE, mUseEllipses );
|
||||
cur_pos += line_length + 1;
|
||||
y -= llfloor(mFontGL->getLineHeight()) + mLineSpacing;
|
||||
@@ -435,7 +438,17 @@ LLView* LLTextBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f
|
||||
{
|
||||
text_box->mFontStyle = LLFontGL::getStyleFromString(font_style);
|
||||
}
|
||||
|
||||
|
||||
if (node->getAttributeString("font-shadow", font_style))
|
||||
{
|
||||
if(font_style == "soft")
|
||||
text_box->mFontShadow = LLFontGL::DROP_SHADOW_SOFT;
|
||||
else if(font_style == "hard")
|
||||
text_box->mFontShadow = LLFontGL::DROP_SHADOW;
|
||||
else
|
||||
text_box->mFontShadow = LLFontGL::NO_SHADOW;
|
||||
}
|
||||
|
||||
BOOL mouse_opaque = text_box->getMouseOpaque();
|
||||
if (node->getAttributeBOOL("mouse_opaque", mouse_opaque))
|
||||
{
|
||||
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
void setBackgroundVisible(BOOL visible) { mBackgroundVisible = visible; }
|
||||
void setBorderVisible(BOOL visible) { mBorderVisible = visible; }
|
||||
void setFontStyle(U8 style) { mFontStyle = style; }
|
||||
void setFontShadow(LLFontGL::ShadowType shadow) { mFontShadow = shadow; }
|
||||
void setBorderDropshadowVisible(BOOL visible){ mBorderDropShadowVisible = visible; }
|
||||
void setHPad(S32 pixels) { mHPad = pixels; }
|
||||
void setVPad(S32 pixels) { mVPad = pixels; }
|
||||
@@ -124,6 +125,7 @@ private:
|
||||
BOOL mBorderVisible;
|
||||
|
||||
U8 mFontStyle; // style bit flags for font
|
||||
LLFontGL::ShadowType mFontShadow;
|
||||
BOOL mBorderDropShadowVisible;
|
||||
BOOL mUseEllipses;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "llrender.h"
|
||||
#include "llui.h"
|
||||
#include "lluictrlfactory.h"
|
||||
#include "lluiimage.h"
|
||||
#include "llrect.h"
|
||||
#include "llfocusmgr.h"
|
||||
#include "lltimer.h"
|
||||
@@ -562,7 +563,7 @@ void LLTextEditor::updateLineStartList(S32 startpos)
|
||||
{
|
||||
const llwchar* str = mWText.c_str() + start_idx;
|
||||
S32 drawn = mGLFont->maxDrawableChars(str, (F32)abs(mTextRect.getWidth()) - line_width,
|
||||
end_idx - start_idx, mWordWrap, mAllowEmbeddedItems );
|
||||
end_idx - start_idx, mWordWrap ? LLFontGL::WORD_BOUNDARY_IF_POSSIBLE : LLFontGL::ANYWHERE, mAllowEmbeddedItems );
|
||||
if( 0 == drawn && line_width == start_x)
|
||||
{
|
||||
// If at the beginning of a line, draw at least one character, even if it doesn't all fit.
|
||||
@@ -3238,6 +3239,7 @@ void LLTextEditor::drawCursor()
|
||||
LLColor4(1.f - text_color.mV[VRED], 1.f - text_color.mV[VGREEN], 1.f - text_color.mV[VBLUE], 1.f),
|
||||
LLFontGL::LEFT, LLFontGL::TOP,
|
||||
LLFontGL::NORMAL,
|
||||
LLFontGL::NO_SHADOW,
|
||||
1);
|
||||
}
|
||||
|
||||
@@ -3429,6 +3431,7 @@ void LLTextEditor::drawText()
|
||||
LLFontGL::LEFT, // horizontal alignment
|
||||
LLFontGL::VCENTER, // vertical alignment
|
||||
style,
|
||||
LLFontGL::NO_SHADOW,
|
||||
S32_MAX, // max chars
|
||||
UI_TEXTEDITOR_LINE_NUMBER_MARGIN); // max pixels
|
||||
}
|
||||
@@ -3553,7 +3556,7 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32
|
||||
S32 start = seg_start;
|
||||
S32 end = llmin( selection_left, seg_end );
|
||||
S32 length = end - start;
|
||||
font->render(text, start, x, y_top, color, LLFontGL::LEFT, LLFontGL::TOP, font_flags, length, S32_MAX, right_x, mAllowEmbeddedItems);
|
||||
font->render(text, start, x, y_top, color, LLFontGL::LEFT, LLFontGL::TOP, font_flags, LLFontGL::NO_SHADOW, length, S32_MAX, right_x, mAllowEmbeddedItems);
|
||||
}
|
||||
x = *right_x;
|
||||
|
||||
@@ -3566,7 +3569,7 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32
|
||||
|
||||
font->render(text, start, x, y_top,
|
||||
LLColor4( 1.f - color.mV[0], 1.f - color.mV[1], 1.f - color.mV[2], 1.f ),
|
||||
LLFontGL::LEFT, LLFontGL::TOP, font_flags, length, S32_MAX, right_x, mAllowEmbeddedItems);
|
||||
LLFontGL::LEFT, LLFontGL::TOP, font_flags, LLFontGL::NO_SHADOW, length, S32_MAX, right_x, mAllowEmbeddedItems);
|
||||
}
|
||||
x = *right_x;
|
||||
if( selection_right < seg_end )
|
||||
@@ -3575,7 +3578,7 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32
|
||||
S32 start = llmax( selection_right, seg_start );
|
||||
S32 end = seg_end;
|
||||
S32 length = end - start;
|
||||
font->render(text, start, x, y_top, color, LLFontGL::LEFT, LLFontGL::TOP, font_flags, length, S32_MAX, right_x, mAllowEmbeddedItems);
|
||||
font->render(text, start, x, y_top, color, LLFontGL::LEFT, LLFontGL::TOP, font_flags, LLFontGL::NO_SHADOW, length, S32_MAX, right_x, mAllowEmbeddedItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -442,7 +442,7 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border
|
||||
gl_draw_scaled_image_with_border(x, y, width, height, image, color, solid_color, uv_rect, scale_rect);
|
||||
}
|
||||
|
||||
void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color, BOOL solid_color, const LLRectf& uv_rect, const LLRectf& scale_rect)
|
||||
void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color, BOOL solid_color, const LLRectf& uv_outer_rect, const LLRectf& center_rect)
|
||||
{
|
||||
stop_glerror();
|
||||
|
||||
@@ -452,36 +452,53 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
|
||||
return;
|
||||
}
|
||||
|
||||
// add in offset of current image to current UI translation
|
||||
const LLVector3 ui_scale = LLVector3(1.f,1.f,1.f);//gGL.getUIScale();
|
||||
const LLVector3 ui_translation = LLVector3(x,y,0.f);//(gGL.getUITranslation() + LLVector3(x, y, 0.f)).scaledVec(ui_scale);
|
||||
|
||||
F32 uv_width = uv_outer_rect.getWidth();
|
||||
F32 uv_height = uv_outer_rect.getHeight();
|
||||
|
||||
// shrink scaling region to be proportional to clipped image region
|
||||
LLRectf scale_rect_uv(
|
||||
uv_rect.mLeft + (scale_rect.mLeft * uv_rect.getWidth()),
|
||||
uv_rect.mBottom + (scale_rect.mTop * uv_rect.getHeight()),
|
||||
uv_rect.mLeft + (scale_rect.mRight * uv_rect.getWidth()),
|
||||
uv_rect.mBottom + (scale_rect.mBottom * uv_rect.getHeight()));
|
||||
LLRectf uv_center_rect(
|
||||
uv_outer_rect.mLeft + (center_rect.mLeft * uv_width),
|
||||
uv_outer_rect.mBottom + (center_rect.mTop * uv_height),
|
||||
uv_outer_rect.mLeft + (center_rect.mRight * uv_width),
|
||||
uv_outer_rect.mBottom + (center_rect.mBottom * uv_height));
|
||||
|
||||
S32 image_natural_width = llround((F32)image->getWidth(0) * uv_rect.getWidth());
|
||||
S32 image_natural_height = llround((F32)image->getHeight(0) * uv_rect.getHeight());
|
||||
F32 image_width = image->getWidth(0);
|
||||
F32 image_height = image->getHeight(0);
|
||||
|
||||
LLRect draw_rect(0, height, width, 0);
|
||||
LLRect draw_scale_rect(llround(scale_rect_uv.mLeft * (F32)image->getWidth(0)),
|
||||
llround(scale_rect_uv.mTop * (F32)image->getHeight(0)),
|
||||
llround(scale_rect_uv.mRight * (F32)image->getWidth(0)),
|
||||
llround(scale_rect_uv.mBottom * (F32)image->getHeight(0)));
|
||||
// scale fixed region of image to drawn region
|
||||
draw_scale_rect.mRight += width - image_natural_width;
|
||||
draw_scale_rect.mTop += height - image_natural_height;
|
||||
S32 image_natural_width = llround(image_width * uv_width);
|
||||
S32 image_natural_height = llround(image_height * uv_height);
|
||||
|
||||
S32 border_shrink_width = llmax(0, draw_scale_rect.mLeft - draw_scale_rect.mRight);
|
||||
S32 border_shrink_height = llmax(0, draw_scale_rect.mBottom - draw_scale_rect.mTop);
|
||||
LLRectf draw_center_rect( uv_center_rect.mLeft * image_width,
|
||||
uv_center_rect.mTop * image_height,
|
||||
uv_center_rect.mRight * image_width,
|
||||
uv_center_rect.mBottom * image_height);
|
||||
|
||||
F32 shrink_width_ratio = scale_rect.getWidth() == 1.f ? 0.f : border_shrink_width / ((F32)image_natural_width * (1.f - scale_rect.getWidth()));
|
||||
F32 shrink_height_ratio = scale_rect.getHeight() == 1.f ? 0.f : border_shrink_height / ((F32)image_natural_height * (1.f - scale_rect.getHeight()));
|
||||
{ // scale fixed region of image to drawn region
|
||||
draw_center_rect.mRight += width - image_natural_width;
|
||||
draw_center_rect.mTop += height - image_natural_height;
|
||||
|
||||
F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio);
|
||||
draw_scale_rect.mLeft = llround((F32)draw_scale_rect.mLeft * shrink_scale);
|
||||
draw_scale_rect.mTop = llround(lerp((F32)height, (F32)draw_scale_rect.mTop, shrink_scale));
|
||||
draw_scale_rect.mRight = llround(lerp((F32)width, (F32)draw_scale_rect.mRight, shrink_scale));
|
||||
draw_scale_rect.mBottom = llround((F32)draw_scale_rect.mBottom * shrink_scale);
|
||||
F32 border_shrink_width = llmax(0.f, draw_center_rect.mLeft - draw_center_rect.mRight);
|
||||
F32 border_shrink_height = llmax(0.f, draw_center_rect.mBottom - draw_center_rect.mTop);
|
||||
|
||||
F32 shrink_width_ratio = center_rect.getWidth() == 1.f ? 0.f : border_shrink_width / ((F32)image_natural_width * (1.f - center_rect.getWidth()));
|
||||
F32 shrink_height_ratio = center_rect.getHeight() == 1.f ? 0.f : border_shrink_height / ((F32)image_natural_height * (1.f - center_rect.getHeight()));
|
||||
|
||||
F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio);
|
||||
|
||||
draw_center_rect.mLeft = llround(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * shrink_scale * ui_scale.mV[VX]);
|
||||
draw_center_rect.mTop = llround(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale) * ui_scale.mV[VY]);
|
||||
draw_center_rect.mRight = llround(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale) * ui_scale.mV[VX]);
|
||||
draw_center_rect.mBottom = llround(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * shrink_scale * ui_scale.mV[VY]);
|
||||
}
|
||||
|
||||
LLRectf draw_outer_rect(ui_translation.mV[VX],
|
||||
ui_translation.mV[VY] + height * ui_scale.mV[VY],
|
||||
ui_translation.mV[VX] + width * ui_scale.mV[VX],
|
||||
ui_translation.mV[VY]);
|
||||
|
||||
LLGLSUIDefault gls_ui;
|
||||
|
||||
@@ -498,136 +515,174 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
|
||||
}
|
||||
}
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.getTexUnit(0)->bind(image, true);
|
||||
|
||||
gGL.color4fv(color.mV);
|
||||
|
||||
const S32 NUM_VERTICES = 9 * 4; // 9 quads
|
||||
LLVector2 uv[NUM_VERTICES];
|
||||
LLVector3 pos[NUM_VERTICES];
|
||||
|
||||
S32 index = 0;
|
||||
|
||||
gGL.begin(LLRender::QUADS);
|
||||
{
|
||||
gGL.translatef((F32)x, (F32)y, 0.f);
|
||||
// draw bottom left
|
||||
uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.getTexUnit(0)->bind(image);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.color4fv(color.mV);
|
||||
|
||||
gGL.begin(LLRender::QUADS);
|
||||
{
|
||||
// draw bottom left
|
||||
gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
|
||||
gGL.vertex2i(0, 0);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, 0);
|
||||
uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
|
||||
// draw bottom middle
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(0, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
// draw bottom middle
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, 0);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, 0);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
|
||||
// draw bottom right
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
// draw bottom right
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, 0);
|
||||
uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
|
||||
gGL.vertex2i(width, 0);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(width, draw_scale_rect.mBottom);
|
||||
// draw left
|
||||
uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
// draw left
|
||||
gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(0, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
|
||||
// draw middle
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(0, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
// draw middle
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
|
||||
// draw right
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mBottom);
|
||||
pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mBottom, 0.f);
|
||||
index++;
|
||||
|
||||
// draw right
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mBottom);
|
||||
gGL.vertex2i(width, draw_scale_rect.mBottom);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(width, draw_scale_rect.mTop);
|
||||
// draw top left
|
||||
uv[index] = LLVector2(uv_outer_rect.mLeft, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_outer_rect.mLeft, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
// draw top left
|
||||
gGL.texCoord2f(uv_rect.mLeft, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(0, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_outer_rect.mLeft, uv_outer_rect.mTop);
|
||||
pos[index] = LLVector3(draw_outer_rect.mLeft, draw_outer_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, height);
|
||||
// draw top middle
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
|
||||
gGL.vertex2i(0, height);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
// draw top middle
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_center_rect.mLeft, uv_outer_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mLeft, draw_outer_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, height);
|
||||
// draw top right
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mLeft, uv_rect.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mLeft, height);
|
||||
uv[index] = LLVector2(uv_outer_rect.mRight, uv_center_rect.mTop);
|
||||
pos[index] = LLVector3(draw_outer_rect.mRight, draw_center_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
// draw top right
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_outer_rect.mRight, uv_outer_rect.mTop);
|
||||
pos[index] = LLVector3(draw_outer_rect.mRight, draw_outer_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mRight, scale_rect_uv.mTop);
|
||||
gGL.vertex2i(width, draw_scale_rect.mTop);
|
||||
uv[index] = LLVector2(uv_center_rect.mRight, uv_outer_rect.mTop);
|
||||
pos[index] = LLVector3(draw_center_rect.mRight, draw_outer_rect.mTop, 0.f);
|
||||
index++;
|
||||
|
||||
gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
|
||||
gGL.vertex2i(width, height);
|
||||
|
||||
gGL.texCoord2f(scale_rect_uv.mRight, uv_rect.mTop);
|
||||
gGL.vertex2i(draw_scale_rect.mRight, height);
|
||||
}
|
||||
gGL.end();
|
||||
gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES);
|
||||
}
|
||||
gGL.popMatrix();
|
||||
gGL.end();
|
||||
|
||||
if (solid_color)
|
||||
{
|
||||
@@ -657,77 +712,88 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre
|
||||
|
||||
LLGLSUIDefault gls_ui;
|
||||
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
gGL.translatef((F32)x, (F32)y, 0.f);
|
||||
if( degrees )
|
||||
{
|
||||
F32 offset_x = F32(width/2);
|
||||
F32 offset_y = F32(height/2);
|
||||
gGL.translatef( offset_x, offset_y, 0.f);
|
||||
gGL.rotatef( degrees, 0.f, 0.f, 1.f );
|
||||
gGL.translatef( -offset_x, -offset_y, 0.f );
|
||||
}
|
||||
|
||||
gGL.getTexUnit(0)->bind(image);
|
||||
gGL.getTexUnit(0)->bind(image, true);
|
||||
|
||||
gGL.color4fv(color.mV);
|
||||
|
||||
if (degrees == 0.f)
|
||||
{
|
||||
const S32 NUM_VERTICES = 4; // 9 quads
|
||||
LLVector2 uv[NUM_VERTICES];
|
||||
LLVector3 pos[NUM_VERTICES];
|
||||
|
||||
gGL.begin(LLRender::QUADS);
|
||||
{
|
||||
LLVector3 ui_scale = LLVector3(1.f,1.f,1.f);//gGL.getUIScale();
|
||||
LLVector3 ui_translation = LLVector3(0.f,0.f,0.f); //gGL.getUITranslation();
|
||||
ui_translation.mV[VX] += x;
|
||||
ui_translation.mV[VY] += y;
|
||||
ui_translation.scaleVec(ui_scale);
|
||||
S32 index = 0;
|
||||
S32 scaled_width = llround(width * ui_scale.mV[VX]);
|
||||
S32 scaled_height = llround(height * ui_scale.mV[VY]);
|
||||
|
||||
uv[index] = LLVector2(uv_rect.mRight, uv_rect.mTop);
|
||||
pos[index] = LLVector3(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY] + scaled_height, 0.f);
|
||||
index++;
|
||||
|
||||
uv[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop);
|
||||
pos[index] = LLVector3(ui_translation.mV[VX], ui_translation.mV[VY] + scaled_height, 0.f);
|
||||
index++;
|
||||
|
||||
uv[index] = LLVector2(uv_rect.mLeft, uv_rect.mBottom);
|
||||
pos[index] = LLVector3(ui_translation.mV[VX], ui_translation.mV[VY], 0.f);
|
||||
index++;
|
||||
|
||||
uv[index] = LLVector2(uv_rect.mRight, uv_rect.mBottom);
|
||||
pos[index] = LLVector3(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY], 0.f);
|
||||
index++;
|
||||
|
||||
gGL.vertexBatchPreTransformed(pos, uv, NUM_VERTICES);
|
||||
}
|
||||
gGL.end();
|
||||
}
|
||||
else
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
gGL.translatef((F32)x, (F32)y, 0.f);
|
||||
|
||||
F32 offset_x = F32(width/2);
|
||||
F32 offset_y = F32(height/2);
|
||||
|
||||
gGL.translatef(offset_x, offset_y, 0.f);
|
||||
|
||||
LLMatrix3 quat(0.f, 0.f, degrees*DEG_TO_RAD);
|
||||
|
||||
gGL.getTexUnit(0)->bind(image, true);
|
||||
|
||||
gGL.color4fv(color.mV);
|
||||
|
||||
gGL.begin(LLRender::QUADS);
|
||||
{
|
||||
LLVector3 v;
|
||||
|
||||
v = LLVector3(offset_x, offset_y, 0.f) * quat;
|
||||
gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
|
||||
gGL.vertex2i(width, height );
|
||||
gGL.vertex2f(v.mV[0], v.mV[1] );
|
||||
|
||||
v = LLVector3(-offset_x, offset_y, 0.f) * quat;
|
||||
gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
|
||||
gGL.vertex2i(0, height );
|
||||
gGL.vertex2f(v.mV[0], v.mV[1] );
|
||||
|
||||
v = LLVector3(-offset_x, -offset_y, 0.f) * quat;
|
||||
gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
|
||||
gGL.vertex2i(0, 0);
|
||||
gGL.vertex2f(v.mV[0], v.mV[1] );
|
||||
|
||||
v = LLVector3(offset_x, -offset_y, 0.f) * quat;
|
||||
gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
|
||||
gGL.vertex2i(width, 0);
|
||||
gGL.vertex2f(v.mV[0], v.mV[1] );
|
||||
}
|
||||
gGL.end();
|
||||
}
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
|
||||
void gl_draw_scaled_image_inverted(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color, const LLRectf& uv_rect)
|
||||
{
|
||||
if (NULL == image)
|
||||
{
|
||||
llwarns << "image == NULL; aborting function" << llendl;
|
||||
return;
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
LLGLSUIDefault gls_ui;
|
||||
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
gGL.translatef((F32)x, (F32)y, 0.f);
|
||||
|
||||
gGL.getTexUnit(0)->bind(image);
|
||||
|
||||
gGL.color4fv(color.mV);
|
||||
|
||||
gGL.begin(LLRender::QUADS);
|
||||
{
|
||||
gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
|
||||
gGL.vertex2i(width, height );
|
||||
|
||||
gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
|
||||
gGL.vertex2i(0, height );
|
||||
|
||||
gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
|
||||
gGL.vertex2i(0, 0);
|
||||
|
||||
gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
|
||||
gGL.vertex2i(width, 0);
|
||||
}
|
||||
gGL.end();
|
||||
}
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -756,25 +822,6 @@ void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LL
|
||||
LLUI::setLineWidth(1.f);
|
||||
}
|
||||
|
||||
|
||||
void gl_rect_2d_xor(S32 left, S32 top, S32 right, S32 bottom)
|
||||
{
|
||||
gGL.color4fv( LLColor4::white.mV );
|
||||
glLogicOp( GL_XOR );
|
||||
stop_glerror();
|
||||
|
||||
gGL.begin(LLRender::QUADS);
|
||||
gGL.vertex2i(left, top);
|
||||
gGL.vertex2i(left, bottom);
|
||||
gGL.vertex2i(right, bottom);
|
||||
gGL.vertex2i(right, top);
|
||||
gGL.end();
|
||||
|
||||
glLogicOp( GL_COPY );
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
|
||||
void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F32 start_angle, F32 end_angle)
|
||||
{
|
||||
if (end_angle < start_angle)
|
||||
@@ -900,7 +947,7 @@ void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor
|
||||
}
|
||||
|
||||
// Draw gray and white checkerboard with black border
|
||||
void gl_rect_2d_checkerboard(const LLRect& rect)
|
||||
void gl_rect_2d_checkerboard(const LLRect& rect, GLfloat alpha)
|
||||
{
|
||||
// Initialize the first time this is called.
|
||||
const S32 PIXELS = 32;
|
||||
@@ -921,16 +968,24 @@ void gl_rect_2d_checkerboard(const LLRect& rect)
|
||||
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
|
||||
|
||||
// ...white squares
|
||||
gGL.color3f( 1.f, 1.f, 1.f );
|
||||
gGL.color4f( 1.f, 1.f, 1.f, alpha );
|
||||
gl_rect_2d(rect);
|
||||
|
||||
// ...gray squares
|
||||
gGL.color3f( .7f, .7f, .7f );
|
||||
gGL.color4f( .7f, .7f, .7f, alpha );
|
||||
gGL.flush();
|
||||
glPolygonStipple( checkerboard );
|
||||
|
||||
LLGLEnable polygon_stipple(GL_POLYGON_STIPPLE);
|
||||
gl_rect_2d(rect);
|
||||
if (!LLGLSLShader::sNoFixedFunction)
|
||||
{ //polygon stipple is deprecated
|
||||
glPolygonStipple( checkerboard );
|
||||
|
||||
LLGLEnable polygon_stipple(GL_POLYGON_STIPPLE);
|
||||
gl_rect_2d(rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_rect_2d(rect);
|
||||
}
|
||||
gGL.flush();
|
||||
}
|
||||
|
||||
@@ -1231,6 +1286,7 @@ void gl_segmented_rect_2d_tex(const S32 left,
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
//FIXME: rewrite to use scissor?
|
||||
void gl_segmented_rect_2d_fragment_tex(const S32 left,
|
||||
const S32 top,
|
||||
const S32 right,
|
||||
@@ -1650,7 +1706,7 @@ void LLUI::setLineWidth(F32 width)
|
||||
}
|
||||
|
||||
//static
|
||||
void LLUI::setCursorPositionScreen(S32 x, S32 y)
|
||||
void LLUI::setMousePositionScreen(S32 x, S32 y)
|
||||
{
|
||||
S32 screen_x, screen_y;
|
||||
screen_x = llround((F32)x * sGLScaleFactor.mV[VX]);
|
||||
@@ -1663,26 +1719,34 @@ void LLUI::setCursorPositionScreen(S32 x, S32 y)
|
||||
}
|
||||
|
||||
//static
|
||||
void LLUI::setCursorPositionLocal(const LLView* viewp, S32 x, S32 y)
|
||||
{
|
||||
S32 screen_x, screen_y;
|
||||
viewp->localPointToScreen(x, y, &screen_x, &screen_y);
|
||||
|
||||
setCursorPositionScreen(screen_x, screen_y);
|
||||
}
|
||||
|
||||
//static
|
||||
void LLUI::getCursorPositionLocal(const LLView* viewp, S32 *x, S32 *y)
|
||||
void LLUI::getMousePositionScreen(S32 *x, S32 *y)
|
||||
{
|
||||
LLCoordWindow cursor_pos_window;
|
||||
LLView::getWindow()->getCursorPosition(&cursor_pos_window);
|
||||
LLCoordGL cursor_pos_gl;
|
||||
LLView::getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl);
|
||||
cursor_pos_gl.mX = llround((F32)cursor_pos_gl.mX / LLUI::sGLScaleFactor.mV[VX]);
|
||||
cursor_pos_gl.mY = llround((F32)cursor_pos_gl.mY / LLUI::sGLScaleFactor.mV[VY]);
|
||||
viewp->screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, x, y);
|
||||
*x = llround((F32)cursor_pos_gl.mX / sGLScaleFactor.mV[VX]);
|
||||
*y = llround((F32)cursor_pos_gl.mY / sGLScaleFactor.mV[VX]);
|
||||
}
|
||||
|
||||
//static
|
||||
void LLUI::setMousePositionLocal(const LLView* viewp, S32 x, S32 y)
|
||||
{
|
||||
S32 screen_x, screen_y;
|
||||
viewp->localPointToScreen(x, y, &screen_x, &screen_y);
|
||||
|
||||
setMousePositionScreen(screen_x, screen_y);
|
||||
}
|
||||
|
||||
//static
|
||||
void LLUI::getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y)
|
||||
{
|
||||
S32 screen_x, screen_y;
|
||||
getMousePositionScreen(&screen_x, &screen_y);
|
||||
viewp->screenPointToLocal(screen_x, screen_y, x, y);
|
||||
}
|
||||
|
||||
|
||||
// On Windows, the user typically sets the language when they install the
|
||||
// app (by running it with a shortcut that sets InstallLanguage). On Mac,
|
||||
// or on Windows if the SecondLife.exe executable is run directly, the
|
||||
@@ -1875,102 +1939,3 @@ LLLocalClipRect::LLLocalClipRect(const LLRect &rect, BOOL enabled)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// LLUIImage
|
||||
//
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
void LLUIImage::setClipRegion(const LLRectf& region)
|
||||
{
|
||||
mClipRegion = region;
|
||||
mNoClip = mClipRegion.mLeft == 0.f
|
||||
&& mClipRegion.mRight == 1.f
|
||||
&& mClipRegion.mBottom == 0.f
|
||||
&& mClipRegion.mTop == 1.f;
|
||||
}
|
||||
|
||||
void LLUIImage::setScaleRegion(const LLRectf& region)
|
||||
{
|
||||
mScaleRegion = region;
|
||||
mUniformScaling = mScaleRegion.mLeft == 0.f
|
||||
&& mScaleRegion.mRight == 1.f
|
||||
&& mScaleRegion.mBottom == 0.f
|
||||
&& mScaleRegion.mTop == 1.f;
|
||||
}
|
||||
|
||||
//TODO: move drawing implementation inside class
|
||||
void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const
|
||||
{
|
||||
gl_draw_image(x, y, mImage, color, mClipRegion);
|
||||
}
|
||||
|
||||
void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
|
||||
{
|
||||
if (mUniformScaling)
|
||||
{
|
||||
gl_draw_scaled_image(x, y, width, height, mImage, color, mClipRegion);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_draw_scaled_image_with_border(
|
||||
x, y,
|
||||
width, height,
|
||||
mImage,
|
||||
color,
|
||||
FALSE,
|
||||
mClipRegion,
|
||||
mScaleRegion);
|
||||
}
|
||||
}
|
||||
|
||||
void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
|
||||
{
|
||||
gl_draw_scaled_image_with_border(
|
||||
x, y,
|
||||
width, height,
|
||||
mImage,
|
||||
color,
|
||||
TRUE,
|
||||
mClipRegion,
|
||||
mScaleRegion);
|
||||
}
|
||||
|
||||
void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const
|
||||
{
|
||||
LLRect border_rect;
|
||||
border_rect.setOriginAndSize(x, y, width, height);
|
||||
border_rect.stretch(border_width, border_width);
|
||||
drawSolid(border_rect, color);
|
||||
}
|
||||
|
||||
S32 LLUIImage::getWidth() const
|
||||
{
|
||||
// return clipped dimensions of actual image area
|
||||
return llround((F32)mImage->getWidth(0) * mClipRegion.getWidth());
|
||||
}
|
||||
|
||||
S32 LLUIImage::getHeight() const
|
||||
{
|
||||
// return clipped dimensions of actual image area
|
||||
return llround((F32)mImage->getHeight(0) * mClipRegion.getHeight());
|
||||
}
|
||||
|
||||
S32 LLUIImage::getTextureWidth() const
|
||||
{
|
||||
return mImage->getWidth(0);
|
||||
}
|
||||
|
||||
S32 LLUIImage::getTextureHeight() const
|
||||
{
|
||||
return mImage->getHeight(0);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
#ifndef LL_LLUI_H
|
||||
#define LL_LLUI_H
|
||||
|
||||
#include "llpointer.h" // LLPointer<>
|
||||
#include "llrect.h"
|
||||
#include "llcontrol.h"
|
||||
#include "llrect.h"
|
||||
#include "llcoord.h"
|
||||
#include "llglslshader.h"
|
||||
//#include "llhtmlhelp.h"
|
||||
@@ -53,10 +53,10 @@ class LLColor4;
|
||||
class LLHtmlHelp;
|
||||
class LLVector3;
|
||||
class LLVector2;
|
||||
class LLUIImage;
|
||||
class LLUUID;
|
||||
class LLWindow;
|
||||
class LLView;
|
||||
class LLUIImage;
|
||||
|
||||
// UI colors
|
||||
extern const LLColor4 UI_VERTEX_COLOR;
|
||||
@@ -78,7 +78,7 @@ void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, const LL
|
||||
void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, S32 pixel_offset = 0, BOOL filled = TRUE );
|
||||
void gl_rect_2d(const LLRect& rect, BOOL filled = TRUE );
|
||||
void gl_rect_2d(const LLRect& rect, const LLColor4& color, BOOL filled = TRUE );
|
||||
void gl_rect_2d_checkerboard(const LLRect& rect);
|
||||
void gl_rect_2d_checkerboard(const LLRect& rect, GLfloat alpha = 1.0f);
|
||||
|
||||
void gl_drop_shadow(S32 left, S32 top, S32 right, S32 bottom, const LLColor4 &start_color, S32 lines);
|
||||
|
||||
@@ -97,10 +97,7 @@ void gl_draw_rotated_image(S32 x, S32 y, F32 degrees, LLTexture* image, const LL
|
||||
void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degrees,LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f));
|
||||
void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border_height, S32 width, S32 height, LLTexture* image, const LLColor4 &color, BOOL solid_color = FALSE, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f));
|
||||
void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4 &color, BOOL solid_color = FALSE, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f), const LLRectf& scale_rect = LLRectf(0.f, 1.f, 1.f, 0.f));
|
||||
// Flip vertical, used for LLFloaterHTML
|
||||
void gl_draw_scaled_image_inverted(S32 x, S32 y, S32 width, S32 height, LLTexture* image, const LLColor4& color = UI_VERTEX_COLOR, const LLRectf& uv_rect = LLRectf(0.f, 1.f, 1.f, 0.f));
|
||||
|
||||
void gl_rect_2d_xor(S32 left, S32 top, S32 right, S32 bottom);
|
||||
void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LLColor4& color, F32 phase = 0.f );
|
||||
|
||||
void gl_rect_2d_simple_tex( S32 width, S32 height );
|
||||
@@ -177,9 +174,10 @@ public:
|
||||
|
||||
//helper functions (should probably move free standing rendering helper functions here)
|
||||
static std::string locateSkin(const std::string& filename);
|
||||
static void setCursorPositionScreen(S32 x, S32 y);
|
||||
static void setCursorPositionLocal(const LLView* viewp, S32 x, S32 y);
|
||||
static void getCursorPositionLocal(const LLView* viewp, S32 *x, S32 *y);
|
||||
static void setMousePositionScreen(S32 x, S32 y);
|
||||
static void getMousePositionScreen(S32 *x, S32 *y);
|
||||
static void setMousePositionLocal(const LLView* viewp, S32 x, S32 y);
|
||||
static void getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y);
|
||||
static void setScaleFactor(const LLVector2& scale_factor);
|
||||
static void setLineWidth(F32 width);
|
||||
static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0);
|
||||
@@ -414,192 +412,16 @@ public:
|
||||
LLLocalClipRect(const LLRect& rect, BOOL enabled = TRUE);
|
||||
};
|
||||
|
||||
class LLUIImage : public LLRefCount
|
||||
{
|
||||
public:
|
||||
LLUIImage(const std::string& name, LLPointer<LLTexture> image);
|
||||
|
||||
void setClipRegion(const LLRectf& region);
|
||||
void setScaleRegion(const LLRectf& region);
|
||||
|
||||
LLPointer<LLTexture> getImage() { return mImage; }
|
||||
const LLPointer<LLTexture>& getImage() const { return mImage; }
|
||||
|
||||
void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const;
|
||||
void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const;
|
||||
void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
|
||||
|
||||
void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const;
|
||||
void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
|
||||
void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, mImage->getWidth(0), mImage->getHeight(0), color); }
|
||||
|
||||
void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const;
|
||||
void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); }
|
||||
void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, mImage->getWidth(0), mImage->getHeight(0), color, border_width); }
|
||||
|
||||
const std::string& getName() const { return mName; }
|
||||
|
||||
S32 getWidth() const;
|
||||
S32 getHeight() const;
|
||||
|
||||
// returns dimensions of underlying textures, which might not be equal to ui image portion
|
||||
S32 getTextureWidth() const;
|
||||
S32 getTextureHeight() const;
|
||||
|
||||
protected:
|
||||
std::string mName;
|
||||
LLRectf mScaleRegion;
|
||||
LLRectf mClipRegion;
|
||||
LLPointer<LLTexture> mImage;
|
||||
BOOL mUniformScaling;
|
||||
BOOL mNoClip;
|
||||
};
|
||||
|
||||
typedef LLPointer<LLUIImage> LLUIImagePtr;
|
||||
|
||||
template <typename T>
|
||||
class LLTombStone : public LLRefCount
|
||||
{
|
||||
public:
|
||||
LLTombStone(T* target = NULL) : mTarget(target) {}
|
||||
|
||||
void setTarget(T* target) { mTarget = target; }
|
||||
T* getTarget() const { return mTarget; }
|
||||
private:
|
||||
T* mTarget;
|
||||
};
|
||||
|
||||
// LLHandles are used to refer to objects whose lifetime you do not control or influence.
|
||||
// Calling get() on a handle will return a pointer to the referenced object or NULL,
|
||||
// if the object no longer exists. Note that during the lifetime of the returned pointer,
|
||||
// you are assuming that the object will not be deleted by any action you perform,
|
||||
// or any other thread, as normal when using pointers, so avoid using that pointer outside of
|
||||
// the local code block.
|
||||
//
|
||||
// https://wiki.lindenlab.com/mediawiki/index.php?title=LLHandle&oldid=79669
|
||||
|
||||
template <typename T>
|
||||
class LLHandle
|
||||
{
|
||||
public:
|
||||
LLHandle() : mTombStone(sDefaultTombStone) {}
|
||||
const LLHandle<T>& operator =(const LLHandle<T>& other)
|
||||
{
|
||||
mTombStone = other.mTombStone;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool isDead() const
|
||||
{
|
||||
return mTombStone->getTarget() == NULL;
|
||||
}
|
||||
|
||||
void markDead()
|
||||
{
|
||||
mTombStone = sDefaultTombStone;
|
||||
}
|
||||
|
||||
T* get() const
|
||||
{
|
||||
return mTombStone->getTarget();
|
||||
}
|
||||
|
||||
friend bool operator== (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
|
||||
{
|
||||
return lhs.mTombStone == rhs.mTombStone;
|
||||
}
|
||||
friend bool operator!= (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
friend bool operator< (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
|
||||
{
|
||||
return lhs.mTombStone < rhs.mTombStone;
|
||||
}
|
||||
friend bool operator> (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
|
||||
{
|
||||
return lhs.mTombStone > rhs.mTombStone;
|
||||
}
|
||||
protected:
|
||||
|
||||
protected:
|
||||
LLPointer<LLTombStone<T> > mTombStone;
|
||||
|
||||
private:
|
||||
static LLPointer<LLTombStone<T> > sDefaultTombStone;
|
||||
};
|
||||
|
||||
// initialize static "empty" tombstone pointer
|
||||
template <typename T> LLPointer<LLTombStone<T> > LLHandle<T>::sDefaultTombStone = new LLTombStone<T>();
|
||||
|
||||
|
||||
template <typename T>
|
||||
class LLRootHandle : public LLHandle<T>
|
||||
{
|
||||
public:
|
||||
LLRootHandle(T* object) { bind(object); }
|
||||
LLRootHandle() {};
|
||||
~LLRootHandle() { unbind(); }
|
||||
|
||||
// this is redundant, since a LLRootHandle *is* an LLHandle
|
||||
LLHandle<T> getHandle() { return LLHandle<T>(*this); }
|
||||
|
||||
void bind(T* object)
|
||||
{
|
||||
// unbind existing tombstone
|
||||
if (LLHandle<T>::mTombStone.notNull())
|
||||
{
|
||||
if (LLHandle<T>::mTombStone->getTarget() == object) return;
|
||||
LLHandle<T>::mTombStone->setTarget(NULL);
|
||||
}
|
||||
// tombstone reference counted, so no paired delete
|
||||
LLHandle<T>::mTombStone = new LLTombStone<T>(object);
|
||||
}
|
||||
|
||||
void unbind()
|
||||
{
|
||||
LLHandle<T>::mTombStone->setTarget(NULL);
|
||||
}
|
||||
|
||||
//don't allow copying of root handles, since there should only be one
|
||||
private:
|
||||
LLRootHandle(const LLRootHandle& other) {};
|
||||
};
|
||||
|
||||
// Use this as a mixin for simple classes that need handles and when you don't
|
||||
// want handles at multiple points of the inheritance hierarchy
|
||||
template <typename T>
|
||||
class LLHandleProvider
|
||||
{
|
||||
protected:
|
||||
typedef LLHandle<T> handle_type_t;
|
||||
LLHandleProvider()
|
||||
{
|
||||
// provided here to enforce T deriving from LLHandleProvider<T>
|
||||
}
|
||||
|
||||
LLHandle<T> getHandle()
|
||||
{
|
||||
// perform lazy binding to avoid small tombstone allocations for handle
|
||||
// providers whose handles are never referenced
|
||||
mHandle.bind(static_cast<T*>(this));
|
||||
return mHandle;
|
||||
}
|
||||
|
||||
private:
|
||||
LLRootHandle<T> mHandle;
|
||||
};
|
||||
|
||||
|
||||
//RN: maybe this needs to moved elsewhere?
|
||||
class LLImageProviderInterface
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
LLImageProviderInterface() {};
|
||||
virtual ~LLImageProviderInterface() {};
|
||||
|
||||
virtual LLUIImagePtr getUIImage(const std::string& name, S32 priority) = 0;
|
||||
virtual LLUIImagePtr getUIImageByID(const LLUUID& id, S32 priority) = 0;
|
||||
public:
|
||||
virtual LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority) = 0;
|
||||
virtual LLPointer<LLUIImage> getUIImageByID(const LLUUID& id, S32 priority) = 0;
|
||||
virtual void cleanUp() = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
#include "lltextbox.h"
|
||||
#include "lltexteditor.h"
|
||||
#include "llui.h"
|
||||
#include "lluiimage.h"
|
||||
#include "llviewborder.h"
|
||||
|
||||
const char XML_HEADER[] = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n";
|
||||
|
||||
154
indra/llui/lluiimage.cpp
Normal file
154
indra/llui/lluiimage.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* @file lluiimage.cpp
|
||||
* @brief UI implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
// Utilities functions the user interface needs
|
||||
|
||||
//#include "llviewerprecompiledheaders.h"
|
||||
#include "linden_common.h"
|
||||
|
||||
// Project includes
|
||||
#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),
|
||||
mImageLoaded(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
LLUIImage::~LLUIImage()
|
||||
{
|
||||
delete mImageLoaded;
|
||||
}
|
||||
|
||||
void LLUIImage::setClipRegion(const LLRectf& region)
|
||||
{
|
||||
mClipRegion = region;
|
||||
mNoClip = mClipRegion.mLeft == 0.f
|
||||
&& mClipRegion.mRight == 1.f
|
||||
&& mClipRegion.mBottom == 0.f
|
||||
&& mClipRegion.mTop == 1.f;
|
||||
}
|
||||
|
||||
void LLUIImage::setScaleRegion(const LLRectf& region)
|
||||
{
|
||||
mScaleRegion = region;
|
||||
mUniformScaling = mScaleRegion.mLeft == 0.f
|
||||
&& mScaleRegion.mRight == 1.f
|
||||
&& mScaleRegion.mBottom == 0.f
|
||||
&& mScaleRegion.mTop == 1.f;
|
||||
}
|
||||
|
||||
//TODO: move drawing implementation inside class
|
||||
void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const
|
||||
{
|
||||
gl_draw_scaled_image(x, y, getWidth(), getHeight(), mImage, color, mClipRegion);
|
||||
}
|
||||
|
||||
void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
|
||||
{
|
||||
if (mUniformScaling)
|
||||
{
|
||||
gl_draw_scaled_image(x, y, width, height, mImage, color, mClipRegion);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_draw_scaled_image_with_border(
|
||||
x, y,
|
||||
width, height,
|
||||
mImage,
|
||||
color,
|
||||
FALSE,
|
||||
mClipRegion,
|
||||
mScaleRegion);
|
||||
}
|
||||
}
|
||||
|
||||
void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
|
||||
{
|
||||
gl_draw_scaled_image_with_border(
|
||||
x, y,
|
||||
width, height,
|
||||
mImage,
|
||||
color,
|
||||
TRUE,
|
||||
mClipRegion,
|
||||
mScaleRegion);
|
||||
}
|
||||
|
||||
void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const
|
||||
{
|
||||
LLRect border_rect;
|
||||
border_rect.setOriginAndSize(x, y, width, height);
|
||||
border_rect.stretch(border_width, border_width);
|
||||
drawSolid(border_rect, color);
|
||||
}
|
||||
|
||||
S32 LLUIImage::getWidth() const
|
||||
{
|
||||
// return clipped dimensions of actual image area
|
||||
return llround((F32)mImage->getWidth(0) * mClipRegion.getWidth());
|
||||
}
|
||||
|
||||
S32 LLUIImage::getHeight() const
|
||||
{
|
||||
// return clipped dimensions of actual image area
|
||||
return llround((F32)mImage->getHeight(0) * mClipRegion.getHeight());
|
||||
}
|
||||
|
||||
S32 LLUIImage::getTextureWidth() const
|
||||
{
|
||||
return mImage->getWidth(0);
|
||||
}
|
||||
|
||||
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)();
|
||||
}
|
||||
}
|
||||
|
||||
93
indra/llui/lluiimage.h
Normal file
93
indra/llui/lluiimage.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @file lluiimage.h
|
||||
* @brief wrapper for images used in the UI that handles smart scaling, etc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLUIIMAGE_H
|
||||
#define LL_LLUIIMAGE_H
|
||||
|
||||
#include "v4color.h"
|
||||
#include "llpointer.h"
|
||||
#include "llrefcount.h"
|
||||
#include "llrefcount.h"
|
||||
#include "llrect.h"
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/signals2.hpp>
|
||||
#include "lltexture.h"
|
||||
|
||||
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();
|
||||
|
||||
void setClipRegion(const LLRectf& region);
|
||||
void setScaleRegion(const LLRectf& region);
|
||||
|
||||
LLPointer<LLTexture> getImage() { return mImage; }
|
||||
const LLPointer<LLTexture>& getImage() const { return mImage; }
|
||||
|
||||
void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const;
|
||||
void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const;
|
||||
void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
|
||||
|
||||
void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const;
|
||||
void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
|
||||
void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, getWidth(), getHeight(), color); }
|
||||
|
||||
void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const;
|
||||
void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); }
|
||||
void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, getWidth(), getHeight(), color, border_width); }
|
||||
|
||||
const std::string& getName() const { return mName; }
|
||||
|
||||
virtual S32 getWidth() const;
|
||||
virtual S32 getHeight() const;
|
||||
|
||||
// returns dimensions of underlying textures, which might not be equal to ui image portion
|
||||
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;
|
||||
LLPointer<LLTexture> mImage;
|
||||
BOOL mUniformScaling;
|
||||
BOOL mNoClip;
|
||||
};
|
||||
|
||||
|
||||
typedef LLPointer<LLUIImage> LLUIImagePtr;
|
||||
#endif
|
||||
@@ -36,7 +36,9 @@
|
||||
#include "llview.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "llrender.h"
|
||||
#include "llevent.h"
|
||||
@@ -239,8 +241,9 @@ BOOL LLView::getUseBoundingRect()
|
||||
// virtual
|
||||
const std::string& LLView::getName() const
|
||||
{
|
||||
static const std::string unnamed("(no name)");
|
||||
return mName.empty() ? unnamed : mName;
|
||||
static std::string no_name("(no name)");
|
||||
|
||||
return mName.empty() ? no_name : mName;
|
||||
}
|
||||
|
||||
void LLView::sendChildToFront(LLView* child)
|
||||
@@ -392,13 +395,11 @@ void LLView::removeCtrl(LLUICtrl* ctrl)
|
||||
LLView::ctrl_list_t LLView::getCtrlList() const
|
||||
{
|
||||
ctrl_list_t controls;
|
||||
for(child_list_const_iter_t iter = mChildList.begin();
|
||||
iter != mChildList.end();
|
||||
iter++)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
if((*iter)->isCtrl())
|
||||
if(viewp->isCtrl())
|
||||
{
|
||||
controls.push_back(static_cast<LLUICtrl*>(*iter));
|
||||
controls.push_back(static_cast<LLUICtrl*>(viewp));
|
||||
}
|
||||
}
|
||||
return controls;
|
||||
@@ -621,9 +622,8 @@ void LLView::deleteAllChildren()
|
||||
|
||||
void LLView::setAllChildrenEnabled(BOOL b)
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
viewp->setEnabled(b);
|
||||
}
|
||||
}
|
||||
@@ -653,9 +653,8 @@ void LLView::setVisible(BOOL visible)
|
||||
// virtual
|
||||
void LLView::handleVisibilityChange ( BOOL new_visibility )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
// only views that are themselves visible will have their overall visibility affected by their ancestors
|
||||
if (viewp->getVisible())
|
||||
{
|
||||
@@ -731,9 +730,8 @@ BOOL LLView::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_s
|
||||
|
||||
std::string tool_tip;
|
||||
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->mRect.mLeft;
|
||||
S32 local_y = y - viewp->mRect.mBottom;
|
||||
// Allow tooltips for disabled views so we can explain to the user why
|
||||
@@ -896,9 +894,8 @@ LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask,
|
||||
if( getVisible() )
|
||||
// if( getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if( viewp->pointInView(local_x, local_y) &&
|
||||
@@ -1041,9 +1038,8 @@ LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks)
|
||||
LLView* handled_view = NULL;
|
||||
if (getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if (viewp->pointInView(local_x, local_y)
|
||||
@@ -1069,9 +1065,8 @@ LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask)
|
||||
LLView* handled_view = NULL;
|
||||
if (getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if(viewp->pointInView(local_x, local_y) &&
|
||||
@@ -1099,9 +1094,8 @@ LLView* LLView::childrenHandleKey(KEY key, MASK mask)
|
||||
|
||||
if ( getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
if (viewp->handleKey(key, mask, TRUE))
|
||||
{
|
||||
if (LLView::sDebugKeys)
|
||||
@@ -1124,9 +1118,8 @@ LLView* LLView::childrenHandleUnicodeChar(llwchar uni_char)
|
||||
|
||||
if ( getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
if (viewp->handleUnicodeChar(uni_char, TRUE))
|
||||
{
|
||||
if (LLView::sDebugKeys)
|
||||
@@ -1146,9 +1139,8 @@ LLView* LLView::childrenHandleMouseDown(S32 x, S32 y, MASK mask)
|
||||
{
|
||||
LLView* handled_view = NULL;
|
||||
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
|
||||
@@ -1174,9 +1166,8 @@ LLView* LLView::childrenHandleRightMouseDown(S32 x, S32 y, MASK mask)
|
||||
|
||||
if (getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if (viewp->pointInView(local_x, local_y) &&
|
||||
@@ -1202,9 +1193,8 @@ LLView* LLView::childrenHandleMiddleMouseDown(S32 x, S32 y, MASK mask)
|
||||
|
||||
if (getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if (viewp->pointInView(local_x, local_y) &&
|
||||
@@ -1230,9 +1220,8 @@ LLView* LLView::childrenHandleDoubleClick(S32 x, S32 y, MASK mask)
|
||||
|
||||
if (getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if (viewp->pointInView(local_x, local_y) &&
|
||||
@@ -1257,9 +1246,8 @@ LLView* LLView::childrenHandleMouseUp(S32 x, S32 y, MASK mask)
|
||||
LLView* handled_view = NULL;
|
||||
if( getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if (!viewp->pointInView(local_x, local_y))
|
||||
@@ -1287,9 +1275,8 @@ LLView* LLView::childrenHandleRightMouseUp(S32 x, S32 y, MASK mask)
|
||||
LLView* handled_view = NULL;
|
||||
if( getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if (viewp->pointInView(local_x, local_y) &&
|
||||
@@ -1314,9 +1301,8 @@ LLView* LLView::childrenHandleMiddleMouseUp(S32 x, S32 y, MASK mask)
|
||||
LLView* handled_view = NULL;
|
||||
if( getVisible() && getEnabled() )
|
||||
{
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
S32 local_x = x - viewp->getRect().mLeft;
|
||||
S32 local_y = y - viewp->getRect().mBottom;
|
||||
if (viewp->pointInView(local_x, local_y) &&
|
||||
@@ -1449,7 +1435,7 @@ void LLView::drawDebugRect()
|
||||
std::string debug_text = llformat("%s (%d x %d)", getName().c_str(),
|
||||
debug_rect.getWidth(), debug_rect.getHeight());
|
||||
LLFontGL::getFontSansSerifSmall()->renderUTF8(debug_text, 0, (F32)x, (F32)y, border_color,
|
||||
LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL,
|
||||
LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
|
||||
S32_MAX, S32_MAX, NULL, FALSE);
|
||||
}
|
||||
}
|
||||
@@ -1492,9 +1478,8 @@ void LLView::reshape(S32 width, S32 height, BOOL called_from_parent)
|
||||
mRect.mTop = getRect().mBottom + height;
|
||||
|
||||
// move child views according to reshape flags
|
||||
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* viewp, mChildList)
|
||||
{
|
||||
LLView* viewp = *child_it;
|
||||
LLRect child_rect( viewp->mRect );
|
||||
|
||||
if (viewp->followsRight() && viewp->followsLeft())
|
||||
@@ -1561,11 +1546,9 @@ void LLView::updateBoundingRect()
|
||||
{
|
||||
LLRect local_bounding_rect = LLRect::null;
|
||||
|
||||
child_list_const_iter_t child_it;
|
||||
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
{
|
||||
LLView* childp = *child_it;
|
||||
// ignore invisible and "top" children when calculating bounding rect
|
||||
BOOST_FOREACH(LLView* childp, mChildList)
|
||||
{
|
||||
// ignore invisible and "top" children when calculating bounding rect
|
||||
// such as combobox popups
|
||||
if (!childp->getVisible() || childp == gFocusMgr.getTopCtrl())
|
||||
{
|
||||
@@ -1686,11 +1669,10 @@ LLView* LLView::getChildView(const std::string& name, BOOL recurse, BOOL create_
|
||||
//richard: should we allow empty names?
|
||||
//if(name.empty())
|
||||
// return NULL;
|
||||
child_list_const_iter_t child_it;
|
||||
// Look for direct children *first*
|
||||
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* childp, mChildList)
|
||||
{
|
||||
LLView* childp = *child_it;
|
||||
llassert(childp);
|
||||
if (childp->getName() == name)
|
||||
{
|
||||
return childp;
|
||||
@@ -1699,9 +1681,9 @@ LLView* LLView::getChildView(const std::string& name, BOOL recurse, BOOL create_
|
||||
if (recurse)
|
||||
{
|
||||
// Look inside each child as well.
|
||||
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
|
||||
BOOST_FOREACH(LLView* childp, mChildList)
|
||||
{
|
||||
LLView* childp = *child_it;
|
||||
llassert(childp);
|
||||
LLView* viewp = childp->getChildView(name, recurse, FALSE);
|
||||
if ( viewp )
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "llcoord.h"
|
||||
#include "llfontgl.h"
|
||||
#include "llhandle.h"
|
||||
#include "llmortician.h"
|
||||
#include "llmousehandler.h"
|
||||
#include "llnametable.h"
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "llviewborder.h"
|
||||
#include "llrender.h"
|
||||
#include "llfocusmgr.h"
|
||||
#include "lluiimage.h"
|
||||
|
||||
static LLRegisterWidget<LLViewBorder> r("view_border");
|
||||
|
||||
@@ -96,18 +97,9 @@ void LLViewBorder::draw()
|
||||
llassert( FALSE ); // not implemented
|
||||
}
|
||||
}
|
||||
else
|
||||
if( STYLE_TEXTURE == mStyle )
|
||||
{
|
||||
if( mTexture )
|
||||
{
|
||||
drawTextures();
|
||||
}
|
||||
}
|
||||
|
||||
// draw the children
|
||||
LLView::draw();
|
||||
|
||||
}
|
||||
|
||||
void LLViewBorder::drawOnePixelLines()
|
||||
@@ -223,56 +215,6 @@ void LLViewBorder::drawTwoPixelLines()
|
||||
gl_line_2d(left+1, bottom+1, right-1, bottom+1);
|
||||
}
|
||||
|
||||
void LLViewBorder::drawTextures()
|
||||
{
|
||||
//LLGLSUIDefault gls_ui;
|
||||
|
||||
//llassert( FALSE ); // TODO: finish implementing
|
||||
|
||||
//gGL.color4fv(UI_VERTEX_COLOR.mV);
|
||||
|
||||
//gGL.getTexUnit(0)->bind(mTexture);
|
||||
//gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP);
|
||||
|
||||
//drawTextureTrapezoid( 0.f, mBorderWidth, getRect().getWidth(), 0, 0 );
|
||||
//drawTextureTrapezoid( 90.f, mBorderWidth, getRect().getHeight(), (F32)getRect().getWidth(),0 );
|
||||
//drawTextureTrapezoid( 180.f, mBorderWidth, getRect().getWidth(), (F32)getRect().getWidth(),(F32)getRect().getHeight() );
|
||||
//drawTextureTrapezoid( 270.f, mBorderWidth, getRect().getHeight(), 0, (F32)getRect().getHeight() );
|
||||
}
|
||||
|
||||
|
||||
void LLViewBorder::drawTextureTrapezoid( F32 degrees, S32 width, S32 length, F32 start_x, F32 start_y )
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
gGL.translatef(start_x, start_y, 0.f);
|
||||
gGL.rotatef( degrees, 0, 0, 1 );
|
||||
|
||||
gGL.begin(LLRender::QUADS);
|
||||
{
|
||||
// width, width /---------\ length-width, width //
|
||||
// / \ //
|
||||
// / \ //
|
||||
// /---------------\ //
|
||||
// 0,0 length, 0 //
|
||||
|
||||
gGL.texCoord2f( 0, 0 );
|
||||
gGL.vertex2i( 0, 0 );
|
||||
|
||||
gGL.texCoord2f( (GLfloat)length, 0 );
|
||||
gGL.vertex2i( length, 0 );
|
||||
|
||||
gGL.texCoord2f( (GLfloat)(length - width), (GLfloat)width );
|
||||
gGL.vertex2i( length - width, width );
|
||||
|
||||
gGL.texCoord2f( (GLfloat)width, (GLfloat)width );
|
||||
gGL.vertex2i( width, width );
|
||||
}
|
||||
gGL.end();
|
||||
}
|
||||
gGL.popMatrix();
|
||||
}
|
||||
|
||||
BOOL LLViewBorder::getBevelFromAttribute(LLXMLNodePtr node, LLViewBorder::EBevel& bevel_style)
|
||||
{
|
||||
if (node->hasAttribute("bevel_style"))
|
||||
|
||||
@@ -74,8 +74,6 @@ public:
|
||||
private:
|
||||
void drawOnePixelLines();
|
||||
void drawTwoPixelLines();
|
||||
void drawTextures();
|
||||
void drawTextureTrapezoid( F32 degrees, S32 width, S32 length, F32 start_x, F32 start_y );
|
||||
|
||||
EBevel mBevel;
|
||||
const EStyle mStyle;
|
||||
@@ -85,7 +83,7 @@ private:
|
||||
LLColor4 mShadowDark;
|
||||
LLColor4 mBackgroundColor;
|
||||
S32 mBorderWidth;
|
||||
LLUIImagePtr mTexture;
|
||||
LLPointer<LLUIImage> mTexture;
|
||||
BOOL mHasKeyboardFocus;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user