LLUI V3 (very)partial merge

This commit is contained in:
Shyotl
2011-08-29 03:33:43 -05:00
parent aaa6417fb7
commit 09fa7edc8d
12 changed files with 136 additions and 130 deletions

View File

@@ -40,7 +40,7 @@
#include <boost/function.hpp> #include <boost/function.hpp>
#include "llsd.h" #include "llsd.h"
#include "llmemory.h" #include "llsingleton.h"
/** /**
* @class LLFunctorRegistry * @class LLFunctorRegistry

View File

@@ -77,11 +77,6 @@ S32 MENU_BAR_WIDTH = 0;
/// Local function declarations, constants, enums, and typedefs /// Local function declarations, constants, enums, and typedefs
///============================================================================ ///============================================================================
const std::string SEPARATOR_NAME("separator");
const std::string TEAROFF_SEPARATOR_LABEL( "~~~~~~~~~~~" );
const std::string SEPARATOR_LABEL( "-----------" );
const std::string VERTICAL_SEPARATOR_LABEL( "|" );
const S32 LABEL_BOTTOM_PAD_PIXELS = 2; const S32 LABEL_BOTTOM_PAD_PIXELS = 2;
const U32 LEFT_PAD_PIXELS = 3; const U32 LEFT_PAD_PIXELS = 3;
@@ -101,7 +96,12 @@ const U32 SEPARATOR_HEIGHT_PIXELS = 8;
const S32 TEAROFF_SEPARATOR_HEIGHT_PIXELS = 10; const S32 TEAROFF_SEPARATOR_HEIGHT_PIXELS = 10;
const S32 MENU_ITEM_PADDING = 4; const S32 MENU_ITEM_PADDING = 4;
const std::string BOOLEAN_TRUE_PREFIX( "\xe2\x9c\x93" ); // U+2714 -- MC const std::string SEPARATOR_NAME("separator");
const std::string SEPARATOR_LABEL( "-----------" );
const std::string VERTICAL_SEPARATOR_LABEL( "|" );
const std::string TEAROFF_SEPARATOR_LABEL( "~~~~~~~~~~~" );
const std::string BOOLEAN_TRUE_PREFIX( "\xE2\x9C\x94" ); // U+2714 HEAVY CHECK MARK
const std::string BRANCH_SUFFIX( "\xE2\x96\xB6" ); // U+25B6 BLACK RIGHT-POINTING TRIANGLE const std::string BRANCH_SUFFIX( "\xE2\x96\xB6" ); // U+25B6 BLACK RIGHT-POINTING TRIANGLE
const std::string ARROW_UP ("^^^^^^^"); const std::string ARROW_UP ("^^^^^^^");
const std::string ARROW_DOWN("vvvvvvv"); const std::string ARROW_DOWN("vvvvvvv");

View File

@@ -88,8 +88,9 @@ LLMultiSlider::LLMultiSlider(
mThumbCenterSelectedColor( LLUI::sColorsGroup->getColor( "MultiSliderThumbCenterSelectedColor" ) ), mThumbCenterSelectedColor( LLUI::sColorsGroup->getColor( "MultiSliderThumbCenterSelectedColor" ) ),
mDisabledThumbColor(LLUI::sColorsGroup->getColor( "MultiSliderDisabledThumbColor" ) ), mDisabledThumbColor(LLUI::sColorsGroup->getColor( "MultiSliderDisabledThumbColor" ) ),
mTriangleColor(LLUI::sColorsGroup->getColor( "MultiSliderTriangleColor" ) ), mTriangleColor(LLUI::sColorsGroup->getColor( "MultiSliderTriangleColor" ) ),
mMouseDownCallback( NULL ), mMouseDownSignal( NULL ),
mMouseUpCallback( NULL ) mMouseUpSignal( NULL ),
mThumbWidth(MULTI_THUMB_WIDTH)
{ {
mValue.emptyMap(); mValue.emptyMap();
mCurSlider = LLStringUtil::null; mCurSlider = LLStringUtil::null;
@@ -101,6 +102,13 @@ LLMultiSlider::LLMultiSlider(
setValue(getValue()); setValue(getValue());
} }
LLMultiSlider::~LLMultiSlider()
{
delete mMouseDownSignal;
delete mMouseUpSignal;
}
void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from_event) void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from_event)
{ {
// exit if not there // exit if not there
@@ -152,12 +160,12 @@ void LLMultiSlider::setSliderValue(const std::string& name, F32 value, BOOL from
F32 t = (newValue - mMinValue) / (mMaxValue - mMinValue); F32 t = (newValue - mMinValue) / (mMaxValue - mMinValue);
S32 left_edge = MULTI_THUMB_WIDTH/2; S32 left_edge = mThumbWidth/2;
S32 right_edge = getRect().getWidth() - (MULTI_THUMB_WIDTH/2); S32 right_edge = getRect().getWidth() - (mThumbWidth/2);
S32 x = left_edge + S32( t * (right_edge - left_edge) ); S32 x = left_edge + S32( t * (right_edge - left_edge) );
mThumbRects[name].mLeft = x - (MULTI_THUMB_WIDTH/2); mThumbRects[name].mLeft = x - (mThumbWidth/2);
mThumbRects[name].mRight = x + (MULTI_THUMB_WIDTH/2); mThumbRects[name].mRight = x + (mThumbWidth/2);
} }
void LLMultiSlider::setValue(const LLSD& value) void LLMultiSlider::setValue(const LLSD& value)
@@ -211,7 +219,7 @@ const std::string& LLMultiSlider::addSlider(F32 val)
} }
// add a new thumb rect // add a new thumb rect
mThumbRects[newName.str()] = LLRect( 0, getRect().getHeight(), MULTI_THUMB_WIDTH, 0 ); mThumbRects[newName.str()] = LLRect( 0, getRect().getHeight(), mThumbWidth, 0 );
// add the value and set the current slider to this one // add the value and set the current slider to this one
mValue.insert(newName.str(), initVal); mValue.insert(newName.str(), initVal);
@@ -223,6 +231,30 @@ const std::string& LLMultiSlider::addSlider(F32 val)
return mCurSlider; return mCurSlider;
} }
void LLMultiSlider::addSlider(F32 val, const std::string& name)
{
F32 initVal = val;
if(mValue.size() >= mMaxNumSliders) {
return;
}
bool foundOne = findUnusedValue(initVal);
if(!foundOne) {
return;
}
// add a new thumb rect
mThumbRects[name] = LLRect( 0, getRect().getHeight(), mThumbWidth, 0 );
// add the value and set the current slider to this one
mValue.insert(name, initVal);
mCurSlider = name;
// move the slider
setSliderValue(mCurSlider, initVal, TRUE);
}
bool LLMultiSlider::findUnusedValue(F32& initVal) bool LLMultiSlider::findUnusedValue(F32& initVal)
{ {
bool firstTry = true; bool firstTry = true;
@@ -302,8 +334,8 @@ BOOL LLMultiSlider::handleHover(S32 x, S32 y, MASK mask)
{ {
if( gFocusMgr.getMouseCapture() == this ) if( gFocusMgr.getMouseCapture() == this )
{ {
S32 left_edge = MULTI_THUMB_WIDTH/2; S32 left_edge = mThumbWidth/2;
S32 right_edge = getRect().getWidth() - (MULTI_THUMB_WIDTH/2); S32 right_edge = getRect().getWidth() - (mThumbWidth/2);
x += mMouseOffset; x += mMouseOffset;
x = llclamp( x, left_edge, right_edge ); x = llclamp( x, left_edge, right_edge );
@@ -331,10 +363,9 @@ BOOL LLMultiSlider::handleMouseUp(S32 x, S32 y, MASK mask)
{ {
gFocusMgr.setMouseCapture( NULL ); gFocusMgr.setMouseCapture( NULL );
if( mMouseUpCallback ) if (mMouseUpSignal)
{ (*mMouseUpSignal)( this, LLSD() );
mMouseUpCallback( this, mCallbackUserData );
}
handled = TRUE; handled = TRUE;
make_ui_sound("UISndClickRelease"); make_ui_sound("UISndClickRelease");
} }
@@ -353,10 +384,8 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask)
{ {
setFocus(TRUE); setFocus(TRUE);
} }
if( mMouseDownCallback ) if (mMouseDownSignal)
{ (*mMouseDownSignal)( this, LLSD() );
mMouseDownCallback( this, mCallbackUserData );
}
if (MASK_CONTROL & mask) // if CTRL is modifying if (MASK_CONTROL & mask) // if CTRL is modifying
{ {
@@ -379,7 +408,7 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask)
// Find the offset of the actual mouse location from the center of the thumb. // Find the offset of the actual mouse location from the center of the thumb.
if (mThumbRects[mCurSlider].pointInRect(x,y)) if (mThumbRects[mCurSlider].pointInRect(x,y))
{ {
mMouseOffset = (mThumbRects[mCurSlider].mLeft + MULTI_THUMB_WIDTH/2) - x; mMouseOffset = (mThumbRects[mCurSlider].mLeft + mThumbWidth/2) - x;
} }
else else
{ {
@@ -566,6 +595,18 @@ void LLMultiSlider::draw()
LLUICtrl::draw(); LLUICtrl::draw();
} }
boost::signals2::connection LLMultiSlider::setMouseDownCallback( const commit_signal_t::slot_type& cb )
{
if (!mMouseDownSignal) mMouseDownSignal = new commit_signal_t();
return mMouseDownSignal->connect(cb);
}
boost::signals2::connection LLMultiSlider::setMouseUpCallback( const commit_signal_t::slot_type& cb )
{
if (!mMouseUpSignal) mMouseUpSignal = new commit_signal_t();
return mMouseUpSignal->connect(cb);
}
// virtual // virtual
LLXMLNodePtr LLMultiSlider::getXML(bool save_children) const LLXMLNodePtr LLMultiSlider::getXML(bool save_children) const
{ {

View File

@@ -59,6 +59,7 @@ public:
virtual LLXMLNodePtr getXML(bool save_children = true) const; virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
virtual ~LLMultiSlider();
void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE); void setSliderValue(const std::string& name, F32 value, BOOL from_event = FALSE);
F32 getSliderValue(const std::string& name) const; F32 getSliderValue(const std::string& name) const;
@@ -80,15 +81,17 @@ public:
void setMinValue(F32 min_value) { mMinValue = min_value; } void setMinValue(F32 min_value) { mMinValue = min_value; }
void setMaxValue(F32 max_value) { mMaxValue = max_value; } void setMaxValue(F32 max_value) { mMaxValue = max_value; }
void setIncrement(F32 increment) { mIncrement = increment; } void setIncrement(F32 increment) { mIncrement = increment; }
void setMouseDownCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseDownCallback = cb; }
void setMouseUpCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseUpCallback = cb; } boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb );
bool findUnusedValue(F32& initVal); bool findUnusedValue(F32& initVal);
const std::string& addSlider(); const std::string& addSlider();
const std::string& addSlider(F32 val); const std::string& addSlider(F32 val);
void deleteSlider(const std::string& name); void addSlider(F32 val, const std::string& name);
void deleteCurSlider() { deleteSlider(mCurSlider); } void deleteSlider(const std::string& name);
void clear(); void deleteCurSlider() { deleteSlider(mCurSlider); }
void clear();
virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
@@ -112,6 +115,7 @@ protected:
S32 mMouseOffset; S32 mMouseOffset;
LLRect mDragStartThumbRect; LLRect mDragStartThumbRect;
S32 mThumbWidth;
std::map<std::string, LLRect> mThumbRects; std::map<std::string, LLRect> mThumbRects;
LLColor4 mTrackColor; LLColor4 mTrackColor;
@@ -121,8 +125,8 @@ protected:
LLColor4 mDisabledThumbColor; LLColor4 mDisabledThumbColor;
LLColor4 mTriangleColor; LLColor4 mTriangleColor;
void (*mMouseDownCallback)(LLUICtrl* ctrl, void* userdata); commit_signal_t* mMouseDownSignal;
void (*mMouseUpCallback)(LLUICtrl* ctrl, void* userdata); commit_signal_t* mMouseUpSignal;
}; };
#endif // LL_LLSLIDER_H #endif // LL_LLSLIDER_H

View File

@@ -78,9 +78,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const std::string& name, const LLRect& rect
mEditor( NULL ), mEditor( NULL ),
mTextBox( NULL ), mTextBox( NULL ),
mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ), mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ),
mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ), mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) )
mSliderMouseUpCallback( NULL ),
mSliderMouseDownCallback( NULL )
{ {
S32 top = getRect().getHeight(); S32 top = getRect().getHeight();
S32 bottom = 0; S32 bottom = 0;
@@ -421,37 +419,14 @@ void LLMultiSliderCtrl::setPrecision(S32 precision)
updateText(); updateText();
} }
void LLMultiSliderCtrl::setSliderMouseDownCallback( void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) ) boost::signals2::connection LLMultiSliderCtrl::setSliderMouseDownCallback( const commit_signal_t::slot_type& cb )
{ {
mSliderMouseDownCallback = slider_mousedown_callback; return mMultiSlider->setMouseDownCallback( cb );
mMultiSlider->setMouseDownCallback( LLMultiSliderCtrl::onSliderMouseDown );
} }
// static boost::signals2::connection LLMultiSliderCtrl::setSliderMouseUpCallback( const commit_signal_t::slot_type& cb )
void LLMultiSliderCtrl::onSliderMouseDown(LLUICtrl* caller, void* userdata)
{ {
LLMultiSliderCtrl* self = (LLMultiSliderCtrl*) userdata; return mMultiSlider->setMouseUpCallback( cb );
if( self->mSliderMouseDownCallback )
{
self->mSliderMouseDownCallback( self, self->mCallbackUserData );
}
}
void LLMultiSliderCtrl::setSliderMouseUpCallback( void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) )
{
mSliderMouseUpCallback = slider_mouseup_callback;
mMultiSlider->setMouseUpCallback( LLMultiSliderCtrl::onSliderMouseUp );
}
// static
void LLMultiSliderCtrl::onSliderMouseUp(LLUICtrl* caller, void* userdata)
{
LLMultiSliderCtrl* self = (LLMultiSliderCtrl*) userdata;
if( self->mSliderMouseUpCallback )
{
self->mSliderMouseUpCallback( self, self->mCallbackUserData );
}
} }
void LLMultiSliderCtrl::onTabInto() void LLMultiSliderCtrl::onTabInto()

View File

@@ -112,8 +112,8 @@ public:
void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; } void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; }
void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; } void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; }
void setSliderMouseDownCallback( void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) ); boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb );
void setSliderMouseUpCallback( void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) ); boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb );
virtual void onTabInto(); virtual void onTabInto();
@@ -124,10 +124,8 @@ public:
virtual std::string getControlName() const; virtual std::string getControlName() const;
static void onSliderCommit(LLUICtrl* caller, void* userdata); static void onSliderCommit(LLUICtrl* caller, void* userdata);
static void onSliderMouseDown(LLUICtrl* caller,void* userdata);
static void onSliderMouseUp(LLUICtrl* caller,void* userdata);
static void onEditorCommit(LLUICtrl* caller, void* userdata); static void onEditorCommit(LLUICtrl* ctrl, void* userdata);
static void onEditorGainFocus(LLFocusableElement* caller, void *userdata); static void onEditorGainFocus(LLFocusableElement* caller, void *userdata);
static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata); static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
@@ -151,9 +149,6 @@ private:
LLColor4 mTextEnabledColor; LLColor4 mTextEnabledColor;
LLColor4 mTextDisabledColor; LLColor4 mTextDisabledColor;
void (*mSliderMouseUpCallback)( LLUICtrl* ctrl, void* userdata );
void (*mSliderMouseDownCallback)( LLUICtrl* ctrl, void* userdata );
}; };
#endif // LL_MULTI_SLIDERCTRL_H #endif // LL_MULTI_SLIDERCTRL_H

View File

@@ -70,8 +70,8 @@ LLSlider::LLSlider(
mTrackColor( LLUI::sColorsGroup->getColor( "SliderTrackColor" ) ), mTrackColor( LLUI::sColorsGroup->getColor( "SliderTrackColor" ) ),
mThumbOutlineColor( LLUI::sColorsGroup->getColor( "SliderThumbOutlineColor" ) ), mThumbOutlineColor( LLUI::sColorsGroup->getColor( "SliderThumbOutlineColor" ) ),
mThumbCenterColor( LLUI::sColorsGroup->getColor( "SliderThumbCenterColor" ) ), mThumbCenterColor( LLUI::sColorsGroup->getColor( "SliderThumbCenterColor" ) ),
mMouseDownCallback( NULL ), mMouseDownSignal( NULL ),
mMouseUpCallback( NULL ) mMouseUpSignal( NULL )
{ {
mThumbImage = LLUI::getUIImage("icn_slide-thumb_dark.tga"); mThumbImage = LLUI::getUIImage("icn_slide-thumb_dark.tga");
mTrackImage = LLUI::getUIImage("icn_slide-groove_dark.tga"); mTrackImage = LLUI::getUIImage("icn_slide-groove_dark.tga");
@@ -87,6 +87,11 @@ LLSlider::LLSlider(
mDragStartThumbRect = mThumbRect; mDragStartThumbRect = mThumbRect;
} }
LLSlider::~LLSlider()
{
delete mMouseDownSignal;
delete mMouseUpSignal;
}
void LLSlider::setValue(F32 value, BOOL from_event) void LLSlider::setValue(F32 value, BOOL from_event)
{ {
@@ -109,10 +114,11 @@ void LLSlider::setValue(F32 value, BOOL from_event)
void LLSlider::updateThumbRect() void LLSlider::updateThumbRect()
{ {
const S32 DEFAULT_THUMB_SIZE = 16;
F32 t = (mValue - mMinValue) / (mMaxValue - mMinValue); F32 t = (mValue - mMinValue) / (mMaxValue - mMinValue);
S32 thumb_width = mThumbImage->getWidth(); S32 thumb_width = mThumbImage ? mThumbImage->getWidth() : DEFAULT_THUMB_SIZE;
S32 thumb_height = mThumbImage->getHeight(); S32 thumb_height = mThumbImage ? mThumbImage->getHeight() : DEFAULT_THUMB_SIZE;
S32 left_edge = (thumb_width / 2); S32 left_edge = (thumb_width / 2);
S32 right_edge = getRect().getWidth() - (thumb_width / 2); S32 right_edge = getRect().getWidth() - (thumb_width / 2);
@@ -169,10 +175,9 @@ BOOL LLSlider::handleMouseUp(S32 x, S32 y, MASK mask)
{ {
gFocusMgr.setMouseCapture( NULL ); gFocusMgr.setMouseCapture( NULL );
if( mMouseUpCallback ) if (mMouseUpSignal)
{ (*mMouseUpSignal)( this, getValueF32() );
mMouseUpCallback( this, mCallbackUserData );
}
handled = TRUE; handled = TRUE;
make_ui_sound("UISndClickRelease"); make_ui_sound("UISndClickRelease");
} }
@@ -191,10 +196,8 @@ BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask)
{ {
setFocus(TRUE); setFocus(TRUE);
} }
if( mMouseDownCallback ) if (mMouseDownSignal)
{ (*mMouseDownSignal)( this, getValueF32() );
mMouseDownCallback( this, mCallbackUserData );
}
if (MASK_CONTROL & mask) // if CTRL is modifying if (MASK_CONTROL & mask) // if CTRL is modifying
{ {
@@ -309,6 +312,17 @@ LLXMLNodePtr LLSlider::getXML(bool save_children) const
return node; return node;
} }
boost::signals2::connection LLSlider::setMouseDownCallback( const commit_signal_t::slot_type& cb )
{
if (!mMouseDownSignal) mMouseDownSignal = new commit_signal_t();
return mMouseDownSignal->connect(cb);
}
boost::signals2::connection LLSlider::setMouseUpCallback( const commit_signal_t::slot_type& cb )
{
if (!mMouseUpSignal) mMouseUpSignal = new commit_signal_t();
return mMouseUpSignal->connect(cb);
}
//static //static
LLView* LLSlider::fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory) LLView* LLSlider::fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory)

View File

@@ -55,6 +55,7 @@ public:
virtual LLXMLNodePtr getXML(bool save_children = true) const; virtual LLXMLNodePtr getXML(bool save_children = true) const;
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
virtual ~LLSlider();
void setValue( F32 value, BOOL from_event = FALSE ); void setValue( F32 value, BOOL from_event = FALSE );
F32 getValueF32() const { return mValue; } F32 getValueF32() const { return mValue; }
@@ -71,8 +72,10 @@ public:
void setMinValue(F32 min_value) {mMinValue = min_value; updateThumbRect(); } void setMinValue(F32 min_value) {mMinValue = min_value; updateThumbRect(); }
void setMaxValue(F32 max_value) {mMaxValue = max_value; updateThumbRect(); } void setMaxValue(F32 max_value) {mMaxValue = max_value; updateThumbRect(); }
void setIncrement(F32 increment) {mIncrement = increment;} void setIncrement(F32 increment) {mIncrement = increment;}
void setMouseDownCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseDownCallback = cb; }
void setMouseUpCallback( void (*cb)(LLUICtrl* ctrl, void* userdata) ) { mMouseUpCallback = cb; } boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb );
virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
@@ -103,8 +106,8 @@ private:
LLColor4 mThumbOutlineColor; LLColor4 mThumbOutlineColor;
LLColor4 mThumbCenterColor; LLColor4 mThumbCenterColor;
void (*mMouseDownCallback)(LLUICtrl* ctrl, void* userdata); commit_signal_t* mMouseDownSignal;
void (*mMouseUpCallback)(LLUICtrl* ctrl, void* userdata); commit_signal_t* mMouseUpSignal;
}; };
#endif // LL_LLSLIDER_H #endif // LL_LLSLIDER_H

View File

@@ -76,9 +76,7 @@ LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect,
mEditor( NULL ), mEditor( NULL ),
mTextBox( NULL ), mTextBox( NULL ),
mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ), mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ),
mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ), mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) )
mSliderMouseUpCallback( NULL ),
mSliderMouseDownCallback( NULL )
{ {
S32 top = getRect().getHeight(); S32 top = getRect().getHeight();
S32 bottom = 0; S32 bottom = 0;
@@ -352,37 +350,14 @@ void LLSliderCtrl::setPrecision(S32 precision)
updateText(); updateText();
} }
void LLSliderCtrl::setSliderMouseDownCallback( void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) ) boost::signals2::connection LLSliderCtrl::setSliderMouseDownCallback( const commit_signal_t::slot_type& cb )
{ {
mSliderMouseDownCallback = slider_mousedown_callback; return mSlider->setMouseDownCallback( cb );
mSlider->setMouseDownCallback( LLSliderCtrl::onSliderMouseDown );
} }
// static boost::signals2::connection LLSliderCtrl::setSliderMouseUpCallback( const commit_signal_t::slot_type& cb )
void LLSliderCtrl::onSliderMouseDown(LLUICtrl* caller, void* userdata)
{ {
LLSliderCtrl* self = (LLSliderCtrl*) userdata; return mSlider->setMouseUpCallback( cb );
if( self->mSliderMouseDownCallback )
{
self->mSliderMouseDownCallback( self, self->mCallbackUserData );
}
}
void LLSliderCtrl::setSliderMouseUpCallback( void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) )
{
mSliderMouseUpCallback = slider_mouseup_callback;
mSlider->setMouseUpCallback( LLSliderCtrl::onSliderMouseUp );
}
// static
void LLSliderCtrl::onSliderMouseUp(LLUICtrl* caller, void* userdata)
{
LLSliderCtrl* self = (LLSliderCtrl*) userdata;
if( self->mSliderMouseUpCallback )
{
self->mSliderMouseUpCallback( self, self->mCallbackUserData );
}
} }
void LLSliderCtrl::onTabInto() void LLSliderCtrl::onTabInto()

View File

@@ -75,14 +75,18 @@ public:
virtual LLSD getValue() const { return LLSD(getValueF32()); } virtual LLSD getValue() const { return LLSD(getValueF32()); }
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
virtual void setMinValue(LLSD min_value) { setMinValue((F32)min_value.asReal()); }
virtual void setMaxValue(LLSD max_value) { setMaxValue((F32)max_value.asReal()); }
BOOL isMouseHeldDown() const { return mSlider->hasMouseCapture(); } BOOL isMouseHeldDown() const { return mSlider->hasMouseCapture(); }
virtual void setPrecision(S32 precision);
virtual void setEnabled( BOOL b ); virtual void setEnabled( BOOL b );
virtual void clear(); virtual void clear();
virtual void setPrecision(S32 precision);
virtual void setMinValue(LLSD min_value) { setMinValue((F32)min_value.asReal()); }
virtual void setMaxValue(LLSD max_value) { setMaxValue((F32)max_value.asReal()); }
void setMinValue(F32 min_value) { mSlider->setMinValue(min_value); updateText(); } void setMinValue(F32 min_value) { mSlider->setMinValue(min_value); updateText(); }
void setMaxValue(F32 max_value) { mSlider->setMaxValue(max_value); updateText(); } void setMaxValue(F32 max_value) { mSlider->setMaxValue(max_value); updateText(); }
void setIncrement(F32 increment) { mSlider->setIncrement(increment);} void setIncrement(F32 increment) { mSlider->setIncrement(increment);}
@@ -94,8 +98,8 @@ public:
void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; } void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; }
void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; } void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; }
void setSliderMouseDownCallback( void (*slider_mousedown_callback)(LLUICtrl* caller, void* userdata) ); boost::signals2::connection setSliderMouseDownCallback( const commit_signal_t::slot_type& cb );
void setSliderMouseUpCallback( void (*slider_mouseup_callback)(LLUICtrl* caller, void* userdata) ); boost::signals2::connection setSliderMouseUpCallback( const commit_signal_t::slot_type& cb );
virtual void onTabInto(); virtual void onTabInto();
@@ -111,8 +115,6 @@ public:
virtual std::string getControlName() const { return mSlider->getControlName(); } virtual std::string getControlName() const { return mSlider->getControlName(); }
static void onSliderCommit(LLUICtrl* caller, void* userdata); static void onSliderCommit(LLUICtrl* caller, void* userdata);
static void onSliderMouseDown(LLUICtrl* caller,void* userdata);
static void onSliderMouseUp(LLUICtrl* caller,void* userdata);
static void onEditorCommit(LLUICtrl* caller, void* userdata); static void onEditorCommit(LLUICtrl* caller, void* userdata);
static void onEditorGainFocus(LLFocusableElement* caller, void *userdata); static void onEditorGainFocus(LLFocusableElement* caller, void *userdata);
@@ -138,9 +140,6 @@ private:
LLColor4 mTextEnabledColor; LLColor4 mTextEnabledColor;
LLColor4 mTextDisabledColor; LLColor4 mTextDisabledColor;
void (*mSliderMouseUpCallback)( LLUICtrl* ctrl, void* userdata );
void (*mSliderMouseDownCallback)( LLUICtrl* ctrl, void* userdata );
}; };
#endif // LL_LLSLIDERCTRL_H #endif // LL_LLSLIDERCTRL_H

View File

@@ -35,7 +35,7 @@
#include <list> #include <list>
#include "llmemory.h" #include "llsingleton.h"
#include "llui.h" #include "llui.h"
class LLView; class LLView;

View File

@@ -120,7 +120,7 @@ BOOL LLPanelDisplay::postBuild()
// radio set for fullscreen size // radio set for fullscreen size
mCtrlWindowed = getChild<LLCheckBoxCtrl>( "windowed mode"); mCtrlWindowed = getChild<LLCheckBoxCtrl>( "windowed mode");
mCtrlWindowed->setCommitCallback(onCommitWindowedMode); mCtrlWindowed->setCommitCallback(&LLPanelDisplay::onCommitWindowedMode);
mCtrlWindowed->setCallbackUserData(this); mCtrlWindowed->setCallbackUserData(this);
mAspectRatioLabel1 = getChild<LLTextBox>("AspectRatioLabel1"); mAspectRatioLabel1 = getChild<LLTextBox>("AspectRatioLabel1");
@@ -215,7 +215,7 @@ BOOL LLPanelDisplay::postBuild()
// radio performance box // radio performance box
mCtrlSliderQuality = getChild<LLSliderCtrl>("QualityPerformanceSelection"); mCtrlSliderQuality = getChild<LLSliderCtrl>("QualityPerformanceSelection");
mCtrlSliderQuality->setSliderMouseUpCallback(onChangeQuality); mCtrlSliderQuality->setSliderMouseUpCallback(boost::bind(&LLPanelDisplay::onChangeQuality,mCtrlSliderQuality,this));
mCtrlSliderQuality->setCallbackUserData(this); mCtrlSliderQuality->setCallbackUserData(this);
mCtrlCustomSettings = getChild<LLCheckBoxCtrl>("CustomSettings"); mCtrlCustomSettings = getChild<LLCheckBoxCtrl>("CustomSettings");