This commit is contained in:
Siana Gearz
2011-08-01 19:56:33 +02:00
131 changed files with 18142 additions and 1761 deletions

View File

@@ -431,7 +431,8 @@ public:
void setText(const LLStringExplicit &new_text) { mSearchEdit->setText(new_text); }
void setSearchCallback(void (*search_callback)(const std::string& search_string, void* user_data), void* data) { mSearchCallback = search_callback; mCallbackUserData = data; }
typedef boost::function<void (const std::string&, void *)> search_callback_t;
void setSearchCallback(search_callback_t cb,void *user_data) { mSearchCallback = boost::bind(cb,_1,user_data); }
// LLUICtrl interface
virtual void setValue(const LLSD& value );
@@ -446,7 +447,8 @@ private:
LLLineEditor* mSearchEdit;
class LLButton* mClearSearchButton;
void (*mSearchCallback)(const std::string& search_string, void* user_data);
search_callback_t mSearchCallback;
};

View File

@@ -307,17 +307,10 @@ void LLMultiSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
val = (F32) atof( text.c_str() );
if( self->mMultiSlider->getMinValue() <= val && val <= self->mMultiSlider->getMaxValue() )
{
if( self->mValidateCallback )
self->setCurSliderValue( val );
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) &&
(!self->mValidateSignal || (*(self->mValidateSignal))(self, val)))
{
self->setCurSliderValue( val ); // set the value temporarily so that the callback can retrieve it.
if( self->mValidateCallback( self, self->mCallbackUserData ) )
{
success = TRUE;
}
}
else
{
self->setCurSliderValue( val );
success = TRUE;
}
}
@@ -348,18 +341,11 @@ void LLMultiSliderCtrl::onSliderCommit( LLUICtrl* caller, void *userdata )
F32 saved_val = self->mCurValue;
F32 new_val = self->mMultiSlider->getCurSliderValue();
if( self->mValidateCallback )
self->mCurValue = new_val; // set the value temporarily so that the callback can retrieve it.
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) &&
(!self->mValidateSignal || (*(self->mValidateSignal))(self, new_val )))
{
self->mCurValue = new_val; // set the value temporarily so that the callback can retrieve it.
if( self->mValidateCallback( self, self->mCallbackUserData ) )
{
success = TRUE;
}
}
else
{
self->mCurValue = new_val;
success = TRUE;
}
if( success )

View File

@@ -238,17 +238,10 @@ void LLSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
val = (F32) atof( text.c_str() );
if( self->mSlider->getMinValue() <= val && val <= self->mSlider->getMaxValue() )
{
if( self->mValidateCallback )
self->setValue( val );
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) &&
(!self->mValidateSignal || (*(self->mValidateSignal))( self, val )))
{
self->setValue( val ); // set the value temporarily so that the callback can retrieve it.
if( self->mValidateCallback( self, self->mCallbackUserData ) )
{
success = TRUE;
}
}
else
{
self->setValue( val );
success = TRUE;
}
}
@@ -279,17 +272,10 @@ void LLSliderCtrl::onSliderCommit( LLUICtrl* caller, void *userdata )
F32 saved_val = self->mValue;
F32 new_val = self->mSlider->getValueF32();
if( self->mValidateCallback )
self->mValue = new_val; // set the value temporarily so that the callback can retrieve it.
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) &&
(!self->mValidateSignal || (*(self->mValidateSignal))( self, new_val )))
{
self->mValue = new_val; // set the value temporarily so that the callback can retrieve it.
if( self->mValidateCallback( self, self->mCallbackUserData ) )
{
success = TRUE;
}
}
else
{
self->mValue = new_val;
success = TRUE;
}

View File

@@ -168,21 +168,15 @@ void LLSpinCtrl::onUpBtn( void *userdata )
val = clamp_precision(val, self->mPrecision);
val = llmin( val, self->mMaxValue );
if( self->mValidateCallback )
F32 saved_val = (F32)self->getValue().asReal();
self->setValue(val);
if( (self->mValidateCallback && !self->mValidateCallback( self, self->mCallbackUserData ) ) ||
(self->mValidateSignal && !(*(self->mValidateSignal))( self, val ) ))
{
F32 saved_val = (F32)self->getValue().asReal();
self->setValue(val);
if( !self->mValidateCallback( self, self->mCallbackUserData ) )
{
self->setValue( saved_val );
self->reportInvalidData();
self->updateEditor();
return;
}
}
else
{
self->setValue(val);
self->setValue( saved_val );
self->reportInvalidData();
self->updateEditor();
return;
}
self->updateEditor();
@@ -201,21 +195,19 @@ void LLSpinCtrl::onDownBtn( void *userdata )
val = clamp_precision(val, self->mPrecision);
val = llmax( val, self->mMinValue );
if( self->mValidateCallback )
if (val < self->mMinValue) val = self->mMinValue;
if (val > self->mMaxValue) val = self->mMaxValue;
F32 saved_val = (F32)self->getValue().asReal();
self->setValue(val);
if( (self->mValidateCallback && !self->mValidateCallback( self, self->mCallbackUserData ) ) ||
(self->mValidateSignal && !(*(self->mValidateSignal))( self, val ) ))
{
F32 saved_val = (F32)self->getValue().asReal();
self->setValue(val);
if( !self->mValidateCallback( self, self->mCallbackUserData ) )
{
self->setValue( saved_val );
self->reportInvalidData();
self->updateEditor();
return;
}
}
else
{
self->setValue(val);
self->setValue( saved_val );
self->reportInvalidData();
self->updateEditor();
return;
}
self->updateEditor();
@@ -303,32 +295,20 @@ void LLSpinCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
if (val < self->mMinValue) val = self->mMinValue;
if (val > self->mMaxValue) val = self->mMaxValue;
if( self->mValidateCallback )
F32 saved_val = self->mValue;
self->mValue = val;
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) &&
(!self->mValidateSignal || (*(self->mValidateSignal))(self, val)))
{
F32 saved_val = self->mValue;
self->mValue = val;
if( self->mValidateCallback( self, self->mCallbackUserData ) )
{
success = TRUE;
self->onCommit();
}
else
{
self->mValue = saved_val;
}
success = TRUE;
self->onCommit();
}
else
{
self->mValue = val;
self->onCommit();
success = TRUE;
self->mValue = saved_val;
}
}
else
{
// We want to update the editor in case it fails while blanking -- MC
success = TRUE;
}
if( success )
{

View File

@@ -4095,7 +4095,7 @@ void LLTextEditor::appendHighlightedText(const std::string &new_text,
if (highlight && stylep)
{
LLSD pieces = highlight->parsePartialLineHighlights(new_text, stylep->getColor(), highlight_part);
LLSD pieces = highlight->parsePartialLineHighlights(new_text, stylep->getColor(), (LLTextParser::EHighlightPosition)highlight_part);
bool lprepend=prepend_newline;
for (S32 i=0;i<pieces.size();i++)
{

View File

@@ -43,29 +43,14 @@
#include "v4color.h"
#include "lldir.h"
// Routines used for parsing text for TextParsers and html
LLTextParser* LLTextParser::sInstance = NULL;
//
// Member Functions
//
LLTextParser::~LLTextParser()
{
sInstance=NULL;
}
LLTextParser::LLTextParser()
: mLoaded(false)
{}
// static
LLTextParser* LLTextParser::getInstance()
{
if (!sInstance)
{
sInstance = new LLTextParser();
sInstance->loadFromDisk();
}
return sInstance;
}
// Moved triggerAlerts() to llfloaterchat.cpp to break llui/llaudio library dependency.
@@ -103,8 +88,10 @@ S32 LLTextParser::findPattern(const std::string &text, LLSD highlight)
return found;
}
LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLColor4 &color, S32 part, S32 index)
LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLColor4 &color, EHighlightPosition part, S32 index)
{
loadKeywords();
//evil recursive string atomizer.
LLSD ret_llsd, start_llsd, middle_llsd, end_llsd;
@@ -122,7 +109,7 @@ LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLC
{
S32 end = std::string(mHighlights[i]["pattern"]).length();
S32 len = text.length();
S32 newpart;
EHighlightPosition newpart;
if (start==0)
{
start_llsd[0]["text"] =text.substr(0,end);
@@ -195,6 +182,8 @@ LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLC
bool LLTextParser::parseFullLineHighlights(const std::string &text, LLColor4 *color)
{
loadKeywords();
for (S32 i=0;i<mHighlights.size();i++)
{
if ((S32)mHighlights[i]["highlight"]==ALL || (S32)mHighlights[i]["condition"]==MATCHES)
@@ -221,14 +210,14 @@ std::string LLTextParser::getFileName()
return path;
}
LLSD LLTextParser::loadFromDisk()
void LLTextParser::loadKeywords()
{
std::string filename=getFileName();
if (filename.empty())
{
llwarns << "LLTextParser::loadFromDisk() no valid user directory." << llendl;
if (mLoaded)
{// keywords already loaded
return;
}
else
std::string filename=getFileName();
if (!filename.empty())
{
llifstream file;
file.open(filename.c_str());
@@ -237,9 +226,8 @@ LLSD LLTextParser::loadFromDisk()
LLSDSerialize::fromXML(mHighlights, file);
}
file.close();
mLoaded = true;
}
return mHighlights;
}
bool LLTextParser::saveToDisk(LLSD highlights)

View File

@@ -35,34 +35,34 @@
#define LL_LLTEXTPARSER_H
#include "llsd.h"
#include "llsingleton.h"
class LLUUID;
class LLVector3d;
class LLColor4;
class LLTextParser
class LLTextParser : public LLSingleton<LLTextParser>
{
public:
enum ConditionType { CONTAINS, MATCHES, STARTS_WITH, ENDS_WITH };
enum HighlightType { PART, ALL };
enum HighlightPosition { WHOLE, START, MIDDLE, END };
enum DialogAction { ACTION_NONE, ACTION_CLOSE, ACTION_ADD, ACTION_COPY, ACTION_UPDATE };
typedef enum e_condition_type { CONTAINS, MATCHES, STARTS_WITH, ENDS_WITH } EConditionType;
typedef enum e_highlight_type { PART, ALL } EHighlightType;
typedef enum e_highlight_position { WHOLE, START, MIDDLE, END } EHighlightPosition;
typedef enum e_dialog_action { ACTION_NONE, ACTION_CLOSE, ACTION_ADD, ACTION_COPY, ACTION_UPDATE } EDialogAction;
static LLTextParser* getInstance();
LLTextParser(){};
~LLTextParser();
LLTextParser();
S32 findPattern(const std::string &text, LLSD highlight);
LLSD parsePartialLineHighlights(const std::string &text,const LLColor4 &color,S32 part=WHOLE, S32 index=0);
LLSD parsePartialLineHighlights(const std::string &text,const LLColor4 &color, EHighlightPosition part=WHOLE, S32 index=0);
bool parseFullLineHighlights(const std::string &text, LLColor4 *color);
std::string getFileName();
LLSD loadFromDisk();
bool saveToDisk(LLSD highlights);
public:
LLSD mHighlights;
S32 findPattern(const std::string &text, LLSD highlight);
private:
static LLTextParser* sInstance;
std::string getFileName();
void loadKeywords();
bool saveToDisk(LLSD highlights);
public:
LLSD mHighlights;
bool mLoaded;
};
#endif

View File

@@ -42,6 +42,8 @@ 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() :
mCommitSignal(NULL),
mValidateSignal(NULL),
mCommitCallback(NULL),
mLostTopCallback(NULL),
mValidateCallback(NULL),
@@ -59,7 +61,9 @@ LLUICtrl::LLUICtrl(const std::string& name, const LLRect& rect, BOOL mouse_opaqu
: // can't make this automatically follow top and left, breaks lots
// of buttons in the UI. JC 7/20/2002
LLView( name, rect, mouse_opaque, reshape ),
mCommitCallback( on_commit_callback) ,
mCommitSignal(NULL),
mValidateSignal(NULL),
mCommitCallback( on_commit_callback),
mLostTopCallback( NULL ),
mValidateCallback( NULL ),
mCallbackUserData( callback_userdata ),
@@ -78,6 +82,9 @@ LLUICtrl::~LLUICtrl()
llwarns << "UI Control holding top ctrl deleted: " << getName() << ". Top view removed." << llendl;
gFocusMgr.removeTopCtrlWithoutCallback( this );
}
delete mCommitSignal;
delete mValidateSignal;
}
void LLUICtrl::onCommit()
@@ -86,6 +93,8 @@ void LLUICtrl::onCommit()
{
mCommitCallback( this, mCallbackUserData );
}
if (mCommitSignal)
(*mCommitSignal)(this, getValue());
}
//virtual
@@ -555,3 +564,15 @@ void LLUICtrl::setMinValue(LLSD min_value)
// virtual
void LLUICtrl::setMaxValue(LLSD max_value)
{ }
boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb )
{
if (!mCommitSignal) mCommitSignal = new commit_signal_t();
return mCommitSignal->connect(cb);
}
boost::signals2::connection LLUICtrl::setValidateCallback( const enable_signal_t::slot_type& cb )
{
if (!mValidateSignal) mValidateSignal = new enable_signal_t();
return mValidateSignal->connect(cb);
}

View File

@@ -43,6 +43,9 @@ class LLUICtrl
: public LLView
{
public:
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;
typedef void (*LLUICtrlCallback)(LLUICtrl* ctrl, void* userdata);
typedef BOOL (*LLUICtrlValidate)(LLUICtrl* ctrl, void* userdata);
@@ -111,6 +114,12 @@ public:
LLUICtrl* getParentUICtrl() const;
//Start using these!
boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb );
// *TODO: Deprecate; for backwards compatability only:
//Keeping userdata around with legacy setCommitCallback because it's used ALL OVER THE PLACE.
void* getCallbackUserData() const { return mCallbackUserData; }
void setCallbackUserData( void* data ) { mCallbackUserData = data; }
@@ -132,6 +141,8 @@ public:
protected:
commit_signal_t* mCommitSignal;
enable_signal_t* mValidateSignal;
void (*mCommitCallback)( LLUICtrl* ctrl, void* userdata );
void (*mLostTopCallback)( LLUICtrl* ctrl, void* userdata );
BOOL (*mValidateCallback)( LLUICtrl* ctrl, void* userdata );