LibGUI: Convert EmojiInputDialog to GML

This will allow easily adding components such as a search box. Also,
increase the number of emoji per row. This does not fix the issue where
too many emoji will cause the dialog to grow limitlessly, but it looks a
bit more reasonable now with the number of emoji that we have.
This commit is contained in:
Timothy Flynn 2022-09-01 08:48:07 -04:00 committed by Linus Groh
parent e268316865
commit 11d29bc2ea
Notes: sideshowbarker 2024-07-17 07:35:03 +09:00
3 changed files with 22 additions and 9 deletions

View file

@ -12,6 +12,7 @@
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
#include <LibGUI/EmojiInputDialog.h>
#include <LibGUI/EmojiInputDialogGML.h>
#include <LibGUI/Event.h>
#include <LibGUI/Frame.h>
#include <stdlib.h>
@ -43,20 +44,17 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
: Dialog(parent_window)
{
auto& main_widget = set_main_widget<Frame>();
main_widget.set_frame_shape(Gfx::FrameShape::Container);
main_widget.set_frame_shadow(Gfx::FrameShadow::Raised);
main_widget.set_fill_with_background_color(true);
auto& main_layout = main_widget.set_layout<VerticalBoxLayout>();
main_layout.set_margins(1);
main_layout.set_spacing(0);
if (!main_widget.load_from_gml(emoji_input_dialog_gml))
VERIFY_NOT_REACHED();
auto& emojis_widget = *main_widget.find_descendant_of_type_named<GUI::Widget>("emojis"sv);
auto code_points = supported_emoji_code_points();
size_t index = 0;
size_t columns = 10;
size_t columns = 18;
size_t rows = ceil_div(code_points.size(), columns);
constexpr int button_size = 18;
constexpr int button_size = 20;
// FIXME: I have no idea why this is needed, you'd think that button width * number of buttons would make them fit, but the last one gets cut off.
constexpr int magic_offset = 7;
int dialog_width = button_size * columns + magic_offset;
@ -66,7 +64,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
set_frameless(true);
for (size_t row = 0; row < rows && index < code_points.size(); ++row) {
auto& horizontal_container = main_widget.add<Widget>();
auto& horizontal_container = 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) {