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:
thankyouverycool 2021-03-08 11:38:43 -05:00 committed by Andreas Kling
parent 5806630cf4
commit cf866cc75a
Notes: sideshowbarker 2024-07-18 21:30:02 +09:00
5 changed files with 48 additions and 2 deletions

View file

@ -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();

View file

@ -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;

View file

@ -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)

View file

@ -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)
{
}
};
}

View file

@ -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" },