|
@@ -52,23 +52,31 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
|
|
|
resize(400, 300);
|
|
|
|
|
|
auto& scrollable_container = *main_widget.find_descendant_of_type_named<GUI::ScrollableContainerWidget>("scrollable_container"sv);
|
|
|
- auto& emojis_widget = *main_widget.find_descendant_of_type_named<GUI::Widget>("emojis"sv);
|
|
|
- auto code_points = supported_emoji_code_points();
|
|
|
+ m_emojis_widget = main_widget.find_descendant_of_type_named<GUI::Widget>("emojis"sv);
|
|
|
+ m_code_points = supported_emoji_code_points();
|
|
|
|
|
|
- size_t index = 0;
|
|
|
- size_t columns = 18;
|
|
|
- size_t rows = ceil_div(code_points.size(), columns);
|
|
|
+ scrollable_container.horizontal_scrollbar().set_visible(false);
|
|
|
+ update_displayed_emoji();
|
|
|
|
|
|
- constexpr int button_size = 20;
|
|
|
+ on_active_window_change = [this](bool is_active_window) {
|
|
|
+ if (!is_active_window)
|
|
|
+ close();
|
|
|
+ };
|
|
|
+}
|
|
|
|
|
|
- scrollable_container.horizontal_scrollbar().set_visible(false);
|
|
|
+void EmojiInputDialog::update_displayed_emoji()
|
|
|
+{
|
|
|
+ constexpr int button_size = 20;
|
|
|
+ constexpr size_t columns = 18;
|
|
|
+ size_t rows = ceil_div(m_code_points.size(), columns);
|
|
|
+ size_t index = 0;
|
|
|
|
|
|
- for (size_t row = 0; row < rows && index < code_points.size(); ++row) {
|
|
|
- auto& horizontal_container = emojis_widget.add<Widget>();
|
|
|
+ for (size_t row = 0; row < rows && index < m_code_points.size(); ++row) {
|
|
|
+ auto& horizontal_container = m_emojis_widget->add<Widget>();
|
|
|
auto& horizontal_layout = horizontal_container.set_layout<HorizontalBoxLayout>();
|
|
|
horizontal_layout.set_spacing(0);
|
|
|
for (size_t column = 0; column < columns; ++column) {
|
|
|
- if (index < code_points.size()) {
|
|
|
+ if (index < m_code_points.size()) {
|
|
|
// FIXME: Also emit U+FE0F for single code point emojis, currently
|
|
|
// they get shown as text glyphs if available.
|
|
|
// This will require buttons to don't calculate their length as 2,
|
|
@@ -76,7 +84,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
|
|
|
// tweaking of the mechanism that is currently being used to insert
|
|
|
// which is a key event with a single code point.
|
|
|
StringBuilder builder;
|
|
|
- builder.append(Utf32View(&code_points[index++], 1));
|
|
|
+ builder.append(Utf32View(&m_code_points[index++], 1));
|
|
|
auto emoji_text = builder.to_string();
|
|
|
auto& button = horizontal_container.add<Button>(emoji_text);
|
|
|
button.set_fixed_size(button_size, button_size);
|
|
@@ -90,11 +98,6 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- on_active_window_change = [this](bool is_active_window) {
|
|
|
- if (!is_active_window)
|
|
|
- close();
|
|
|
- };
|
|
|
}
|
|
|
|
|
|
void EmojiInputDialog::event(Core::Event& event)
|