Modernized lluictrl. Added LLViewModel. Fixed focus callbacks being called excessively. Updated LLButton, and implemented boost::signals2 to replace old callback handling.
This commit is contained in:
@@ -79,6 +79,7 @@ set(llui_SOURCE_FILES
|
||||
lluistring.cpp
|
||||
llundo.cpp
|
||||
llviewborder.cpp
|
||||
llviewmodel.cpp
|
||||
llview.cpp
|
||||
llviewquery.cpp
|
||||
)
|
||||
@@ -146,6 +147,7 @@ set(llui_HEADER_FILES
|
||||
lluixmltags.h
|
||||
llundo.h
|
||||
llviewborder.h
|
||||
llviewmodel.h
|
||||
llview.h
|
||||
llviewquery.h
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,6 +41,8 @@
|
||||
#include "llfontgl.h"
|
||||
#include "lluiimage.h"
|
||||
#include "lluistring.h"
|
||||
#include "llinitparam.h"
|
||||
#include "lluicolor.h"
|
||||
|
||||
//
|
||||
// Constants
|
||||
@@ -85,21 +87,26 @@ public:
|
||||
const LLFontGL* mGLFont = NULL,
|
||||
const std::string& unselected_label = LLStringUtil::null,
|
||||
const std::string& selected_label = LLStringUtil::null );
|
||||
public:
|
||||
|
||||
virtual ~LLButton();
|
||||
void init(void (*click_callback)(void*), void *callback_data, const LLFontGL* font, const std::string& control_name);
|
||||
~LLButton();
|
||||
// For backward compatability only
|
||||
typedef boost::function<void(void*)> button_callback_t;
|
||||
|
||||
|
||||
void addImageAttributeToXML(LLXMLNodePtr node, const std::string& imageName,
|
||||
const LLUUID& imageID,const std::string& xmlTagName) const;
|
||||
void addImageAttributeToXML(LLXMLNodePtr node, const LLPointer<LLUIImage>, const std::string& xmlTagName) const;
|
||||
void init(void (*click_callback)(void*), void *callback_data, const std::string& control_name);
|
||||
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 void setAlpha( F32 alpha ) { mAlpha = alpha; }
|
||||
virtual BOOL handleUnicodeCharHere(llwchar uni_char);
|
||||
virtual BOOL handleKeyHere(KEY key, MASK mask);
|
||||
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
|
||||
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
|
||||
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
|
||||
virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
|
||||
virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
|
||||
virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
|
||||
virtual void draw();
|
||||
|
||||
virtual void onMouseCaptureLost();
|
||||
@@ -109,29 +116,48 @@ public:
|
||||
void setUnselectedLabelColor( const LLColor4& c ) { mUnselectedLabelColor = c; }
|
||||
void setSelectedLabelColor( const LLColor4& c ) { mSelectedLabelColor = c; }
|
||||
|
||||
void setClickedCallback( void (*cb)(void *data), void* data = NULL ); // mouse down and up within button
|
||||
void setMouseDownCallback( void (*cb)(void *data) ) { mMouseDownCallback = cb; } // mouse down within button
|
||||
void setMouseUpCallback( void (*cb)(void *data) ) { mMouseUpCallback = cb; } // mouse up, EVEN IF NOT IN BUTTON
|
||||
void setHeldDownCallback( void (*cb)(void *data) ) { mHeldDownCallback = cb; } // Mouse button held down and in button
|
||||
|
||||
/*boost::signals2::connection setClickedCallback(const CommitCallbackParam& cb);
|
||||
boost::signals2::connection setMouseDownCallback(const CommitCallbackParam& cb);
|
||||
boost::signals2::connection setMouseUpCallback(const CommitCallbackParam& cb);
|
||||
boost::signals2::connection setHeldDownCallback(const CommitCallbackParam& cb);*/
|
||||
|
||||
boost::signals2::connection setClickedCallback( const commit_signal_t::slot_type& cb ); // mouse down and up within button
|
||||
boost::signals2::connection setMouseDownCallback( const commit_signal_t::slot_type& cb );
|
||||
boost::signals2::connection setMouseUpCallback( const commit_signal_t::slot_type& cb ); // mouse up, EVEN IF NOT IN BUTTON
|
||||
// Passes a 'count' parameter in the commit param payload, i.e. param["count"])
|
||||
boost::signals2::connection setHeldDownCallback( const commit_signal_t::slot_type& cb ); // Mouse button held down and in button
|
||||
|
||||
|
||||
// *TODO: Deprecate (for backwards compatability only)
|
||||
boost::signals2::connection setClickedCallback( button_callback_t cb, void* data );
|
||||
boost::signals2::connection setMouseDownCallback( button_callback_t cb, void* data );
|
||||
boost::signals2::connection setMouseUpCallback( button_callback_t cb, void* data );
|
||||
boost::signals2::connection setHeldDownCallback( button_callback_t cb, void* data );
|
||||
|
||||
void setHeldDownDelay( F32 seconds, S32 frames = 0) { mHeldDownDelay = seconds; mHeldDownFrameDelay = frames; }
|
||||
|
||||
F32 getHeldDownTime() const { return mMouseDownTimer.getElapsedTimeF32(); }
|
||||
|
||||
BOOL getIsToggle() const { return mIsToggle; }
|
||||
void setIsToggle(BOOL is_toggle) { mIsToggle = is_toggle; }
|
||||
BOOL toggleState();
|
||||
BOOL getToggleState() const { return mToggleState; }
|
||||
BOOL getToggleState() const;
|
||||
void setToggleState(BOOL b);
|
||||
|
||||
void setHighlight(bool b);
|
||||
void setFlashing( BOOL b );
|
||||
BOOL getFlashing() const { return mFlashing; }
|
||||
|
||||
void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; }
|
||||
LLFontGL::HAlign getHAlign() const { return mHAlign; }
|
||||
void setLeftHPad( S32 pad ) { mLeftHPad = pad; }
|
||||
S32 getLeftHPad() const { return mLeftHPad; }
|
||||
S32 getLeftHPad() const { return mLeftHPad; }
|
||||
void setRightHPad( S32 pad ) { mRightHPad = pad; }
|
||||
S32 getRightHPad() const { return mRightHPad; }
|
||||
S32 getRightHPad() const { return mRightHPad; }
|
||||
|
||||
void setImageOverlayTopPad( S32 pad ) { mImageOverlayTopPad = pad; }
|
||||
S32 getImageOverlayTopPad() const { return mImageOverlayTopPad; }
|
||||
void setImageOverlayBottomPad( S32 pad ) { mImageOverlayBottomPad = pad; }
|
||||
S32 getImageOverlayBottomPad() const { return mImageOverlayBottomPad; }
|
||||
|
||||
const std::string getLabelUnselected() const { return wstring_to_utf8str(mUnselectedLabel); }
|
||||
const std::string getLabelSelected() const { return wstring_to_utf8str(mSelectedLabel); }
|
||||
@@ -139,35 +165,31 @@ public:
|
||||
void setImageColor(const std::string& color_control);
|
||||
void setImageColor(const LLColor4& c);
|
||||
/*virtual*/ void setColor(const LLColor4& c);
|
||||
/*virtual*/ void setAlpha(F32 alpha);
|
||||
|
||||
void setImages(const std::string &image_name, const std::string &selected_name);
|
||||
void setDisabledImages(const std::string &image_name, const std::string &selected_name);
|
||||
void setDisabledImages(const std::string &image_name, const std::string &selected_name, const LLColor4& c);
|
||||
|
||||
void setHoverImages(const std::string &image_name, const std::string &selected_name);
|
||||
|
||||
void setDisabledImageColor(const LLColor4& c) { mDisabledImageColor = c; }
|
||||
|
||||
void setDisabledSelectedLabelColor( const LLColor4& c ) { mDisabledSelectedLabelColor = c; }
|
||||
|
||||
void setImageOverlay(const std::string& image_name, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white);
|
||||
void setImageOverlay(const LLUUID& image_id, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white);
|
||||
LLPointer<LLUIImage> getImageOverlay() { return mImageOverlay; }
|
||||
LLFontGL::HAlign getImageOverlayHAlign() const { return mImageOverlayAlignment; }
|
||||
|
||||
|
||||
virtual void setValue(const LLSD& value );
|
||||
virtual LLSD getValue() const;
|
||||
|
||||
void autoResize(); // resize with label of current btn state
|
||||
void resize(LLUIString label); // resize with label input
|
||||
void setLabel( const LLStringExplicit& label);
|
||||
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
|
||||
void setLabelUnselected(const LLStringExplicit& label);
|
||||
void setLabelSelected(const LLStringExplicit& label);
|
||||
void setDisabledLabel(const LLStringExplicit& disabled_label);
|
||||
void setDisabledSelectedLabel(const LLStringExplicit& disabled_label);
|
||||
void setDisabledLabelColor( const LLColor4& c ) { mDisabledLabelColor = c; }
|
||||
|
||||
void setFont(const LLFontGL *font)
|
||||
{ mGLFont = ( font ? font : LLFontGL::getFontSansSerif()); }
|
||||
const LLFontGL* getFont() const { return mGLFont; }
|
||||
const LLUIString& getCurrentLabel() const;
|
||||
|
||||
void setScaleImage(BOOL scale) { mScaleImage = scale; }
|
||||
BOOL getScaleImage() const { return mScaleImage; }
|
||||
|
||||
@@ -175,132 +197,130 @@ public:
|
||||
|
||||
void setBorderEnabled(BOOL b) { mBorderEnabled = b; }
|
||||
|
||||
static void onHeldDown(void *userdata); // to be called by gIdleCallbacks
|
||||
|
||||
void setHoverGlowStrength(F32 strength) { mHoverGlowStrength = strength; }
|
||||
|
||||
void setImageUnselected(const std::string &image_name);
|
||||
const std::string& getImageUnselectedName() const { return mImageUnselectedName; }
|
||||
void setImageSelected(const std::string &image_name);
|
||||
const std::string& getImageSelectedName() const { return mImageSelectedName; }
|
||||
void setImageHoverSelected(const std::string &image_name);
|
||||
void setImageHoverUnselected(const std::string &image_name);
|
||||
void setImageDisabled(const std::string &image_name);
|
||||
void setImageDisabledSelected(const std::string &image_name);
|
||||
|
||||
void setImageUnselected(LLPointer<LLUIImage> image);
|
||||
void setImageSelected(LLPointer<LLUIImage> image);
|
||||
void setImageHoverSelected(LLPointer<LLUIImage> image);
|
||||
void setImageHoverUnselected(LLPointer<LLUIImage> image);
|
||||
void setImageDisabled(LLPointer<LLUIImage> image);
|
||||
void setImageDisabledSelected(LLPointer<LLUIImage> image);
|
||||
|
||||
void setImageFlash(LLPointer<LLUIImage> image);
|
||||
void setImagePressed(LLPointer<LLUIImage> image);
|
||||
|
||||
void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; }
|
||||
BOOL getCommitOnReturn() const { return mCommitOnReturn; }
|
||||
|
||||
static void onHeldDown(void *userdata); // to be called by gIdleCallbacks
|
||||
void setHelpURLCallback(const std::string &help_url);
|
||||
const std::string& getHelpURL() const { return mHelpURL; }
|
||||
|
||||
void setForcePressedState(bool b) { mForcePressedState = b; }
|
||||
|
||||
void setAutoResize(bool auto_resize) { mAutoResize = auto_resize; }
|
||||
|
||||
bool getIsToggle() const { return mIsToggle; }
|
||||
bool setIsToggle(bool toggle) { return mIsToggle = toggle; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual void drawBorder(const LLColor4& color, S32 size);
|
||||
|
||||
void setImageUnselectedID(const LLUUID &image_id);
|
||||
const LLUUID& getImageUnselectedID() const { return mImageUnselectedID; }
|
||||
void setImageSelectedID(const LLUUID &image_id);
|
||||
const LLUUID& getImageSelectedID() const { return mImageSelectedID; }
|
||||
void setImageHoverSelectedID(const LLUUID &image_id);
|
||||
void setImageHoverUnselectedID(const LLUUID &image_id);
|
||||
void setImageDisabledID(const LLUUID &image_id);
|
||||
void setImageDisabledSelectedID(const LLUUID &image_id);
|
||||
const LLPointer<LLUIImage>& getImageUnselected() const { return mImageUnselected; }
|
||||
const LLPointer<LLUIImage>& getImageSelected() const { return mImageSelected; }
|
||||
|
||||
void getOverlayImageSize(S32& overlay_width, S32& overlay_height);
|
||||
|
||||
LLFrameTimer mMouseDownTimer;
|
||||
bool mNeedsHighlight;
|
||||
S32 mButtonFlashCount;
|
||||
F32 mButtonFlashRate;
|
||||
|
||||
private:
|
||||
|
||||
void (*mClickedCallback)(void* data );
|
||||
void (*mMouseDownCallback)(void *data);
|
||||
void (*mMouseUpCallback)(void *data);
|
||||
void (*mHeldDownCallback)(void *data);
|
||||
void drawBorder(LLUIImage* imagep, const LLColor4& color, S32 size);
|
||||
void resetMouseDownTimer();
|
||||
|
||||
commit_signal_t* mMouseDownSignal;
|
||||
commit_signal_t* mMouseUpSignal;
|
||||
commit_signal_t* mHeldDownSignal;
|
||||
|
||||
const LLFontGL *mGLFont;
|
||||
|
||||
S32 mMouseDownFrame;
|
||||
F32 mHeldDownDelay; // seconds, after which held-down callbacks get called
|
||||
S32 mHeldDownFrameDelay; // frames, after which held-down callbacks get called
|
||||
S32 mMouseDownFrame;
|
||||
S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback
|
||||
F32 mHeldDownDelay; // seconds, after which held-down callbacks get called
|
||||
S32 mHeldDownFrameDelay; // frames, after which held-down callbacks get called
|
||||
|
||||
LLPointer<LLUIImage> mImageOverlay;
|
||||
LLFontGL::HAlign mImageOverlayAlignment;
|
||||
LLColor4 mImageOverlayColor;
|
||||
LLFontGL::HAlign mImageOverlayAlignment;
|
||||
LLUIColor mImageOverlayColor;
|
||||
LLUIColor mImageOverlaySelectedColor;
|
||||
LLUIColor mImageOverlayDisabledColor;
|
||||
|
||||
LLPointer<LLUIImage> mImageUnselected;
|
||||
LLUIString mUnselectedLabel;
|
||||
LLColor4 mUnselectedLabelColor;
|
||||
LLPointer<LLUIImage> mImageUnselected;
|
||||
LLUIString mUnselectedLabel;
|
||||
LLUIColor mUnselectedLabelColor;
|
||||
|
||||
LLPointer<LLUIImage> mImageSelected;
|
||||
LLUIString mSelectedLabel;
|
||||
LLColor4 mSelectedLabelColor;
|
||||
LLPointer<LLUIImage> mImageSelected;
|
||||
LLUIString mSelectedLabel;
|
||||
LLUIColor mSelectedLabelColor;
|
||||
|
||||
LLPointer<LLUIImage> mImageHoverSelected;
|
||||
LLPointer<LLUIImage> mImageHoverSelected;
|
||||
|
||||
LLPointer<LLUIImage> mImageHoverUnselected;
|
||||
LLPointer<LLUIImage> mImageHoverUnselected;
|
||||
|
||||
LLPointer<LLUIImage> mImageDisabled;
|
||||
LLUIString mDisabledLabel;
|
||||
LLColor4 mDisabledLabelColor;
|
||||
LLPointer<LLUIImage> mImageDisabled;
|
||||
LLUIColor mDisabledLabelColor;
|
||||
|
||||
LLPointer<LLUIImage> mImageDisabledSelected;
|
||||
LLUIString mDisabledSelectedLabel;
|
||||
LLColor4 mDisabledSelectedLabelColor;
|
||||
LLPointer<LLUIImage> mImageDisabledSelected;
|
||||
LLUIString mDisabledSelectedLabel;
|
||||
LLUIColor mDisabledSelectedLabelColor;
|
||||
|
||||
LLUUID mImageUnselectedID;
|
||||
LLUUID mImageSelectedID;
|
||||
LLUUID mImageHoverSelectedID;
|
||||
LLUUID mImageHoverUnselectedID;
|
||||
LLUUID mImageDisabledID;
|
||||
LLUUID mImageDisabledSelectedID;
|
||||
std::string mImageUnselectedName;
|
||||
std::string mImageSelectedName;
|
||||
std::string mImageHoverSelectedName;
|
||||
std::string mImageHoverUnselectedName;
|
||||
std::string mImageDisabledName;
|
||||
std::string mImageDisabledSelectedName;
|
||||
LLPointer<LLUIImage> mImagePressed;
|
||||
LLPointer<LLUIImage> mImagePressedSelected;
|
||||
|
||||
LLColor4 mHighlightColor;
|
||||
LLColor4 mUnselectedBgColor;
|
||||
LLColor4 mSelectedBgColor;
|
||||
LLColor4 mFlashBgColor;
|
||||
/* There are two ways an image can flash- by making changes in color according to flash_color attribute
|
||||
or by changing icon from current to the one specified in image_flash. Second way is used only if
|
||||
flash icon name is set in attributes(by default it isn't). First way is used otherwise. */
|
||||
LLPointer<LLUIImage> mImageFlash;
|
||||
|
||||
LLColor4 mImageColor;
|
||||
LLColor4 mDisabledImageColor;
|
||||
LLUIColor mFlashBgColor;
|
||||
|
||||
BOOL mIsToggle;
|
||||
BOOL mToggleState;
|
||||
BOOL mScaleImage;
|
||||
LLUIColor mImageColor;
|
||||
LLUIColor mDisabledImageColor;
|
||||
|
||||
BOOL mDropShadowedText;
|
||||
bool mIsToggle;
|
||||
bool mScaleImage;
|
||||
|
||||
BOOL mBorderEnabled;
|
||||
bool mDropShadowedText;
|
||||
bool mAutoResize;
|
||||
bool mBorderEnabled;
|
||||
bool mFlashing;
|
||||
|
||||
BOOL mFlashing;
|
||||
LLFontGL::HAlign mHAlign;
|
||||
S32 mLeftHPad;
|
||||
S32 mRightHPad;
|
||||
S32 mBottomVPad; // under text label
|
||||
|
||||
LLFontGL::HAlign mHAlign;
|
||||
S32 mLeftHPad;
|
||||
S32 mRightHPad;
|
||||
S32 mImageOverlayTopPad;
|
||||
S32 mImageOverlayBottomPad;
|
||||
|
||||
F32 mHoverGlowStrength;
|
||||
F32 mCurGlowStrength;
|
||||
/*
|
||||
* Space between image_overlay and label
|
||||
*/
|
||||
S32 mImgOverlayLabelSpace;
|
||||
|
||||
BOOL mNeedsHighlight;
|
||||
BOOL mCommitOnReturn;
|
||||
F32 mHoverGlowStrength;
|
||||
F32 mCurGlowStrength;
|
||||
|
||||
std::string mHelpURL;
|
||||
bool mCommitOnReturn;
|
||||
bool mFadeWhenDisabled;
|
||||
|
||||
LLPointer<LLUIImage> mImagep;
|
||||
bool mForcePressedState;
|
||||
bool mDisplayPressedState;
|
||||
|
||||
LLFrameTimer mFlashingTimer;
|
||||
std::string mHelpURL;
|
||||
|
||||
LLFrameTimer mFlashingTimer;
|
||||
|
||||
bool mHandleRightMouse;
|
||||
|
||||
F32 mAlpha;
|
||||
};
|
||||
|
||||
#endif // LL_LLBUTTON_H
|
||||
|
||||
@@ -113,37 +113,27 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect,
|
||||
LLCHECKBOXCTRL_VPAD,
|
||||
LLCHECKBOXCTRL_BTN_SIZE + LLCHECKBOXCTRL_SPACING + text_width + LLCHECKBOXCTRL_HPAD,
|
||||
llmax( text_height, LLCHECKBOXCTRL_BTN_SIZE ) + LLCHECKBOXCTRL_VPAD);
|
||||
std::string active_true_id, active_false_id;
|
||||
std::string inactive_true_id, inactive_false_id;
|
||||
if (mRadioStyle)
|
||||
{
|
||||
active_true_id = "UIImgRadioActiveSelectedUUID";
|
||||
active_false_id = "UIImgRadioActiveUUID";
|
||||
inactive_true_id = "UIImgRadioInactiveSelectedUUID";
|
||||
inactive_false_id = "UIImgRadioInactiveUUID";
|
||||
mButton = new LLButton(std::string("Radio control button"), btn_rect,
|
||||
active_false_id, active_true_id, control_which,
|
||||
&LLCheckBoxCtrl::onButtonPress, this, LLFontGL::getFontSansSerif() );
|
||||
mButton->setDisabledImages( inactive_false_id, inactive_true_id );
|
||||
mButton->setHoverGlowStrength(0.35f);
|
||||
}
|
||||
else
|
||||
{
|
||||
active_false_id = "UIImgCheckboxActiveUUID";
|
||||
active_true_id = "UIImgCheckboxActiveSelectedUUID";
|
||||
inactive_true_id = "UIImgCheckboxInactiveSelectedUUID";
|
||||
inactive_false_id = "UIImgCheckboxInactiveUUID";
|
||||
mButton = new LLButton(std::string("Checkbox control button"), btn_rect,
|
||||
active_false_id, active_true_id, control_which,
|
||||
&LLCheckBoxCtrl::onButtonPress, this, LLFontGL::getFontSansSerif() );
|
||||
mButton->setDisabledImages( inactive_false_id, inactive_true_id );
|
||||
mButton->setHoverGlowStrength(0.35f);
|
||||
}
|
||||
|
||||
std::string active_true_id = mRadioStyle ? "UIImgRadioActiveSelectedUUID" : "UIImgCheckboxActiveSelectedUUID";
|
||||
std::string active_false_id = mRadioStyle ? "UIImgRadioActiveUUID" : "UIImgCheckboxActiveUUID";
|
||||
std::string inactive_true_id = mRadioStyle ? "UIImgRadioInactiveSelectedUUID" : "UIImgCheckboxInactiveSelectedUUID";
|
||||
std::string inactive_false_id = mRadioStyle ? "UIImgRadioInactiveUUID" : "UIImgCheckboxInactiveUUID";
|
||||
std::string button_name = mRadioStyle ? "Radio control button" : "Checkbox control button";
|
||||
|
||||
mButton = new LLButton( button_name, btn_rect,
|
||||
active_false_id, active_true_id, control_which,
|
||||
&LLCheckBoxCtrl::onButtonPress, this, LLFontGL::getFontSansSerif() );
|
||||
|
||||
mButton->setImageDisabledSelected(LLUI::getUIImage(inactive_true_id));
|
||||
mButton->setImageDisabled(LLUI::getUIImage(inactive_false_id));
|
||||
mButton->setHoverGlowStrength(0.35f);
|
||||
|
||||
mButton->setIsToggle(TRUE);
|
||||
mButton->setToggleState( initial_value );
|
||||
mButton->setFollowsLeft();
|
||||
mButton->setFollowsBottom();
|
||||
mButton->setCommitOnReturn(FALSE);
|
||||
mButton->setScaleImage(FALSE);
|
||||
addChild(mButton);
|
||||
}
|
||||
|
||||
@@ -156,22 +146,8 @@ LLCheckBoxCtrl::~LLCheckBoxCtrl()
|
||||
// static
|
||||
void LLCheckBoxCtrl::onButtonPress( void *userdata )
|
||||
{
|
||||
LLCheckBoxCtrl* self = (LLCheckBoxCtrl*) userdata;
|
||||
|
||||
if (self->mRadioStyle)
|
||||
{
|
||||
self->setValue(TRUE);
|
||||
}
|
||||
|
||||
self->setControlValue(self->getValue());
|
||||
// HACK: because buttons don't normally commit
|
||||
LLCheckBoxCtrl* self = (LLCheckBoxCtrl*)userdata;
|
||||
self->onCommit();
|
||||
|
||||
if (self->mKeyboardFocusOnClick)
|
||||
{
|
||||
self->setFocus( TRUE );
|
||||
self->onFocusReceived();
|
||||
}
|
||||
}
|
||||
|
||||
void LLCheckBoxCtrl::onCommit()
|
||||
@@ -179,6 +155,7 @@ void LLCheckBoxCtrl::onCommit()
|
||||
if( getEnabled() )
|
||||
{
|
||||
setTentative(FALSE);
|
||||
setControlValue(getValue());
|
||||
LLUICtrl::onCommit();
|
||||
}
|
||||
}
|
||||
@@ -186,7 +163,15 @@ void LLCheckBoxCtrl::onCommit()
|
||||
void LLCheckBoxCtrl::setEnabled(BOOL b)
|
||||
{
|
||||
LLView::setEnabled(b);
|
||||
mButton->setEnabled(b);
|
||||
|
||||
if (b)
|
||||
{
|
||||
mLabel->setColor( mTextEnabledColor.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mLabel->setColor( mTextDisabledColor.get() );
|
||||
}
|
||||
}
|
||||
|
||||
void LLCheckBoxCtrl::clear()
|
||||
@@ -219,21 +204,6 @@ void LLCheckBoxCtrl::reshape(S32 width, S32 height, BOOL called_from_parent)
|
||||
LLUICtrl::reshape(width, height, called_from_parent);
|
||||
}
|
||||
|
||||
void LLCheckBoxCtrl::draw()
|
||||
{
|
||||
if (getEnabled())
|
||||
{
|
||||
mLabel->setColor( mTextEnabledColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
mLabel->setColor( mTextDisabledColor );
|
||||
}
|
||||
|
||||
// Draw children
|
||||
LLUICtrl::draw();
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLCheckBoxCtrl::setValue(const LLSD& value )
|
||||
{
|
||||
@@ -246,6 +216,18 @@ LLSD LLCheckBoxCtrl::getValue() const
|
||||
return mButton->getValue();
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLCheckBoxCtrl::setTentative(BOOL b)
|
||||
{
|
||||
mButton->setTentative(b);
|
||||
}
|
||||
|
||||
//virtual
|
||||
BOOL LLCheckBoxCtrl::getTentative() const
|
||||
{
|
||||
return mButton->getTentative();
|
||||
}
|
||||
|
||||
void LLCheckBoxCtrl::setLabel( const LLStringExplicit& label )
|
||||
{
|
||||
mLabel->setText( label );
|
||||
@@ -282,7 +264,7 @@ BOOL LLCheckBoxCtrl::isDirty() const
|
||||
{
|
||||
if ( mButton )
|
||||
{
|
||||
return (mSetValue != mButton->getToggleState());
|
||||
return mButton->isDirty();
|
||||
}
|
||||
return FALSE; // Shouldn't get here
|
||||
}
|
||||
@@ -293,11 +275,12 @@ void LLCheckBoxCtrl::resetDirty()
|
||||
{
|
||||
if ( mButton )
|
||||
{
|
||||
mSetValue = mButton->getToggleState();
|
||||
mButton->resetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// virtual
|
||||
LLXMLNodePtr LLCheckBoxCtrl::getXML(bool save_children) const
|
||||
{
|
||||
|
||||
@@ -82,7 +82,6 @@ public:
|
||||
|
||||
virtual void setEnabled( BOOL b );
|
||||
|
||||
virtual void draw();
|
||||
virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
|
||||
|
||||
// LLUICtrl interface
|
||||
@@ -91,8 +90,8 @@ public:
|
||||
BOOL get() { return (BOOL)getValue().asBoolean(); }
|
||||
void set(BOOL value) { setValue(value); }
|
||||
|
||||
virtual void setTentative(BOOL b) { mButton->setTentative(b); }
|
||||
virtual BOOL getTentative() const { return mButton->getTentative(); }
|
||||
virtual void setTentative(BOOL b);
|
||||
virtual BOOL getTentative() const;
|
||||
|
||||
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
|
||||
|
||||
@@ -108,6 +107,9 @@ public:
|
||||
void setLabel( const LLStringExplicit& label );
|
||||
std::string getLabel() const;
|
||||
|
||||
void setFont( const LLFontGL* font ) { mFont = font; }
|
||||
const LLFontGL* getFont() { return mFont; }
|
||||
|
||||
virtual void setControlName(const std::string& control_name, LLView* context);
|
||||
virtual std::string getControlName() const;
|
||||
|
||||
@@ -121,8 +123,9 @@ protected:
|
||||
LLButton* mButton;
|
||||
LLTextBox* mLabel;
|
||||
const LLFontGL* mFont;
|
||||
LLColor4 mTextEnabledColor;
|
||||
LLColor4 mTextDisabledColor;
|
||||
|
||||
LLUIColor mTextEnabledColor;
|
||||
LLUIColor mTextDisabledColor;
|
||||
BOOL mRadioStyle;
|
||||
BOOL mInitialValue; // Value set in constructor
|
||||
BOOL mSetValue; // Value set programmatically
|
||||
|
||||
@@ -85,13 +85,13 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::
|
||||
LLRect(),
|
||||
LLStringUtil::null,
|
||||
NULL, this);
|
||||
mButton->setImageUnselected(std::string("square_btn_32x128.tga"));
|
||||
mButton->setImageSelected(std::string("square_btn_selected_32x128.tga"));
|
||||
mButton->setImageDisabled(std::string("square_btn_32x128.tga"));
|
||||
mButton->setImageDisabledSelected(std::string("square_btn_selected_32x128.tga"));
|
||||
mButton->setImageUnselected(LLUI::getUIImage("square_btn_32x128.tga"));
|
||||
mButton->setImageSelected(LLUI::getUIImage("square_btn_selected_32x128.tga"));
|
||||
mButton->setImageDisabled(LLUI::getUIImage("square_btn_32x128.tga"));
|
||||
mButton->setImageDisabledSelected(LLUI::getUIImage("square_btn_selected_32x128.tga"));
|
||||
mButton->setScaleImage(TRUE);
|
||||
|
||||
mButton->setMouseDownCallback(onButtonDown);
|
||||
mButton->setMouseDownCallback(boost::bind(&LLComboBox::onButtonDown,this));
|
||||
mButton->setFont(LLFontGL::getFontSansSerifSmall());
|
||||
mButton->setFollows(FOLLOWS_LEFT | FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
|
||||
mButton->setHAlign( LLFontGL::LEFT );
|
||||
@@ -244,8 +244,6 @@ void LLComboBox::clear()
|
||||
}
|
||||
mButton->setLabelSelected(LLStringUtil::null);
|
||||
mButton->setLabelUnselected(LLStringUtil::null);
|
||||
mButton->setDisabledLabel(LLStringUtil::null);
|
||||
mButton->setDisabledSelectedLabel(LLStringUtil::null);
|
||||
mList->deselectAllItems();
|
||||
}
|
||||
|
||||
@@ -445,8 +443,6 @@ void LLComboBox::setLabel(const LLStringExplicit& name)
|
||||
{
|
||||
mButton->setLabelUnselected(name);
|
||||
mButton->setLabelSelected(name);
|
||||
mButton->setDisabledLabel(name);
|
||||
mButton->setDisabledSelectedLabel(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1218,7 +1214,7 @@ LLFlyoutButton::LLFlyoutButton(
|
||||
LLRect(), LLStringUtil::null, NULL, this);
|
||||
mActionButton->setScaleImage(TRUE);
|
||||
|
||||
mActionButton->setClickedCallback(onActionButtonClick);
|
||||
mActionButton->setClickedCallback(boost::bind(&LLFlyoutButton::onActionButtonClick, this));
|
||||
mActionButton->setFollowsAll();
|
||||
mActionButton->setHAlign( LLFontGL::HCENTER );
|
||||
mActionButton->setLabel(label);
|
||||
|
||||
@@ -707,6 +707,8 @@ const std::string& LLFloater::getCurrentTitle() const
|
||||
|
||||
void LLFloater::setTitle( const std::string& title )
|
||||
{
|
||||
if(mTitle == title)
|
||||
return;
|
||||
mTitle = title;
|
||||
applyTitle();
|
||||
}
|
||||
@@ -1742,8 +1744,8 @@ void LLFloater::buildButtons()
|
||||
buttonp->setFollowsRight();
|
||||
buttonp->setToolTip( sButtonToolTips[i] );
|
||||
buttonp->setImageColor(LLUI::sColorsGroup->getColor("FloaterButtonImageColor"));
|
||||
buttonp->setHoverImages(sButtonPressedImageNames[i],
|
||||
sButtonPressedImageNames[i]);
|
||||
buttonp->setImageHoverSelected(LLUI::getUIImage(sButtonPressedImageNames[i]));
|
||||
buttonp->setImageHoverUnselected(LLUI::getUIImage(sButtonPressedImageNames[i]));
|
||||
buttonp->setScaleImage(TRUE);
|
||||
buttonp->setSaveToXML(false);
|
||||
addChild(buttonp);
|
||||
|
||||
@@ -127,7 +127,7 @@ LLScrollbar::LLScrollbar(
|
||||
line_up_btn->setFollowsLeft();
|
||||
line_up_btn->setFollowsBottom();
|
||||
}
|
||||
line_up_btn->setHeldDownCallback( &LLScrollbar::onLineUpBtnPressed );
|
||||
line_up_btn->setHeldDownCallback( boost::bind(&LLScrollbar::onLineUpBtnPressed, (void*)this) );
|
||||
line_up_btn->setTabStop(FALSE);
|
||||
line_up_btn->setScaleImage(TRUE);
|
||||
|
||||
@@ -138,7 +138,7 @@ LLScrollbar::LLScrollbar(
|
||||
&LLScrollbar::onLineDownBtnPressed, this, LLFontGL::getFontSansSerif() );
|
||||
line_down_btn->setFollowsRight();
|
||||
line_down_btn->setFollowsBottom();
|
||||
line_down_btn->setHeldDownCallback( &LLScrollbar::onLineDownBtnPressed );
|
||||
line_down_btn->setHeldDownCallback( boost::bind(&LLScrollbar::onLineDownBtnPressed, this) );
|
||||
line_down_btn->setTabStop(FALSE);
|
||||
line_down_btn->setScaleImage(TRUE);
|
||||
addChild(line_down_btn);
|
||||
|
||||
@@ -3679,9 +3679,9 @@ LLColumnHeader::LLColumnHeader(const std::string& label, const LLRect &rect, LLS
|
||||
mButton->setTabStop(FALSE);
|
||||
// require at least two frames between mouse down and mouse up event to capture intentional "hold" not just bad framerate
|
||||
mButton->setHeldDownDelay(LLUI::sConfigGroup->getF32("ColumnHeaderDropDownDelay"), 2);
|
||||
mButton->setHeldDownCallback(onHeldDown);
|
||||
mButton->setClickedCallback(onClick);
|
||||
mButton->setMouseDownCallback(onMouseDown);
|
||||
mButton->setHeldDownCallback(boost::bind(&LLColumnHeader::onHeldDown, this));
|
||||
mButton->setClickedCallback(boost::bind(&LLColumnHeader::onClick, this));
|
||||
mButton->setMouseDownCallback(boost::bind(&LLColumnHeader::onMouseDown, this));
|
||||
|
||||
mButton->setCallbackUserData(this);
|
||||
mButton->setToolTip(label);
|
||||
@@ -3843,8 +3843,8 @@ void LLColumnHeader::setImage(const std::string &image_name)
|
||||
{
|
||||
if (mButton)
|
||||
{
|
||||
mButton->setImageSelected(image_name);
|
||||
mButton->setImageUnselected(image_name);
|
||||
mButton->setImageSelected(LLUI::getUIImage(image_name));
|
||||
mButton->setImageUnselected(LLUI::getUIImage(image_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::
|
||||
&LLSpinCtrl::onUpBtn, this, LLFontGL::getFontSansSerif() );
|
||||
mUpBtn->setFollowsLeft();
|
||||
mUpBtn->setFollowsBottom();
|
||||
mUpBtn->setHeldDownCallback( &LLSpinCtrl::onUpBtn );
|
||||
mUpBtn->setHeldDownCallback(boost::bind(&LLSpinCtrl::onUpBtn,this));
|
||||
mUpBtn->setTabStop(FALSE);
|
||||
addChild(mUpBtn);
|
||||
|
||||
@@ -115,7 +115,7 @@ LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::
|
||||
&LLSpinCtrl::onDownBtn, this, LLFontGL::getFontSansSerif() );
|
||||
mDownBtn->setFollowsLeft();
|
||||
mDownBtn->setFollowsBottom();
|
||||
mDownBtn->setHeldDownCallback( &LLSpinCtrl::onDownBtn );
|
||||
mDownBtn->setHeldDownCallback(boost::bind(&LLSpinCtrl::onDownBtn,this));
|
||||
mDownBtn->setTabStop(FALSE);
|
||||
addChild(mDownBtn);
|
||||
|
||||
|
||||
@@ -803,7 +803,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
|
||||
LLStringUtil::null,
|
||||
LLStringUtil::null,
|
||||
LLStringUtil::null,
|
||||
&LLTabContainer::onTabBtn, NULL,
|
||||
NULL, NULL,
|
||||
font,
|
||||
trimmed_label, trimmed_label);
|
||||
btn->setImages(std::string("tab_left.tga"), std::string("tab_left_selected.tga"));
|
||||
@@ -825,7 +825,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
|
||||
btn = new LLButton(std::string(child->getName()) + " tab",
|
||||
btn_rect,
|
||||
LLStringUtil::null, LLStringUtil::null, LLStringUtil::null,
|
||||
&LLTabContainer::onTabBtn, NULL, // set userdata below
|
||||
NULL, NULL, // set userdata below
|
||||
font,
|
||||
trimmed_label, trimmed_label );
|
||||
btn->setVisible( FALSE );
|
||||
@@ -865,7 +865,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
|
||||
if (btn)
|
||||
{
|
||||
btn->setSaveToXML(false);
|
||||
btn->setCallbackUserData( tuple );
|
||||
btn->setClickedCallback(&LLTabContainer::onTabBtn, tuple);
|
||||
addChild( btn, 0 );
|
||||
}
|
||||
if (child)
|
||||
@@ -1682,7 +1682,7 @@ void LLTabContainer::initButtons()
|
||||
mPrevArrowBtn = new LLButton(std::string("Left Arrow"), left_arrow_btn_rect,
|
||||
out_id, in_id, LLStringUtil::null,
|
||||
&LLTabContainer::onPrevBtn, this, LLFontGL::getFontSansSerif() );
|
||||
mPrevArrowBtn->setHeldDownCallback(onPrevBtnHeld);
|
||||
mPrevArrowBtn->setHeldDownCallback(boost::bind(LLTabContainer::onPrevBtnHeld, this));
|
||||
mPrevArrowBtn->setFollowsLeft();
|
||||
|
||||
out_id = "UIImgBtnJumpRightOutUUID";
|
||||
@@ -1717,12 +1717,12 @@ void LLTabContainer::initButtons()
|
||||
}
|
||||
}
|
||||
|
||||
mPrevArrowBtn->setHeldDownCallback(onPrevBtnHeld);
|
||||
mPrevArrowBtn->setHeldDownCallback(boost::bind(&LLTabContainer::onPrevBtnHeld, this));
|
||||
mPrevArrowBtn->setSaveToXML(false);
|
||||
mPrevArrowBtn->setTabStop(FALSE);
|
||||
addChild(mPrevArrowBtn);
|
||||
|
||||
mNextArrowBtn->setHeldDownCallback(onNextBtnHeld);
|
||||
mNextArrowBtn->setHeldDownCallback(boost::bind(&LLTabContainer::onNextBtnHeld, this));
|
||||
mNextArrowBtn->setSaveToXML(false);
|
||||
mNextArrowBtn->setTabStop(FALSE);
|
||||
addChild(mNextArrowBtn);
|
||||
|
||||
@@ -42,6 +42,7 @@ static LLRegisterWidget<LLUICtrl> r("ui_ctrl");
|
||||
// NOTE: the LLFocusableElement implementation has been moved to llfocusmgr.cpp, to mirror the header where the class is defined.
|
||||
|
||||
LLUICtrl::LLUICtrl() :
|
||||
mViewModel(LLViewModelPtr(new LLViewModel)),
|
||||
mCommitSignal(NULL),
|
||||
mValidateSignal(NULL),
|
||||
mCommitCallback(NULL),
|
||||
@@ -62,6 +63,7 @@ LLUICtrl::LLUICtrl(const std::string& name, const LLRect& rect, BOOL mouse_opaqu
|
||||
LLView( name, rect, mouse_opaque, reshape ),
|
||||
mCommitSignal(NULL),
|
||||
mValidateSignal(NULL),
|
||||
mViewModel(LLViewModelPtr(new LLViewModel)),
|
||||
mCommitCallback( on_commit_callback),
|
||||
mValidateCallback( NULL ),
|
||||
mCallbackUserData( callback_userdata ),
|
||||
@@ -101,12 +103,33 @@ BOOL LLUICtrl::isCtrl() const
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLUICtrl::setValue(const LLSD& value)
|
||||
{
|
||||
mViewModel->setValue(value);
|
||||
}
|
||||
|
||||
//virtual
|
||||
LLSD LLUICtrl::getValue() const
|
||||
{
|
||||
return LLSD();
|
||||
return mViewModel->getValue();
|
||||
}
|
||||
|
||||
/// When two widgets are displaying the same data (e.g. during a skin
|
||||
/// change), share their ViewModel.
|
||||
void LLUICtrl::shareViewModelFrom(const LLUICtrl& other)
|
||||
{
|
||||
// Because mViewModel is an LLViewModelPtr, this assignment will quietly
|
||||
// dispose of the previous LLViewModel -- unless it's already shared by
|
||||
// somebody else.
|
||||
mViewModel = other.mViewModel;
|
||||
}
|
||||
|
||||
//virtual
|
||||
LLViewModel* LLUICtrl::getViewModel() const
|
||||
{
|
||||
return mViewModel;
|
||||
}
|
||||
// virtual
|
||||
BOOL LLUICtrl::setTextArg( const std::string& key, const LLStringExplicit& text )
|
||||
{
|
||||
@@ -169,43 +192,12 @@ void LLUICtrl::onFocusReceived()
|
||||
{
|
||||
// trigger callbacks
|
||||
LLFocusableElement::onFocusReceived();
|
||||
|
||||
// find first view in hierarchy above new focus that is a LLUICtrl
|
||||
LLView* viewp = getParent();
|
||||
LLUICtrl* last_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getLastKeyboardFocus());
|
||||
|
||||
while (viewp && !viewp->isCtrl())
|
||||
{
|
||||
viewp = viewp->getParent();
|
||||
}
|
||||
|
||||
// and if it has newly gained focus, call onFocusReceived()
|
||||
LLUICtrl* ctrlp = static_cast<LLUICtrl*>(viewp);
|
||||
if (ctrlp && (!last_focus || !last_focus->hasAncestor(ctrlp)))
|
||||
{
|
||||
ctrlp->onFocusReceived();
|
||||
}
|
||||
}
|
||||
|
||||
void LLUICtrl::onFocusLost()
|
||||
{
|
||||
// trigger callbacks
|
||||
LLFocusableElement::onFocusLost();
|
||||
|
||||
// find first view in hierarchy above old focus that is a LLUICtrl
|
||||
LLView* viewp = getParent();
|
||||
while (viewp && !viewp->isCtrl())
|
||||
{
|
||||
viewp = viewp->getParent();
|
||||
}
|
||||
|
||||
// and if it has just lost focus, call onFocusReceived()
|
||||
LLUICtrl* ctrlp = static_cast<LLUICtrl*>(viewp);
|
||||
// hasFocus() includes any descendants
|
||||
if (ctrlp && !ctrlp->hasFocus())
|
||||
{
|
||||
ctrlp->onFocusLost();
|
||||
}
|
||||
}
|
||||
|
||||
// virtual
|
||||
@@ -229,12 +221,13 @@ BOOL LLUICtrl::acceptsTextInput() const
|
||||
//virtual
|
||||
BOOL LLUICtrl::isDirty() const
|
||||
{
|
||||
return FALSE;
|
||||
return mViewModel->isDirty();
|
||||
};
|
||||
|
||||
//virtual
|
||||
void LLUICtrl::resetDirty()
|
||||
{
|
||||
mViewModel->resetDirty();
|
||||
}
|
||||
|
||||
// virtual
|
||||
|
||||
@@ -38,11 +38,13 @@
|
||||
#include "llrect.h"
|
||||
#include "llsd.h"
|
||||
|
||||
#include "llviewmodel.h" // *TODO move dependency to .cpp file
|
||||
|
||||
class LLUICtrl
|
||||
: public LLView
|
||||
{
|
||||
public:
|
||||
typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> commit_callback_t;
|
||||
typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t;
|
||||
typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t;
|
||||
|
||||
@@ -56,6 +58,10 @@ public:
|
||||
U32 reshape=FOLLOWS_NONE);
|
||||
/*virtual*/ ~LLUICtrl();
|
||||
|
||||
// We need this virtual so we can override it with derived versions
|
||||
virtual LLViewModel* getViewModel() const;
|
||||
// We shouldn't ever need to set this directly
|
||||
//virtual void setViewModel(const LLViewModelPtr&);
|
||||
// LLView interface
|
||||
/*virtual*/ void initFromXML(LLXMLNodePtr node, LLView* parent);
|
||||
/*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
@@ -63,8 +69,6 @@ public:
|
||||
/*virtual*/ void onFocusReceived();
|
||||
/*virtual*/ void onFocusLost();
|
||||
/*virtual*/ BOOL isCtrl() const;
|
||||
/*virtual*/ void setTentative(BOOL b);
|
||||
/*virtual*/ BOOL getTentative() const;
|
||||
|
||||
// From LLFocusableElement
|
||||
/*virtual*/ void setFocus( BOOL b );
|
||||
@@ -77,7 +81,14 @@ public:
|
||||
virtual class LLCtrlListInterface* getListInterface();
|
||||
virtual class LLCtrlScrollInterface* getScrollInterface();
|
||||
|
||||
virtual void setTentative(BOOL b);
|
||||
virtual BOOL getTentative() const;
|
||||
virtual void setValue(const LLSD& value);
|
||||
virtual LLSD getValue() const;
|
||||
/// When two widgets are displaying the same data (e.g. during a skin
|
||||
/// change), share their ViewModel.
|
||||
virtual void shareViewModelFrom(const LLUICtrl& other);
|
||||
|
||||
virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text );
|
||||
virtual void setIsChrome(BOOL is_chrome);
|
||||
|
||||
@@ -141,6 +152,8 @@ protected:
|
||||
|
||||
commit_signal_t* mCommitSignal;
|
||||
enable_signal_t* mValidateSignal;
|
||||
|
||||
LLViewModelPtr mViewModel;
|
||||
void (*mCommitCallback)( LLUICtrl* ctrl, void* userdata );
|
||||
BOOL (*mValidateCallback)( LLUICtrl* ctrl, void* userdata );
|
||||
|
||||
|
||||
@@ -504,16 +504,6 @@ LLRect LLView::getRequiredRect()
|
||||
return mRect;
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLView::onFocusLost()
|
||||
{
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLView::onFocusReceived()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL LLView::focusNextRoot()
|
||||
{
|
||||
LLView::child_list_t result = LLView::getFocusRootsQuery().run(this);
|
||||
|
||||
@@ -411,10 +411,6 @@ public:
|
||||
BOOL getSaveToXML() const { return mSaveToXML; }
|
||||
void setSaveToXML(BOOL b) { mSaveToXML = b; }
|
||||
|
||||
// inherited from LLFocusableElement
|
||||
/* virtual */ void onFocusLost();
|
||||
/* virtual */ void onFocusReceived();
|
||||
|
||||
typedef enum e_hit_test_type
|
||||
{
|
||||
HIT_TEST_USE_BOUNDING_RECT,
|
||||
|
||||
157
indra/llui/llviewmodel.cpp
Normal file
157
indra/llui/llviewmodel.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* @file llviewmodel.cpp
|
||||
* @author Nat Goodspeed
|
||||
* @date 2008-08-08
|
||||
* @brief Implementation for llviewmodel.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&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$
|
||||
*/
|
||||
|
||||
// Precompiled header
|
||||
#include "linden_common.h"
|
||||
// associated header
|
||||
#include "llviewmodel.h"
|
||||
// STL headers
|
||||
// std headers
|
||||
// external library headers
|
||||
// other Linden headers
|
||||
|
||||
///
|
||||
LLViewModel::LLViewModel()
|
||||
: mDirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
/// Instantiate an LLViewModel with an existing data value
|
||||
LLViewModel::LLViewModel(const LLSD& value)
|
||||
: mDirty(false)
|
||||
{
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
/// Update the stored value
|
||||
void LLViewModel::setValue(const LLSD& value)
|
||||
{
|
||||
mValue = value;
|
||||
mDirty = true;
|
||||
}
|
||||
|
||||
LLSD LLViewModel::getValue() const
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///
|
||||
LLTextViewModel::LLTextViewModel()
|
||||
: LLViewModel(false),
|
||||
mUpdateFromDisplay(false)
|
||||
{
|
||||
}
|
||||
|
||||
/// Instantiate an LLViewModel with an existing data value
|
||||
LLTextViewModel::LLTextViewModel(const LLSD& value)
|
||||
: LLViewModel(value),
|
||||
mUpdateFromDisplay(false)
|
||||
{
|
||||
}
|
||||
|
||||
/// Update the stored value
|
||||
void LLTextViewModel::setValue(const LLSD& value)
|
||||
{
|
||||
LLViewModel::setValue(value);
|
||||
mDisplay = utf8str_to_wstring(value.asString());
|
||||
// mDisplay and mValue agree
|
||||
mUpdateFromDisplay = false;
|
||||
}
|
||||
|
||||
void LLTextViewModel::setDisplay(const LLWString& value)
|
||||
{
|
||||
// This is the strange way to alter the value. Normally we'd setValue()
|
||||
// and do the utf8str_to_wstring() to get the corresponding mDisplay
|
||||
// value. But a text editor might want to edit the display string
|
||||
// directly, then convert back to UTF8 on commit.
|
||||
mDisplay = value;
|
||||
mDirty = true;
|
||||
// Don't immediately convert to UTF8 -- do it lazily -- we expect many
|
||||
// more setDisplay() calls than getValue() calls. Just flag that it needs
|
||||
// doing.
|
||||
mUpdateFromDisplay = true;
|
||||
}
|
||||
|
||||
LLSD LLTextViewModel::getValue() const
|
||||
{
|
||||
// Has anyone called setDisplay() since the last setValue()? If so, have
|
||||
// to convert mDisplay back to UTF8.
|
||||
if (mUpdateFromDisplay)
|
||||
{
|
||||
// The fact that we're lazily updating fields in this object should be
|
||||
// transparent to clients, which is why this method is left
|
||||
// conventionally const. Nor do we particularly want to make these
|
||||
// members mutable. Just cast away constness in this one place.
|
||||
LLTextViewModel* nthis = const_cast<LLTextViewModel*>(this);
|
||||
nthis->mUpdateFromDisplay = false;
|
||||
nthis->mValue = wstring_to_utf8str(mDisplay);
|
||||
}
|
||||
return LLViewModel::getValue();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLListViewModel::LLListViewModel(const LLSD& values)
|
||||
: LLViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
void LLListViewModel::addColumn(const LLSD& column, EAddPosition pos)
|
||||
{
|
||||
}
|
||||
|
||||
void LLListViewModel::clearColumns()
|
||||
{
|
||||
}
|
||||
|
||||
void LLListViewModel::setColumnLabel(const std::string& column, const std::string& label)
|
||||
{
|
||||
}
|
||||
|
||||
LLScrollListItem* LLListViewModel::addElement(const LLSD& value, EAddPosition pos,
|
||||
void* userdata)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LLScrollListItem* LLListViewModel::addSimpleElement(const std::string& value, EAddPosition pos,
|
||||
const LLSD& id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void LLListViewModel::clearRows()
|
||||
{
|
||||
}
|
||||
|
||||
void LLListViewModel::sortByColumn(const std::string& name, bool ascending)
|
||||
{
|
||||
}
|
||||
214
indra/llui/llviewmodel.h
Normal file
214
indra/llui/llviewmodel.h
Normal file
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* @file llviewmodel.h
|
||||
* @author Nat Goodspeed
|
||||
* @date 2008-08-08
|
||||
* @brief Define "View Model" classes intended to store data values for use
|
||||
* by LLUICtrl subclasses. The phrase is borrowed from Microsoft
|
||||
* terminology, in which "View Model" means the storage object
|
||||
* underlying a specific widget object -- as in our case -- rather
|
||||
* than the business "model" object underlying the overall "view"
|
||||
* presented by the collection of widgets.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&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$
|
||||
*/
|
||||
|
||||
#if ! defined(LL_LLVIEWMODEL_H)
|
||||
#define LL_LLVIEWMODEL_H
|
||||
|
||||
#include "llpointer.h"
|
||||
#include "llsd.h"
|
||||
#include "llrefcount.h"
|
||||
#include "stdenums.h"
|
||||
#include "llstring.h"
|
||||
#include <string>
|
||||
|
||||
class LLScrollListItem;
|
||||
|
||||
class LLViewModel;
|
||||
class LLTextViewModel;
|
||||
class LLListViewModel;
|
||||
// Because LLViewModel is derived from LLRefCount, always pass, store
|
||||
// and return LLViewModelPtr rather than plain LLViewModel*.
|
||||
typedef LLPointer<LLViewModel> LLViewModelPtr;
|
||||
typedef LLPointer<LLTextViewModel> LLTextViewModelPtr;
|
||||
typedef LLPointer<LLListViewModel> LLListViewModelPtr;
|
||||
|
||||
/**
|
||||
* LLViewModel stores a scalar LLSD data item, the current display value of a
|
||||
* scalar LLUICtrl widget. LLViewModel subclasses are used to store data
|
||||
* collections used for aggregate widgets. LLViewModel is ref-counted because
|
||||
* -- for multiple skins -- we may have distinct widgets sharing the same
|
||||
* LLViewModel data. This way, the LLViewModel is quietly deleted when the
|
||||
* last referencing widget is destroyed.
|
||||
*/
|
||||
class LLViewModel: public LLRefCount
|
||||
{
|
||||
public:
|
||||
LLViewModel();
|
||||
/// Instantiate an LLViewModel with an existing data value
|
||||
LLViewModel(const LLSD& value);
|
||||
|
||||
/// Update the stored value
|
||||
virtual void setValue(const LLSD& value);
|
||||
/// Get the stored value, in appropriate type.
|
||||
virtual LLSD getValue() const;
|
||||
|
||||
/// Has the value been changed since last time we checked?
|
||||
bool isDirty() const { return mDirty; }
|
||||
/// Once the value has been saved to a file, or otherwise consumed by the
|
||||
/// app, we no longer need to enable the Save button
|
||||
void resetDirty() { mDirty = false; }
|
||||
//
|
||||
void setDirty() { mDirty = true; }
|
||||
|
||||
protected:
|
||||
LLSD mValue;
|
||||
bool mDirty;
|
||||
};
|
||||
|
||||
/**
|
||||
* LLTextViewModel stores a value displayed as text.
|
||||
*/
|
||||
class LLTextViewModel: public LLViewModel
|
||||
{
|
||||
public:
|
||||
LLTextViewModel();
|
||||
/// Instantiate an LLViewModel with an existing data value
|
||||
LLTextViewModel(const LLSD& value);
|
||||
|
||||
// LLViewModel functions
|
||||
virtual void setValue(const LLSD& value);
|
||||
virtual LLSD getValue() const;
|
||||
|
||||
// New functions
|
||||
/// Get the stored value in string form
|
||||
const LLWString& getDisplay() const { return mDisplay; }
|
||||
|
||||
/**
|
||||
* Set the display string directly (see LLTextEditor). What the user is
|
||||
* editing is actually the LLWString value rather than the underlying
|
||||
* UTF-8 value.
|
||||
*/
|
||||
void setDisplay(const LLWString& value);
|
||||
|
||||
private:
|
||||
/// To avoid converting every widget's stored value from LLSD to LLWString
|
||||
/// every frame, cache the converted value
|
||||
LLWString mDisplay;
|
||||
/// As the user edits individual characters (setDisplay()), defer
|
||||
/// LLWString-to-UTF8 conversions until s/he's done.
|
||||
bool mUpdateFromDisplay;
|
||||
};
|
||||
|
||||
/**
|
||||
* LLListViewModel stores a list of data items. The semantics are borrowed
|
||||
* from LLScrollListCtrl.
|
||||
*/
|
||||
class LLListViewModel: public LLViewModel
|
||||
{
|
||||
public:
|
||||
LLListViewModel() {}
|
||||
LLListViewModel(const LLSD& values);
|
||||
|
||||
virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM);
|
||||
virtual void clearColumns();
|
||||
virtual void setColumnLabel(const std::string& column, const std::string& label);
|
||||
virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM,
|
||||
void* userdata = NULL);
|
||||
virtual LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos,
|
||||
const LLSD& id);
|
||||
virtual void clearRows();
|
||||
virtual void sortByColumn(const std::string& name, bool ascending);
|
||||
};
|
||||
|
||||
//namespace LLViewModel
|
||||
//{
|
||||
// class Value
|
||||
// {
|
||||
// public:
|
||||
// Value(const LLSD& value = LLSD());
|
||||
//
|
||||
// LLSD getValue() const { return mValue; }
|
||||
// void setValue(const LLSD& value) { mValue = value; }
|
||||
//
|
||||
// bool isAvailable() const { return false; }
|
||||
// bool isReadOnly() const { return false; }
|
||||
//
|
||||
// bool undo() { return false; }
|
||||
// bool redo() { return false; }
|
||||
//
|
||||
// /// Has the value been changed since last time we checked?
|
||||
// bool isDirty() const { return mDirty; }
|
||||
// /// Once the value has been saved to a file, or otherwise consumed by the
|
||||
// /// app, we no longer need to enable the Save button
|
||||
// void resetDirty() { mDirty = false; }
|
||||
// //
|
||||
// void setDirty() { mDirty = true; }
|
||||
//
|
||||
// protected:
|
||||
// LLSD mValue;
|
||||
// bool mDirty;
|
||||
// };
|
||||
//
|
||||
// class Numeric : public Value
|
||||
// {
|
||||
// public:
|
||||
// Numeric(S32 value = 0);
|
||||
// Numeric(F32 value);
|
||||
//
|
||||
// F32 getPrecision();
|
||||
// F32 getMin();
|
||||
// F32 getMax();
|
||||
//
|
||||
// void increment();
|
||||
// void decrement();
|
||||
// };
|
||||
//
|
||||
// class MultipleValues : public Value
|
||||
// {
|
||||
// class Selector
|
||||
// {};
|
||||
//
|
||||
// MultipleValues();
|
||||
// virtual S32 numElements();
|
||||
// };
|
||||
//
|
||||
// class Tuple : public MultipleValues
|
||||
// {
|
||||
// Tuple(S32 size);
|
||||
// LLSD getValue(S32 which) const;
|
||||
// void setValue(S32 which, const LLSD& value);
|
||||
// };
|
||||
//
|
||||
// class List : public MultipleValues
|
||||
// {
|
||||
// List();
|
||||
//
|
||||
// void add(const ValueModel& value);
|
||||
// bool remove(const Selector& item);
|
||||
//
|
||||
// void setSortElement(const Selector& element);
|
||||
// void sort();
|
||||
// };
|
||||
//
|
||||
//};
|
||||
#endif /* ! defined(LL_LLVIEWMODEL_H) */
|
||||
Reference in New Issue
Block a user