Finished LLGLTexture. Migrated opengl related code from llui.h/cpp to llrender2dutils.h/cpp. Moved lluiimage to llrender library.
This commit is contained in:
@@ -72,7 +72,6 @@ set(llui_SOURCE_FILES
|
||||
lluicolor.cpp
|
||||
lluictrl.cpp
|
||||
lluictrlfactory.cpp
|
||||
lluiimage.cpp
|
||||
lluistring.cpp
|
||||
llundo.cpp
|
||||
llviewborder.cpp
|
||||
@@ -139,7 +138,6 @@ set(llui_HEADER_FILES
|
||||
lluifwd.h
|
||||
llui.h
|
||||
lluicolor.h
|
||||
lluiimage.h
|
||||
lluistring.h
|
||||
lluixmltags.h
|
||||
llundo.h
|
||||
|
||||
@@ -603,7 +603,7 @@ void LLComboBox::showList()
|
||||
LLCoordWindow window_size;
|
||||
getWindow()->getSize(&window_size);
|
||||
//HACK: shouldn't have to know about scale here
|
||||
mList->fitContents( 192, llfloor((F32)window_size.mY / LLUI::sGLScaleFactor.mV[VY]) - 50 );
|
||||
mList->fitContents( 192, llfloor((F32)window_size.mY / LLUI::getScaleFactor().mV[VY]) - 50 );
|
||||
|
||||
// Make sure that we can see the whole list
|
||||
LLRect root_view_local;
|
||||
|
||||
@@ -1973,8 +1973,8 @@ void LLLineEditor::draw()
|
||||
LLRect screen_pos = calcScreenRect();
|
||||
LLCoordGL ime_pos( screen_pos.mLeft + pixels_after_scroll, screen_pos.mTop - UI_LINEEDITOR_V_PAD );
|
||||
|
||||
ime_pos.mX = (S32) (ime_pos.mX * LLUI::sGLScaleFactor.mV[VX]);
|
||||
ime_pos.mY = (S32) (ime_pos.mY * LLUI::sGLScaleFactor.mV[VY]);
|
||||
ime_pos.mX = (S32) (ime_pos.mX * LLUI::getScaleFactor().mV[VX]);
|
||||
ime_pos.mY = (S32) (ime_pos.mY * LLUI::getScaleFactor().mV[VY]);
|
||||
getWindow()->setLanguageTextInput( ime_pos );
|
||||
}
|
||||
}
|
||||
@@ -2959,7 +2959,7 @@ void LLLineEditor::markAsPreedit(S32 position, S32 length)
|
||||
|
||||
S32 LLLineEditor::getPreeditFontSize() const
|
||||
{
|
||||
return llround(mGLFont->getLineHeight() * LLUI::sGLScaleFactor.mV[VY]);
|
||||
return llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]);
|
||||
}
|
||||
|
||||
void LLLineEditor::setReplaceNewlinesWithSpaces(BOOL replace)
|
||||
|
||||
@@ -88,10 +88,10 @@ void LLScreenClipRect::updateScissorRegion()
|
||||
LLRect rect = sClipRectStack.top();
|
||||
stop_glerror();
|
||||
S32 x,y,w,h;
|
||||
x = llfloor(rect.mLeft * LLUI::sGLScaleFactor.mV[VX]);
|
||||
y = llfloor(rect.mBottom * LLUI::sGLScaleFactor.mV[VY]);
|
||||
w = llmax(0, llceil(rect.getWidth() * LLUI::sGLScaleFactor.mV[VX])) + 1;
|
||||
h = llmax(0, llceil(rect.getHeight() * LLUI::sGLScaleFactor.mV[VY])) + 1;
|
||||
x = llfloor(rect.mLeft * LLUI::getScaleFactor().mV[VX]);
|
||||
y = llfloor(rect.mBottom * LLUI::getScaleFactor().mV[VY]);
|
||||
w = llmax(0, llceil(rect.getWidth() * LLUI::getScaleFactor().mV[VX])) + 1;
|
||||
h = llmax(0, llceil(rect.getHeight() * LLUI::getScaleFactor().mV[VY])) + 1;
|
||||
glScissor( x,y,w,h );
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#define LLLOCALCLIPRECT_H
|
||||
|
||||
#include "llgl.h"
|
||||
#include "lllocalcliprect.h"
|
||||
#include "llrect.h" // can't forward declare, it's templated
|
||||
#include <stack>
|
||||
|
||||
|
||||
@@ -3244,8 +3244,8 @@ void LLTextEditor::drawCursor()
|
||||
LLRect screen_pos = calcScreenRect();
|
||||
LLCoordGL ime_pos( screen_pos.mLeft + llfloor(cursor_left), screen_pos.mBottom + llfloor(cursor_top) );
|
||||
|
||||
ime_pos.mX = (S32) (ime_pos.mX * LLUI::sGLScaleFactor.mV[VX]);
|
||||
ime_pos.mY = (S32) (ime_pos.mY * LLUI::sGLScaleFactor.mV[VY]);
|
||||
ime_pos.mX = (S32) (ime_pos.mX * LLUI::getScaleFactor().mV[VX]);
|
||||
ime_pos.mY = (S32) (ime_pos.mY * LLUI::getScaleFactor().mV[VY]);
|
||||
getWindow()->setLanguageTextInput( ime_pos );
|
||||
}
|
||||
}
|
||||
@@ -5224,5 +5224,5 @@ void LLTextEditor::markAsPreedit(S32 position, S32 length)
|
||||
|
||||
S32 LLTextEditor::getPreeditFontSize() const
|
||||
{
|
||||
return llround(mGLFont->getLineHeight() * LLUI::sGLScaleFactor.mV[VY]);
|
||||
return llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]);
|
||||
}
|
||||
|
||||
1620
indra/llui/llui.cpp
1620
indra/llui/llui.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,145 +1,52 @@
|
||||
/**
|
||||
* @file llui.h
|
||||
* @brief GL function declarations and other general static UI services.
|
||||
* @brief General static UI services.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* 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.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* 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.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* 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$
|
||||
*/
|
||||
|
||||
// All immediate-mode gl drawing should happen here.
|
||||
|
||||
#ifndef LL_LLUI_H
|
||||
#define LL_LLUI_H
|
||||
|
||||
#include "llpointer.h" // LLPointer<>
|
||||
#include "llrect.h"
|
||||
#include "llcontrol.h"
|
||||
#include "llcoord.h"
|
||||
#include "llglslshader.h"
|
||||
//#include "llhtmlhelp.h"
|
||||
#include "llgl.h" // *TODO: break this dependency
|
||||
#include <stack>
|
||||
#include "lltexture.h"
|
||||
#include "v2math.h"
|
||||
#include "llrender2dutils.h"
|
||||
#include "llpointer.h"
|
||||
#include "lluiimage.h"
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
// LLUIFactory
|
||||
#include "llsd.h"
|
||||
|
||||
class LLColor4;
|
||||
class LLHtmlHelp;
|
||||
class LLVector3;
|
||||
class LLVector2;
|
||||
class LLUIImage;
|
||||
class LLUUID;
|
||||
class LLWindow;
|
||||
class LLView;
|
||||
|
||||
// UI colors
|
||||
extern const LLColor4 UI_VERTEX_COLOR;
|
||||
void make_ui_sound(const char* name);
|
||||
|
||||
BOOL ui_point_in_rect(S32 x, S32 y, S32 left, S32 top, S32 right, S32 bottom);
|
||||
void gl_state_for_2d(S32 width, S32 height);
|
||||
|
||||
void gl_line_2d(S32 x1, S32 y1, S32 x2, S32 y2);
|
||||
void gl_line_2d(S32 x1, S32 y1, S32 x2, S32 y2, const LLColor4 &color );
|
||||
void gl_triangle_2d(S32 x1, S32 y1, S32 x2, S32 y2, S32 x3, S32 y3, const LLColor4& color, BOOL filled);
|
||||
void gl_rect_2d_simple( S32 width, S32 height );
|
||||
|
||||
void gl_draw_x(const LLRect& rect, const LLColor4& color);
|
||||
|
||||
void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, BOOL filled = TRUE );
|
||||
void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, const LLColor4 &color, BOOL filled = TRUE );
|
||||
void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, const LLColor4 &color, S32 pixel_offset = 0, BOOL filled = TRUE );
|
||||
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& parent_screen_rect, 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);
|
||||
|
||||
void gl_circle_2d(F32 x, F32 y, F32 radius, S32 steps, BOOL filled);
|
||||
void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F32 start_angle, F32 end_angle);
|
||||
void gl_deep_circle( F32 radius, F32 depth );
|
||||
void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor4& side_color, S32 steps, BOOL render_center );
|
||||
void gl_corners_2d(S32 left, S32 top, S32 right, S32 bottom, S32 length, F32 max_frac);
|
||||
void gl_washer_2d(F32 outer_radius, F32 inner_radius, S32 steps, const LLColor4& inner_color, const LLColor4& outer_color);
|
||||
void gl_washer_segment_2d(F32 outer_radius, F32 inner_radius, F32 start_radians, F32 end_radians, S32 steps, const LLColor4& inner_color, const LLColor4& outer_color);
|
||||
void gl_washer_spokes_2d(F32 outer_radius, F32 inner_radius, S32 count, const LLColor4& inner_color, const LLColor4& outer_color);
|
||||
|
||||
void gl_draw_image(S32 x, S32 y, 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(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_draw_rotated_image(S32 x, S32 y, 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_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));
|
||||
|
||||
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 );
|
||||
|
||||
// segmented rectangles
|
||||
|
||||
/*
|
||||
TL |______TOP_________| TR
|
||||
/| |\
|
||||
_/_|__________________|_\_
|
||||
L| | MIDDLE | |R
|
||||
_|_|__________________|_|_
|
||||
\ | BOTTOM | /
|
||||
BL\|__________________|/ BR
|
||||
| |
|
||||
*/
|
||||
|
||||
typedef enum e_rounded_edge
|
||||
{
|
||||
ROUNDED_RECT_LEFT = 0x1,
|
||||
ROUNDED_RECT_TOP = 0x2,
|
||||
ROUNDED_RECT_RIGHT = 0x4,
|
||||
ROUNDED_RECT_BOTTOM = 0x8,
|
||||
ROUNDED_RECT_ALL = 0xf
|
||||
}ERoundedEdge;
|
||||
|
||||
|
||||
void gl_segmented_rect_2d_tex(const S32 left, const S32 top, const S32 right, const S32 bottom, const S32 texture_width, const S32 texture_height, const S32 border_size, const U32 edges = ROUNDED_RECT_ALL);
|
||||
void gl_segmented_rect_2d_fragment_tex(const S32 left, const S32 top, const S32 right, const S32 bottom, const S32 texture_width, const S32 texture_height, const S32 border_size, const F32 start_fragment, const F32 end_fragment, const U32 edges = ROUNDED_RECT_ALL);
|
||||
void gl_segmented_rect_3d_tex(const LLVector2& border_scale, const LLVector3& border_width, const LLVector3& border_height, const LLVector3& width_vec, const LLVector3& height_vec, U32 edges = ROUNDED_RECT_ALL);
|
||||
void gl_segmented_rect_3d_tex_top(const LLVector2& border_scale, const LLVector3& border_width, const LLVector3& border_height, const LLVector3& width_vec, const LLVector3& height_vec);
|
||||
|
||||
inline void gl_rect_2d( const LLRect& rect, BOOL filled )
|
||||
{
|
||||
gl_rect_2d( rect.mLeft, rect.mTop, rect.mRight, rect.mBottom, filled );
|
||||
}
|
||||
|
||||
inline void gl_rect_2d_offset_local( const LLRect& rect, S32 pixel_offset, BOOL filled)
|
||||
{
|
||||
gl_rect_2d_offset_local( rect.mLeft, rect.mTop, rect.mRight, rect.mBottom, pixel_offset, filled );
|
||||
}
|
||||
|
||||
// Used to hide the flashing text cursor when window doesn't have focus.
|
||||
extern BOOL gShowTextEditCursor;
|
||||
|
||||
@@ -163,10 +70,10 @@ public:
|
||||
const std::string& language = LLStringUtil::null);
|
||||
static void cleanupClass();
|
||||
|
||||
static void pushMatrix();
|
||||
static void popMatrix();
|
||||
static void loadIdentity();
|
||||
static void translate(F32 x, F32 y, F32 z = 0.0f);
|
||||
static void pushMatrix() { LLRender2D::pushMatrix(); }
|
||||
static void popMatrix() { LLRender2D::popMatrix(); }
|
||||
static void loadIdentity() { LLRender2D::loadIdentity(); }
|
||||
static void translate(F32 x, F32 y, F32 z = 0.0f) { LLRender2D::translate(x, y, z); }
|
||||
|
||||
// Return the ISO639 language name ("en", "ko", etc.) for the viewer UI.
|
||||
// http://www.loc.gov/standards/iso639-2/php/code_list.php
|
||||
@@ -178,10 +85,13 @@ public:
|
||||
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);
|
||||
static LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0);
|
||||
static LLVector2& getScaleFactor() { return LLRender2D::sGLScaleFactor; }
|
||||
static void setScaleFactor(const LLVector2& scale_factor) { LLRender2D::setScaleFactor(scale_factor); }
|
||||
static void setLineWidth(F32 width) { LLRender2D::setLineWidth(width); }
|
||||
static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0)
|
||||
{ return LLRender2D::getUIImageByID(image_id, priority); }
|
||||
static LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0)
|
||||
{ return LLRender2D::getUIImage(name, priority); }
|
||||
static LLVector2 getWindowSize();
|
||||
static void screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y);
|
||||
static void glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y);
|
||||
@@ -195,9 +105,7 @@ public:
|
||||
static LLControlGroup* sConfigGroup;
|
||||
static LLControlGroup* sIgnoresGroup;
|
||||
static LLControlGroup* sColorsGroup;
|
||||
static LLImageProviderInterface* sImageProvider;
|
||||
static LLUIAudioCallback sAudioCallback;
|
||||
static LLVector2 sGLScaleFactor;
|
||||
static LLWindow* sWindow;
|
||||
static BOOL sShowXUINames;
|
||||
static LLHtmlHelp* sHtmlHelp;
|
||||
@@ -388,18 +296,7 @@ private:
|
||||
|
||||
template <class T, class U> T* LLUISingleton<T,U>::sInstance = NULL;
|
||||
|
||||
|
||||
//RN: maybe this needs to moved elsewhere?
|
||||
class LLImageProviderInterface
|
||||
{
|
||||
protected:
|
||||
LLImageProviderInterface() {};
|
||||
virtual ~LLImageProviderInterface() {};
|
||||
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;
|
||||
};
|
||||
// Moved LLLocalClipRect to lllocalcliprect.h
|
||||
|
||||
class LLCallbackRegistry
|
||||
{
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
/**
|
||||
* @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)();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* @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
|
||||
Reference in New Issue
Block a user