mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 13:27:35 +00:00
LibGUI: Ensure unknown emoji have a set display order
Currently, we use code point values as a tie break when sorting emoji by display order. When multiple code point emoji are supported, this will become a bit awkward. Rather than dealing with varying code point length while sorting, just set a maximum display order to ensure these are placed at the end.
This commit is contained in:
parent
b7ef36aa36
commit
4cb9472f97
2 changed files with 14 additions and 17 deletions
|
@ -125,7 +125,13 @@ auto EmojiInputDialog::supported_emoji() -> Vector<Emoji>
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u32 code_point = strtoul(basename.to_string().characters() + 2, nullptr, 16);
|
u32 code_point = strtoul(basename.to_string().characters() + 2, nullptr, 16);
|
||||||
|
|
||||||
auto emoji = Unicode::find_emoji_for_code_points({ code_point });
|
auto emoji = Unicode::find_emoji_for_code_points({ code_point });
|
||||||
|
if (!emoji.has_value()) {
|
||||||
|
emoji = Unicode::Emoji {};
|
||||||
|
emoji->group = Unicode::EmojiGroup::Unknown;
|
||||||
|
emoji->display_order = NumericLimits<u32>::max();
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Also emit U+FE0F for single code point emojis, currently
|
// FIXME: Also emit U+FE0F for single code point emojis, currently
|
||||||
// they get shown as text glyphs if available.
|
// they get shown as text glyphs if available.
|
||||||
|
@ -145,20 +151,14 @@ auto EmojiInputDialog::supported_emoji() -> Vector<Emoji>
|
||||||
done(ExecResult::OK);
|
done(ExecResult::OK);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (emoji.has_value())
|
if (!emoji->name.is_empty())
|
||||||
button->set_tooltip(emoji->name);
|
button->set_tooltip(emoji->name);
|
||||||
|
|
||||||
code_points.empend(code_point, move(button), move(emoji));
|
code_points.empend(move(button), emoji.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
quick_sort(code_points, [](auto const& lhs, auto const& rhs) {
|
quick_sort(code_points, [](auto const& lhs, auto const& rhs) {
|
||||||
if (lhs.emoji.has_value() && rhs.emoji.has_value())
|
return lhs.emoji.display_order < rhs.emoji.display_order;
|
||||||
return lhs.emoji->display_order < rhs.emoji->display_order;
|
|
||||||
if (lhs.emoji.has_value())
|
|
||||||
return true;
|
|
||||||
if (rhs.emoji.has_value())
|
|
||||||
return false;
|
|
||||||
return lhs.code_point < rhs.code_point;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return code_points;
|
return code_points;
|
||||||
|
@ -188,13 +188,11 @@ void EmojiInputDialog::update_displayed_emoji()
|
||||||
while (!found_match && (index < m_emojis.size())) {
|
while (!found_match && (index < m_emojis.size())) {
|
||||||
auto& emoji = m_emojis[index++];
|
auto& emoji = m_emojis[index++];
|
||||||
|
|
||||||
if (m_selected_category.has_value()) {
|
if (m_selected_category.has_value() && emoji.emoji.group != m_selected_category)
|
||||||
if (!emoji.emoji.has_value() || emoji.emoji->group != m_selected_category)
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (emoji.emoji.has_value())
|
if (!emoji.emoji.name.is_empty())
|
||||||
found_match = emoji.emoji->name.contains(m_search_box->text(), CaseSensitivity::CaseInsensitive);
|
found_match = emoji.emoji.name.contains(m_search_box->text(), CaseSensitivity::CaseInsensitive);
|
||||||
else
|
else
|
||||||
found_match = m_search_box->text().is_empty();
|
found_match = m_search_box->text().is_empty();
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,8 @@ class EmojiInputDialog final : public Dialog {
|
||||||
C_OBJECT(EmojiInputDialog);
|
C_OBJECT(EmojiInputDialog);
|
||||||
|
|
||||||
struct Emoji {
|
struct Emoji {
|
||||||
u32 code_point { 0 };
|
|
||||||
RefPtr<Button> button;
|
RefPtr<Button> button;
|
||||||
Optional<Unicode::Emoji> emoji;
|
Unicode::Emoji emoji;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue