diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp index 2a32d0054e..2bee2866e7 100644 --- a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp +++ b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -38,10 +39,6 @@ static Vector supported_emoji_code_points() EmojiInputDialog::EmojiInputDialog(Window* parent_window) : Dialog(parent_window) { - // FIXME: Dialog should automatically adjust to content - set_minimum_size(190, 190); - set_frameless(true); - auto& main_widget = set_main_widget(); main_widget.set_frame_shape(Gfx::FrameShape::Container); main_widget.set_frame_shadow(Gfx::FrameShadow::Raised); @@ -56,6 +53,15 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window) size_t columns = 10; size_t rows = ceil_div(code_points.size(), columns); + constexpr int button_size = 18; + // 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; + int dialog_height = button_size * rows; + + set_minimum_size(dialog_width, dialog_height); + set_frameless(true); + for (size_t row = 0; row < rows && index < code_points.size(); ++row) { auto& horizontal_container = main_widget.add(); auto& horizontal_layout = horizontal_container.set_layout(); @@ -66,7 +72,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window) builder.append(Utf32View(&code_points[index++], 1)); auto emoji_text = builder.to_string(); auto& button = horizontal_container.add