LibGUI: Add a GToolBar class that can be populated with GActions.

The same action can be added to both a menu and a toolbar.
Use this to put a toolbar into FileManager. This is pretty neat. :^)
This commit is contained in:
Andreas Kling 2019-02-20 02:39:46 +01:00
commit b704d3d295
Notes: sideshowbarker 2024-07-19 15:40:07 +09:00
24 changed files with 196 additions and 44 deletions

25
LibGUI/GToolBar.h Normal file
View file

@ -0,0 +1,25 @@
#pragma once
#include <LibGUI/GWidget.h>
class GAction;
class GToolBar : public GWidget {
public:
explicit GToolBar(GWidget* parent);
virtual ~GToolBar() override;
void add_action(RetainPtr<GAction>&&);
void add_separator();
private:
virtual const char* class_name() const override { return "GToolBar"; }
virtual void paint_event(GPaintEvent&) override;
struct Item {
enum Type { Invalid, Separator, Action };
Type type { Invalid };
RetainPtr<GAction> action;
};
Vector<OwnPtr<Item>> m_items;
};