mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:27:35 +00:00
LibGUI: Add PathBreadcrumbbar
This Widget wraps both a Breadcrumbbar and a TextBox for editing the path manually, based heavily on the existing code in FileManager. Breadcrumbbar itself requires outside code to micro-manage what it does. This class provides a simpler interface for it: Users don't have to worry about segments, they just give/receive a string for the current path.
This commit is contained in:
parent
f5cf41eb5d
commit
f0c2dcdbac
5 changed files with 228 additions and 2 deletions
45
Userland/Libraries/LibGUI/PathBreadcrumbbar.h
Normal file
45
Userland/Libraries/LibGUI/PathBreadcrumbbar.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class PathBreadcrumbbar : public Widget {
|
||||
C_OBJECT_ABSTRACT(PathBreadcrumbbar)
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<PathBreadcrumbbar>> try_create();
|
||||
virtual ~PathBreadcrumbbar() override;
|
||||
|
||||
void set_current_path(DeprecatedString const&);
|
||||
|
||||
void show_location_text_box();
|
||||
void hide_location_text_box();
|
||||
|
||||
bool has_parent_segment() const;
|
||||
bool has_child_segment() const;
|
||||
|
||||
void select_parent_segment();
|
||||
void select_child_segment();
|
||||
|
||||
Function<void(StringView path)> on_path_change;
|
||||
Function<void(StringView path, GUI::DropEvent const&)> on_paths_drop;
|
||||
Function<void()> on_hide_location_box;
|
||||
|
||||
private:
|
||||
PathBreadcrumbbar(NonnullRefPtr<GUI::TextBox>, NonnullRefPtr<GUI::Breadcrumbbar>);
|
||||
|
||||
NonnullRefPtr<GUI::TextBox> m_location_text_box;
|
||||
NonnullRefPtr<GUI::Breadcrumbbar> m_breadcrumbbar;
|
||||
|
||||
DeprecatedString m_current_path;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue