UI cleanup.
-Added ui-local transformation matrix. -Gutted legacy commitcallbacks throughout ui widget ctors. -Created filter_editor ui widget which issues commit on keypress -search_editor commits on focus loss/enter press -search_editor and filter_editor now have a built in 'x' button to clear text. -LLComboBox::setPrearrangeCallback now uses boost::function -LLComboBox::setTextEntryCallback now uses boost::function -LLLineEditor::setKeystrokeCallback now uses boost::function -LLLineEditor::setPrevalidate now uses boost::function -LLPanel::childSetKeystrokeCallback removed -LLPanel::childSetPrevalidate removed -LLPanel::childSetActionTextbox now uses boost::function -LLTextBox::setClickedCallback now uses boost::function -LLTextEditor::setKeystrokeCallback added. -Cleaned up JCFloaterAreaSearch
This commit is contained in:
@@ -32,6 +32,7 @@ set(llui_SOURCE_FILES
|
||||
llctrlselectioninterface.cpp
|
||||
lldraghandle.cpp
|
||||
lleditmenuhandler.cpp
|
||||
llfiltereditor.cpp
|
||||
llfloater.cpp
|
||||
llfocusmgr.cpp
|
||||
llfunctorregistry.cpp
|
||||
@@ -57,6 +58,7 @@ set(llui_SOURCE_FILES
|
||||
llscrollcontainer.cpp
|
||||
llscrollingpanellist.cpp
|
||||
llscrolllistctrl.cpp
|
||||
llsearcheditor.cpp
|
||||
llslider.cpp
|
||||
llsliderctrl.cpp
|
||||
llspinctrl.cpp
|
||||
@@ -91,6 +93,7 @@ set(llui_HEADER_FILES
|
||||
llctrlselectioninterface.h
|
||||
lldraghandle.h
|
||||
lleditmenuhandler.h
|
||||
llfiltereditor.h
|
||||
llfloater.h
|
||||
llfocusmgr.h
|
||||
llfunctorregistry.h
|
||||
@@ -116,6 +119,7 @@ set(llui_HEADER_FILES
|
||||
llresizehandle.h
|
||||
llresmgr.h
|
||||
llrootview.h
|
||||
llsearcheditor.h
|
||||
llscrollbar.h
|
||||
llscrollcontainer.h
|
||||
llscrollingpanellist.h
|
||||
|
||||
@@ -251,7 +251,7 @@ LLAlertDialog::LLAlertDialog( LLNotificationPtr notification, bool modal)
|
||||
LLButton* btn = new LLButton(
|
||||
button_data.mName, button_rect,
|
||||
"","", "",
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
font,
|
||||
button_data.mText,
|
||||
button_data.mText);
|
||||
@@ -369,8 +369,7 @@ bool LLAlertDialog::setCheckBox( const std::string& check_title, const std::stri
|
||||
check_rect.setOriginAndSize(msg_x, VPAD+BTN_HEIGHT+LINE_HEIGHT/2,
|
||||
max_msg_width, LINE_HEIGHT);
|
||||
|
||||
mCheck = new LLCheckboxCtrl(std::string("check"), check_rect, check_title, font);
|
||||
mCheck->setCommitCallback(boost::bind(&LLAlertDialog::onClickIgnore, this, _1));
|
||||
mCheck = new LLCheckboxCtrl(std::string("check"), check_rect, check_title, font, boost::bind(&LLAlertDialog::onClickIgnore, this, _1));
|
||||
addChild(mCheck);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -61,8 +61,8 @@ S32 BTN_HEIGHT = 0;
|
||||
S32 BTN_GRID = 12;
|
||||
S32 BORDER_SIZE = 1;
|
||||
|
||||
LLButton::LLButton( const std::string& name, const LLRect& rect, const std::string& control_name, void (*click_callback)(void*), void *callback_data)
|
||||
: LLUICtrl(name, rect, TRUE, NULL, NULL),
|
||||
LLButton::LLButton( const std::string& name, const LLRect& rect, const std::string& control_name, commit_callback_t commit_callback)
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback),
|
||||
|
||||
mMouseDownFrame( 0 ),
|
||||
mMouseHeldDownCount(0),
|
||||
@@ -120,7 +120,7 @@ LLButton::LLButton( const std::string& name, const LLRect& rect, const std::stri
|
||||
mButtonFlashRate(LLUI::sConfigGroup->getF32("ButtonFlashRate")),
|
||||
mAlpha(1.f)
|
||||
{
|
||||
init(click_callback, callback_data, control_name);
|
||||
init(control_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,12 +128,11 @@ LLButton::LLButton(const std::string& name, const LLRect& rect,
|
||||
const std::string &unselected_image_name,
|
||||
const std::string &selected_image_name,
|
||||
const std::string& control_name,
|
||||
void (*click_callback)(void*),
|
||||
void *callback_data,
|
||||
commit_callback_t commit_callback,
|
||||
const LLFontGL *font,
|
||||
const std::string& unselected_label,
|
||||
const std::string& selected_label )
|
||||
: LLUICtrl(name, rect, TRUE, NULL, NULL),
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback),
|
||||
mMouseDownFrame( 0 ),
|
||||
mMouseHeldDownCount(0),
|
||||
mBorderEnabled( FALSE ),
|
||||
@@ -215,10 +214,10 @@ LLButton::LLButton(const std::string& name, const LLRect& rect,
|
||||
mImagePressed = mImageSelected;
|
||||
}
|
||||
|
||||
init(click_callback, callback_data, control_name);
|
||||
init(control_name);
|
||||
}
|
||||
|
||||
void LLButton::init(void (*click_callback)(void*), void *callback_data, const std::string& control_name)
|
||||
void LLButton::init(const std::string& control_name)
|
||||
{
|
||||
// Hack to make sure there is space for at least one character
|
||||
if (getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(std::string(" ")))
|
||||
@@ -230,11 +229,7 @@ void LLButton::init(void (*click_callback)(void*), void *callback_data, const st
|
||||
|
||||
mMouseDownTimer.stop();
|
||||
|
||||
if(click_callback)
|
||||
setClickedCallback(click_callback, callback_data);
|
||||
|
||||
setControlName(control_name, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1219,7 +1214,6 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa
|
||||
image_selected,
|
||||
LLStringUtil::null,
|
||||
NULL,
|
||||
parent,
|
||||
font,
|
||||
label,
|
||||
label_selected);
|
||||
|
||||
@@ -75,15 +75,14 @@ class LLButton
|
||||
{
|
||||
public:
|
||||
// simple button with text label
|
||||
LLButton(const std::string& name, const LLRect &rect, const std::string& control_name = std::string(),
|
||||
void (*on_click)(void*) = NULL, void *data = NULL);
|
||||
LLButton(const std::string& name, const LLRect &rect = LLRect(), const std::string& control_name = std::string(),
|
||||
commit_callback_t commit_callback = NULL);
|
||||
|
||||
LLButton(const std::string& name, const LLRect& rect,
|
||||
const std::string &unselected_image,
|
||||
const std::string &selected_image,
|
||||
const std::string& control_name,
|
||||
void (*click_callback)(void*),
|
||||
void *callback_data = NULL,
|
||||
commit_callback_t commit_callback,
|
||||
const LLFontGL* mGLFont = NULL,
|
||||
const std::string& unselected_label = LLStringUtil::null,
|
||||
const std::string& selected_label = LLStringUtil::null );
|
||||
@@ -94,7 +93,7 @@ public:
|
||||
typedef boost::function<void(void*)> button_callback_t;
|
||||
|
||||
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);
|
||||
void init(const std::string& control_name);
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
||||
|
||||
|
||||
@@ -55,12 +55,11 @@ static LLRegisterWidget<LLCheckBoxCtrl> r("check_box");
|
||||
LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect,
|
||||
const std::string& label,
|
||||
const LLFontGL* font,
|
||||
void (*commit_callback)(LLUICtrl* ctrl, void* userdata),
|
||||
void* callback_user_data,
|
||||
commit_callback_t commit_callback,
|
||||
BOOL initial_value,
|
||||
BOOL use_radio_style,
|
||||
const std::string& control_which)
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ),
|
||||
mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ),
|
||||
mRadioStyle( use_radio_style ),
|
||||
@@ -122,7 +121,7 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect,
|
||||
|
||||
mButton = new LLButton( button_name, btn_rect,
|
||||
active_false_id, active_true_id, control_which,
|
||||
&LLCheckBoxCtrl::onButtonPress, this, LLFontGL::getFontSansSerif() );
|
||||
boost::bind(&LLCheckBoxCtrl::onButtonPress, this, _2), LLFontGL::getFontSansSerif() );
|
||||
|
||||
mButton->setImageDisabledSelected(LLUI::getUIImage(inactive_true_id));
|
||||
mButton->setImageDisabled(LLUI::getUIImage(inactive_false_id));
|
||||
@@ -144,10 +143,14 @@ LLCheckBoxCtrl::~LLCheckBoxCtrl()
|
||||
|
||||
|
||||
// static
|
||||
void LLCheckBoxCtrl::onButtonPress( void *userdata )
|
||||
void LLCheckBoxCtrl::onButtonPress( const LLSD& data )
|
||||
{
|
||||
LLCheckBoxCtrl* self = (LLCheckBoxCtrl*)userdata;
|
||||
self->onCommit();
|
||||
//if (mRadioStyle)
|
||||
//{
|
||||
// setValue(TRUE);
|
||||
//}
|
||||
|
||||
onCommit();
|
||||
}
|
||||
|
||||
void LLCheckBoxCtrl::onCommit()
|
||||
@@ -315,8 +318,6 @@ LLView* LLCheckBoxCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto
|
||||
BOOL radio_style = FALSE;
|
||||
node->getAttributeBOOL("radio_style", radio_style);
|
||||
|
||||
LLUICtrlCallback callback = NULL;
|
||||
|
||||
if (label.empty())
|
||||
{
|
||||
label.assign(node->getTextContents());
|
||||
@@ -329,7 +330,6 @@ LLView* LLCheckBoxCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto
|
||||
rect,
|
||||
label,
|
||||
font,
|
||||
callback,
|
||||
NULL,
|
||||
FALSE,
|
||||
radio_style); // if true, draw radio button style icons
|
||||
|
||||
@@ -68,8 +68,7 @@ class LLCheckBoxCtrl
|
||||
public:
|
||||
LLCheckBoxCtrl(const std::string& name, const LLRect& rect, const std::string& label,
|
||||
const LLFontGL* font = NULL,
|
||||
void (*commit_callback)(LLUICtrl*, void*) = NULL,
|
||||
void* callback_userdata = NULL,
|
||||
commit_callback_t commit_callback = NULL,
|
||||
BOOL initial_value = FALSE,
|
||||
BOOL use_radio_style = FALSE, // if true, draw radio button style icons
|
||||
const std::string& control_which = LLStringUtil::null);
|
||||
@@ -113,7 +112,7 @@ public:
|
||||
virtual void setControlName(const std::string& control_name, LLView* context);
|
||||
virtual std::string getControlName() const;
|
||||
|
||||
static void onButtonPress(void *userdata);
|
||||
void onButtonPress(const LLSD& data);
|
||||
|
||||
virtual BOOL isDirty() const; // Returns TRUE if the user has modified this control.
|
||||
virtual void resetDirty(); // Clear dirty state
|
||||
|
||||
@@ -61,11 +61,8 @@ S32 MAX_COMBO_WIDTH = 500;
|
||||
static LLRegisterWidget<LLComboBox> r1("combo_box");
|
||||
|
||||
LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::string& label,
|
||||
void (*commit_callback)(LLUICtrl*,void*),
|
||||
void *callback_userdata
|
||||
)
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback, callback_userdata,
|
||||
FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
commit_callback_t commit_callback)
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mTextEntry(NULL),
|
||||
mArrowImage(NULL),
|
||||
mAllowTextEntry(FALSE),
|
||||
@@ -83,15 +80,14 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::
|
||||
// Text label button
|
||||
mButton = new LLButton(mLabel,
|
||||
LLRect(),
|
||||
LLStringUtil::null,
|
||||
NULL, this);
|
||||
LLStringUtil::null);
|
||||
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(boost::bind(&LLComboBox::onButtonDown,this));
|
||||
mButton->setMouseDownCallback(boost::bind(&LLComboBox::onButtonMouseDown,this));
|
||||
mButton->setFont(LLFontGL::getFontSansSerifSmall());
|
||||
mButton->setFollows(FOLLOWS_LEFT | FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
|
||||
mButton->setHAlign( LLFontGL::LEFT );
|
||||
@@ -100,7 +96,7 @@ LLComboBox::LLComboBox( const std::string& name, const LLRect &rect, const std::
|
||||
|
||||
// disallow multiple selection
|
||||
mList = new LLScrollListCtrl(std::string("ComboBox"), LLRect(),
|
||||
&LLComboBox::onItemSelected, this, FALSE);
|
||||
boost::bind(&LLComboBox::onItemSelected, this), FALSE);
|
||||
mList->setVisible(FALSE);
|
||||
mList->setBgWriteableColor(mListColor);
|
||||
mList->setCommitOnKeyboardMovement(FALSE);
|
||||
@@ -168,13 +164,9 @@ LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
|
||||
S32 max_chars = 20;
|
||||
node->getAttributeS32("max_chars", max_chars);
|
||||
|
||||
LLUICtrlCallback callback = NULL;
|
||||
|
||||
LLComboBox* combo_box = new LLComboBox(name,
|
||||
rect,
|
||||
label,
|
||||
callback,
|
||||
NULL);
|
||||
label);
|
||||
combo_box->setAllowTextEntry(allow_text_entry, max_chars);
|
||||
|
||||
const std::string& contents = node->getValue();
|
||||
@@ -550,10 +542,8 @@ void LLComboBox::updateLayout()
|
||||
LLStringUtil::null,
|
||||
LLFontGL::getFontSansSerifSmall(),
|
||||
mMaxChars,
|
||||
onTextCommit,
|
||||
onTextEntry,
|
||||
NULL,
|
||||
this);
|
||||
boost::bind(&LLComboBox::onTextCommit, this, _2),
|
||||
boost::bind(&LLComboBox::onTextEntry, this, _1));
|
||||
mTextEntry->setSelectAllonFocusReceived(TRUE);
|
||||
mTextEntry->setHandleEditKeysDirectly(TRUE);
|
||||
mTextEntry->setCommitOnFocusLost(FALSE);
|
||||
@@ -720,31 +710,27 @@ void LLComboBox::hideList()
|
||||
// static functions
|
||||
//------------------------------------------------------------------
|
||||
|
||||
// static
|
||||
void LLComboBox::onButtonDown(void *userdata)
|
||||
void LLComboBox::onButtonMouseDown()
|
||||
{
|
||||
LLComboBox *self = (LLComboBox *)userdata;
|
||||
|
||||
if (!self->mList->getVisible())
|
||||
if (!mList->getVisible())
|
||||
{
|
||||
LLScrollListItem* last_selected_item = self->mList->getLastSelectedItem();
|
||||
// this might change selection, so do it first
|
||||
prearrangeList();
|
||||
|
||||
// highlight the last selected item from the original selection before potentially selecting a new item
|
||||
// as visual cue to original value of combo box
|
||||
LLScrollListItem* last_selected_item = mList->getLastSelectedItem();
|
||||
if (last_selected_item)
|
||||
{
|
||||
// highlight the original selection before potentially selecting a new item
|
||||
self->mList->mouseOverHighlightNthItem(self->mList->getItemIndex(last_selected_item));
|
||||
mList->mouseOverHighlightNthItem(mList->getItemIndex(last_selected_item));
|
||||
}
|
||||
|
||||
if( self->mPrearrangeCallback )
|
||||
if (mList->getItemCount() != 0)
|
||||
{
|
||||
self->mPrearrangeCallback( self, self->mCallbackUserData );
|
||||
showList();
|
||||
}
|
||||
|
||||
if (self->mList->getItemCount() != 0)
|
||||
{
|
||||
self->showList();
|
||||
}
|
||||
|
||||
self->setFocus( TRUE );
|
||||
setFocus( TRUE );
|
||||
|
||||
// pass mouse capture on to list if button is depressed
|
||||
/*if (self->mButton->hasMouseCapture())
|
||||
@@ -754,36 +740,33 @@ void LLComboBox::onButtonDown(void *userdata)
|
||||
}
|
||||
else
|
||||
{
|
||||
self->hideList();
|
||||
hideList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// static
|
||||
void LLComboBox::onItemSelected(LLUICtrl* item, void *userdata)
|
||||
void LLComboBox::onItemSelected()
|
||||
{
|
||||
// Note: item is the LLScrollListCtrl
|
||||
LLComboBox *self = (LLComboBox *) userdata;
|
||||
const std::string name = mList->getSelectedItemLabel();
|
||||
|
||||
const std::string name = self->mList->getSelectedItemLabel();
|
||||
|
||||
S32 cur_id = self->getCurrentIndex();
|
||||
S32 cur_id = getCurrentIndex();
|
||||
if (cur_id != -1)
|
||||
{
|
||||
self->setLabel(name);
|
||||
setLabel(name);
|
||||
|
||||
if (self->mAllowTextEntry)
|
||||
if (mAllowTextEntry)
|
||||
{
|
||||
gFocusMgr.setKeyboardFocus(self->mTextEntry);
|
||||
self->mTextEntry->selectAll();
|
||||
gFocusMgr.setKeyboardFocus(mTextEntry);
|
||||
mTextEntry->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
// hiding the list reasserts the old value stored in the text editor/dropdown button
|
||||
self->hideList();
|
||||
hideList();
|
||||
|
||||
// commit does the reverse, asserting the value in the list
|
||||
self->onCommit();
|
||||
onCommit();
|
||||
}
|
||||
|
||||
BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
|
||||
@@ -908,28 +891,26 @@ const std::string LLComboBox::getTextEntry() const
|
||||
return mTextEntry->getText();
|
||||
}
|
||||
|
||||
//static
|
||||
void LLComboBox::onTextEntry(LLLineEditor* line_editor, void* user_data)
|
||||
void LLComboBox::onTextEntry(LLLineEditor* line_editor)
|
||||
{
|
||||
LLComboBox* self = (LLComboBox*)user_data;
|
||||
|
||||
if (self->mTextEntryCallback)
|
||||
if (mTextEntryCallback != NULL)
|
||||
{
|
||||
(*self->mTextEntryCallback)(line_editor, self->mCallbackUserData);
|
||||
(mTextEntryCallback)(line_editor, LLSD());
|
||||
}
|
||||
|
||||
KEY key = gKeyboard->currentKey();
|
||||
if (key == KEY_BACKSPACE ||
|
||||
key == KEY_DELETE)
|
||||
{
|
||||
if (self->mList->selectItemByLabel(line_editor->getText(), FALSE))
|
||||
if (mList->selectItemByLabel(line_editor->getText(), FALSE))
|
||||
{
|
||||
line_editor->setTentative(FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!self->mSuppressTentative) line_editor->setTentative(self->mTextEntryTentative);
|
||||
self->mList->deselectAllItems();
|
||||
if (!mSuppressTentative)
|
||||
line_editor->setTentative(mTextEntryTentative);
|
||||
mList->deselectAllItems();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -942,17 +923,14 @@ void LLComboBox::onTextEntry(LLLineEditor* line_editor, void* user_data)
|
||||
|
||||
if (key == KEY_DOWN)
|
||||
{
|
||||
self->setCurrentByIndex(llmin(self->getItemCount() - 1, self->getCurrentIndex() + 1));
|
||||
if (!self->mList->getVisible())
|
||||
setCurrentByIndex(llmin(getItemCount() - 1, getCurrentIndex() + 1));
|
||||
if (!mList->getVisible())
|
||||
{
|
||||
if( self->mPrearrangeCallback )
|
||||
{
|
||||
self->mPrearrangeCallback( self, self->mCallbackUserData );
|
||||
}
|
||||
prearrangeList();
|
||||
|
||||
if (self->mList->getItemCount() != 0)
|
||||
if (mList->getItemCount() != 0)
|
||||
{
|
||||
self->showList();
|
||||
showList();
|
||||
}
|
||||
}
|
||||
line_editor->selectAll();
|
||||
@@ -960,17 +938,14 @@ void LLComboBox::onTextEntry(LLLineEditor* line_editor, void* user_data)
|
||||
}
|
||||
else if (key == KEY_UP)
|
||||
{
|
||||
self->setCurrentByIndex(llmax(0, self->getCurrentIndex() - 1));
|
||||
if (!self->mList->getVisible())
|
||||
setCurrentByIndex(llmax(0, getCurrentIndex() - 1));
|
||||
if (!mList->getVisible())
|
||||
{
|
||||
if( self->mPrearrangeCallback )
|
||||
{
|
||||
self->mPrearrangeCallback( self, self->mCallbackUserData );
|
||||
}
|
||||
prearrangeList();
|
||||
|
||||
if (self->mList->getItemCount() != 0)
|
||||
if (mList->getItemCount() != 0)
|
||||
{
|
||||
self->showList();
|
||||
showList();
|
||||
}
|
||||
}
|
||||
line_editor->selectAll();
|
||||
@@ -979,7 +954,7 @@ void LLComboBox::onTextEntry(LLLineEditor* line_editor, void* user_data)
|
||||
else
|
||||
{
|
||||
// RN: presumably text entry
|
||||
self->updateSelection();
|
||||
updateSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,10 +975,7 @@ void LLComboBox::updateSelection()
|
||||
// callback to populate content
|
||||
if( mTextEntry->getWText().size() == 1 )
|
||||
{
|
||||
if (mPrearrangeCallback)
|
||||
{
|
||||
mPrearrangeCallback( this, mCallbackUserData );
|
||||
}
|
||||
prearrangeList(mTextEntry->getText());
|
||||
}
|
||||
|
||||
if (mList->selectItemByLabel(full_string, FALSE))
|
||||
@@ -1027,14 +999,12 @@ void LLComboBox::updateSelection()
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void LLComboBox::onTextCommit(LLUICtrl* caller, void* user_data)
|
||||
void LLComboBox::onTextCommit(const LLSD& data)
|
||||
{
|
||||
LLComboBox* self = (LLComboBox*)user_data;
|
||||
std::string text = self->mTextEntry->getText();
|
||||
self->setSimple(text);
|
||||
self->onCommit();
|
||||
self->mTextEntry->selectAll();
|
||||
std::string text = mTextEntry->getText();
|
||||
setSimple(text);
|
||||
onCommit();
|
||||
mTextEntry->selectAll();
|
||||
}
|
||||
|
||||
void LLComboBox::setSuppressTentative(bool suppress)
|
||||
@@ -1081,6 +1051,14 @@ void LLComboBox::setPrevalidate( BOOL (*func)(const LLWString &) )
|
||||
if (mTextEntry) mTextEntry->setPrevalidate(func);
|
||||
}
|
||||
|
||||
void LLComboBox::prearrangeList(std::string filter)
|
||||
{
|
||||
if (mPrearrangeCallback)
|
||||
{
|
||||
mPrearrangeCallback(this, LLSD(filter));
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// LLCtrlListInterface functions
|
||||
|
||||
@@ -1201,20 +1179,16 @@ const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24;
|
||||
LLFlyoutButton::LLFlyoutButton(
|
||||
const std::string& name,
|
||||
const LLRect &rect,
|
||||
const std::string& label,
|
||||
void (*commit_callback)(LLUICtrl*, void*) ,
|
||||
void *callback_userdata)
|
||||
: LLComboBox(name, rect, LLStringUtil::null, commit_callback, callback_userdata),
|
||||
const std::string& label)
|
||||
: LLComboBox(name, rect, LLStringUtil::null),
|
||||
mToggleState(FALSE),
|
||||
mActionButton(NULL)
|
||||
{
|
||||
// Always use text box
|
||||
// Text label button
|
||||
mActionButton = new LLButton(label,
|
||||
LLRect(), LLStringUtil::null, NULL, this);
|
||||
LLRect(), LLStringUtil::null, boost::bind(&LLFlyoutButton::onActionButtonClick, this));
|
||||
mActionButton->setScaleImage(TRUE);
|
||||
|
||||
mActionButton->setClickedCallback(boost::bind(&LLFlyoutButton::onActionButtonClick, this));
|
||||
mActionButton->setFollowsAll();
|
||||
mActionButton->setHAlign( LLFontGL::HCENTER );
|
||||
mActionButton->setLabel(label);
|
||||
@@ -1280,13 +1254,9 @@ LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto
|
||||
LLRect rect;
|
||||
createRect(node, rect, parent, LLRect());
|
||||
|
||||
LLUICtrlCallback callback = NULL;
|
||||
|
||||
LLFlyoutButton* flyout_button = new LLFlyoutButton(name,
|
||||
rect,
|
||||
label,
|
||||
callback,
|
||||
NULL);
|
||||
label);
|
||||
|
||||
std::string list_position;
|
||||
node->getAttributeString("list_position", list_position);
|
||||
@@ -1335,13 +1305,11 @@ void LLFlyoutButton::updateLayout()
|
||||
mActionButton->reshape(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight());
|
||||
}
|
||||
|
||||
//static
|
||||
void LLFlyoutButton::onActionButtonClick(void *user_data)
|
||||
void LLFlyoutButton::onActionButtonClick()
|
||||
{
|
||||
LLFlyoutButton* buttonp = (LLFlyoutButton*)user_data;
|
||||
// remember last list selection?
|
||||
buttonp->mList->deselect();
|
||||
buttonp->onCommit();
|
||||
mList->deselect();
|
||||
onCommit();
|
||||
}
|
||||
|
||||
void LLFlyoutButton::draw()
|
||||
|
||||
@@ -68,11 +68,13 @@ public:
|
||||
const std::string& name,
|
||||
const LLRect &rect,
|
||||
const std::string& label,
|
||||
void (*commit_callback)(LLUICtrl*, void*) = NULL,
|
||||
void *callback_userdata = NULL
|
||||
commit_callback_t commit_callback = NULL
|
||||
);
|
||||
virtual ~LLComboBox();
|
||||
protected:
|
||||
void prearrangeList(std::string filter = "");
|
||||
|
||||
public:
|
||||
// LLView interface
|
||||
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
@@ -176,15 +178,16 @@ public:
|
||||
|
||||
void* getCurrentUserdata();
|
||||
|
||||
void setPrearrangeCallback( void (*cb)(LLUICtrl*,void*) ) { mPrearrangeCallback = cb; }
|
||||
void setTextEntryCallback( void (*cb)(LLLineEditor*, void*) ) { mTextEntryCallback = cb; }
|
||||
void setPrearrangeCallback( commit_callback_t cb ) { mPrearrangeCallback = cb; }
|
||||
void setTextEntryCallback( commit_callback_t cb ) { mTextEntryCallback = cb; }
|
||||
|
||||
|
||||
void setButtonVisible(BOOL visible);
|
||||
|
||||
static void onButtonDown(void *userdata);
|
||||
static void onItemSelected(LLUICtrl* item, void *userdata);
|
||||
static void onTextEntry(LLLineEditor* line_editor, void* user_data);
|
||||
static void onTextCommit(LLUICtrl* caller, void* user_data);
|
||||
void onButtonMouseDown();
|
||||
void onItemSelected();
|
||||
|
||||
void onTextCommit(const LLSD& data);
|
||||
|
||||
void setSuppressTentative(bool suppress);
|
||||
void setSuppressAutoComplete(bool suppress);
|
||||
@@ -193,8 +196,11 @@ public:
|
||||
virtual void showList();
|
||||
virtual void hideList();
|
||||
|
||||
virtual void onTextEntry(LLLineEditor* line_editor);
|
||||
|
||||
protected:
|
||||
LLButton* mButton;
|
||||
LLLineEditor* mTextEntry;
|
||||
LLScrollListCtrl* mList;
|
||||
EPreferredPosition mListPosition;
|
||||
LLPointer<LLUIImage> mArrowImage;
|
||||
@@ -203,14 +209,13 @@ protected:
|
||||
|
||||
private:
|
||||
S32 mButtonPadding;
|
||||
LLLineEditor* mTextEntry;
|
||||
BOOL mAllowTextEntry;
|
||||
S32 mMaxChars;
|
||||
BOOL mTextEntryTentative;
|
||||
bool mSuppressAutoComplete;
|
||||
bool mSuppressTentative;
|
||||
void (*mPrearrangeCallback)(LLUICtrl*,void*);
|
||||
void (*mTextEntryCallback)(LLLineEditor*, void*);
|
||||
commit_callback_t mPrearrangeCallback;
|
||||
commit_callback_t mTextEntryCallback;
|
||||
boost::signals2::connection mTopLostSignalConnection;
|
||||
};
|
||||
|
||||
@@ -220,9 +225,7 @@ public:
|
||||
LLFlyoutButton(
|
||||
const std::string& name,
|
||||
const LLRect &rect,
|
||||
const std::string& label,
|
||||
void (*commit_callback)(LLUICtrl*, void*) = NULL,
|
||||
void *callback_userdata = NULL);
|
||||
const std::string& label);
|
||||
|
||||
virtual void updateLayout();
|
||||
virtual void draw();
|
||||
@@ -232,8 +235,8 @@ public:
|
||||
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
||||
static void onActionButtonClick(void *userdata);
|
||||
static void onSelectAction(LLUICtrl* ctrl, void *userdata);
|
||||
void onActionButtonClick();
|
||||
void onSelectAction(LLUICtrl* ctrl);
|
||||
|
||||
protected:
|
||||
LLButton* mActionButton;
|
||||
|
||||
81
indra/llui/llfiltereditor.cpp
Normal file
81
indra/llui/llfiltereditor.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @file llfiltereditor.cpp
|
||||
* @brief LLFilterEditor implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
// Text editor widget to let users enter a single line.
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llfiltereditor.h"
|
||||
|
||||
static LLRegisterWidget<LLFilterEditor> r2("filter_editor");
|
||||
|
||||
LLFilterEditor::LLFilterEditor(const std::string& name,
|
||||
const LLRect& rect,
|
||||
S32 max_length_bytes)
|
||||
: LLSearchEditor(name,rect,max_length_bytes)
|
||||
{
|
||||
setCommitOnFocusLost(FALSE); // we'll commit on every keystroke, don't re-commit when we take focus away (i.e. we go to interact with the actual results!)
|
||||
}
|
||||
|
||||
|
||||
void LLFilterEditor::handleKeystroke()
|
||||
{
|
||||
this->LLSearchEditor::handleKeystroke();
|
||||
|
||||
// Commit on every keystroke.
|
||||
onCommit();
|
||||
}
|
||||
|
||||
// static
|
||||
LLView* LLFilterEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
|
||||
{
|
||||
std::string name("filter_editor");
|
||||
node->getAttributeString("name", name);
|
||||
|
||||
LLRect rect;
|
||||
createRect(node, rect, parent, LLRect());
|
||||
|
||||
S32 max_text_length = 128;
|
||||
node->getAttributeS32("max_length", max_text_length);
|
||||
|
||||
std::string text = node->getValue().substr(0, max_text_length - 1);
|
||||
|
||||
LLFilterEditor* search_editor = new LLFilterEditor(name,
|
||||
rect,
|
||||
max_text_length);
|
||||
|
||||
std::string label;
|
||||
if(node->getAttributeString("label", label))
|
||||
{
|
||||
search_editor->setLabel(label);
|
||||
}
|
||||
|
||||
search_editor->setText(text);
|
||||
|
||||
search_editor->initFromXML(node, parent);
|
||||
|
||||
return search_editor;
|
||||
}
|
||||
54
indra/llui/llfiltereditor.h
Normal file
54
indra/llui/llfiltereditor.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file llfiltereditor.h
|
||||
* @brief Text editor widget that represents a filter operation
|
||||
*
|
||||
* Features:
|
||||
* Text entry of a single line (text, delete, left and right arrow, insert, return).
|
||||
* Callbacks either on every keystroke or just on the return key.
|
||||
* Focus (allow multiple text entry widgets)
|
||||
* Clipboard (cut, copy, and paste)
|
||||
* Horizontal scrolling to allow strings longer than widget size allows
|
||||
* Pre-validation (limit which keys can be used)
|
||||
* Optional line history so previous entries can be recalled by CTRL UP/DOWN
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_FILTEREDITOR_H
|
||||
#define LL_FILTEREDITOR_H
|
||||
|
||||
#include "llsearcheditor.h"
|
||||
|
||||
class LLFilterEditor : public LLSearchEditor
|
||||
{
|
||||
public:
|
||||
LLFilterEditor(const std::string& name,
|
||||
const LLRect& rect,
|
||||
S32 max_length_bytes);
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
||||
protected:
|
||||
friend class LLUICtrlFactory;
|
||||
|
||||
/*virtual*/ void handleKeystroke();
|
||||
};
|
||||
|
||||
#endif // LL_FILTEREDITOR_H
|
||||
@@ -113,13 +113,14 @@ std::string LLFloater::sButtonToolTips[BUTTON_COUNT] =
|
||||
"Edit", //BUTTON_EDIT
|
||||
};
|
||||
|
||||
LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] =
|
||||
|
||||
LLFloater::button_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] =
|
||||
{
|
||||
LLFloater::onClickClose, //BUTTON_CLOSE
|
||||
LLFloater::onClickMinimize, //BUTTON_RESTORE
|
||||
LLFloater::onClickMinimize, //BUTTON_MINIMIZE
|
||||
LLFloater::onClickTearOff, //BUTTON_TEAR_OFF
|
||||
LLFloater::onClickEdit, //BUTTON_EDIT
|
||||
&LLFloater::onClickClose, //BUTTON_CLOSE
|
||||
&LLFloater::onClickMinimize, //BUTTON_RESTORE
|
||||
&LLFloater::onClickMinimize, //BUTTON_MINIMIZE
|
||||
&LLFloater::onClickTearOff, //BUTTON_TEAR_OFF
|
||||
&LLFloater::onClickEdit, //BUTTON_EDIT
|
||||
};
|
||||
|
||||
LLMultiFloater* LLFloater::sHostp = NULL;
|
||||
@@ -1286,60 +1287,49 @@ void LLFloater::setEditModeEnabled(BOOL enable)
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
void LLFloater::onClickMinimize(void *userdata)
|
||||
void LLFloater::onClickMinimize()
|
||||
{
|
||||
LLFloater* self = (LLFloater*) userdata;
|
||||
if (!self) return;
|
||||
|
||||
self->setMinimized( !self->isMinimized() );
|
||||
setMinimized( !isMinimized() );
|
||||
}
|
||||
|
||||
void LLFloater::onClickTearOff(void *userdata)
|
||||
void LLFloater::onClickTearOff()
|
||||
{
|
||||
LLFloater* self = (LLFloater*) userdata;
|
||||
if (!self) return;
|
||||
|
||||
LLMultiFloater* host_floater = self->getHost();
|
||||
LLMultiFloater* host_floater = getHost();
|
||||
if (host_floater) //Tear off
|
||||
{
|
||||
LLRect new_rect;
|
||||
host_floater->removeFloater(self);
|
||||
host_floater->removeFloater(this);
|
||||
// reparent to floater view
|
||||
gFloaterView->addChild(self);
|
||||
gFloaterView->addChild(this);
|
||||
|
||||
self->open(); /* Flawfinder: ignore */
|
||||
open(); /* Flawfinder: ignore */
|
||||
|
||||
// only force position for floaters that don't have that data saved
|
||||
if (self->getRectControl().empty())
|
||||
if (getRectControl().empty())
|
||||
{
|
||||
new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - LLFLOATER_HEADER_SIZE - 5, self->getRect().getWidth(), self->getRect().getHeight());
|
||||
self->setRect(new_rect);
|
||||
new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - LLFLOATER_HEADER_SIZE - 5, getRect().getWidth(), getRect().getHeight());
|
||||
setRect(new_rect);
|
||||
}
|
||||
gFloaterView->adjustToFitScreen(self, FALSE);
|
||||
gFloaterView->adjustToFitScreen(this, FALSE);
|
||||
// give focus to new window to keep continuity for the user
|
||||
self->setFocus(TRUE);
|
||||
setFocus(TRUE);
|
||||
}
|
||||
else //Attach to parent.
|
||||
{
|
||||
LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get();
|
||||
LLMultiFloater* new_host = (LLMultiFloater*)mLastHostHandle.get();
|
||||
if (new_host)
|
||||
{
|
||||
self->setMinimized(FALSE); // to reenable minimize button if it was minimized
|
||||
new_host->showFloater(self);
|
||||
setMinimized(FALSE); // to reenable minimize button if it was minimized
|
||||
new_host->showFloater(this);
|
||||
// make sure host is visible
|
||||
new_host->open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLFloater::onClickEdit(void *userdata)
|
||||
void LLFloater::onClickEdit()
|
||||
{
|
||||
LLFloater* self = (LLFloater*) userdata;
|
||||
if (!self) return;
|
||||
|
||||
self->mEditing = self->mEditing ? FALSE : TRUE;
|
||||
mEditing = mEditing ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -1393,13 +1383,9 @@ void LLFloater::closeFocusedFloater()
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
void LLFloater::onClickClose( void* userdata )
|
||||
void LLFloater::onClickClose()
|
||||
{
|
||||
LLFloater* self = (LLFloater*) userdata;
|
||||
if (!self) return;
|
||||
|
||||
self->close();
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1716,8 +1702,7 @@ void LLFloater::buildButtons()
|
||||
sButtonActiveImageNames[i],
|
||||
sButtonPressedImageNames[i],
|
||||
LLStringUtil::null,
|
||||
sButtonCallbacks[i],
|
||||
this,
|
||||
boost::bind(sButtonCallbacks[i],this),
|
||||
LLFontGL::getFontSansSerif());
|
||||
|
||||
buttonp->setTabStop(FALSE);
|
||||
@@ -1740,7 +1725,7 @@ void LLFloater::buildButtons()
|
||||
// LLFloaterView
|
||||
|
||||
LLFloaterView::LLFloaterView( const std::string& name, const LLRect& rect )
|
||||
: LLUICtrl( name, rect, FALSE, NULL, NULL, FOLLOWS_ALL ),
|
||||
: LLUICtrl( name, rect, FALSE, NULL, FOLLOWS_ALL ),
|
||||
mFocusCycleMode(FALSE),
|
||||
mSnapOffsetBottom(0)
|
||||
{
|
||||
|
||||
@@ -241,10 +241,10 @@ public:
|
||||
return LLNotification::Params(name).context(mNotificationContext);
|
||||
}
|
||||
|
||||
static void onClickClose(void *userdata);
|
||||
static void onClickMinimize(void *userdata);
|
||||
static void onClickTearOff(void *userdata);
|
||||
static void onClickEdit(void *userdata);
|
||||
void onClickClose();
|
||||
void onClickMinimize();
|
||||
void onClickTearOff();
|
||||
void onClickEdit();
|
||||
|
||||
static void setFloaterHost(LLMultiFloater* hostp) {sHostp = hostp; }
|
||||
static void setEditModeEnabled(BOOL enable);
|
||||
@@ -317,8 +317,10 @@ private:
|
||||
static std::string sButtonPressedImageNames[BUTTON_COUNT];
|
||||
static std::string sButtonNames[BUTTON_COUNT];
|
||||
static std::string sButtonToolTips[BUTTON_COUNT];
|
||||
typedef void (*click_callback)(void *);
|
||||
static click_callback sButtonCallbacks[BUTTON_COUNT];
|
||||
|
||||
typedef void (LLFloater::*button_callback)();
|
||||
|
||||
static button_callback sButtonCallbacks[BUTTON_COUNT];
|
||||
|
||||
typedef std::map<LLHandle<LLFloater>, LLFloater*> handle_map_t;
|
||||
typedef std::map<LLHandle<LLFloater>, LLFloater*>::iterator handle_map_iter_t;
|
||||
|
||||
@@ -49,7 +49,7 @@ LLIconCtrl::LLIconCtrl(const std::string& name, const LLRect &rect, const LLUUID
|
||||
: LLUICtrl(name,
|
||||
rect,
|
||||
FALSE, // mouse opaque
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mColor( LLColor4::white )
|
||||
{
|
||||
@@ -61,7 +61,7 @@ LLIconCtrl::LLIconCtrl(const std::string& name, const LLRect &rect, const std::s
|
||||
: LLUICtrl(name,
|
||||
rect,
|
||||
FALSE, // mouse opaque
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mColor( LLColor4::white ),
|
||||
mImageName(image_name)
|
||||
|
||||
@@ -93,16 +93,15 @@ static LLRegisterWidget<LLLineEditor> r1("line_editor");
|
||||
LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect,
|
||||
const std::string& default_text, const LLFontGL* font,
|
||||
S32 max_length_bytes,
|
||||
void (*commit_callback)(LLUICtrl* caller, void* user_data ),
|
||||
void (*keystroke_callback)(LLLineEditor* caller, void* user_data ),
|
||||
void (*focus_lost_callback)(LLFocusableElement* caller, void* user_data ),
|
||||
void* userdata,
|
||||
LLLinePrevalidateFunc prevalidate_func,
|
||||
commit_callback_t commit_callback,
|
||||
keystroke_callback_t keystroke_callback,
|
||||
focus_lost_callback_t focus_lost_callback,
|
||||
validate_func_t prevalidate_func,
|
||||
LLViewBorder::EBevel border_bevel,
|
||||
LLViewBorder::EStyle border_style,
|
||||
S32 border_thickness)
|
||||
:
|
||||
LLUICtrl( name, rect, TRUE, commit_callback, userdata, FOLLOWS_TOP | FOLLOWS_LEFT ),
|
||||
LLUICtrl( name, rect, TRUE, commit_callback, FOLLOWS_TOP | FOLLOWS_LEFT ),
|
||||
mMaxLengthBytes(max_length_bytes),
|
||||
mCursorPos( 0 ),
|
||||
mScrollHPos( 0 ),
|
||||
@@ -142,6 +141,9 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect,
|
||||
mSpellCheckable( FALSE ),
|
||||
mContextMenuHandle()
|
||||
{
|
||||
if(focus_lost_callback)
|
||||
setFocusLostCallback(focus_lost_callback);
|
||||
|
||||
llassert( max_length_bytes > 0 );
|
||||
|
||||
// Initialize current history line iterator
|
||||
@@ -156,9 +158,6 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect,
|
||||
mGLFont = LLFontGL::getFontSansSerifSmall();
|
||||
}
|
||||
|
||||
if(focus_lost_callback)
|
||||
setFocusLostCallback(boost::bind(focus_lost_callback,_1,(void*)NULL));
|
||||
|
||||
setTextPadding(0, 0);
|
||||
|
||||
mScrollTimer.reset();
|
||||
@@ -1112,9 +1111,8 @@ void LLLineEditor::cut()
|
||||
reportBadKeystroke();
|
||||
}
|
||||
else
|
||||
if( mKeystrokeCallback )
|
||||
{
|
||||
mKeystrokeCallback( this, mCallbackUserData );
|
||||
onKeystroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1160,8 +1158,10 @@ void LLLineEditor::insert(std::string what, S32 wher)
|
||||
rollback.doRollback( this );
|
||||
reportBadKeystroke();
|
||||
}
|
||||
else if( mKeystrokeCallback )
|
||||
mKeystrokeCallback( this, mCallbackUserData );
|
||||
else
|
||||
{
|
||||
onKeystroke();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLLineEditor::canPaste() const
|
||||
@@ -1261,9 +1261,8 @@ void LLLineEditor::pasteHelper(bool is_primary)
|
||||
reportBadKeystroke();
|
||||
}
|
||||
else
|
||||
if( mKeystrokeCallback )
|
||||
{
|
||||
mKeystrokeCallback( this, mCallbackUserData );
|
||||
onKeystroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1582,10 +1581,7 @@ BOOL LLLineEditor::handleKeyHere(KEY key, MASK mask )
|
||||
// Notify owner if requested
|
||||
if (!need_to_rollback && handled)
|
||||
{
|
||||
if (mKeystrokeCallback)
|
||||
{
|
||||
mKeystrokeCallback(this, mCallbackUserData);
|
||||
}
|
||||
onKeystroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1637,12 +1633,10 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char)
|
||||
// Notify owner if requested
|
||||
if( !need_to_rollback && handled )
|
||||
{
|
||||
if( mKeystrokeCallback )
|
||||
{
|
||||
// HACK! The only usage of this callback doesn't do anything with the character.
|
||||
// We'll have to do something about this if something ever changes! - Doug
|
||||
mKeystrokeCallback( this, mCallbackUserData );
|
||||
}
|
||||
// HACK! The only usage of this callback doesn't do anything with the character.
|
||||
// We'll have to do something about this if something ever changes! - Doug
|
||||
onKeystroke();
|
||||
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
@@ -1651,7 +1645,7 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char)
|
||||
|
||||
BOOL LLLineEditor::canDoDelete() const
|
||||
{
|
||||
return ( !mReadOnly && (!mPassDelete || (hasSelection() || (getCursor() < mText.length()))) );
|
||||
return ( !mReadOnly && mText.length() > 0 && (!mPassDelete || (hasSelection() || (getCursor() < mText.length()))) );
|
||||
}
|
||||
|
||||
void LLLineEditor::doDelete()
|
||||
@@ -1680,10 +1674,7 @@ void LLLineEditor::doDelete()
|
||||
}
|
||||
else
|
||||
{
|
||||
if( mKeystrokeCallback )
|
||||
{
|
||||
mKeystrokeCallback( this, mCallbackUserData );
|
||||
}
|
||||
onKeystroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1757,7 +1748,8 @@ void LLLineEditor::draw()
|
||||
}
|
||||
|
||||
// draw rectangle for the background
|
||||
LLRect background( 0, getRect().getHeight(), getRect().getWidth(), 0 );
|
||||
//LLRect background( 0, getRect().getHeight(), getRect().getWidth(), 0 );
|
||||
LLRect background = getLocalRect();
|
||||
background.stretch( -mBorderThickness );
|
||||
|
||||
LLColor4 bg_color = mReadOnlyBgColor;
|
||||
@@ -2131,7 +2123,7 @@ void LLLineEditor::setRect(const LLRect& rect)
|
||||
}
|
||||
}
|
||||
|
||||
void LLLineEditor::setPrevalidate(BOOL (*func)(const LLWString &))
|
||||
void LLLineEditor::setPrevalidate(LLLineEditor::validate_func_t func)
|
||||
{
|
||||
mPrevalidateFunc = func;
|
||||
updateAllowingLanguageInput();
|
||||
@@ -2483,12 +2475,21 @@ void LLLineEditor::setSelectAllonFocusReceived(BOOL b)
|
||||
mSelectAllonFocusReceived = b;
|
||||
}
|
||||
|
||||
|
||||
void LLLineEditor::setKeystrokeCallback(void (*keystroke_callback)(LLLineEditor* caller, void* user_data))
|
||||
void LLLineEditor::onKeystroke()
|
||||
{
|
||||
mKeystrokeCallback = keystroke_callback;
|
||||
if (mKeystrokeCallback)
|
||||
{
|
||||
mKeystrokeCallback(this);
|
||||
}
|
||||
}
|
||||
|
||||
void LLLineEditor::setKeystrokeCallback(keystroke_callback_t callback)
|
||||
{
|
||||
mKeystrokeCallback = callback;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// virtual
|
||||
LLXMLNodePtr LLLineEditor::getXML(bool save_children) const
|
||||
{
|
||||
@@ -2579,14 +2580,11 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
|
||||
S32 border_thickness = 1;
|
||||
node->getAttributeS32("border_thickness", border_thickness);
|
||||
|
||||
LLUICtrlCallback commit_callback = NULL;
|
||||
|
||||
LLLineEditor* line_editor = new LLLineEditor(name,
|
||||
rect,
|
||||
text,
|
||||
font,
|
||||
max_text_length,
|
||||
commit_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -2833,10 +2831,8 @@ void LLLineEditor::updatePreedit(const LLWString &preedit_string,
|
||||
|
||||
// Update of the preedit should be caused by some key strokes.
|
||||
mKeystrokeTimer.reset();
|
||||
if( mKeystrokeCallback )
|
||||
{
|
||||
mKeystrokeCallback( this, mCallbackUserData );
|
||||
}
|
||||
onKeystroke();
|
||||
|
||||
}
|
||||
|
||||
BOOL LLLineEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const
|
||||
@@ -3093,156 +3089,3 @@ void LLLineEditor::setContextMenu(LLMenuGL* new_context_menu)
|
||||
mContextMenuHandle.markDead();
|
||||
}
|
||||
|
||||
static LLRegisterWidget<LLSearchEditor> r2("search_editor");
|
||||
|
||||
|
||||
LLSearchEditor::LLSearchEditor(const std::string& name,
|
||||
const LLRect& rect,
|
||||
S32 max_length_bytes,
|
||||
void (*search_callback)(const std::string& search_string, void* user_data),
|
||||
void* userdata)
|
||||
:
|
||||
LLUICtrl(name, rect, TRUE, NULL, userdata),
|
||||
mSearchCallback(search_callback)
|
||||
{
|
||||
LLRect search_edit_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
|
||||
mSearchEdit = new LLLineEditor(std::string("search edit"),
|
||||
search_edit_rect,
|
||||
LLStringUtil::null,
|
||||
NULL,
|
||||
max_length_bytes,
|
||||
NULL,
|
||||
onSearchEdit,
|
||||
NULL,
|
||||
this);
|
||||
|
||||
mSearchEdit->setFollowsAll();
|
||||
mSearchEdit->setSelectAllonFocusReceived(TRUE);
|
||||
|
||||
addChild(mSearchEdit);
|
||||
|
||||
S32 btn_width = rect.getHeight(); // button is square, and as tall as search editor
|
||||
LLRect clear_btn_rect(rect.getWidth() - btn_width, rect.getHeight(), rect.getWidth(), 0);
|
||||
mClearSearchButton = new LLButton(std::string("clear search"),
|
||||
clear_btn_rect,
|
||||
std::string("icn_clear_lineeditor.tga"),
|
||||
std::string("UIImgBtnCloseInactiveUUID"),
|
||||
LLStringUtil::null,
|
||||
onClearSearch,
|
||||
this,
|
||||
NULL,
|
||||
LLStringUtil::null);
|
||||
mClearSearchButton->setFollowsRight();
|
||||
mClearSearchButton->setFollowsTop();
|
||||
mClearSearchButton->setImageColor(LLUI::sColorsGroup->getColor("TextFgTentativeColor"));
|
||||
mClearSearchButton->setTabStop(FALSE);
|
||||
mSearchEdit->addChild(mClearSearchButton);
|
||||
|
||||
mSearchEdit->setTextPadding(0, btn_width);
|
||||
}
|
||||
|
||||
|
||||
//virtual
|
||||
void LLSearchEditor::setValue(const LLSD& value )
|
||||
{
|
||||
mSearchEdit->setValue(value);
|
||||
}
|
||||
|
||||
//virtual
|
||||
LLSD LLSearchEditor::getValue() const
|
||||
{
|
||||
return mSearchEdit->getValue();
|
||||
}
|
||||
|
||||
//virtual
|
||||
BOOL LLSearchEditor::setTextArg( const std::string& key, const LLStringExplicit& text )
|
||||
{
|
||||
return mSearchEdit->setTextArg(key, text);
|
||||
}
|
||||
|
||||
//virtual
|
||||
BOOL LLSearchEditor::setLabelArg( const std::string& key, const LLStringExplicit& text )
|
||||
{
|
||||
return mSearchEdit->setLabelArg(key, text);
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLSearchEditor::clear()
|
||||
{
|
||||
if (mSearchEdit)
|
||||
{
|
||||
mSearchEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void LLSearchEditor::draw()
|
||||
{
|
||||
mClearSearchButton->setVisible(!mSearchEdit->getWText().empty());
|
||||
|
||||
LLUICtrl::draw();
|
||||
}
|
||||
|
||||
|
||||
//static
|
||||
void LLSearchEditor::onSearchEdit(LLLineEditor* caller, void* user_data )
|
||||
{
|
||||
LLSearchEditor* search_editor = (LLSearchEditor*)user_data;
|
||||
if (search_editor->mSearchCallback)
|
||||
{
|
||||
search_editor->mSearchCallback(caller->getText(), search_editor->mCallbackUserData);
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void LLSearchEditor::onClearSearch(void* user_data)
|
||||
{
|
||||
LLSearchEditor* search_editor = (LLSearchEditor*)user_data;
|
||||
|
||||
search_editor->setText(LLStringUtil::null);
|
||||
if (search_editor->mSearchCallback)
|
||||
{
|
||||
search_editor->mSearchCallback(LLStringUtil::null, search_editor->mCallbackUserData);
|
||||
}
|
||||
}
|
||||
|
||||
// virtual
|
||||
LLXMLNodePtr LLSearchEditor::getXML(bool save_children) const
|
||||
{
|
||||
LLXMLNodePtr node = LLUICtrl::getXML();
|
||||
|
||||
node->setName(LL_SEARCH_EDITOR_TAG);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
// static
|
||||
LLView* LLSearchEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
|
||||
{
|
||||
std::string name("search_editor");
|
||||
node->getAttributeString("name", name);
|
||||
|
||||
LLRect rect;
|
||||
createRect(node, rect, parent, LLRect());
|
||||
|
||||
S32 max_text_length = 128;
|
||||
node->getAttributeS32("max_length", max_text_length);
|
||||
|
||||
std::string text = node->getValue().substr(0, max_text_length - 1);
|
||||
|
||||
LLSearchEditor* search_editor = new LLSearchEditor(name,
|
||||
rect,
|
||||
max_text_length,
|
||||
NULL, NULL);
|
||||
|
||||
std::string label;
|
||||
if(node->getAttributeString("label", label))
|
||||
{
|
||||
search_editor->mSearchEdit->setLabel(label);
|
||||
}
|
||||
|
||||
search_editor->setText(text);
|
||||
|
||||
search_editor->initFromXML(node, parent);
|
||||
|
||||
return search_editor;
|
||||
}
|
||||
|
||||
@@ -58,24 +58,24 @@ class LLLineEditorRollback;
|
||||
class LLButton;
|
||||
class LLMenuGL;
|
||||
|
||||
typedef BOOL (*LLLinePrevalidateFunc)(const LLWString &wstr);
|
||||
|
||||
|
||||
class LLLineEditor
|
||||
: public LLUICtrl, public LLEditMenuHandler, protected LLPreeditor
|
||||
{
|
||||
|
||||
public:
|
||||
typedef boost::function<void (LLLineEditor* caller)> keystroke_callback_t;
|
||||
typedef boost::function<void (LLFocusableElement*)> focus_lost_callback_t;
|
||||
typedef boost::function<BOOL (const LLWString &wstr)> validate_func_t;
|
||||
|
||||
LLLineEditor(const std::string& name,
|
||||
const LLRect& rect,
|
||||
const std::string& default_text = LLStringUtil::null,
|
||||
const LLFontGL* glfont = NULL,
|
||||
S32 max_length_bytes = 254,
|
||||
void (*commit_callback)(LLUICtrl* caller, void* user_data) = NULL,
|
||||
void (*keystroke_callback)(LLLineEditor* caller, void* user_data) = NULL,
|
||||
void (*focus_lost_callback)(LLFocusableElement* caller, void* user_data) = NULL,
|
||||
void* userdata = NULL,
|
||||
LLLinePrevalidateFunc prevalidate_func = NULL,
|
||||
commit_callback_t commit_callback = NULL,
|
||||
keystroke_callback_t keystroke_callback = NULL,
|
||||
focus_lost_callback_t focus_lost_callback = NULL,
|
||||
validate_func_t prevalidate_func = NULL,
|
||||
LLViewBorder::EBevel border_bevel = LLViewBorder::BEVEL_IN,
|
||||
LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE,
|
||||
S32 border_thickness = 1);
|
||||
@@ -230,13 +230,14 @@ public:
|
||||
void setSelectAllonFocusReceived(BOOL b);
|
||||
void setSelectAllonCommit(BOOL b) { mSelectAllonCommit = b; }
|
||||
|
||||
void setKeystrokeCallback(void (*keystroke_callback)(LLLineEditor* caller, void* user_data));
|
||||
void onKeystroke();
|
||||
void setKeystrokeCallback(keystroke_callback_t callback);
|
||||
|
||||
void setMaxTextLength(S32 max_text_length);
|
||||
void setTextPadding(S32 left, S32 right); // Used to specify room for children before or after text.
|
||||
|
||||
// Prevalidation controls which keystrokes can affect the editor
|
||||
void setPrevalidate( BOOL (*func)(const LLWString &) );
|
||||
void setPrevalidate( validate_func_t func );
|
||||
static BOOL prevalidateFloat(const LLWString &str );
|
||||
static BOOL prevalidateInt(const LLWString &str );
|
||||
static BOOL prevalidatePositiveS32(const LLWString &str);
|
||||
@@ -323,7 +324,7 @@ protected:
|
||||
BOOL mCommitOnFocusLost;
|
||||
BOOL mRevertOnEsc;
|
||||
|
||||
void (*mKeystrokeCallback)( LLLineEditor* caller, void* userdata );
|
||||
keystroke_callback_t mKeystrokeCallback;
|
||||
|
||||
BOOL mIsSelecting; // Selection for clipboard operations
|
||||
S32 mSelectionStart;
|
||||
@@ -333,8 +334,7 @@ protected:
|
||||
S32 mLastSelectionStart;
|
||||
S32 mLastSelectionEnd;
|
||||
|
||||
S32 (*mPrevalidateFunc)(const LLWString &str);
|
||||
|
||||
validate_func_t mPrevalidateFunc;
|
||||
LLFrameTimer mKeystrokeTimer;
|
||||
|
||||
LLColor4 mCursorColor;
|
||||
@@ -418,46 +418,4 @@ private:
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @brief A line editor with a button to clear it and a callback to call on every edit event.
|
||||
*/
|
||||
class LLSearchEditor : public LLUICtrl
|
||||
{
|
||||
public:
|
||||
LLSearchEditor(const std::string& name,
|
||||
const LLRect& rect,
|
||||
S32 max_length_bytes,
|
||||
void (*search_callback)(const std::string& search_string, void* user_data),
|
||||
void* userdata);
|
||||
|
||||
virtual ~LLSearchEditor() {}
|
||||
|
||||
/*virtual*/ void draw();
|
||||
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
||||
|
||||
void setText(const LLStringExplicit &new_text) { mSearchEdit->setText(new_text); }
|
||||
|
||||
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 );
|
||||
virtual LLSD getValue() const;
|
||||
virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text );
|
||||
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
|
||||
virtual void clear();
|
||||
|
||||
private:
|
||||
static void onSearchEdit(LLLineEditor* caller, void* user_data );
|
||||
static void onClearSearch(void* user_data);
|
||||
|
||||
LLLineEditor* mSearchEdit;
|
||||
class LLButton* mClearSearchButton;
|
||||
|
||||
search_callback_t mSearchCallback;
|
||||
|
||||
};
|
||||
|
||||
#endif // LL_LINEEDITOR_
|
||||
|
||||
@@ -136,7 +136,7 @@ const F32 ACTIVATE_HIGHLIGHT_TIME = 0.3f;
|
||||
|
||||
// Default constructor
|
||||
LLMenuItemGL::LLMenuItemGL( const std::string& name, const std::string& label, KEY key, MASK mask ) :
|
||||
LLUICtrl( name, LLRect(), TRUE, NULL, NULL ),
|
||||
LLUICtrl( name ),
|
||||
mJumpKey(KEY_NONE),
|
||||
mAllowKeyRepeat(FALSE),
|
||||
mHighlight( FALSE ),
|
||||
@@ -268,19 +268,6 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp)
|
||||
accelerator = *list_it;
|
||||
if ((accelerator->mKey == mAcceleratorKey) && (accelerator->mMask == (mAcceleratorMask & MASK_NORMALKEYS)))
|
||||
{
|
||||
|
||||
// *NOTE: get calling code to throw up warning or route
|
||||
// warning messages back to app-provided output
|
||||
// std::string warning;
|
||||
// warning.append("Duplicate key binding <");
|
||||
// appendAcceleratorString( warning );
|
||||
// warning.append("> for menu items:\n ");
|
||||
// warning.append(accelerator->mName);
|
||||
// warning.append("\n ");
|
||||
// warning.append(mLabel);
|
||||
|
||||
// llwarns << warning << llendl;
|
||||
// LLAlertDialog::modalAlert(warning);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1826,7 +1813,7 @@ static LLRegisterWidget<LLMenuGL> r1("menu");
|
||||
|
||||
// Default constructor
|
||||
LLMenuGL::LLMenuGL( const std::string& name, const std::string& label )
|
||||
: LLUICtrl( name, LLRect(), FALSE, NULL, NULL ),
|
||||
: LLUICtrl( name, LLRect(), FALSE),
|
||||
mBackgroundColor( sDefaultBackgroundColor ),
|
||||
mBgVisible( TRUE ),
|
||||
mHasSelection( FALSE ),
|
||||
@@ -1852,7 +1839,7 @@ LLMenuGL::LLMenuGL( const std::string& name, const std::string& label )
|
||||
}
|
||||
|
||||
LLMenuGL::LLMenuGL( const std::string& label)
|
||||
: LLUICtrl( label, LLRect(), FALSE, NULL, NULL ),
|
||||
: LLUICtrl( label, LLRect(), FALSE),
|
||||
mBackgroundColor( sDefaultBackgroundColor ),
|
||||
mBgVisible( TRUE ),
|
||||
mHasSelection( FALSE ),
|
||||
|
||||
@@ -57,8 +57,7 @@ S32 LLMultiSlider::mNameCounter = 0;
|
||||
LLMultiSlider::LLMultiSlider(
|
||||
const std::string& name,
|
||||
const LLRect& rect,
|
||||
void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata),
|
||||
void* callback_userdata,
|
||||
commit_callback_t commit_callback,
|
||||
F32 initial_value,
|
||||
F32 min_value,
|
||||
F32 max_value,
|
||||
@@ -69,8 +68,7 @@ LLMultiSlider::LLMultiSlider(
|
||||
BOOL use_triangle,
|
||||
const std::string& control_name)
|
||||
:
|
||||
LLUICtrl( name, rect, TRUE, on_commit_callback, callback_userdata,
|
||||
FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
LLUICtrl( name, rect, TRUE, commit_callback, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
|
||||
mInitialValue( initial_value ),
|
||||
mMinValue( min_value ),
|
||||
@@ -659,7 +657,6 @@ LLView* LLMultiSlider::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor
|
||||
LLMultiSlider* multiSlider = new LLMultiSlider(name,
|
||||
rect,
|
||||
NULL,
|
||||
NULL,
|
||||
initial_value,
|
||||
min_value,
|
||||
max_value,
|
||||
|
||||
@@ -44,8 +44,7 @@ public:
|
||||
LLMultiSlider(
|
||||
const std::string& name,
|
||||
const LLRect& rect,
|
||||
void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata),
|
||||
void* callback_userdata,
|
||||
commit_callback_t commit_callback,
|
||||
F32 initial_value,
|
||||
F32 min_value,
|
||||
F32 max_value,
|
||||
|
||||
@@ -60,14 +60,12 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const std::string& name, const LLRect& rect
|
||||
S32 text_left,
|
||||
BOOL show_text,
|
||||
BOOL can_edit_text,
|
||||
void (*commit_callback)(LLUICtrl*, void*),
|
||||
void* callback_user_data,
|
||||
F32 initial_value, F32 min_value, F32 max_value, F32 increment,
|
||||
S32 max_sliders, BOOL allow_overlap,
|
||||
BOOL draw_track,
|
||||
BOOL use_triangle,
|
||||
const std::string& control_which)
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data ),
|
||||
: LLUICtrl(name, rect, TRUE ),
|
||||
mFont(font),
|
||||
mShowText( show_text ),
|
||||
mCanEditText( can_edit_text ),
|
||||
@@ -107,7 +105,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const std::string& name, const LLRect& rect
|
||||
mMultiSlider = new LLMultiSlider(
|
||||
std::string("multi_slider"),
|
||||
slider_rect,
|
||||
LLMultiSliderCtrl::onSliderCommit, this,
|
||||
boost::bind(&LLMultiSliderCtrl::onSliderCommit,this,_2),
|
||||
initial_value, min_value, max_value, increment,
|
||||
max_sliders, allow_overlap, draw_track,
|
||||
use_triangle,
|
||||
@@ -123,8 +121,10 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const std::string& name, const LLRect& rect
|
||||
mEditor = new LLLineEditor( std::string("MultiSliderCtrl Editor"), text_rect,
|
||||
LLStringUtil::null, font,
|
||||
MAX_STRING_LENGTH,
|
||||
&LLMultiSliderCtrl::onEditorCommit, NULL, NULL, this,
|
||||
&LLLineEditor::prevalidateFloat );
|
||||
boost::bind(&LLMultiSliderCtrl::onEditorCommit,this,_2),
|
||||
NULL,
|
||||
NULL,
|
||||
boost::bind(&LLLineEditor::prevalidateFloat, _1) );
|
||||
mEditor->setFollowsLeft();
|
||||
mEditor->setFollowsBottom();
|
||||
mEditor->setFocusReceivedCallback( boost::bind(&LLMultiSliderCtrl::onFocusReceived, this) );
|
||||
@@ -278,26 +278,24 @@ void LLMultiSliderCtrl::updateText()
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLMultiSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
|
||||
void LLMultiSliderCtrl::onEditorCommit(const LLSD& value)
|
||||
{
|
||||
LLMultiSliderCtrl* self = (LLMultiSliderCtrl*) userdata;
|
||||
llassert( caller == self->mEditor );
|
||||
llassert( caller == mEditor );
|
||||
|
||||
BOOL success = FALSE;
|
||||
F32 val = self->mCurValue;
|
||||
F32 saved_val = self->mCurValue;
|
||||
F32 val = mCurValue;
|
||||
F32 saved_val = mCurValue;
|
||||
|
||||
std::string text = self->mEditor->getText();
|
||||
std::string text = value.asString();
|
||||
if( LLLineEditor::postvalidateFloat( text ) )
|
||||
{
|
||||
LLLocale locale(LLLocale::USER_LOCALE);
|
||||
val = (F32) atof( text.c_str() );
|
||||
if( self->mMultiSlider->getMinValue() <= val && val <= self->mMultiSlider->getMaxValue() )
|
||||
if( mMultiSlider->getMinValue() <= val && val <= mMultiSlider->getMaxValue() )
|
||||
{
|
||||
self->setCurSliderValue( val );
|
||||
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) &&
|
||||
(!self->mValidateSignal || (*(self->mValidateSignal))(self, val)))
|
||||
setCurSliderValue( val );
|
||||
if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) &&
|
||||
(!mValidateSignal || (*(mValidateSignal))(this, val)))
|
||||
{
|
||||
success = TRUE;
|
||||
}
|
||||
@@ -306,49 +304,45 @@ void LLMultiSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
|
||||
|
||||
if( success )
|
||||
{
|
||||
self->onCommit();
|
||||
onCommit();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( self->getCurSliderValue() != saved_val )
|
||||
if( getCurSliderValue() != saved_val )
|
||||
{
|
||||
self->setCurSliderValue( saved_val );
|
||||
setCurSliderValue( saved_val );
|
||||
}
|
||||
self->reportInvalidData();
|
||||
reportInvalidData();
|
||||
}
|
||||
self->updateText();
|
||||
updateText();
|
||||
}
|
||||
|
||||
// static
|
||||
void LLMultiSliderCtrl::onSliderCommit( LLUICtrl* caller, void *userdata )
|
||||
void LLMultiSliderCtrl::onSliderCommit(const LLSD& value)
|
||||
{
|
||||
LLMultiSliderCtrl* self = (LLMultiSliderCtrl*) userdata;
|
||||
//llassert( caller == self->mSlider );
|
||||
|
||||
BOOL success = FALSE;
|
||||
F32 saved_val = self->mCurValue;
|
||||
F32 new_val = self->mMultiSlider->getCurSliderValue();
|
||||
F32 saved_val = mCurValue;
|
||||
F32 new_val = mMultiSlider->getCurSliderValue();
|
||||
|
||||
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 )))
|
||||
mCurValue = new_val; // set the value temporarily so that the callback can retrieve it.
|
||||
if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) &&
|
||||
(!mValidateSignal || (*mValidateSignal)(this, new_val ) ))
|
||||
{
|
||||
success = TRUE;
|
||||
}
|
||||
|
||||
if( success )
|
||||
{
|
||||
self->onCommit();
|
||||
onCommit();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( self->mCurValue != saved_val )
|
||||
if( mCurValue != saved_val )
|
||||
{
|
||||
self->setCurSliderValue( saved_val );
|
||||
setCurSliderValue( saved_val );
|
||||
}
|
||||
self->reportInvalidData();
|
||||
reportInvalidData();
|
||||
}
|
||||
self->updateText();
|
||||
updateText();
|
||||
}
|
||||
|
||||
void LLMultiSliderCtrl::setEnabled(BOOL b)
|
||||
@@ -561,8 +555,6 @@ LLView* LLMultiSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFa
|
||||
}
|
||||
}
|
||||
|
||||
LLUICtrlCallback callback = NULL;
|
||||
|
||||
if (label.empty())
|
||||
{
|
||||
label.assign(node->getTextContents());
|
||||
@@ -576,8 +568,6 @@ LLView* LLMultiSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFa
|
||||
rect.getWidth() - text_left,
|
||||
show_text,
|
||||
can_edit_text,
|
||||
callback,
|
||||
NULL,
|
||||
initial_value,
|
||||
min_value,
|
||||
max_value,
|
||||
|
||||
@@ -64,8 +64,6 @@ public:
|
||||
S32 text_left,
|
||||
BOOL show_text,
|
||||
BOOL can_edit_text,
|
||||
void (*commit_callback)(LLUICtrl*, void*),
|
||||
void* callback_userdata,
|
||||
F32 initial_value, F32 min_value, F32 max_value, F32 increment,
|
||||
S32 max_sliders, BOOL allow_overlap, BOOL draw_track,
|
||||
BOOL use_triangle,
|
||||
@@ -123,10 +121,9 @@ public:
|
||||
virtual void setControlName(const std::string& control_name, LLView* context);
|
||||
virtual std::string getControlName() const;
|
||||
|
||||
static void onSliderCommit(LLUICtrl* caller, void* userdata);
|
||||
void onSliderCommit(const LLSD& value);
|
||||
|
||||
static void onEditorCommit(LLUICtrl* ctrl, void* userdata);
|
||||
static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
|
||||
void onEditorCommit(const LLSD& value);
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
|
||||
@@ -880,6 +880,7 @@ bool LLNotificationChannelBase::updateItem(const LLSD& payload, LLNotificationPt
|
||||
assert(!wasFound);
|
||||
if (passesFilter)
|
||||
{
|
||||
llinfos << "Inserting " << pNotification->getName() << llendl;
|
||||
// not in our list, add it and say so
|
||||
mItems.insert(pNotification);
|
||||
abortProcessing = mChanged(payload);
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
#include "llpanel.h"
|
||||
|
||||
#include "llalertdialog.h"
|
||||
#include "llfocusmgr.h"
|
||||
#include "llfontgl.h"
|
||||
#include "lllocalcliprect.h"
|
||||
@@ -92,7 +91,7 @@ LLPanel::LLPanel()
|
||||
}
|
||||
|
||||
LLPanel::LLPanel(const std::string& name)
|
||||
: LLUICtrl(name, LLRect(0, 0, 0, 0), TRUE, NULL, NULL),
|
||||
: LLUICtrl(name),
|
||||
mRectControl()
|
||||
{
|
||||
init();
|
||||
@@ -100,7 +99,7 @@ LLPanel::LLPanel(const std::string& name)
|
||||
|
||||
|
||||
LLPanel::LLPanel(const std::string& name, const LLRect& rect, BOOL bordered)
|
||||
: LLUICtrl(name, rect, TRUE, NULL, NULL),
|
||||
: LLUICtrl(name,rect),
|
||||
mRectControl()
|
||||
{
|
||||
init();
|
||||
@@ -112,7 +111,7 @@ LLPanel::LLPanel(const std::string& name, const LLRect& rect, BOOL bordered)
|
||||
|
||||
|
||||
LLPanel::LLPanel(const std::string& name, const std::string& rect_control, BOOL bordered)
|
||||
: LLUICtrl(name, LLUI::sConfigGroup->getRect(rect_control), TRUE, NULL, NULL),
|
||||
: LLUICtrl(name, LLUI::sConfigGroup->getRect(rect_control)),
|
||||
mRectControl( rect_control )
|
||||
{
|
||||
init();
|
||||
@@ -186,19 +185,14 @@ void LLPanel::draw()
|
||||
// draw background
|
||||
if( mBgVisible )
|
||||
{
|
||||
//RN: I don't see the point of this
|
||||
S32 left = 0;//LLPANEL_BORDER_WIDTH;
|
||||
S32 top = getRect().getHeight();// - LLPANEL_BORDER_WIDTH;
|
||||
S32 right = getRect().getWidth();// - LLPANEL_BORDER_WIDTH;
|
||||
S32 bottom = 0;//LLPANEL_BORDER_WIDTH;
|
||||
|
||||
LLRect local_rect = getLocalRect();
|
||||
if (mBgOpaque )
|
||||
{
|
||||
gl_rect_2d( left, top, right, bottom, mBgColorOpaque );
|
||||
gl_rect_2d( local_rect, mBgColorOpaque );
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_rect_2d( left, top, right, bottom, mBgColorAlpha );
|
||||
gl_rect_2d( local_rect, mBgColorAlpha );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,6 +605,11 @@ void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parent)
|
||||
setLabel(label);
|
||||
}
|
||||
|
||||
bool LLPanel::hasString(const std::string& name)
|
||||
{
|
||||
return mUIStrings.find(name) != mUIStrings.end();
|
||||
}
|
||||
|
||||
std::string LLPanel::getString(const std::string& name, const LLStringUtil::format_map_t& args) const
|
||||
{
|
||||
ui_string_map_t::const_iterator found_it = mUIStrings.find(name);
|
||||
@@ -916,29 +915,6 @@ LLPanel *LLPanel::childGetVisibleTab(const std::string& id) const
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void LLPanel::childSetKeystrokeCallback(const std::string& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data)
|
||||
{
|
||||
LLLineEditor* child = getChild<LLLineEditor>(id);
|
||||
if (child)
|
||||
{
|
||||
child->setKeystrokeCallback(keystroke_callback);
|
||||
if (user_data)
|
||||
{
|
||||
child->setCallbackUserData(user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLPanel::childSetPrevalidate(const std::string& id, BOOL (*func)(const LLWString &) )
|
||||
{
|
||||
LLLineEditor* child = getChild<LLLineEditor>(id);
|
||||
if (child)
|
||||
{
|
||||
child->setPrevalidate(func);
|
||||
}
|
||||
}
|
||||
|
||||
void LLPanel::childSetWrappedText(const std::string& id, const std::string& text, bool visible)
|
||||
{
|
||||
LLTextBox* child = getChild<LLTextBox>(id);
|
||||
@@ -949,14 +925,7 @@ void LLPanel::childSetWrappedText(const std::string& id, const std::string& text
|
||||
}
|
||||
}
|
||||
|
||||
void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> function, void* value)
|
||||
{
|
||||
LLButton* button = getChild<LLButton>(id);
|
||||
if (button)
|
||||
{
|
||||
button->setClickedCallback(function, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function)
|
||||
{
|
||||
@@ -967,12 +936,21 @@ void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_
|
||||
}
|
||||
}
|
||||
|
||||
void LLPanel::childSetActionTextbox(const std::string& id, void(*function)(void*), void* value)
|
||||
void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> function, void* value)
|
||||
{
|
||||
LLButton* button = getChild<LLButton>(id);
|
||||
if (button)
|
||||
{
|
||||
button->setClickedCallback(boost::bind(function, value));
|
||||
}
|
||||
}
|
||||
|
||||
void LLPanel::childSetActionTextbox(const std::string& id, boost::function<void(void*)> function, void* value)
|
||||
{
|
||||
LLTextBox* textbox = getChild<LLTextBox>(id);
|
||||
if (textbox)
|
||||
{
|
||||
textbox->setClickedCallback(function, value);
|
||||
textbox->setClickedCallback(boost::bind(function, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ public:
|
||||
void initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory);
|
||||
void setPanelParameters(LLXMLNodePtr node, LLView *parentp);
|
||||
|
||||
bool hasString(const std::string& name);
|
||||
std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const;
|
||||
std::string getString(const std::string& name) const;
|
||||
|
||||
@@ -205,14 +206,13 @@ public:
|
||||
void childSetText(const std::string& id, const LLStringExplicit& text) { childSetValue(id, LLSD(text)); }
|
||||
std::string childGetText(const std::string& id) const { return childGetValue(id).asString(); }
|
||||
|
||||
// LLLineEditor
|
||||
void childSetKeystrokeCallback(const std::string& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data);
|
||||
void childSetPrevalidate(const std::string& id, BOOL (*func)(const LLWString &) );
|
||||
|
||||
// LLButton
|
||||
void childSetAction(const std::string& id, boost::function<void(void*)> function, void* value);
|
||||
void childSetAction(const std::string& id, const commit_signal_t::slot_type& function);
|
||||
void childSetActionTextbox(const std::string& id, void(*function)(void*), void* value = NULL);
|
||||
|
||||
// LLTextBox
|
||||
void childSetActionTextbox(const std::string& id, boost::function<void(void*)> function, void* value = NULL);
|
||||
|
||||
void childSetControlName(const std::string& id, const std::string& control_name);
|
||||
|
||||
// Error reporting
|
||||
|
||||
@@ -47,19 +47,9 @@
|
||||
static LLRegisterWidget<LLRadioGroup> r("radio_group");
|
||||
|
||||
LLRadioGroup::LLRadioGroup(const std::string& name, const LLRect& rect,
|
||||
const std::string& control_name, LLUICtrlCallback callback,
|
||||
void* userdata, BOOL border) :
|
||||
LLUICtrl(name, rect, TRUE, callback, userdata, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mSelectedIndex(0)
|
||||
{
|
||||
setControlName(control_name, NULL);
|
||||
init(border);
|
||||
}
|
||||
|
||||
LLRadioGroup::LLRadioGroup(const std::string& name, const LLRect& rect,
|
||||
S32 initial_index, LLUICtrlCallback callback,
|
||||
void* userdata, BOOL border) :
|
||||
LLUICtrl(name, rect, TRUE, callback, userdata, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
S32 initial_index, commit_callback_t commit_callback,
|
||||
BOOL border) :
|
||||
LLUICtrl(name, rect, TRUE, commit_callback, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mSelectedIndex(initial_index)
|
||||
{
|
||||
init(border);
|
||||
@@ -251,7 +241,7 @@ void LLRadioGroup::draw()
|
||||
LLRadioCtrl* LLRadioGroup::addRadioButton(const std::string& name, const std::string& label, const LLRect& rect, const LLFontGL* font )
|
||||
{
|
||||
// Highlight will get fixed in draw method above
|
||||
LLRadioCtrl* radio = new LLRadioCtrl(name, rect, label, font, onClickButton, this);
|
||||
LLRadioCtrl* radio = new LLRadioCtrl(name, rect, label, font, boost::bind(&LLRadioGroup::onClickButton, this, _1));
|
||||
addChild(radio);
|
||||
mRadioButtons.push_back(radio);
|
||||
return radio;
|
||||
@@ -260,32 +250,30 @@ LLRadioCtrl* LLRadioGroup::addRadioButton(const std::string& name, const std::st
|
||||
// Handle one button being clicked. All child buttons must have this
|
||||
// function as their callback function.
|
||||
|
||||
// static
|
||||
void LLRadioGroup::onClickButton(LLUICtrl* ui_ctrl, void* userdata)
|
||||
void LLRadioGroup::onClickButton(LLUICtrl* ctrl)
|
||||
{
|
||||
// llinfos << "LLRadioGroup::onClickButton" << llendl;
|
||||
|
||||
LLRadioCtrl* clickedRadio = (LLRadioCtrl*) ui_ctrl;
|
||||
LLRadioGroup* self = (LLRadioGroup*) userdata;
|
||||
|
||||
S32 counter = 0;
|
||||
for (button_list_t::iterator iter = self->mRadioButtons.begin();
|
||||
iter != self->mRadioButtons.end(); ++iter)
|
||||
LLRadioCtrl* clicked_radio = dynamic_cast<LLRadioCtrl*>(ctrl);
|
||||
if (!clicked_radio)
|
||||
return;
|
||||
S32 index = 0;
|
||||
for (button_list_t::iterator iter = mRadioButtons.begin();
|
||||
iter != mRadioButtons.end(); ++iter)
|
||||
{
|
||||
LLRadioCtrl* radio = *iter;
|
||||
if (radio == clickedRadio)
|
||||
if (radio == clicked_radio)
|
||||
{
|
||||
// llinfos << "clicked button " << counter << llendl;
|
||||
self->setSelectedIndex(counter);
|
||||
self->setControlValue(counter);
|
||||
setSelectedIndex(index);
|
||||
setControlValue(index);
|
||||
|
||||
// BUG: Calls click callback even if button didn't actually change
|
||||
self->onCommit();
|
||||
onCommit();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
counter++;
|
||||
index++;
|
||||
}
|
||||
|
||||
llwarns << "LLRadioGroup::onClickButton - clicked button that isn't a child" << llendl;
|
||||
@@ -380,7 +368,6 @@ LLView* LLRadioGroup::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
|
||||
rect,
|
||||
initial_value,
|
||||
NULL,
|
||||
NULL,
|
||||
draw_border);
|
||||
|
||||
const std::string& contents = node->getValue();
|
||||
|
||||
@@ -45,8 +45,8 @@ class LLRadioCtrl : public LLCheckBoxCtrl
|
||||
{
|
||||
public:
|
||||
LLRadioCtrl(const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font = NULL,
|
||||
void (*commit_callback)(LLUICtrl*, void*) = NULL, void* callback_userdata = NULL) :
|
||||
LLCheckBoxCtrl(name, rect, label, font, commit_callback, callback_userdata, FALSE, RADIO_STYLE)
|
||||
commit_callback_t commit_callback = NULL) :
|
||||
LLCheckBoxCtrl(name, rect, label, font, commit_callback, FALSE, RADIO_STYLE)
|
||||
{
|
||||
setTabStop(FALSE);
|
||||
}
|
||||
@@ -66,21 +66,11 @@ class LLRadioGroup
|
||||
: public LLUICtrl, public LLCtrlSelectionInterface
|
||||
{
|
||||
public:
|
||||
// Build a radio group. The number (0...n-1) of the currently selected
|
||||
// element will be stored in the named control. After the control is
|
||||
// changed the callback will be called.
|
||||
LLRadioGroup(const std::string& name, const LLRect& rect,
|
||||
const std::string& control_name,
|
||||
LLUICtrlCallback callback = NULL,
|
||||
void* userdata = NULL,
|
||||
BOOL border = TRUE);
|
||||
|
||||
// Another radio group constructor, but this one doesn't rely on
|
||||
// Radio group constructor. Doesn't rely on
|
||||
// needing a control
|
||||
LLRadioGroup(const std::string& name, const LLRect& rect,
|
||||
S32 initial_index,
|
||||
LLUICtrlCallback callback = NULL,
|
||||
void* userdata = NULL,
|
||||
commit_callback_t commit_callback,
|
||||
BOOL border = TRUE);
|
||||
|
||||
virtual ~LLRadioGroup();
|
||||
@@ -111,7 +101,7 @@ public:
|
||||
LLRadioCtrl* addRadioButton(const std::string& name, const std::string& label, const LLRect& rect, const LLFontGL* font);
|
||||
LLRadioCtrl* getRadioButton(const S32& index) { return mRadioButtons[index]; }
|
||||
// Update the control as needed. Userdata must be a pointer to the button.
|
||||
static void onClickButton(LLUICtrl* radio, void* userdata);
|
||||
void onClickButton(LLUICtrl* clicked_radio);
|
||||
|
||||
//========================================================================
|
||||
LLCtrlSelectionInterface* getSelectionInterface() { return (LLCtrlSelectionInterface*)this; };
|
||||
|
||||
@@ -51,13 +51,11 @@ LLScrollbar::LLScrollbar(
|
||||
const std::string& name, LLRect rect,
|
||||
LLScrollbar::ORIENTATION orientation,
|
||||
S32 doc_size, S32 doc_pos, S32 page_size,
|
||||
void (*change_callback)( S32 new_pos, LLScrollbar* self, void* userdata ),
|
||||
void* callback_user_data,
|
||||
callback_t change_callback,
|
||||
S32 step_size)
|
||||
: LLUICtrl( name, rect, TRUE, NULL, NULL ),
|
||||
: LLUICtrl( name, rect ),
|
||||
|
||||
mChangeCallback( change_callback ),
|
||||
mCallbackUserData( callback_user_data ),
|
||||
mOrientation( orientation ),
|
||||
mDocSize( doc_size ),
|
||||
mDocPos( doc_pos ),
|
||||
@@ -115,7 +113,7 @@ LLScrollbar::LLScrollbar(
|
||||
|
||||
LLButton* line_up_btn = new LLButton(std::string("Line Up"), line_up_rect,
|
||||
line_up_img, line_up_selected_img, LLStringUtil::null,
|
||||
&LLScrollbar::onLineUpBtnPressed, this, LLFontGL::getFontSansSerif() );
|
||||
boost::bind(&LLScrollbar::onLineUpBtnPressed, this, _2), LLFontGL::getFontSansSerif() );
|
||||
if( LLScrollbar::VERTICAL == mOrientation )
|
||||
{
|
||||
line_up_btn->setFollowsRight();
|
||||
@@ -127,7 +125,7 @@ LLScrollbar::LLScrollbar(
|
||||
line_up_btn->setFollowsLeft();
|
||||
line_up_btn->setFollowsBottom();
|
||||
}
|
||||
line_up_btn->setHeldDownCallback( boost::bind(&LLScrollbar::onLineUpBtnPressed, (void*)this) );
|
||||
line_up_btn->setHeldDownCallback( boost::bind(&LLScrollbar::onLineUpBtnPressed, this, _2) );
|
||||
line_up_btn->setTabStop(FALSE);
|
||||
line_up_btn->setScaleImage(TRUE);
|
||||
|
||||
@@ -135,10 +133,10 @@ LLScrollbar::LLScrollbar(
|
||||
|
||||
LLButton* line_down_btn = new LLButton(std::string("Line Down"), line_down_rect,
|
||||
line_down_img, line_down_selected_img, LLStringUtil::null,
|
||||
&LLScrollbar::onLineDownBtnPressed, this, LLFontGL::getFontSansSerif() );
|
||||
boost::bind(&LLScrollbar::onLineDownBtnPressed, this, _2), LLFontGL::getFontSansSerif() );
|
||||
line_down_btn->setFollowsRight();
|
||||
line_down_btn->setFollowsBottom();
|
||||
line_down_btn->setHeldDownCallback( boost::bind(&LLScrollbar::onLineDownBtnPressed, this) );
|
||||
line_down_btn->setHeldDownCallback( boost::bind(&LLScrollbar::onLineDownBtnPressed, this, _2) );
|
||||
line_down_btn->setTabStop(FALSE);
|
||||
line_down_btn->setScaleImage(TRUE);
|
||||
addChild(line_down_btn);
|
||||
@@ -170,7 +168,7 @@ bool LLScrollbar::setDocPos(S32 pos, BOOL update_thumb)
|
||||
|
||||
if( mChangeCallback )
|
||||
{
|
||||
mChangeCallback( mDocPos, this, mCallbackUserData );
|
||||
mChangeCallback( mDocPos, this );
|
||||
}
|
||||
|
||||
if( update_thumb )
|
||||
@@ -629,19 +627,12 @@ void LLScrollbar::pageDown(S32 overlap)
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLScrollbar::onLineUpBtnPressed( void* userdata )
|
||||
void LLScrollbar::onLineUpBtnPressed( const LLSD& data )
|
||||
{
|
||||
LLScrollbar* self = (LLScrollbar*) userdata;
|
||||
|
||||
self->changeLine( - self->mStepSize, TRUE );
|
||||
changeLine( -mStepSize, TRUE );
|
||||
}
|
||||
|
||||
// static
|
||||
void LLScrollbar::onLineDownBtnPressed( void* userdata )
|
||||
void LLScrollbar::onLineDownBtnPressed( const LLSD& data )
|
||||
{
|
||||
LLScrollbar* self = (LLScrollbar*) userdata;
|
||||
self->changeLine( self->mStepSize, TRUE );
|
||||
changeLine( mStepSize, TRUE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,11 +52,11 @@ class LLScrollbar
|
||||
public:
|
||||
enum ORIENTATION { HORIZONTAL, VERTICAL };
|
||||
|
||||
typedef boost::function<void (S32, LLScrollbar*)> callback_t;
|
||||
LLScrollbar(const std::string& name, LLRect rect,
|
||||
ORIENTATION orientation,
|
||||
S32 doc_size, S32 doc_pos, S32 page_size,
|
||||
void(*change_callback)( S32 new_pos, LLScrollbar* self, void* userdata ),
|
||||
void* callback_user_data = NULL,
|
||||
callback_t change_callback,
|
||||
S32 step_size = 1);
|
||||
|
||||
virtual ~LLScrollbar();
|
||||
@@ -101,8 +101,8 @@ public:
|
||||
void pageUp(S32 overlap);
|
||||
void pageDown(S32 overlap);
|
||||
|
||||
static void onLineUpBtnPressed(void* userdata);
|
||||
static void onLineDownBtnPressed(void* userdata);
|
||||
void onLineUpBtnPressed(const LLSD& data);
|
||||
void onLineDownBtnPressed(const LLSD& data);
|
||||
|
||||
void setTrackColor( const LLColor4& color ) { mTrackColor = color; }
|
||||
void setThumbColor( const LLColor4& color ) { mThumbColor = color; }
|
||||
@@ -115,8 +115,7 @@ private:
|
||||
void updateThumbRect();
|
||||
bool changeLine(S32 delta, BOOL update_thumb );
|
||||
|
||||
void (*mChangeCallback)( S32 new_pos, LLScrollbar* self, void* userdata );
|
||||
void* mCallbackUserData;
|
||||
callback_t mChangeCallback;
|
||||
|
||||
const ORIENTATION mOrientation;
|
||||
S32 mDocSize; // Size of the document that the scrollbar is modeling. Units depend on the user. 0 <= mDocSize.
|
||||
|
||||
@@ -68,7 +68,7 @@ LLScrollableContainerView::LLScrollableContainerView( const std::string& name,
|
||||
LLView* scrolled_view,
|
||||
BOOL is_opaque,
|
||||
const LLColor4& bg_color ) :
|
||||
LLUICtrl( name, rect, FALSE, NULL, NULL ),
|
||||
LLUICtrl( name, rect, FALSE ),
|
||||
mAutoScrolling( FALSE ),
|
||||
mAutoScrollRate( 0.f ),
|
||||
mBackgroundColor( bg_color ),
|
||||
@@ -101,7 +101,7 @@ LLScrollableContainerView::LLScrollableContainerView( const std::string& name,
|
||||
mInnerRect.getHeight(),
|
||||
0,
|
||||
mInnerRect.getHeight(),
|
||||
NULL, this,
|
||||
NULL,
|
||||
VERTICAL_MULTIPLE);
|
||||
LLView::addChild( mScrollbar[VERTICAL] );
|
||||
mScrollbar[VERTICAL]->setVisible( FALSE );
|
||||
@@ -117,7 +117,7 @@ LLScrollableContainerView::LLScrollableContainerView( const std::string& name,
|
||||
mInnerRect.getWidth(),
|
||||
0,
|
||||
mInnerRect.getWidth(),
|
||||
NULL, this,
|
||||
NULL,
|
||||
HORIZONTAL_MULTIPLE);
|
||||
LLView::addChild( mScrollbar[HORIZONTAL] );
|
||||
mScrollbar[HORIZONTAL]->setVisible( FALSE );
|
||||
|
||||
@@ -57,7 +57,7 @@ class LLScrollingPanelList : public LLUICtrl
|
||||
{
|
||||
public:
|
||||
LLScrollingPanelList(const std::string& name, const LLRect& rect)
|
||||
: LLUICtrl(name, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_BOTTOM ) {}
|
||||
: LLUICtrl(name, rect, TRUE, NULL, FOLLOWS_LEFT | FOLLOWS_BOTTOM ) {}
|
||||
|
||||
typedef std::deque<LLScrollingPanel*> panel_list_t;
|
||||
|
||||
|
||||
@@ -662,13 +662,12 @@ public:
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect,
|
||||
void (*commit_callback)(LLUICtrl* ctrl, void* userdata),
|
||||
void* callback_user_data,
|
||||
commit_callback_t commit_callback,
|
||||
BOOL allow_multiple_selection,
|
||||
BOOL show_border,
|
||||
bool draw_heading
|
||||
)
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data),
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback),
|
||||
mLineHeight(0),
|
||||
mScrollLines(0),
|
||||
mMouseWheelOpaque(true),
|
||||
@@ -735,7 +734,7 @@ LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect,
|
||||
getItemCount(),
|
||||
mScrollLines,
|
||||
getLinesPerPage(),
|
||||
&LLScrollListCtrl::onScrollChange, this );
|
||||
boost::bind(&LLScrollListCtrl::onScrollChange, this, _1, _2) );
|
||||
mScrollbar->setFollowsRight();
|
||||
mScrollbar->setFollowsTop();
|
||||
mScrollbar->setFollowsBottom();
|
||||
@@ -2853,11 +2852,9 @@ S32 LLScrollListCtrl::getLinesPerPage()
|
||||
}
|
||||
|
||||
// Called by scrollbar
|
||||
//static
|
||||
void LLScrollListCtrl::onScrollChange( S32 new_pos, LLScrollbar* scrollbar, void* userdata )
|
||||
void LLScrollListCtrl::onScrollChange( S32 new_pos, LLScrollbar* scrollbar )
|
||||
{
|
||||
LLScrollListCtrl* self = (LLScrollListCtrl*) userdata;
|
||||
self->mScrollLines = new_pos;
|
||||
mScrollLines = new_pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -2932,7 +2929,7 @@ void LLScrollListCtrl::setScrollPos( S32 pos )
|
||||
{
|
||||
mScrollbar->setDocPos( pos );
|
||||
|
||||
onScrollChange(mScrollbar->getDocPos(), mScrollbar, this);
|
||||
onScrollChange(mScrollbar->getDocPos(), mScrollbar);
|
||||
}
|
||||
|
||||
|
||||
@@ -3134,12 +3131,9 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
|
||||
BOOL mouse_wheel_opaque = TRUE;
|
||||
node->getAttributeBOOL("mouse_wheel_opaque", mouse_wheel_opaque);
|
||||
|
||||
LLUICtrlCallback callback = NULL;
|
||||
|
||||
LLScrollListCtrl* scroll_list = new LLScrollListCtrl(
|
||||
name,
|
||||
rect,
|
||||
callback,
|
||||
NULL,
|
||||
multi_select,
|
||||
draw_border,
|
||||
@@ -3868,7 +3862,7 @@ void LLScrollListCtrl::onFocusLost()
|
||||
}
|
||||
|
||||
LLScrollColumnHeader::LLScrollColumnHeader(const std::string& label, const LLRect &rect, LLScrollListColumn* column, const LLFontGL* fontp) :
|
||||
LLComboBox(label, rect, label, NULL, NULL),
|
||||
LLComboBox(label, rect, label),
|
||||
mColumn(column),
|
||||
mOrigLabel(label),
|
||||
mShowSortOptions(FALSE),
|
||||
|
||||
@@ -390,8 +390,7 @@ public:
|
||||
LLScrollListCtrl(
|
||||
const std::string& name,
|
||||
const LLRect& rect,
|
||||
void (*commit_callback)(LLUICtrl*, void*),
|
||||
void* callback_userdata,
|
||||
commit_callback_t commit_callback,
|
||||
BOOL allow_multiple_selection,
|
||||
BOOL draw_border = TRUE, bool draw_heading = false);
|
||||
|
||||
@@ -594,7 +593,7 @@ public:
|
||||
LLRect getCellRect(S32 row_index, S32 column_index);
|
||||
|
||||
// Used "internally" by the scroll bar.
|
||||
static void onScrollChange( S32 new_pos, LLScrollbar* src, void* userdata );
|
||||
void onScrollChange( S32 new_pos, LLScrollbar* src);
|
||||
|
||||
static void onClickColumn(void *userdata);
|
||||
|
||||
|
||||
176
indra/llui/llsearcheditor.cpp
Normal file
176
indra/llui/llsearcheditor.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* @file llsearcheditor.cpp
|
||||
* @brief LLSearchEditor implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
// Text editor widget to let users enter a single line.
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llsearcheditor.h"
|
||||
|
||||
static LLRegisterWidget<LLSearchEditor> r2("search_editor");
|
||||
|
||||
|
||||
LLSearchEditor::LLSearchEditor(const std::string& name,
|
||||
const LLRect& rect,
|
||||
S32 max_length_bytes)
|
||||
:
|
||||
LLUICtrl(name, rect),
|
||||
mSearchEditor(NULL),
|
||||
mClearButton(NULL)
|
||||
{
|
||||
mSearchEditor = new LLLineEditor(std::string("filter edit box"),
|
||||
getLocalRect(),
|
||||
LLStringUtil::null,
|
||||
NULL,
|
||||
max_length_bytes,
|
||||
boost::bind(&LLUICtrl::onCommit, this),
|
||||
boost::bind(&LLSearchEditor::handleKeystroke, this));
|
||||
|
||||
mSearchEditor->setFollowsAll();
|
||||
mSearchEditor->setSelectAllonFocusReceived(TRUE);
|
||||
mSearchEditor->setRevertOnEsc( FALSE );
|
||||
mSearchEditor->setPassDelete(TRUE);
|
||||
|
||||
addChild(mSearchEditor);
|
||||
|
||||
S32 btn_width = rect.getHeight(); // button is square, and as tall as search editor
|
||||
LLRect clear_btn_rect(rect.getWidth() - btn_width, rect.getHeight(), rect.getWidth(), 0);
|
||||
mClearButton = new LLButton(std::string("clear button"),
|
||||
clear_btn_rect,
|
||||
std::string("icn_clear_lineeditor.tga"),
|
||||
std::string("UIImgBtnCloseInactiveUUID"),
|
||||
LLStringUtil::null,
|
||||
boost::bind(&LLSearchEditor::onClearButtonClick, this, _2));
|
||||
mClearButton->setFollowsRight();
|
||||
mClearButton->setFollowsTop();
|
||||
mClearButton->setImageColor(LLUI::sColorsGroup->getColor("TextFgTentativeColor"));
|
||||
mClearButton->setTabStop(FALSE);
|
||||
mSearchEditor->addChild(mClearButton);
|
||||
|
||||
mSearchEditor->setTextPadding(0, btn_width);
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLSearchEditor::draw()
|
||||
{
|
||||
if (mClearButton)
|
||||
mClearButton->setVisible(!mSearchEditor->getWText().empty());
|
||||
|
||||
LLUICtrl::draw();
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLSearchEditor::setValue(const LLSD& value )
|
||||
{
|
||||
mSearchEditor->setValue(value);
|
||||
}
|
||||
|
||||
//virtual
|
||||
LLSD LLSearchEditor::getValue() const
|
||||
{
|
||||
return mSearchEditor->getValue();
|
||||
}
|
||||
|
||||
//virtual
|
||||
BOOL LLSearchEditor::setTextArg( const std::string& key, const LLStringExplicit& text )
|
||||
{
|
||||
return mSearchEditor->setTextArg(key, text);
|
||||
}
|
||||
|
||||
//virtual
|
||||
BOOL LLSearchEditor::setLabelArg( const std::string& key, const LLStringExplicit& text )
|
||||
{
|
||||
return mSearchEditor->setLabelArg(key, text);
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLSearchEditor::setLabel( const LLStringExplicit &new_label )
|
||||
{
|
||||
mSearchEditor->setLabel(new_label);
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLSearchEditor::clear()
|
||||
{
|
||||
if (mSearchEditor)
|
||||
{
|
||||
mSearchEditor->clear();
|
||||
}
|
||||
}
|
||||
|
||||
//virtual
|
||||
void LLSearchEditor::setFocus( BOOL b )
|
||||
{
|
||||
if (mSearchEditor)
|
||||
{
|
||||
mSearchEditor->setFocus(b);
|
||||
}
|
||||
}
|
||||
|
||||
void LLSearchEditor::onClearButtonClick(const LLSD& data)
|
||||
{
|
||||
setText(LLStringUtil::null);
|
||||
mSearchEditor->onCommit(); // force keystroke callback
|
||||
}
|
||||
|
||||
void LLSearchEditor::handleKeystroke()
|
||||
{
|
||||
if (mKeystrokeCallback)
|
||||
{
|
||||
mKeystrokeCallback(this, getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
LLView* LLSearchEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
|
||||
{
|
||||
std::string name("search_editor");
|
||||
node->getAttributeString("name", name);
|
||||
|
||||
LLRect rect;
|
||||
createRect(node, rect, parent, LLRect());
|
||||
|
||||
S32 max_text_length = 128;
|
||||
node->getAttributeS32("max_length", max_text_length);
|
||||
|
||||
std::string text = node->getValue().substr(0, max_text_length - 1);
|
||||
|
||||
LLSearchEditor* search_editor = new LLSearchEditor(name,
|
||||
rect,
|
||||
max_text_length);
|
||||
|
||||
std::string label;
|
||||
if(node->getAttributeString("label", label))
|
||||
{
|
||||
search_editor->setLabel(label);
|
||||
}
|
||||
|
||||
search_editor->setText(text);
|
||||
|
||||
search_editor->initFromXML(node, parent);
|
||||
|
||||
return search_editor;
|
||||
}
|
||||
80
indra/llui/llsearcheditor.h
Normal file
80
indra/llui/llsearcheditor.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @file llsearcheditor.h
|
||||
* @brief Text editor widget that represents a search operation
|
||||
*
|
||||
* Features:
|
||||
* Text entry of a single line (text, delete, left and right arrow, insert, return).
|
||||
* Callbacks either on every keystroke or just on the return key.
|
||||
* Focus (allow multiple text entry widgets)
|
||||
* Clipboard (cut, copy, and paste)
|
||||
* Horizontal scrolling to allow strings longer than widget size allows
|
||||
* Pre-validation (limit which keys can be used)
|
||||
* Optional line history so previous entries can be recalled by CTRL UP/DOWN
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_SEARCHEDITOR_H
|
||||
#define LL_SEARCHEDITOR_H
|
||||
|
||||
#include "lllineeditor.h"
|
||||
#include "llbutton.h"
|
||||
|
||||
class LLSearchEditor : public LLUICtrl
|
||||
{
|
||||
public:
|
||||
LLSearchEditor(const std::string& name,
|
||||
const LLRect& rect,
|
||||
S32 max_length_bytes);
|
||||
|
||||
void setCommitOnFocusLost(BOOL b) { if (mSearchEditor) mSearchEditor->setCommitOnFocusLost(b); }
|
||||
|
||||
virtual ~LLSearchEditor() {}
|
||||
|
||||
/*virtual*/ void draw();
|
||||
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
||||
|
||||
void setText(const LLStringExplicit &new_text) { mSearchEditor->setText(new_text); }
|
||||
const std::string& getText() const { return mSearchEditor->getText(); }
|
||||
|
||||
// LLUICtrl interface
|
||||
virtual void setValue(const LLSD& value );
|
||||
virtual LLSD getValue() const;
|
||||
virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text );
|
||||
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
|
||||
virtual void setLabel( const LLStringExplicit &new_label );
|
||||
virtual void clear();
|
||||
virtual void setFocus( BOOL b );
|
||||
|
||||
void setKeystrokeCallback( commit_callback_t cb ) { mKeystrokeCallback = cb; }
|
||||
|
||||
protected:
|
||||
void onClearButtonClick(const LLSD& data);
|
||||
virtual void handleKeystroke();
|
||||
|
||||
commit_callback_t mKeystrokeCallback;
|
||||
LLLineEditor* mSearchEditor;
|
||||
LLButton* mClearButton;
|
||||
};
|
||||
|
||||
#endif //LL_SEARCHEDITOR_H
|
||||
@@ -49,8 +49,7 @@ static LLRegisterWidget<LLSlider> r2("volume_slider");
|
||||
LLSlider::LLSlider(
|
||||
const std::string& name,
|
||||
const LLRect& rect,
|
||||
void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata),
|
||||
void* callback_userdata,
|
||||
commit_callback_t commit_callback,
|
||||
F32 initial_value,
|
||||
F32 min_value,
|
||||
F32 max_value,
|
||||
@@ -58,7 +57,7 @@ LLSlider::LLSlider(
|
||||
BOOL volume,
|
||||
const std::string& control_name)
|
||||
:
|
||||
LLUICtrl( name, rect, TRUE, on_commit_callback, callback_userdata,
|
||||
LLUICtrl( name, rect, TRUE, commit_callback,
|
||||
FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mValue( initial_value ),
|
||||
mInitialValue( initial_value ),
|
||||
@@ -350,7 +349,6 @@ LLView* LLSlider::fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFacto
|
||||
LLSlider* slider = new LLSlider(name,
|
||||
rect,
|
||||
NULL,
|
||||
NULL,
|
||||
initial_value,
|
||||
min_value,
|
||||
max_value,
|
||||
|
||||
@@ -43,8 +43,7 @@ public:
|
||||
LLSlider(
|
||||
const std::string& name,
|
||||
const LLRect& rect,
|
||||
void (*on_commit_callback)(LLUICtrl* ctrl, void* userdata),
|
||||
void* callback_userdata,
|
||||
commit_callback_t commit_callback,
|
||||
F32 initial_value,
|
||||
F32 min_value,
|
||||
F32 max_value,
|
||||
|
||||
@@ -60,11 +60,10 @@ LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect,
|
||||
BOOL show_text,
|
||||
BOOL can_edit_text,
|
||||
BOOL volume,
|
||||
void (*commit_callback)(LLUICtrl*, void*),
|
||||
void* callback_user_data,
|
||||
commit_callback_t commit_callback,
|
||||
F32 initial_value, F32 min_value, F32 max_value, F32 increment,
|
||||
const std::string& control_which)
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data ),
|
||||
: LLUICtrl(name, rect, TRUE, commit_callback ),
|
||||
mFont(font),
|
||||
mShowText( show_text ),
|
||||
mCanEditText( can_edit_text ),
|
||||
@@ -104,7 +103,7 @@ LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect,
|
||||
LLRect slider_rect( slider_left, top, slider_right, bottom );
|
||||
mSlider = new LLSlider(std::string("slider"),
|
||||
slider_rect,
|
||||
LLSliderCtrl::onSliderCommit, this,
|
||||
boost::bind(&LLSliderCtrl::onSliderCommit,_1,_2),
|
||||
initial_value, min_value, max_value, increment, volume,
|
||||
control_which );
|
||||
addChild( mSlider );
|
||||
@@ -117,7 +116,9 @@ LLSliderCtrl::LLSliderCtrl(const std::string& name, const LLRect& rect,
|
||||
mEditor = new LLLineEditor( std::string("SliderCtrl Editor"), text_rect,
|
||||
LLStringUtil::null, font,
|
||||
MAX_STRING_LENGTH,
|
||||
&LLSliderCtrl::onEditorCommit, NULL, NULL, this,
|
||||
&LLSliderCtrl::onEditorCommit,
|
||||
NULL,
|
||||
NULL,
|
||||
&LLLineEditor::prevalidateFloat );
|
||||
mEditor->setFollowsLeft();
|
||||
mEditor->setFollowsBottom();
|
||||
@@ -209,10 +210,11 @@ void LLSliderCtrl::updateText()
|
||||
}
|
||||
|
||||
// static
|
||||
void LLSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
|
||||
void LLSliderCtrl::onEditorCommit( LLUICtrl* ctrl, const LLSD& userdata )
|
||||
{
|
||||
LLSliderCtrl* self = (LLSliderCtrl*) userdata;
|
||||
llassert( caller == self->mEditor );
|
||||
LLSliderCtrl* self = dynamic_cast<LLSliderCtrl*>(ctrl->getParent());
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
BOOL success = FALSE;
|
||||
F32 val = self->mValue;
|
||||
@@ -250,10 +252,11 @@ void LLSliderCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
|
||||
}
|
||||
|
||||
// static
|
||||
void LLSliderCtrl::onSliderCommit( LLUICtrl* caller, void *userdata )
|
||||
void LLSliderCtrl::onSliderCommit( LLUICtrl* ctrl, const LLSD& userdata )
|
||||
{
|
||||
LLSliderCtrl* self = (LLSliderCtrl*) userdata;
|
||||
llassert( caller == self->mSlider );
|
||||
LLSliderCtrl* self = dynamic_cast<LLSliderCtrl*>(ctrl->getParent());
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
BOOL success = FALSE;
|
||||
F32 saved_val = self->mValue;
|
||||
@@ -472,8 +475,6 @@ LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
|
||||
}
|
||||
}
|
||||
|
||||
LLUICtrlCallback callback = NULL;
|
||||
|
||||
if (label.empty())
|
||||
{
|
||||
label.assign(node->getTextContents());
|
||||
@@ -488,7 +489,6 @@ LLView* LLSliderCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
|
||||
show_text,
|
||||
can_edit_text,
|
||||
volume,
|
||||
callback,
|
||||
NULL,
|
||||
initial_value,
|
||||
min_value,
|
||||
|
||||
@@ -58,8 +58,7 @@ public:
|
||||
BOOL show_text,
|
||||
BOOL can_edit_text,
|
||||
BOOL volume, //TODO: create a "volume" slider sub-class or just use image art, no? -MG
|
||||
void (*commit_callback)(LLUICtrl*, void*),
|
||||
void* callback_userdata,
|
||||
commit_callback_t commit_callback,
|
||||
F32 initial_value, F32 min_value, F32 max_value, F32 increment,
|
||||
const std::string& control_which = LLStringUtil::null );
|
||||
|
||||
@@ -114,10 +113,9 @@ public:
|
||||
|
||||
virtual std::string getControlName() const { return mSlider->getControlName(); }
|
||||
|
||||
static void onSliderCommit(LLUICtrl* caller, void* userdata);
|
||||
static void onSliderCommit(LLUICtrl* ctrl, const LLSD& userdata);
|
||||
|
||||
static void onEditorCommit(LLUICtrl* caller, void* userdata);
|
||||
static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
|
||||
static void onEditorCommit(LLUICtrl* ctrl, const LLSD& userdata);
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
|
||||
@@ -54,13 +54,12 @@ const U32 MAX_STRING_LENGTH = 32;
|
||||
static LLRegisterWidget<LLSpinCtrl> r2("spinner");
|
||||
|
||||
LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font,
|
||||
void (*commit_callback)(LLUICtrl*, void*),
|
||||
void* callback_user_data,
|
||||
commit_callback_t commit_callback,
|
||||
F32 initial_value, F32 min_value, F32 max_value, F32 increment,
|
||||
const std::string& control_name,
|
||||
S32 label_width)
|
||||
:
|
||||
LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data, FOLLOWS_LEFT | FOLLOWS_TOP ),
|
||||
LLUICtrl(name, rect, TRUE, commit_callback, FOLLOWS_LEFT | FOLLOWS_TOP ),
|
||||
mValue( initial_value ),
|
||||
mInitialValue( initial_value ),
|
||||
mMaxValue( max_value ),
|
||||
@@ -98,10 +97,10 @@ LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::
|
||||
out_id,
|
||||
in_id,
|
||||
LLStringUtil::null,
|
||||
&LLSpinCtrl::onUpBtn, this, LLFontGL::getFontSansSerif() );
|
||||
boost::bind(&LLSpinCtrl::onUpBtn, this, _2), LLFontGL::getFontSansSerif() );
|
||||
mUpBtn->setFollowsLeft();
|
||||
mUpBtn->setFollowsBottom();
|
||||
mUpBtn->setHeldDownCallback(boost::bind(&LLSpinCtrl::onUpBtn,this));
|
||||
mUpBtn->setHeldDownCallback(boost::bind(&LLSpinCtrl::onUpBtn,this, _2));
|
||||
mUpBtn->setTabStop(FALSE);
|
||||
addChild(mUpBtn);
|
||||
|
||||
@@ -112,17 +111,17 @@ LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::
|
||||
out_id,
|
||||
in_id,
|
||||
LLStringUtil::null,
|
||||
&LLSpinCtrl::onDownBtn, this, LLFontGL::getFontSansSerif() );
|
||||
boost::bind(&LLSpinCtrl::onDownBtn, this, _2), LLFontGL::getFontSansSerif() );
|
||||
mDownBtn->setFollowsLeft();
|
||||
mDownBtn->setFollowsBottom();
|
||||
mDownBtn->setHeldDownCallback(boost::bind(&LLSpinCtrl::onDownBtn,this));
|
||||
mDownBtn->setHeldDownCallback(boost::bind(&LLSpinCtrl::onDownBtn,this, _2));
|
||||
mDownBtn->setTabStop(FALSE);
|
||||
addChild(mDownBtn);
|
||||
|
||||
LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom );
|
||||
mEditor = new LLLineEditor( std::string("SpinCtrl Editor"), editor_rect, LLStringUtil::null, font,
|
||||
MAX_STRING_LENGTH,
|
||||
&LLSpinCtrl::onEditorCommit, NULL, NULL, this,
|
||||
boost::bind(&LLSpinCtrl::onEditorCommit, this, _2), NULL, NULL,
|
||||
&LLLineEditor::prevalidateASCII );
|
||||
mEditor->setFollowsLeft();
|
||||
mEditor->setFollowsBottom();
|
||||
@@ -186,60 +185,59 @@ F32 get_increment(F32 inc, S32 decimal_precision) //CF: finetune increments
|
||||
|
||||
|
||||
// static
|
||||
void LLSpinCtrl::onUpBtn( void *userdata )
|
||||
void LLSpinCtrl::onUpBtn( const LLSD& data )
|
||||
{
|
||||
LLSpinCtrl* self = (LLSpinCtrl*) userdata;
|
||||
if( self->getEnabled() )
|
||||
if( getEnabled() )
|
||||
{
|
||||
// use getValue()/setValue() to force reload from/to control
|
||||
F32 val = (F32)self->getValue().asReal() + get_increment(self->mIncrement, self->mPrecision);
|
||||
val = clamp_precision(val, self->mPrecision);
|
||||
val = llmin( val, self->mMaxValue );
|
||||
F32 val = (F32)getValue().asReal() + get_increment(mIncrement, mPrecision);
|
||||
val = clamp_precision(val, mPrecision);
|
||||
val = llmin( val, mMaxValue );
|
||||
if (val < mMinValue) val = mMinValue;
|
||||
if (val > mMaxValue) val = 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)getValue().asReal();
|
||||
setValue(val);
|
||||
if( (mValidateCallback && !mValidateCallback( this, mCallbackUserData ) ) ||
|
||||
(mValidateSignal && !(*mValidateSignal)( this, val ) ))
|
||||
{
|
||||
self->setValue( saved_val );
|
||||
self->reportInvalidData();
|
||||
self->updateEditor();
|
||||
setValue( saved_val );
|
||||
reportInvalidData();
|
||||
updateEditor();
|
||||
return;
|
||||
}
|
||||
|
||||
self->updateEditor();
|
||||
self->onCommit();
|
||||
updateEditor();
|
||||
onCommit();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLSpinCtrl::onDownBtn( void *userdata )
|
||||
|
||||
void LLSpinCtrl::onDownBtn( const LLSD& data )
|
||||
{
|
||||
LLSpinCtrl* self = (LLSpinCtrl*) userdata;
|
||||
|
||||
if( self->getEnabled() )
|
||||
if( getEnabled() )
|
||||
{
|
||||
F32 val = (F32)self->getValue().asReal() - get_increment(self->mIncrement, self->mPrecision);
|
||||
val = clamp_precision(val, self->mPrecision);
|
||||
val = llmax( val, self->mMinValue );
|
||||
F32 val = (F32)getValue().asReal() - get_increment(mIncrement, mPrecision);
|
||||
val = clamp_precision(val, mPrecision);
|
||||
val = llmax( val, mMinValue );
|
||||
|
||||
|
||||
if (val < self->mMinValue) val = self->mMinValue;
|
||||
if (val > self->mMaxValue) val = self->mMaxValue;
|
||||
if (val < mMinValue) val = mMinValue;
|
||||
if (val > mMaxValue) val = 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)getValue().asReal();
|
||||
setValue(val);
|
||||
if( (mValidateCallback && !mValidateCallback( this, mCallbackUserData ) ) ||
|
||||
(mValidateSignal && !(*mValidateSignal)( this, val ) ))
|
||||
{
|
||||
self->setValue( saved_val );
|
||||
self->reportInvalidData();
|
||||
self->updateEditor();
|
||||
setValue( saved_val );
|
||||
reportInvalidData();
|
||||
updateEditor();
|
||||
return;
|
||||
}
|
||||
|
||||
self->updateEditor();
|
||||
self->onCommit();
|
||||
updateEditor();
|
||||
onCommit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +276,13 @@ void LLSpinCtrl::clear()
|
||||
mbHasBeenSet = FALSE;
|
||||
}
|
||||
|
||||
|
||||
void LLSpinCtrl::updateLabelColor()
|
||||
{
|
||||
if( mLabelBox )
|
||||
{
|
||||
mLabelBox->setColor( getEnabled() ? mTextEnabledColor : mTextDisabledColor );
|
||||
}
|
||||
}
|
||||
|
||||
void LLSpinCtrl::updateEditor()
|
||||
{
|
||||
@@ -297,52 +301,50 @@ void LLSpinCtrl::updateEditor()
|
||||
mEditor->setText( text );
|
||||
}
|
||||
|
||||
void LLSpinCtrl::onEditorCommit( LLUICtrl* caller, void *userdata )
|
||||
void LLSpinCtrl::onEditorCommit( const LLSD& data )
|
||||
{
|
||||
BOOL success = FALSE;
|
||||
|
||||
LLSpinCtrl* self = (LLSpinCtrl*) userdata;
|
||||
llassert( caller == self->mEditor );
|
||||
|
||||
if( self->mEditor->evaluateFloat() )
|
||||
if( mEditor->evaluateFloat() )
|
||||
{
|
||||
std::string text = self->mEditor->getText();
|
||||
std::string text = mEditor->getText();
|
||||
|
||||
LLLocale locale(LLLocale::USER_LOCALE);
|
||||
F32 val = (F32) atof(text.c_str());
|
||||
|
||||
if (val < self->mMinValue) val = self->mMinValue;
|
||||
if (val > self->mMaxValue) val = self->mMaxValue;
|
||||
if (val < mMinValue) val = mMinValue;
|
||||
if (val > mMaxValue) val = mMaxValue;
|
||||
|
||||
F32 saved_val = self->mValue;
|
||||
self->mValue = val;
|
||||
F32 saved_val = mValue;
|
||||
mValue = val;
|
||||
|
||||
if( (!self->mValidateCallback || self->mValidateCallback( self, self->mCallbackUserData )) &&
|
||||
(!self->mValidateSignal || (*(self->mValidateSignal))(self, val)))
|
||||
if( (!mValidateCallback || mValidateCallback( this, mCallbackUserData )) &&
|
||||
(!mValidateSignal || (*mValidateSignal)(this, val) ))
|
||||
{
|
||||
success = TRUE;
|
||||
self->onCommit();
|
||||
onCommit();
|
||||
}
|
||||
else
|
||||
{
|
||||
self->mValue = saved_val;
|
||||
mValue = saved_val;
|
||||
}
|
||||
}
|
||||
updateEditor();
|
||||
|
||||
if( success )
|
||||
{
|
||||
self->updateEditor();
|
||||
updateEditor();
|
||||
}
|
||||
else
|
||||
{
|
||||
self->reportInvalidData();
|
||||
reportInvalidData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLSpinCtrl::forceEditorCommit()
|
||||
{
|
||||
onEditorCommit(mEditor, this);
|
||||
onEditorCommit( LLSD() );
|
||||
}
|
||||
|
||||
|
||||
@@ -356,6 +358,7 @@ void LLSpinCtrl::setEnabled(BOOL b)
|
||||
{
|
||||
LLView::setEnabled( b );
|
||||
mEditor->setEnabled( b );
|
||||
updateLabelColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -403,6 +406,7 @@ void LLSpinCtrl::setLabel(const LLStringExplicit& label)
|
||||
{
|
||||
llwarns << "Attempting to set label on LLSpinCtrl constructed without one " << getName() << llendl;
|
||||
}
|
||||
updateLabelColor();
|
||||
}
|
||||
|
||||
BOOL LLSpinCtrl::setLabelArg( const std::string& key, const LLStringExplicit& text )
|
||||
@@ -434,29 +438,19 @@ void LLSpinCtrl::reportInvalidData()
|
||||
make_ui_sound("UISndBadKeystroke");
|
||||
}
|
||||
|
||||
void LLSpinCtrl::draw()
|
||||
{
|
||||
if( mLabelBox )
|
||||
{
|
||||
mLabelBox->setColor( getEnabled() ? mTextEnabledColor : mTextDisabledColor );
|
||||
}
|
||||
LLUICtrl::draw();
|
||||
}
|
||||
|
||||
|
||||
BOOL LLSpinCtrl::handleScrollWheel(S32 x, S32 y, S32 clicks)
|
||||
{
|
||||
if( clicks > 0 )
|
||||
{
|
||||
while( clicks-- )
|
||||
{
|
||||
LLSpinCtrl::onDownBtn(this);
|
||||
onDownBtn(getValue());
|
||||
}
|
||||
}
|
||||
else
|
||||
while( clicks++ )
|
||||
{
|
||||
LLSpinCtrl::onUpBtn(this);
|
||||
onUpBtn(getValue());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -476,12 +470,12 @@ BOOL LLSpinCtrl::handleKeyHere(KEY key, MASK mask)
|
||||
}
|
||||
if(key == KEY_UP)
|
||||
{
|
||||
LLSpinCtrl::onUpBtn(this);
|
||||
onUpBtn(getValue());
|
||||
return TRUE;
|
||||
}
|
||||
if(key == KEY_DOWN)
|
||||
{
|
||||
LLSpinCtrl::onDownBtn(this);
|
||||
onDownBtn(getValue());
|
||||
return TRUE;
|
||||
}
|
||||
if(key == KEY_RETURN)
|
||||
@@ -557,8 +551,6 @@ LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
|
||||
BOOL allow_text_entry = TRUE;
|
||||
node->getAttributeBOOL("allow_text_entry", allow_text_entry);
|
||||
|
||||
LLUICtrlCallback callback = NULL;
|
||||
|
||||
if(label.empty())
|
||||
{
|
||||
label.assign( node->getValue() );
|
||||
@@ -568,7 +560,6 @@ LLView* LLSpinCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
|
||||
rect,
|
||||
label,
|
||||
font,
|
||||
callback,
|
||||
NULL,
|
||||
initial_value,
|
||||
min_value,
|
||||
|
||||
@@ -56,8 +56,7 @@ public:
|
||||
LLSpinCtrl(const std::string& name, const LLRect& rect,
|
||||
const std::string& label,
|
||||
const LLFontGL* font,
|
||||
void (*commit_callback)(LLUICtrl*, void*),
|
||||
void* callback_userdata,
|
||||
commit_callback_t commit_callback,
|
||||
F32 initial_value, F32 min_value, F32 max_value, F32 increment,
|
||||
const std::string& control_name = std::string(),
|
||||
S32 label_width = SPINCTRL_DEFAULT_LABEL_WIDTH );
|
||||
@@ -93,8 +92,8 @@ public:
|
||||
virtual F32 getIncrement() { return mIncrement ; }
|
||||
|
||||
void setLabel(const LLStringExplicit& label);
|
||||
void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; }
|
||||
void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; }
|
||||
void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; updateLabelColor(); }
|
||||
void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; updateLabelColor();}
|
||||
void setAllowEdit(BOOL allow_edit);
|
||||
|
||||
virtual void onTabInto();
|
||||
@@ -107,17 +106,15 @@ public:
|
||||
virtual BOOL handleScrollWheel(S32 x,S32 y,S32 clicks);
|
||||
virtual BOOL handleKeyHere(KEY key, MASK mask);
|
||||
|
||||
virtual void draw();
|
||||
void onEditorCommit(const LLSD& data);
|
||||
|
||||
static void onEditorCommit(LLUICtrl* caller, void* userdata);
|
||||
static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
|
||||
|
||||
static void onUpBtn(void *userdata);
|
||||
static void onDownBtn(void *userdata);
|
||||
void onUpBtn(const LLSD& data);
|
||||
void onDownBtn(const LLSD& data);
|
||||
|
||||
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
|
||||
|
||||
private:
|
||||
void updateLabelColor();
|
||||
void updateEditor();
|
||||
void reportInvalidData();
|
||||
|
||||
|
||||
@@ -318,15 +318,15 @@ void LLTabContainer::draw()
|
||||
if( mIsVertical && has_scroll_arrows )
|
||||
{
|
||||
// Redraw the arrows so that they appears on top.
|
||||
gGL.pushMatrix();
|
||||
gGL.translatef((F32)mPrevArrowBtn->getRect().mLeft, (F32)mPrevArrowBtn->getRect().mBottom, 0.f);
|
||||
gGL.pushUIMatrix();
|
||||
gGL.translateUI((F32)mPrevArrowBtn->getRect().mLeft, (F32)mPrevArrowBtn->getRect().mBottom, 0.f);
|
||||
mPrevArrowBtn->draw();
|
||||
gGL.popMatrix();
|
||||
gGL.popUIMatrix();
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.translatef((F32)mNextArrowBtn->getRect().mLeft, (F32)mNextArrowBtn->getRect().mBottom, 0.f);
|
||||
gGL.pushUIMatrix();
|
||||
gGL.translateUI((F32)mNextArrowBtn->getRect().mLeft, (F32)mNextArrowBtn->getRect().mBottom, 0.f);
|
||||
mNextArrowBtn->draw();
|
||||
gGL.popMatrix();
|
||||
gGL.popUIMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,7 +817,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
|
||||
btn_rect.translate(0, -LLBUTTON_V_PAD-2);
|
||||
textbox = new LLTextBox(trimmed_label, btn_rect, trimmed_label, font);
|
||||
|
||||
btn = new LLButton(LLStringUtil::null, LLRect(0,0,0,0));
|
||||
btn = new LLButton(LLStringUtil::null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -828,7 +828,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
|
||||
LLStringUtil::null,
|
||||
LLStringUtil::null,
|
||||
LLStringUtil::null,
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
font,
|
||||
trimmed_label, trimmed_label);
|
||||
btn->setImages(std::string("tab_left.tga"), std::string("tab_left_selected.tga"));
|
||||
@@ -850,7 +850,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
|
||||
btn = new LLButton(std::string(child->getName()) + " tab",
|
||||
btn_rect,
|
||||
LLStringUtil::null, LLStringUtil::null, LLStringUtil::null,
|
||||
NULL, NULL, // set userdata below
|
||||
NULL, // set userdata below
|
||||
font,
|
||||
trimmed_label, trimmed_label );
|
||||
btn->setVisible( FALSE );
|
||||
@@ -1646,19 +1646,17 @@ void LLTabContainer::initButtons()
|
||||
out_id = "UIImgBtnScrollUpOutUUID";
|
||||
in_id = "UIImgBtnScrollUpInUUID";
|
||||
mPrevArrowBtn = new LLButton(std::string("Up Arrow"), up_arrow_btn_rect,
|
||||
out_id, in_id, LLStringUtil::null, NULL );
|
||||
out_id, in_id, LLStringUtil::null, boost::bind(&LLTabContainer::onPrevBtn,this,_2));
|
||||
mPrevArrowBtn->setFollowsTop();
|
||||
mPrevArrowBtn->setFollowsLeft();
|
||||
mPrevArrowBtn->setCommitCallback(boost::bind(&LLTabContainer::onPrevBtn,this,_2));
|
||||
mPrevArrowBtn->setHeldDownCallback(boost::bind(&LLTabContainer::onPrevBtnHeld, this, _2));
|
||||
|
||||
out_id = "UIImgBtnScrollDownOutUUID";
|
||||
in_id = "UIImgBtnScrollDownInUUID";
|
||||
mNextArrowBtn = new LLButton(std::string("Down Arrow"), down_arrow_btn_rect,
|
||||
out_id, in_id, LLStringUtil::null, NULL );
|
||||
out_id, in_id, LLStringUtil::null, boost::bind(&LLTabContainer::onNextBtn,this,_2) );
|
||||
mNextArrowBtn->setFollowsBottom();
|
||||
mNextArrowBtn->setFollowsLeft();
|
||||
mNextArrowBtn->setCommitCallback(boost::bind(&LLTabContainer::onNextBtn,this,_2));
|
||||
mNextArrowBtn->setHeldDownCallback(boost::bind(&LLTabContainer::onNextBtnHeld, this, _2));
|
||||
}
|
||||
else // Horizontal
|
||||
@@ -1697,17 +1695,14 @@ void LLTabContainer::initButtons()
|
||||
in_id = "UIImgBtnJumpLeftInUUID";
|
||||
mJumpPrevArrowBtn = new LLButton(std::string("Jump Left Arrow"), jump_left_arrow_btn_rect,
|
||||
out_id, in_id, LLStringUtil::null,
|
||||
NULL, NULL, LLFontGL::getFontSansSerif() );
|
||||
mJumpPrevArrowBtn->setCommitCallback(boost::bind(&LLTabContainer::onJumpFirstBtn, this, _2));
|
||||
boost::bind(&LLTabContainer::onJumpFirstBtn, this, _2), LLFontGL::getFontSansSerif() );
|
||||
mJumpPrevArrowBtn->setFollowsLeft();
|
||||
|
||||
out_id = "UIImgBtnScrollLeftOutUUID";
|
||||
in_id = "UIImgBtnScrollLeftInUUID";
|
||||
mPrevArrowBtn = new LLButton(std::string("Left Arrow"), left_arrow_btn_rect,
|
||||
out_id, in_id, LLStringUtil::null,
|
||||
NULL, NULL, LLFontGL::getFontSansSerif() );
|
||||
|
||||
mPrevArrowBtn->setCommitCallback(boost::bind(&LLTabContainer::onPrevBtn, this, _2));
|
||||
boost::bind(&LLTabContainer::onPrevBtn, this, _2), LLFontGL::getFontSansSerif() );
|
||||
mPrevArrowBtn->setHeldDownCallback(boost::bind(&LLTabContainer::onPrevBtnHeld, this, _2));
|
||||
mPrevArrowBtn->setFollowsLeft();
|
||||
|
||||
@@ -1715,16 +1710,14 @@ void LLTabContainer::initButtons()
|
||||
in_id = "UIImgBtnJumpRightInUUID";
|
||||
mJumpNextArrowBtn = new LLButton(std::string("Jump Right Arrow"), jump_right_arrow_btn_rect,
|
||||
out_id, in_id, LLStringUtil::null,
|
||||
NULL, NULL, LLFontGL::getFontSansSerif());
|
||||
mJumpNextArrowBtn->setCommitCallback(boost::bind(&LLTabContainer::onJumpLastBtn, this, _2));
|
||||
boost::bind(&LLTabContainer::onJumpLastBtn, this, _2), LLFontGL::getFontSansSerif());
|
||||
mJumpNextArrowBtn->setFollowsRight();
|
||||
|
||||
out_id = "UIImgBtnScrollRightOutUUID";
|
||||
in_id = "UIImgBtnScrollRightInUUID";
|
||||
mNextArrowBtn = new LLButton(std::string("Right Arrow"), right_arrow_btn_rect,
|
||||
out_id, in_id, LLStringUtil::null,
|
||||
NULL, NULL, LLFontGL::getFontSansSerif());
|
||||
mNextArrowBtn->setCommitCallback(boost::bind(&LLTabContainer::onNextBtn, this, _2));
|
||||
boost::bind(&LLTabContainer::onNextBtn, this, _2), LLFontGL::getFontSansSerif());
|
||||
mNextArrowBtn->setHeldDownCallback(boost::bind(&LLTabContainer::onNextBtnHeld, this, _2));
|
||||
mNextArrowBtn->setFollowsRight();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ static LLRegisterWidget<LLTextBox> r("text");
|
||||
|
||||
LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::string& text,
|
||||
const LLFontGL* font, BOOL mouse_opaque)
|
||||
: LLUICtrl(name, rect, mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP ),
|
||||
: LLUICtrl(name, rect, mouse_opaque, NULL, FOLLOWS_LEFT | FOLLOWS_TOP ),
|
||||
mFontGL(font ? font : LLFontGL::getFontSansSerifSmall())
|
||||
{
|
||||
initDefaults();
|
||||
@@ -50,7 +50,7 @@ LLTextBox::LLTextBox(const std::string& name, const LLRect& rect, const std::str
|
||||
|
||||
LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_width,
|
||||
const LLFontGL* font, BOOL mouse_opaque) :
|
||||
LLUICtrl(name, LLRect(0, 0, 1, 1), mouse_opaque, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
LLUICtrl(name, LLRect(0, 0, 1, 1), mouse_opaque, NULL, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mFontGL(font ? font : LLFontGL::getFontSansSerifSmall())
|
||||
{
|
||||
initDefaults();
|
||||
@@ -60,7 +60,7 @@ LLTextBox::LLTextBox(const std::string& name, const std::string& text, F32 max_w
|
||||
}
|
||||
|
||||
LLTextBox::LLTextBox(const std::string& name_and_label, const LLRect& rect) :
|
||||
LLUICtrl(name_and_label, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
LLUICtrl(name_and_label, rect, TRUE, NULL, FOLLOWS_LEFT | FOLLOWS_TOP),
|
||||
mFontGL(LLFontGL::getFontSansSerifSmall())
|
||||
{
|
||||
initDefaults();
|
||||
@@ -89,7 +89,6 @@ void LLTextBox::initDefaults()
|
||||
mHAlign = LLFontGL::LEFT;
|
||||
mVAlign = LLFontGL::TOP;
|
||||
mClickedCallback = NULL;
|
||||
mCallbackUserData = NULL;
|
||||
}
|
||||
|
||||
BOOL LLTextBox::handleMouseDown(S32 x, S32 y, MASK mask)
|
||||
@@ -140,7 +139,7 @@ BOOL LLTextBox::handleMouseUp(S32 x, S32 y, MASK mask)
|
||||
// If mouseup in the widget, it's been clicked
|
||||
if (mClickedCallback)
|
||||
{
|
||||
(*mClickedCallback)( mCallbackUserData );
|
||||
mClickedCallback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,8 +297,7 @@ void LLTextBox::draw()
|
||||
|
||||
if (mBackgroundVisible)
|
||||
{
|
||||
LLRect r( 0, getRect().getHeight(), getRect().getWidth(), 0 );
|
||||
gl_rect_2d( r, mBackgroundColor );
|
||||
gl_rect_2d( getLocalRect(), mBackgroundColor );
|
||||
}
|
||||
|
||||
S32 text_x = 0;
|
||||
|
||||
@@ -43,6 +43,7 @@ class LLTextBox
|
||||
: public LLUICtrl
|
||||
{
|
||||
public:
|
||||
typedef boost::function<void (void)> callback_t;
|
||||
// By default, follows top and left and is mouse-opaque.
|
||||
// If no text, text = name.
|
||||
// If no font, uses default system font.
|
||||
@@ -93,7 +94,7 @@ public:
|
||||
void setVPad(S32 pixels) { mVPad = pixels; }
|
||||
void setRightAlign() { mHAlign = LLFontGL::RIGHT; }
|
||||
void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; }
|
||||
void setClickedCallback( void (*cb)(void *data), void* data = NULL ){ mClickedCallback = cb; mCallbackUserData = data; } // mouse down and up within button
|
||||
void setClickedCallback( callback_t cb ) { mClickedCallback = cb; }
|
||||
|
||||
const LLFontGL* getFont() const { return mFontGL; }
|
||||
|
||||
@@ -137,7 +138,7 @@ private:
|
||||
LLFontGL::VAlign mVAlign;
|
||||
|
||||
std::vector<S32> mLineLengthList;
|
||||
void (*mClickedCallback)(void* data );
|
||||
callback_t mClickedCallback;
|
||||
void* mCallbackUserData;
|
||||
};
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ LLTextEditor::LLTextEditor(
|
||||
const LLFontGL* font,
|
||||
BOOL allow_embedded_items)
|
||||
:
|
||||
LLUICtrl( name, rect, TRUE, NULL, NULL, FOLLOWS_TOP | FOLLOWS_LEFT ),
|
||||
LLUICtrl( name, rect, TRUE, NULL, FOLLOWS_TOP | FOLLOWS_LEFT ),
|
||||
mTextIsUpToDate(TRUE),
|
||||
mMaxTextByteLength( max_length ),
|
||||
mPopupMenuHandle(),
|
||||
@@ -331,7 +331,7 @@ LLTextEditor::LLTextEditor(
|
||||
lines_in_doc,
|
||||
0,
|
||||
page_size,
|
||||
NULL, this );
|
||||
NULL);
|
||||
mScrollbar->setFollowsRight();
|
||||
mScrollbar->setFollowsTop();
|
||||
mScrollbar->setFollowsBottom();
|
||||
@@ -2128,6 +2128,8 @@ void LLTextEditor::cut()
|
||||
deleteSelection( FALSE );
|
||||
|
||||
needsReflow();
|
||||
|
||||
onKeyStroke();
|
||||
}
|
||||
|
||||
BOOL LLTextEditor::canCopy() const
|
||||
@@ -2244,6 +2246,8 @@ void LLTextEditor::pasteHelper(bool is_primary)
|
||||
deselect();
|
||||
|
||||
needsReflow();
|
||||
|
||||
onKeyStroke();
|
||||
}
|
||||
|
||||
|
||||
@@ -2506,6 +2510,10 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask, BOOL* return
|
||||
break;
|
||||
}
|
||||
|
||||
if (handled)
|
||||
{
|
||||
onKeyStroke();
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
@@ -2665,6 +2673,7 @@ BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char)
|
||||
deselect();
|
||||
|
||||
needsReflow();
|
||||
onKeyStroke();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2723,6 +2732,7 @@ void LLTextEditor::doDelete()
|
||||
}
|
||||
|
||||
needsReflow();
|
||||
onKeyStroke();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -2766,6 +2776,7 @@ void LLTextEditor::undo()
|
||||
setCursorPos(pos);
|
||||
|
||||
needsReflow();
|
||||
onKeyStroke();
|
||||
}
|
||||
|
||||
BOOL LLTextEditor::canRedo() const
|
||||
@@ -2808,6 +2819,7 @@ void LLTextEditor::redo()
|
||||
setCursorPos(pos);
|
||||
|
||||
needsReflow();
|
||||
onKeyStroke();
|
||||
}
|
||||
|
||||
void LLTextEditor::onFocusReceived()
|
||||
@@ -5068,6 +5080,7 @@ void LLTextEditor::updatePreedit(const LLWString &preedit_string,
|
||||
|
||||
// Update of the preedit should be caused by some key strokes.
|
||||
mKeystrokeTimer.reset();
|
||||
onKeyStroke();
|
||||
}
|
||||
|
||||
BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const
|
||||
@@ -5226,3 +5239,13 @@ S32 LLTextEditor::getPreeditFontSize() const
|
||||
{
|
||||
return llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]);
|
||||
}
|
||||
|
||||
void LLTextEditor::setKeystrokeCallback(const keystroke_signal_t::slot_type& callback)
|
||||
{
|
||||
mKeystrokeSignal.connect(callback);
|
||||
}
|
||||
|
||||
void LLTextEditor::onKeyStroke()
|
||||
{
|
||||
mKeystrokeSignal(this);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,10 @@ public:
|
||||
|
||||
virtual ~LLTextEditor();
|
||||
|
||||
typedef boost::signals2::signal<void (LLTextEditor* caller)> keystroke_signal_t;
|
||||
|
||||
void setKeystrokeCallback(const keystroke_signal_t::slot_type& callback);
|
||||
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
|
||||
void setTextEditorParameters(LLXMLNodePtr node);
|
||||
@@ -480,6 +484,7 @@ private:
|
||||
// Methods
|
||||
//
|
||||
void pasteHelper(bool is_primary);
|
||||
void onKeyStroke();
|
||||
|
||||
void updateSegments();
|
||||
void pruneSegments();
|
||||
@@ -603,6 +608,7 @@ private:
|
||||
BOOL mHandleEditKeysDirectly;
|
||||
|
||||
LLCoordGL mLastIMEPosition; // Last position of the IME editor
|
||||
keystroke_signal_t mKeystrokeSignal;
|
||||
}; // end class LLTextEditor
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "lltrans.h"
|
||||
#include "llxmlnode.h"
|
||||
#include "lluictrlfactory.h"
|
||||
#include "llalertdialog.h"
|
||||
#include "llnotificationsutil.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -54,23 +54,24 @@ LLUICtrl::LLUICtrl() :
|
||||
{
|
||||
}
|
||||
|
||||
LLUICtrl::LLUICtrl(const std::string& name, const LLRect& rect, BOOL mouse_opaque,
|
||||
void (*on_commit_callback)(LLUICtrl*, void*),
|
||||
void* callback_userdata,
|
||||
LLUICtrl::LLUICtrl(const std::string& name, const LLRect rect, BOOL mouse_opaque,
|
||||
commit_callback_t commit_callback,
|
||||
U32 reshape)
|
||||
: // 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 ),
|
||||
mCommitSignal(NULL),
|
||||
mValidateSignal(NULL),
|
||||
mCommitCallback(NULL),
|
||||
mViewModel(LLViewModelPtr(new LLViewModel)),
|
||||
mCommitCallback( on_commit_callback),
|
||||
mValidateCallback( NULL ),
|
||||
mCallbackUserData( callback_userdata ),
|
||||
mCallbackUserData( NULL ),
|
||||
mTentative( FALSE ),
|
||||
mTabStop( TRUE ),
|
||||
mIsChrome(FALSE)
|
||||
{
|
||||
if(commit_callback)
|
||||
setCommitCallback(commit_callback);
|
||||
}
|
||||
|
||||
LLUICtrl::~LLUICtrl()
|
||||
|
||||
@@ -54,9 +54,8 @@ public:
|
||||
typedef BOOL (*LLUICtrlValidate)(LLUICtrl* ctrl, void* userdata);
|
||||
|
||||
LLUICtrl();
|
||||
LLUICtrl( const std::string& name, const LLRect& rect, BOOL mouse_opaque,
|
||||
LLUICtrlCallback callback,
|
||||
void* callback_userdata,
|
||||
LLUICtrl( const std::string& name, const LLRect rect = LLRect(), BOOL mouse_opaque = TRUE,
|
||||
commit_callback_t commit_callback = NULL,
|
||||
U32 reshape=FOLLOWS_NONE);
|
||||
/*virtual*/ ~LLUICtrl();
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ std::vector<std::string> LLUICtrlFactory::sXUIPaths;
|
||||
class LLUICtrlLocate : public LLUICtrl
|
||||
{
|
||||
public:
|
||||
LLUICtrlLocate() : LLUICtrl(std::string("locate"), LLRect(0,0,0,0), FALSE, NULL, NULL) { setTabStop(FALSE); }
|
||||
LLUICtrlLocate() : LLUICtrl(std::string("locate"), LLRect(0,0,0,0), FALSE) { setTabStop(FALSE); }
|
||||
virtual void draw() { }
|
||||
|
||||
virtual LLXMLNodePtr getXML(bool save_children = true) const
|
||||
|
||||
Reference in New Issue
Block a user