mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 18:22:45 +00:00 
			
		
		
		
	LibGUI: Move widget registrations to the corresponding cpp file
This gets a lot of unecessary includes out of Widget.cpp. Doing this didn't work before, but improvements in the C library and using dynamic libraries have likely un-broken it :^). Also, move the registration global object to an anonymous namespace. No reason it has to be an extern symbol.
This commit is contained in:
		
							parent
							
								
									0bf44ac9d8
								
							
						
					
					
						commit
						39908fd569
					
				
					 27 changed files with 59 additions and 56 deletions
				
			
		|  | @ -29,6 +29,8 @@ | ||||||
| #include <LibGUI/Button.h> | #include <LibGUI/Button.h> | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, BreadcrumbBar) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| // FIXME: Move this somewhere else
 | // FIXME: Move this somewhere else
 | ||||||
|  |  | ||||||
|  | @ -34,6 +34,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, Button) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| Button::Button(String text) | Button::Button(String text) | ||||||
|  |  | ||||||
|  | @ -31,6 +31,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, CheckBox) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| static const int s_box_width = 13; | static const int s_box_width = 13; | ||||||
|  |  | ||||||
|  | @ -30,6 +30,8 @@ | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, ColorInput) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| ColorInput::ColorInput() | ColorInput::ColorInput() | ||||||
|  |  | ||||||
|  | @ -33,6 +33,8 @@ | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, ComboBox) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| class ComboBoxEditor final : public TextEditor { | class ComboBoxEditor final : public TextEditor { | ||||||
|  |  | ||||||
|  | @ -29,6 +29,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, Frame) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| Frame::Frame() | Frame::Frame() | ||||||
|  |  | ||||||
|  | @ -30,6 +30,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, GroupBox) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| GroupBox::GroupBox(const StringView& title) | GroupBox::GroupBox(const StringView& title) | ||||||
|  |  | ||||||
|  | @ -30,6 +30,8 @@ | ||||||
| #include <LibGfx/Bitmap.h> | #include <LibGfx/Bitmap.h> | ||||||
| #include <LibGfx/ImageDecoder.h> | #include <LibGfx/ImageDecoder.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, ImageWidget) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| ImageWidget::ImageWidget(const StringView&) | ImageWidget::ImageWidget(const StringView&) | ||||||
|  |  | ||||||
|  | @ -30,6 +30,8 @@ | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, Label) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| Label::Label(String text) | Label::Label(String text) | ||||||
|  |  | ||||||
|  | @ -31,6 +31,8 @@ | ||||||
| #include <LibGfx/Font.h> | #include <LibGfx/Font.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, LinkLabel) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| LinkLabel::LinkLabel(String text) | LinkLabel::LinkLabel(String text) | ||||||
|  |  | ||||||
|  | @ -30,6 +30,8 @@ | ||||||
| #include <LibGUI/ScrollBar.h> | #include <LibGUI/ScrollBar.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, ListView) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| ListView::ListView() | ListView::ListView() | ||||||
|  |  | ||||||
|  | @ -29,6 +29,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, OpacitySlider) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| OpacitySlider::OpacitySlider(Gfx::Orientation orientation) | OpacitySlider::OpacitySlider(Gfx::Orientation orientation) | ||||||
|  |  | ||||||
|  | @ -30,6 +30,8 @@ | ||||||
| #include <LibGUI/ProgressBar.h> | #include <LibGUI/ProgressBar.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, ProgressBar) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| ProgressBar::ProgressBar() | ProgressBar::ProgressBar() | ||||||
|  |  | ||||||
|  | @ -31,6 +31,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, RadioButton) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| RadioButton::RadioButton(String text) | RadioButton::RadioButton(String text) | ||||||
|  |  | ||||||
|  | @ -31,6 +31,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, ScrollBar) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| static const char* s_up_arrow_bitmap_data = { | static const char* s_up_arrow_bitmap_data = { | ||||||
|  |  | ||||||
|  | @ -31,6 +31,10 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, HorizontalSlider) | ||||||
|  | REGISTER_WIDGET(GUI, Slider) | ||||||
|  | REGISTER_WIDGET(GUI, VerticalSlider) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| Slider::Slider(Orientation orientation) | Slider::Slider(Orientation orientation) | ||||||
|  |  | ||||||
|  | @ -28,6 +28,8 @@ | ||||||
| #include <LibGUI/SpinBox.h> | #include <LibGUI/SpinBox.h> | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, SpinBox) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| SpinBox::SpinBox() | SpinBox::SpinBox() | ||||||
|  |  | ||||||
|  | @ -30,6 +30,9 @@ | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, HorizontalSplitter) | ||||||
|  | REGISTER_WIDGET(GUI, VerticalSplitter) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| Splitter::Splitter(Orientation orientation) | Splitter::Splitter(Orientation orientation) | ||||||
|  |  | ||||||
|  | @ -33,6 +33,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, StatusBar) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| StatusBar::StatusBar(int label_count) | StatusBar::StatusBar(int label_count) | ||||||
|  |  | ||||||
|  | @ -35,6 +35,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, TabWidget) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| TabWidget::TabWidget() | TabWidget::TabWidget() | ||||||
|  |  | ||||||
|  | @ -26,6 +26,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/TextBox.h> | #include <LibGUI/TextBox.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, TextBox) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| TextBox::TextBox() | TextBox::TextBox() | ||||||
|  |  | ||||||
|  | @ -51,6 +51,8 @@ | ||||||
| 
 | 
 | ||||||
