1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:57:36 +00:00

FileManager: Add a "Location:" label.

This commit is contained in:
Andreas Kling 2019-03-20 22:01:02 +01:00
parent 86e2348b74
commit 1030e6b848
3 changed files with 14 additions and 0 deletions

View file

@ -7,6 +7,7 @@
#include <LibGUI/GToolBar.h>
#include <LibGUI/GMenuBar.h>
#include <LibGUI/GAction.h>
#include <LibGUI/GLabel.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
@ -36,7 +37,12 @@ int main(int argc, char** argv)
auto* main_toolbar = new GToolBar(widget);
auto* location_toolbar = new GToolBar(widget);
location_toolbar->layout()->set_margins({ 8, 3, 8, 3 });
location_toolbar->set_preferred_size({ 0, 21 });
auto* location_label = new GLabel("Location: ", location_toolbar);
location_label->size_to_fit();
auto* location_textbox = new GTextEditor(GTextEditor::SingleLine, location_toolbar);
auto* directory_table_view = new DirectoryTableView(widget);

View file

@ -43,3 +43,9 @@ void GLabel::paint_event(GPaintEvent& event)
if (!text().is_empty())
painter.draw_text({ 0, 0, width(), height() }, text(), m_text_alignment, foreground_color());
}
void GLabel::size_to_fit()
{
set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
set_preferred_size({ font().width(m_text), 0 });
}

View file

@ -22,6 +22,8 @@ public:
TextAlignment text_alignment() const { return m_text_alignment; }
void set_text_alignment(TextAlignment text_alignment) { m_text_alignment = text_alignment; }
void size_to_fit();
virtual const char* class_name() const override { return "GLabel"; }
private: