summaryrefslogtreecommitdiff
path: root/indra/llui/llsearcheditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llsearcheditor.cpp')
-rw-r--r--indra/llui/llsearcheditor.cpp82
1 files changed, 28 insertions, 54 deletions
diff --git a/indra/llui/llsearcheditor.cpp b/indra/llui/llsearcheditor.cpp
index 9522d32a8b..3516712dc9 100644
--- a/indra/llui/llsearcheditor.cpp
+++ b/indra/llui/llsearcheditor.cpp
@@ -1,6 +1,6 @@
/**
- * @file lllineeditor.cpp
- * @brief LLLineEditor base class
+ * @file llsearcheditor.cpp
+ * @brief LLSearchEditor implementation
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
@@ -36,89 +36,63 @@
#include "llsearcheditor.h"
-//static LLDefaultWidgetRegistry::Register<LLSearchEditor> r2("search_editor");
-
LLSearchEditor::LLSearchEditor(const LLSearchEditor::Params& p)
: LLUICtrl(p)
{
- LLLineEditor::Params line_editor_p(p);
- line_editor_p.name("search edit box");
- line_editor_p.rect(getLocalRect());
- line_editor_p.follows.flags(FOLLOWS_ALL);
- line_editor_p.text_pad_right(getRect().getHeight());
- line_editor_p.keystroke_callback(boost::bind(&LLSearchEditor::onSearchEdit, this, _1));
-
- mSearchEdit = LLUICtrlFactory::create<LLLineEditor>(line_editor_p);
- addChild(mSearchEdit);
-
- S32 btn_width = getRect().getHeight(); // button is square, and as tall as search editor
- LLRect clear_btn_rect(getRect().getWidth() - btn_width, getRect().getHeight(), getRect().getWidth(), 0);
- LLButton::Params button_params(p.clear_search_button);
- button_params.name(std::string("clear search"));
- button_params.rect(clear_btn_rect) ;
+ const S32 fudge = 2;
+ S32 btn_height = getRect().getHeight() - (fudge * 2);
+
+ LLLineEditor::Params line_editor_params(p);
+ line_editor_params.name("filter edit box");
+ line_editor_params.rect(getLocalRect());
+ line_editor_params.follows.flags(FOLLOWS_ALL);
+ line_editor_params.text_pad_left(btn_height + fudge);
+ line_editor_params.commit_callback.function(boost::bind(&LLUICtrl::onCommit, this));
+
+ mSearchEditor = LLUICtrlFactory::create<LLLineEditor>(line_editor_params);
+ addChild(mSearchEditor);
+
+ LLRect search_btn_rect(fudge, fudge + btn_height, fudge + btn_height, fudge);
+ LLButton::Params button_params(p.search_button);
+ button_params.name(std::string("clear filter"));
+ button_params.rect(search_btn_rect) ;
button_params.follows.flags(FOLLOWS_RIGHT|FOLLOWS_TOP);
button_params.tab_stop(false);
- button_params.click_callback.function(boost::bind(&LLSearchEditor::onClearSearch, this, _2));
+ button_params.click_callback.function(boost::bind(&LLUICtrl::onCommit, this));
- mClearSearchButton = LLUICtrlFactory::create<LLButton>(button_params);
- mSearchEdit->addChild(mClearSearchButton);
+ mSearchButton = LLUICtrlFactory::create<LLButton>(button_params);
+ mSearchEditor->addChild(mSearchButton);
}
//virtual
void LLSearchEditor::setValue(const LLSD& value )
{
- mSearchEdit->setValue(value);
+ mSearchEditor->setValue(value);
}
//virtual
LLSD LLSearchEditor::getValue() const
{
- return mSearchEdit->getValue();
+ return mSearchEditor->getValue();
}
//virtual
BOOL LLSearchEditor::setTextArg( const std::string& key, const LLStringExplicit& text )
{
- return mSearchEdit->setTextArg(key, text);
+ return mSearchEditor->setTextArg(key, text);
}
//virtual
BOOL LLSearchEditor::setLabelArg( const std::string& key, const LLStringExplicit& text )
{
- return mSearchEdit->setLabelArg(key, text);
+ return mSearchEditor->setLabelArg(key, text);
}
//virtual
void LLSearchEditor::clear()
{
- if (mSearchEdit)
+ if (mSearchEditor)
{
- mSearchEdit->clear();
+ mSearchEditor->clear();
}
}
-
-void LLSearchEditor::draw()
-{
- mClearSearchButton->setVisible(!mSearchEdit->getWText().empty());
-
- LLUICtrl::draw();
-}
-
-
-void LLSearchEditor::onSearchEdit(LLLineEditor* caller )
-{
- if (mSearchCallback)
- {
- mSearchCallback(caller->getText());
- }
-}
-
-void LLSearchEditor::onClearSearch(const LLSD& data)
-{
- setText(LLStringUtil::null);
- if (mSearchCallback)
- {
- mSearchCallback(LLStringUtil::null);
- }
-}
-