summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Applications/FontEditor/FontEditor.cpp22
-rw-r--r--Applications/FontEditor/main.cpp2
-rw-r--r--LibGUI/GGroupBox.cpp31
-rw-r--r--LibGUI/GGroupBox.h19
-rw-r--r--LibGUI/Makefile1
5 files changed, 65 insertions, 10 deletions
diff --git a/Applications/FontEditor/FontEditor.cpp b/Applications/FontEditor/FontEditor.cpp
index 1ebedb37a9..0fa7cd1686 100644
--- a/Applications/FontEditor/FontEditor.cpp
+++ b/Applications/FontEditor/FontEditor.cpp
@@ -7,6 +7,7 @@
#include <LibGUI/GTextBox.h>
#include <LibGUI/GCheckBox.h>
#include <LibGUI/GSpinBox.h>
+#include <LibGUI/GGroupBox.h>
#include <stdlib.h>
FontEditorWidget::FontEditorWidget(const String& path, RetainPtr<Font>&& edited_font, GWidget* parent)
@@ -26,20 +27,23 @@ FontEditorWidget::FontEditorWidget(const String& path, RetainPtr<Font>&& edited_
m_glyph_editor_widget = new GlyphEditorWidget(*m_edited_font, this);
m_glyph_editor_widget->move_to({ 5, 5 });
- auto* fixed_width_checkbox = new GCheckBox(this);
- fixed_width_checkbox->set_caption("Fixed width");
- fixed_width_checkbox->set_checked(m_edited_font->is_fixed_width());
- fixed_width_checkbox->set_relative_rect({ 5, 195, 100, 20 });
+ auto* font_group_box = new GGroupBox("Font metadata", this);
+ font_group_box->set_relative_rect(5, 195, 210, 70);
- m_name_textbox = new GTextBox(this);
- m_name_textbox->set_relative_rect({ 5, 220, 300, 20 });
+ m_name_textbox = new GTextBox(font_group_box);
+ m_name_textbox->set_relative_rect(10, 20, 180, 20);
m_name_textbox->set_text(m_edited_font->name());
m_name_textbox->on_change = [this] {
m_edited_font->set_name(m_name_textbox->text());
};
+ auto* fixed_width_checkbox = new GCheckBox(font_group_box);
+ fixed_width_checkbox->set_relative_rect(10, 45, 190, 20);
+ fixed_width_checkbox->set_caption("Fixed width");
+ fixed_width_checkbox->set_checked(m_edited_font->is_fixed_width());
+
m_path_textbox = new GTextBox(this);
- m_path_textbox->set_relative_rect({ 5, 245, 300, 20 });
+ m_path_textbox->set_relative_rect(5, 270, 210, 20);
m_path_textbox->set_text(m_path);
m_path_textbox->on_change = [this] {
m_path = m_path_textbox->text();
@@ -47,7 +51,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RetainPtr<Font>&& edited_
auto* save_button = new GButton(this);
save_button->set_caption("Save");
- save_button->set_relative_rect({ 5, 270, 100, 20 });
+ save_button->set_relative_rect({ 5, 300, 105, 20 });
save_button->on_click = [this] (GButton&) {
dbgprintf("write to file: '%s'\n", m_path.characters());
m_edited_font->write_to_file(m_path);
@@ -55,7 +59,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RetainPtr<Font>&& edited_
auto* quit_button = new GButton(this);
quit_button->set_caption("Quit");
- quit_button->set_relative_rect({ 110, 270, 100, 20 });
+ quit_button->set_relative_rect({ 110, 300, 105, 20 });
quit_button->on_click = [] (GButton&) {
exit(0);
};
diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp
index dfd0d8132f..cc4010d0b8 100644
--- a/Applications/FontEditor/main.cpp
+++ b/Applications/FontEditor/main.cpp
@@ -26,7 +26,7 @@ int main(int argc, char** argv)
auto* window = new GWindow;
window->set_title("FontEditor");
- window->set_rect({ 50, 50, 390, 295 });
+ window->set_rect({ 50, 50, 390, 325 });
auto* font_editor = new FontEditorWidget(path, move(edited_font));
window->set_main_widget(font_editor);
window->set_should_exit_event_loop_on_close(true);
diff --git a/LibGUI/GGroupBox.cpp b/LibGUI/GGroupBox.cpp
new file mode 100644
index 0000000000..5aba8b5e87
--- /dev/null
+++ b/LibGUI/GGroupBox.cpp
@@ -0,0 +1,31 @@
+#include <LibGUI/GGroupBox.h>
+#include <LibGUI/GPainter.h>
+#include <SharedGraphics/StylePainter.h>
+
+GGroupBox::GGroupBox(const String& name, GWidget* parent)
+ : GWidget(parent)
+ , m_name(name)
+{
+ set_fill_with_background_color(true);
+ set_background_color(Color::LightGray);
+}
+
+GGroupBox::~GGroupBox()
+{
+}
+
+void GGroupBox::paint_event(GPaintEvent& event)
+{
+ GPainter painter(*this);
+ painter.add_clip_rect(event.rect());
+
+ Rect frame_rect {
+ 0, font().glyph_height() / 2,
+ width(), height() - font().glyph_height() / 2
+ };
+ StylePainter::paint_frame(painter, frame_rect, FrameShape::Panel, FrameShadow::Sunken, 1);
+
+ Rect text_rect { 4, 0, font().width(m_name) + 6, font().glyph_height() };
+ painter.fill_rect(text_rect, background_color());
+ painter.draw_text(text_rect, m_name, TextAlignment::Center, foreground_color());
+}
diff --git a/LibGUI/GGroupBox.h b/LibGUI/GGroupBox.h
new file mode 100644
index 0000000000..1f0f533794
--- /dev/null
+++ b/LibGUI/GGroupBox.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <LibGUI/GWidget.h>
+
+class GGroupBox : public GWidget {
+public:
+ GGroupBox(const String& name, GWidget* parent);
+ virtual ~GGroupBox() override;
+
+ String name() const { return m_name; }
+
+ virtual const char* class_name() const override { return "GGroupBox"; }
+
+protected:
+ virtual void paint_event(GPaintEvent&) override;
+
+private:
+ String m_name;
+};
diff --git a/LibGUI/Makefile b/LibGUI/Makefile
index f36ebbedf8..f0a4ec1ccc 100644
--- a/LibGUI/Makefile
+++ b/LibGUI/Makefile
@@ -64,6 +64,7 @@ LIBGUI_OBJS = \
GHttpResponse.o \
GHttpJob.o \
GSpinBox.o \
+ GGroupBox.o \
GWindow.o
OBJS = $(SHAREDGRAPHICS_OBJS) $(LIBGUI_OBJS)