Skip to content
Snippets Groups Projects
Commit fbf5b199 authored by Alexander Gavriliuk's avatar Alexander Gavriliuk Committed by Guru
Browse files

SL-19575 LLFloaterEmojiPicker - code cleanup and layout fixup

parent 8fcf6916
No related branches found
No related tags found
No related merge requests found
......@@ -237,6 +237,7 @@ Ansariel Hiller
SL-15227
SL-15398
SL-18432
SL-19575
SL-19623
Aralara Rajal
Arare Chantilly
......
......@@ -57,8 +57,11 @@ class LLEmojiDictionary : public LLParamSingleton<LLEmojiDictionary>, public LLI
public:
typedef std::map<llwchar, const LLEmojiDescriptor*> emoji2descr_map_t;
typedef std::pair<llwchar, const LLEmojiDescriptor*> emoji2descr_item_t;
typedef std::map<std::string, const LLEmojiDescriptor*> code2descr_map_t;
typedef std::pair<std::string, const LLEmojiDescriptor*> code2descr_item_t;
typedef std::map<std::string, std::vector<const LLEmojiDescriptor*>> cat2descrs_map_t;
typedef std::pair<std::string, std::vector<const LLEmojiDescriptor*>> cat2descrs_item_t;
static void initClass();
LLWString findMatchingEmojis(const std::string& needle) const;
......
......@@ -111,7 +111,7 @@ class LLView
Alternative<std::string> string;
Alternative<U32> flags;
Follows();
Follows();
};
struct Params : public LLInitParam::Block<Params>
......@@ -656,8 +656,8 @@ class LLView
// Draw debug rectangles around widgets to help with alignment and spacing
static bool sDebugRects;
static bool sIsRectDirty;
static LLRect sDirtyRect;
static bool sIsRectDirty;
static LLRect sDirtyRect;
// Draw widget names and sizes when drawing debug rectangles, turning this
// off is useful to make the rectangles themselves easier to see.
......@@ -700,20 +700,16 @@ template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) co
if (!result)
{
result = LLUICtrlFactory::getDefaultWidget<T>(name);
if (result)
{
// *NOTE: You cannot call mFoo = getChild<LLFoo>("bar")
// in a floater or panel constructor. The widgets will not
// be ready. Instead, put it in postBuild().
LL_WARNS() << "Making dummy " << typeid(T).name() << " named \"" << name << "\" in " << getName() << LL_ENDL;
}
else
if (!result)
{
LL_WARNS() << "Failed to create dummy " << typeid(T).name() << LL_ENDL;
return NULL;
LL_ERRS() << "Failed to create dummy " << typeid(T).name() << LL_ENDL;
}
// *NOTE: You cannot call mFoo = getChild<LLFoo>("bar")
// in a floater or panel constructor. The widgets will not
// be ready. Instead, put it in postBuild().
LL_WARNS() << "Making dummy " << typeid(T).name() << " named \"" << name << "\" in " << getName() << LL_ENDL;
getDefaultWidgetContainer().addChild(result);
}
}
......
......@@ -73,15 +73,14 @@ LLFloaterEmojiPicker* LLFloaterEmojiPicker::getInstance()
{
LLFloaterEmojiPicker* floater = LLFloaterReg::getTypedInstance<LLFloaterEmojiPicker>("emoji_picker");
if (!floater)
LL_WARNS() << "Cannot instantiate emoji picker" << LL_ENDL;
LL_ERRS() << "Cannot instantiate emoji picker" << LL_ENDL;
return floater;
}
LLFloaterEmojiPicker* LLFloaterEmojiPicker::showInstance(pick_callback_t pick_callback, close_callback_t close_callback)
{
LLFloaterEmojiPicker* floater = getInstance();
if (floater)
floater->show(pick_callback, close_callback);
floater->show(pick_callback, close_callback);
return floater;
}
......@@ -106,9 +105,9 @@ BOOL LLFloaterEmojiPicker::postBuild()
mCategory = getChild<LLComboBox>("Category");
mCategory->setCommitCallback(boost::bind(&LLFloaterEmojiPicker::onCategoryCommit, this));
const auto& cat2Descrs = LLEmojiDictionary::instance().getCategory2Descrs();
const LLEmojiDictionary::cat2descrs_map_t& cat2Descrs = LLEmojiDictionary::instance().getCategory2Descrs();
mCategory->clearRows();
for (const auto& item : cat2Descrs)
for (const LLEmojiDictionary::cat2descrs_item_t& item : cat2Descrs)
{
std::string value = item.first;
std::string name = value;
......@@ -139,8 +138,8 @@ void LLFloaterEmojiPicker::fillEmojis()
{
mEmojis->clearRows();
const auto& emoji2Descr = LLEmojiDictionary::instance().getEmoji2Descr();
for (const std::pair<const llwchar, const LLEmojiDescriptor*>& it : emoji2Descr)
const LLEmojiDictionary::emoji2descr_map_t& emoji2Descr = LLEmojiDictionary::instance().getEmoji2Descr();
for (const LLEmojiDictionary::emoji2descr_item_t& it : emoji2Descr)
{
const LLEmojiDescriptor* descr = it.second;
......@@ -179,10 +178,10 @@ bool LLFloaterEmojiPicker::matchesPattern(const LLEmojiDescriptor* descr)
{
if (descr->Name.find(mSearchPattern) != std::string::npos)
return true;
for (auto shortCode : descr->ShortCodes)
for (const std::string& shortCode : descr->ShortCodes)
if (shortCode.find(mSearchPattern) != std::string::npos)
return true;
for (auto category : descr->Categories)
for (const std::string& category : descr->Categories)
if (category.find(mSearchPattern) != std::string::npos)
return true;
return false;
......@@ -204,7 +203,7 @@ void LLFloaterEmojiPicker::onSearchKeystroke(LLLineEditor* caller, void* user_da
void LLFloaterEmojiPicker::onPreviewEmojiClick()
{
if (mEmojis && mEmojiPickCallback)
if (mEmojiPickCallback)
{
if (LLEmojiScrollListItem* item = dynamic_cast<LLEmojiScrollListItem*>(mEmojis->getFirstSelected()))
{
......@@ -221,8 +220,7 @@ void LLFloaterEmojiPicker::onEmojiSelect()
mSelectedEmojiIndex = mEmojis->getFirstSelectedIndex();
LLUIString text;
text.insert(0, LLWString(1, item->getEmoji()));
if (mPreviewEmoji)
mPreviewEmoji->setLabel(text);
mPreviewEmoji->setLabel(text);
return;
}
......@@ -232,13 +230,12 @@ void LLFloaterEmojiPicker::onEmojiSelect()
void LLFloaterEmojiPicker::onEmojiEmpty()
{
mSelectedEmojiIndex = 0;
if (mPreviewEmoji)
mPreviewEmoji->setLabel(LLUIString());
mPreviewEmoji->setLabel(LLUIString());
}
void LLFloaterEmojiPicker::onEmojiPick()
{
if (mEmojis && mEmojiPickCallback)
if (mEmojiPickCallback)
{
if (LLEmojiScrollListItem* item = dynamic_cast<LLEmojiScrollListItem*>(mEmojis->getFirstSelected()))
{
......
......@@ -11,44 +11,44 @@
width="200">
<line_editor
name="Search"
label="Type to search an emoji"
label="Type to search"
layout="bottomleft"
follows="bottom|left|right"
text_tentative_color="TextFgTentativeColor"
max_length_bytes="63"
bottom="5"
left="39"
bottom="14"
left="34"
height="29"
width="158" />
width="162" />
<button
name="PreviewEmoji"
name="PreviewEmoji"
layout="bottomleft"
follows="bottom|left"
font="EmojiHuge"
use_font_color="true"
bottom="5"
left="5"
height="29"
width="29" />
font="EmojiHuge"
use_font_color="true"
bottom="14"
left="2"
height="29"
width="29" />
<scroll_list
name="Emojis"
layout="topleft"
follows="all"
sort_column="0"
max_chars="63"
commit_on_selection_change="true"
max_chars="63"
commit_on_selection_change="true"
draw_heading="true"
heading_height="25"
left="5"
row_padding="0"
top="25"
height="338"
width="192">
row_padding="0"
top="25"
left="0"
height="330"
width="200">
<columns
label="Look"
label="@"
name="look"
width="50" />
<columns
width="16" />
<columns
label="Name"
name="name" />
</scroll_list>
......@@ -57,9 +57,9 @@
label="Choose a category"
layout="topleft"
follows="top|left|right"
allow_text_entry="true"
top="0"
left="5"
allow_text_entry="true"
top="0"
left="2"
height="25"
width="192" />
width="196" />
</floater>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment