IncrementalSearchBanner: Port to GML compilation

This commit is contained in:
Aryan Baburajan 2024-04-02 13:52:43 +05:30 committed by Tim Schumacher
parent b2587cb11b
commit 3336d00241
5 changed files with 24 additions and 15 deletions

View file

@ -5,7 +5,7 @@ stringify_gml(DatePickerDialog.gml DatePickerDialogGML.h date_picker_dialog_gml)
compile_gml(EmojiInputDialog.gml EmojiInputDialogGML.cpp)
compile_gml(FontPickerDialog.gml FontPickerDialogGML.cpp)
compile_gml(FilePickerDialog.gml FilePickerDialogGML.cpp)
stringify_gml(IncrementalSearchBanner.gml IncrementalSearchBannerGML.h incremental_search_banner_gml)
compile_gml(IncrementalSearchBanner.gml IncrementalSearchBannerGML.cpp)
compile_gml(PasswordInputDialog.gml PasswordInputDialogGML.cpp)
set(SOURCES
@ -70,6 +70,7 @@ set(SOURCES
IconView.cpp
ImageWidget.cpp
IncrementalSearchBanner.cpp
IncrementalSearchBannerGML.cpp
INILexer.cpp
INISyntaxHighlighter.cpp
InputBox.cpp
@ -152,7 +153,6 @@ set(GENERATED_SOURCES
../../Services/WindowServer/WindowManagerServerEndpoint.h
../../Services/WindowServer/WindowServerEndpoint.h
DatePickerDialogGML.h
IncrementalSearchBannerGML.h
)
serenity_lib(LibGUI gui)

View file

@ -7,7 +7,6 @@
#include <LibGUI/Button.h>
#include <LibGUI/IncrementalSearchBanner.h>
#include <LibGUI/IncrementalSearchBannerGML.h>
#include <LibGUI/Label.h>
#include <LibGUI/Layout.h>
#include <LibGUI/Painter.h>
@ -16,10 +15,15 @@
namespace GUI {
IncrementalSearchBanner::IncrementalSearchBanner(TextEditor& editor)
: m_editor(editor)
ErrorOr<NonnullRefPtr<IncrementalSearchBanner>> IncrementalSearchBanner::try_create(TextEditor& editor)
{
auto widget = TRY(IncrementalSearchBanner::try_create());
widget->m_editor = editor;
return widget;
}
ErrorOr<void> IncrementalSearchBanner::initialize()
{
load_from_gml(incremental_search_banner_gml).release_value_but_fixme_should_propagate_errors();
m_index_label = find_descendant_of_type_named<Label>("incremental_search_banner_index_label");
m_wrap_search_button = find_descendant_of_type_named<Button>("incremental_search_banner_wrap_search_button");
@ -69,6 +73,7 @@ IncrementalSearchBanner::IncrementalSearchBanner(TextEditor& editor)
m_search_textbox->on_escape_pressed = [this]() {
hide();
};
return {};
}
void IncrementalSearchBanner::show()

View file

@ -1,4 +1,4 @@
@GUI::Widget {
@GUI::IncrementalSearchBanner {
fill_with_background_color: true
visible: false
layout: @GUI::HorizontalBoxLayout {
@ -20,7 +20,7 @@
@GUI::Button {
name: "incremental_search_banner_previous_button"
icon: "/res/icons/16x16/go-up.png"
icon_from_path: "/res/icons/16x16/go-up.png"
fixed_width: 18
button_style: "Coolbar"
focus_policy: "NoFocus"
@ -28,7 +28,7 @@
@GUI::Button {
name: "incremental_search_banner_next_button"
icon: "/res/icons/16x16/go-down.png"
icon_from_path: "/res/icons/16x16/go-down.png"
fixed_width: 18
button_style: "Coolbar"
focus_policy: "NoFocus"
@ -51,7 +51,7 @@
@GUI::Button {
name: "incremental_search_banner_wrap_search_button"
fixed_width: 24
icon: "/res/icons/16x16/reload.png"
icon_from_path: "/res/icons/16x16/reload.png"
tooltip: "Wrap Search"
checkable: true
checked: true
@ -62,7 +62,7 @@
@GUI::Button {
name: "incremental_search_banner_match_case_button"
fixed_width: 24
icon: "/res/icons/16x16/app-font-editor.png"
icon_from_path: "/res/icons/16x16/app-font-editor.png"
tooltip: "Match Case"
checkable: true
button_style: "Coolbar"

View file

@ -15,21 +15,25 @@ class IncrementalSearchBanner final : public Widget {
C_OBJECT(IncrementalSearchBanner);
public:
static ErrorOr<NonnullRefPtr<IncrementalSearchBanner>> try_create(TextEditor& editor);
ErrorOr<void> initialize();
virtual ~IncrementalSearchBanner() override = default;
void show();
void hide();
protected:
explicit IncrementalSearchBanner(TextEditor&);
virtual void paint_event(PaintEvent&) override;
virtual Optional<UISize> calculated_min_size() const override;
private:
IncrementalSearchBanner() = default;
static ErrorOr<NonnullRefPtr<IncrementalSearchBanner>> try_create();
void search(TextEditor::SearchDirection);
NonnullRefPtr<TextEditor> m_editor;
RefPtr<TextEditor> m_editor;
RefPtr<Button> m_close_button;
RefPtr<Button> m_next_button;
RefPtr<Button> m_previous_button;

View file

@ -67,7 +67,7 @@ TextEditor::TextEditor(Type type)
if (is_multi_line()) {
set_font(Gfx::FontDatabase::default_fixed_width_font());
set_wrapping_mode(WrappingMode::WrapAtWords);
m_search_banner = GUI::IncrementalSearchBanner::construct(*this);
m_search_banner = GUI::IncrementalSearchBanner::try_create(*this).release_value_but_fixme_should_propagate_errors();
set_banner_widget(m_search_banner);
}
vertical_scrollbar().set_step(line_height());