| //#define DEBUG_TEXTEDITOR
 | //#define DEBUG_TEXTEDITOR
 | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, TextEditor) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| TextEditor::TextEditor(Type type) | TextEditor::TextEditor(Type type) | ||||||
|  |  | ||||||
|  | @ -35,6 +35,8 @@ | ||||||
| #include <LibGUI/ToolBar.h> | #include <LibGUI/ToolBar.h> | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, ToolBar) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| ToolBar::ToolBar(Orientation orientation, int button_size) | ToolBar::ToolBar(Orientation orientation, int button_size) | ||||||
|  |  | ||||||
|  | @ -30,6 +30,8 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <LibGfx/StylePainter.h> | #include <LibGfx/StylePainter.h> | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, ToolBarContainer) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| void ToolBarContainer::child_event(Core::ChildEvent& event) | void ToolBarContainer::child_event(Core::ChildEvent& event) | ||||||
|  |  | ||||||
|  | @ -34,6 +34,8 @@ | ||||||
| 
 | 
 | ||||||
| //#define DEBUG_ITEM_RECTS
 | //#define DEBUG_ITEM_RECTS
 | ||||||
| 
 | 
 | ||||||
|  | REGISTER_WIDGET(GUI, TreeView) | ||||||
|  | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
| struct TreeView::MetadataForIndex { | struct TreeView::MetadataForIndex { | ||||||
|  |  | ||||||
|  | @ -29,34 +29,11 @@ | ||||||
| #include <LibGUI/Action.h> | #include <LibGUI/Action.h> | ||||||
| #include <LibGUI/Application.h> | #include <LibGUI/Application.h> | ||||||
| #include <LibGUI/BoxLayout.h> | #include <LibGUI/BoxLayout.h> | ||||||
| #include <LibGUI/BreadcrumbBar.h> |  | ||||||
| #include <LibGUI/Button.h> |  | ||||||
| #include <LibGUI/CheckBox.h> |  | ||||||
| #include <LibGUI/ColorInput.h> |  | ||||||
| #include <LibGUI/ComboBox.h> |  | ||||||
| #include <LibGUI/Event.h> | #include <LibGUI/Event.h> | ||||||
| #include <LibGUI/GMLParser.h> | #include <LibGUI/GMLParser.h> | ||||||
| #include <LibGUI/GroupBox.h> |  | ||||||
| #include <LibGUI/ImageWidget.h> |  | ||||||
| #include <LibGUI/Label.h> |  | ||||||
| #include <LibGUI/Layout.h> | #include <LibGUI/Layout.h> | ||||||
| #include <LibGUI/LinkLabel.h> |  | ||||||
| #include <LibGUI/ListView.h> |  | ||||||
| #include <LibGUI/Menu.h> | #include <LibGUI/Menu.h> | ||||||
| #include <LibGUI/OpacitySlider.h> |  | ||||||
| #include <LibGUI/Painter.h> | #include <LibGUI/Painter.h> | ||||||
| #include <LibGUI/ProgressBar.h> |  | ||||||
| #include <LibGUI/RadioButton.h> |  | ||||||
| #include <LibGUI/ScrollBar.h> |  | ||||||
| #include <LibGUI/Slider.h> |  | ||||||
| #include <LibGUI/SpinBox.h> |  | ||||||
| #include <LibGUI/Splitter.h> |  | ||||||
| #include <LibGUI/StatusBar.h> |  | ||||||
| #include <LibGUI/TabWidget.h> |  | ||||||
| #include <LibGUI/TextBox.h> |  | ||||||
| #include <LibGUI/ToolBar.h> |  | ||||||
| #include <LibGUI/ToolBarContainer.h> |  | ||||||
| #include <LibGUI/TreeView.h> |  | ||||||
| #include <LibGUI/Widget.h> | #include <LibGUI/Widget.h> | ||||||
| #include <LibGUI/Window.h> | #include <LibGUI/Window.h> | ||||||
| #include <LibGUI/WindowServerConnection.h> | #include <LibGUI/WindowServerConnection.h> | ||||||
|  | @ -66,38 +43,10 @@ | ||||||
| #include <LibGfx/Palette.h> | #include <LibGfx/Palette.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
| namespace GUI { |  | ||||||
| 
 |  | ||||||
| REGISTER_WIDGET(GUI, BreadcrumbBar) |  | ||||||
| REGISTER_WIDGET(GUI, Button) |  | ||||||
| REGISTER_WIDGET(GUI, CheckBox) |  | ||||||
| REGISTER_WIDGET(GUI, ColorInput) |  | ||||||
| REGISTER_WIDGET(GUI, ComboBox) |  | ||||||
| REGISTER_WIDGET(GUI, Frame) |  | ||||||
| REGISTER_WIDGET(GUI, GroupBox) |  | ||||||
| REGISTER_WIDGET(GUI, HorizontalSlider) |  | ||||||
| REGISTER_WIDGET(GUI, HorizontalSplitter) |  | ||||||
| REGISTER_WIDGET(GUI, ImageWidget) |  | ||||||
| REGISTER_WIDGET(GUI, Label) |  | ||||||
| REGISTER_WIDGET(GUI, LinkLabel) |  | ||||||
| REGISTER_WIDGET(GUI, ListView) |  | ||||||
| REGISTER_WIDGET(GUI, OpacitySlider) |  | ||||||
| REGISTER_WIDGET(GUI, ProgressBar) |  | ||||||
| REGISTER_WIDGET(GUI, RadioButton) |  | ||||||
| REGISTER_WIDGET(GUI, ScrollBar) |  | ||||||
| REGISTER_WIDGET(GUI, Slider) |  | ||||||
| REGISTER_WIDGET(GUI, SpinBox) |  | ||||||
| REGISTER_WIDGET(GUI, StatusBar) |  | ||||||
| REGISTER_WIDGET(GUI, TabWidget) |  | ||||||
| REGISTER_WIDGET(GUI, TextBox) |  | ||||||
| REGISTER_WIDGET(GUI, TextEditor) |  | ||||||
| REGISTER_WIDGET(GUI, ToolBar) |  | ||||||
| REGISTER_WIDGET(GUI, ToolBarContainer) |  | ||||||
| REGISTER_WIDGET(GUI, TreeView) |  | ||||||
| REGISTER_WIDGET(GUI, VerticalSlider) |  | ||||||
| REGISTER_WIDGET(GUI, VerticalSplitter) |  | ||||||
| REGISTER_WIDGET(GUI, Widget) | REGISTER_WIDGET(GUI, Widget) | ||||||
| 
 | 
 | ||||||
|  | namespace GUI { | ||||||
|  | 
 | ||||||
| static HashMap<String, WidgetClassRegistration*>& widget_classes() | static HashMap<String, WidgetClassRegistration*>& widget_classes() | ||||||
| { | { | ||||||
|     static HashMap<String, WidgetClassRegistration*>* map; |     static HashMap<String, WidgetClassRegistration*>* map; | ||||||
|  |  | ||||||
|  | @ -40,8 +40,9 @@ | ||||||
| #include <LibGfx/StandardCursor.h> | #include <LibGfx/StandardCursor.h> | ||||||
| 
 | 
 | ||||||
| #define REGISTER_WIDGET(namespace_, class_name)                                                                                                 \ | #define REGISTER_WIDGET(namespace_, class_name)                                                                                                 \ | ||||||
|     extern GUI::WidgetClassRegistration registration_##class_name; \ |     namespace {                                                                                                                                 \ | ||||||
|     GUI::WidgetClassRegistration registration_##class_name(#namespace_ "::" #class_name, []() { return namespace_::class_name::construct(); }); |     GUI::WidgetClassRegistration registration_##class_name(#namespace_ "::" #class_name, []() { return namespace_::class_name::construct(); }); \ | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| namespace GUI { | namespace GUI { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrew Kaster
						Andrew Kaster