1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:57:35 +00:00

Everywhere: Run clang-format

This commit is contained in:
Idan Horowitz 2022-04-01 20:58:27 +03:00 committed by Linus Groh
parent 0376c127f6
commit 086969277e
1665 changed files with 8479 additions and 8479 deletions

View file

@ -35,17 +35,17 @@ static float get_normalized_aspect_ratio(float a, float b)
}
}
static bool node_is_leaf(const TreeMapNode& node)
static bool node_is_leaf(TreeMapNode const& node)
{
return node.num_children() == 0;
}
bool TreeMapWidget::rect_can_contain_label(const Gfx::IntRect& rect) const
bool TreeMapWidget::rect_can_contain_label(Gfx::IntRect const& rect) const
{
return rect.height() >= font().presentation_size() && rect.width() > 20;
}
void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, const TreeMapNode& node, const Gfx::IntRect& cell_rect, const Gfx::IntRect& inner_rect, int depth, HasLabel has_label) const
void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, TreeMapNode const& node, Gfx::IntRect const& cell_rect, Gfx::IntRect const& inner_rect, int depth, HasLabel has_label) const
{
if (cell_rect.width() <= 2 || cell_rect.height() <= 2) {
painter.fill_rect(cell_rect, Color::Black);
@ -101,7 +101,7 @@ void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, const TreeMapNode& n
}
template<typename Function>
void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect& rect, int depth, Function callback)
void TreeMapWidget::lay_out_children(TreeMapNode const& node, Gfx::IntRect const& rect, int depth, Function callback)
{
if (node.num_children() == 0) {
return;
@ -179,7 +179,7 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect
inner_rect = cell_rect;
inner_rect.shrink(4, 4); // border and shading
if (rect_can_contain_label(inner_rect)) {
const int margin = 5;
int const margin = 5;
has_label = HasLabel::Yes;
inner_rect.set_y(inner_rect.y() + font().presentation_size() + margin);
inner_rect.set_height(inner_rect.height() - (font().presentation_size() + margin * 2));
@ -214,11 +214,11 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect
}
}
const TreeMapNode* TreeMapWidget::path_node(size_t n) const
TreeMapNode const* TreeMapWidget::path_node(size_t n) const
{
if (!m_tree.ptr())
return nullptr;
const TreeMapNode* iter = &m_tree->root();
TreeMapNode const* iter = &m_tree->root();
size_t path_index = 0;
while (iter && path_index < m_path.size() && path_index < n) {
size_t child_index = m_path[path_index];
@ -238,13 +238,13 @@ void TreeMapWidget::paint_event(GUI::PaintEvent& event)
m_selected_node_cache = path_node(m_path.size());
const TreeMapNode* node = path_node(m_viewpoint);
TreeMapNode const* node = path_node(m_viewpoint);
if (!node) {
painter.fill_rect(frame_inner_rect(), Color::MidGray);
} else if (node_is_leaf(*node)) {
paint_cell_frame(painter, *node, frame_inner_rect(), Gfx::IntRect(), m_viewpoint - 1, HasLabel::Yes);
} else {
lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](const TreeMapNode& node, int, const Gfx::IntRect& rect, const Gfx::IntRect& inner_rect, int depth, HasLabel has_label, IsRemainder remainder) {
lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](TreeMapNode const& node, int, Gfx::IntRect const& rect, Gfx::IntRect const& inner_rect, int depth, HasLabel has_label, IsRemainder remainder) {
if (remainder == IsRemainder::No) {
paint_cell_frame(painter, node, rect, inner_rect, depth, has_label);
} else {
@ -258,14 +258,14 @@ void TreeMapWidget::paint_event(GUI::PaintEvent& event)
}
}
Vector<int> TreeMapWidget::path_to_position(const Gfx::IntPoint& position)
Vector<int> TreeMapWidget::path_to_position(Gfx::IntPoint const& position)
{
const TreeMapNode* node = path_node(m_viewpoint);
TreeMapNode const* node = path_node(m_viewpoint);
if (!node) {
return {};
}
Vector<int> path;
lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](const TreeMapNode&, int index, const Gfx::IntRect& rect, const Gfx::IntRect&, int, HasLabel, IsRemainder is_remainder) {
lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](TreeMapNode const&, int index, Gfx::IntRect const& rect, Gfx::IntRect const&, int, HasLabel, IsRemainder is_remainder) {
if (is_remainder == IsRemainder::No && rect.contains(position)) {
path.append(index);
}
@ -275,7 +275,7 @@ Vector<int> TreeMapWidget::path_to_position(const Gfx::IntPoint& position)
void TreeMapWidget::mousedown_event(GUI::MouseEvent& event)
{
const TreeMapNode* node = path_node(m_viewpoint);
TreeMapNode const* node = path_node(m_viewpoint);
if (node && !node_is_leaf(*node)) {
Vector<int> path = path_to_position(event.position());
if (!path.is_empty()) {
@ -293,7 +293,7 @@ void TreeMapWidget::doubleclick_event(GUI::MouseEvent& event)
{
if (event.button() != GUI::MouseButton::Primary)
return;
const TreeMapNode* node = path_node(m_viewpoint);
TreeMapNode const* node = path_node(m_viewpoint);
if (node && !node_is_leaf(*node)) {
Vector<int> path = path_to_position(event.position());
m_path.shrink(m_viewpoint);

View file

@ -15,7 +15,7 @@ struct TreeMapNode {
virtual String name() const = 0;
virtual i64 area() const = 0;
virtual size_t num_children() const = 0;
virtual const TreeMapNode& child_at(size_t i) const = 0;
virtual TreeMapNode const& child_at(size_t i) const = 0;
virtual void sort_children_by_area() const = 0;
protected:
@ -24,7 +24,7 @@ protected:
struct TreeMap : public RefCounted<TreeMap> {
virtual ~TreeMap() = default;
virtual const TreeMapNode& root() const = 0;
virtual TreeMapNode const& root() const = 0;
};
class TreeMapWidget final : public GUI::Frame {
@ -35,7 +35,7 @@ public:
Function<void()> on_path_change;
Function<void(GUI::ContextMenuEvent&)> on_context_menu_request;
size_t path_size() const;
const TreeMapNode* path_node(size_t n) const;
TreeMapNode const* path_node(size_t n) const;
size_t viewpoint() const;
void set_viewpoint(size_t);
void set_tree(RefPtr<TreeMap> tree);
@ -49,8 +49,8 @@ private:
virtual void context_menu_event(GUI::ContextMenuEvent&) override;
virtual void keydown_event(GUI::KeyEvent&) override;
bool rect_can_contain_children(const Gfx::IntRect& rect) const;
bool rect_can_contain_label(const Gfx::IntRect& rect) const;
bool rect_can_contain_children(Gfx::IntRect const& rect) const;
bool rect_can_contain_label(Gfx::IntRect const& rect) const;
enum class HasLabel {
Yes,
@ -62,14 +62,14 @@ private:
};
template<typename Function>
void lay_out_children(const TreeMapNode&, const Gfx::IntRect&, int depth, Function);
void paint_cell_frame(GUI::Painter&, const TreeMapNode&, const Gfx::IntRect&, const Gfx::IntRect&, int depth, HasLabel has_label) const;
Vector<int> path_to_position(const Gfx::IntPoint&);
void lay_out_children(TreeMapNode const&, Gfx::IntRect const&, int depth, Function);
void paint_cell_frame(GUI::Painter&, TreeMapNode const&, Gfx::IntRect const&, Gfx::IntRect const&, int depth, HasLabel has_label) const;
Vector<int> path_to_position(Gfx::IntPoint const&);
RefPtr<TreeMap> m_tree;
Vector<int> m_path;
size_t m_viewpoint { 0 };
const void* m_selected_node_cache;
void const* m_selected_node_cache;
};
}

View file

@ -46,7 +46,7 @@ struct TreeNode : public SpaceAnalyzer::TreeMapNode {
}
return 0;
}
virtual const TreeNode& child_at(size_t i) const override { return m_children->at(i); }
virtual TreeNode const& child_at(size_t i) const override { return m_children->at(i); }
virtual void sort_children_by_area() const override
{
if (m_children) {
@ -65,7 +65,7 @@ struct Tree : public SpaceAnalyzer::TreeMap {
: m_root(move(root_name)) {};
virtual ~Tree() {};
TreeNode m_root;
virtual const SpaceAnalyzer::TreeMapNode& root() const override
virtual SpaceAnalyzer::TreeMapNode const& root() const override
{
return m_root;
};
@ -278,7 +278,7 @@ static void analyze(RefPtr<Tree> tree, SpaceAnalyzer::TreeMapWidget& treemapwidg
treemapwidget.set_tree(tree);
}
static bool is_removable(const String& absolute_path)
static bool is_removable(String const& absolute_path)
{
VERIFY(!absolute_path.is_empty());
int access_result = access(LexicalPath::dirname(absolute_path).characters(), W_OK);
@ -287,14 +287,14 @@ static bool is_removable(const String& absolute_path)
return access_result == 0;
}
static String get_absolute_path_to_selected_node(const SpaceAnalyzer::TreeMapWidget& treemapwidget, bool include_last_node = true)
static String get_absolute_path_to_selected_node(SpaceAnalyzer::TreeMapWidget const& treemapwidget, bool include_last_node = true)
{
StringBuilder path_builder;
for (size_t k = 0; k < treemapwidget.path_size() - (include_last_node ? 0 : 1); k++) {
if (k != 0) {
path_builder.append('/');
}
const SpaceAnalyzer::TreeMapNode* node = treemapwidget.path_node(k);
SpaceAnalyzer::TreeMapNode const* node = treemapwidget.path_node(k);
path_builder.append(node->name());
}
return path_builder.build();