mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 10:12:25 -05:00
LibGUI: Register more GML properties and widgets
Register "placeholder" for TextEditor and ComboBox; "models_only" for ComboBox; Vertical/HorizontalSeparator for SeparatorWidget
This commit is contained in:
parent
5806630cf4
commit
cf866cc75a
Notes:
sideshowbarker
2024-07-18 21:30:02 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/cf866cc75a0 Pull-request: https://github.com/SerenityOS/serenity/pull/5741 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/emanuele6
5 changed files with 48 additions and 2 deletions
|
@ -60,6 +60,9 @@ private:
|
|||
|
||||
ComboBox::ComboBox()
|
||||
{
|
||||
REGISTER_STRING_PROPERTY("placeholder", editor_placeholder, set_editor_placeholder);
|
||||
REGISTER_BOOL_PROPERTY("model_only", only_allow_values_from_model, set_only_allow_values_from_model);
|
||||
|
||||
set_min_width(32);
|
||||
set_fixed_height(22);
|
||||
|
||||
|
@ -144,6 +147,16 @@ ComboBox::~ComboBox()
|
|||
{
|
||||
}
|
||||
|
||||
void ComboBox::set_editor_placeholder(const StringView& placeholder)
|
||||
{
|
||||
m_editor->set_placeholder(placeholder);
|
||||
}
|
||||
|
||||
const String& ComboBox::editor_placeholder() const
|
||||
{
|
||||
return m_editor->placeholder();
|
||||
}
|
||||
|
||||
void ComboBox::navigate(AbstractView::CursorMovement cursor_movement)
|
||||
{
|
||||
auto previous_selected = m_list_view->cursor_index();
|
||||
|
|
|
@ -60,6 +60,9 @@ public:
|
|||
int model_column() const;
|
||||
void set_model_column(int);
|
||||
|
||||
void set_editor_placeholder(const StringView& placeholder);
|
||||
const String& editor_placeholder() const;
|
||||
|
||||
Function<void(const String&, const ModelIndex&)> on_change;
|
||||
Function<void()> on_return_pressed;
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#include <LibGUI/SeparatorWidget.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
REGISTER_WIDGET(GUI, HorizontalSeparator)
|
||||
REGISTER_WIDGET(GUI, VerticalSeparator)
|
||||
|
||||
namespace GUI {
|
||||
|
||||
SeparatorWidget::SeparatorWidget(Gfx::Orientation orientation)
|
||||
|
|
|
@ -30,17 +30,43 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
class SeparatorWidget final : public Widget {
|
||||
class SeparatorWidget : public Widget {
|
||||
C_OBJECT(SeparatorWidget);
|
||||
|
||||
public:
|
||||
virtual ~SeparatorWidget() override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
explicit SeparatorWidget(Gfx::Orientation);
|
||||
|
||||
private:
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
const Gfx::Orientation m_orientation;
|
||||
};
|
||||
|
||||
class VerticalSeparator final : public SeparatorWidget {
|
||||
C_OBJECT(VerticalSeparator)
|
||||
public:
|
||||
virtual ~VerticalSeparator() override { }
|
||||
|
||||
private:
|
||||
VerticalSeparator()
|
||||
: SeparatorWidget(Gfx::Orientation::Vertical)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class HorizontalSeparator final : public SeparatorWidget {
|
||||
C_OBJECT(HorizontalSeparator)
|
||||
public:
|
||||
virtual ~HorizontalSeparator() override { }
|
||||
|
||||
private:
|
||||
HorizontalSeparator()
|
||||
: SeparatorWidget(Gfx::Orientation::Horizontal)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ TextEditor::TextEditor(Type type)
|
|||
: m_type(type)
|
||||
{
|
||||
REGISTER_STRING_PROPERTY("text", text, set_text);
|
||||
REGISTER_STRING_PROPERTY("placeholder", placeholder, set_placeholder);
|
||||
REGISTER_ENUM_PROPERTY("mode", mode, set_mode, Mode,
|
||||
{ Editable, "Editable" },
|
||||
{ ReadOnly, "ReadOnly" },
|
||||
|
|
Loading…
Add table
Reference in a new issue