mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
LibGUI: Add a new GComboBox widget.
This widget combines a GTextEditor, a GButton, a GWindow and a GListView to implement a nice drop-down list. It's currently using the GWindowType::Tooltip type because that's the most appropriately behaving window type available at the moment. This should definitely be fixed though.
This commit is contained in:
parent
d0b7d5e84c
commit
7d17689e17
3 changed files with 128 additions and 0 deletions
35
LibGUI/GComboBox.h
Normal file
35
LibGUI/GComboBox.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GListView.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class GButton;
|
||||
class GTextEditor;
|
||||
|
||||
class GComboBox : public GWidget {
|
||||
public:
|
||||
explicit GComboBox(GWidget* parent = nullptr);
|
||||
virtual ~GComboBox() override;
|
||||
|
||||
String text() const;
|
||||
|
||||
void open();
|
||||
void close();
|
||||
|
||||
GModel* model() { return m_list_view->model(); }
|
||||
const GModel* model() const { return m_list_view->model(); }
|
||||
void set_model(NonnullRefPtr<GModel>);
|
||||
|
||||
Function<void(const String&)> on_change;
|
||||
|
||||
virtual const char* class_name() const override { return "GComboBox"; }
|
||||
|
||||
protected:
|
||||
virtual void resize_event(GResizeEvent&) override;
|
||||
|
||||
private:
|
||||
GTextEditor* m_editor { nullptr };
|
||||
GButton* m_open_button { nullptr };
|
||||
GWindow* m_list_window { nullptr };
|
||||
GListView* m_list_view { nullptr };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue