summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-03-06 17:16:25 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-06 23:46:35 +0100
commit359d6e7b0b0ef7add9eb2015d0dd664a82cf73d7 (patch)
treebe51963e0f0dc7e1eeeb670188c8fe1fa5eea37f /Userland/Libraries/LibGUI
parent689ca370d4eca80eb5c3856a69c3eed4ed848a29 (diff)
downloadserenity-359d6e7b0b0ef7add9eb2015d0dd664a82cf73d7.zip
Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/CommandPalette.cpp8
-rw-r--r--Userland/Libraries/LibGUI/EditingEngine.cpp4
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.cpp22
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.h2
-rw-r--r--Userland/Libraries/LibGUI/Menu.cpp10
-rw-r--r--Userland/Libraries/LibGUI/Menu.h4
-rw-r--r--Userland/Libraries/LibGUI/RegularEditingEngine.cpp2
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.cpp2
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.h10
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp46
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.h6
-rw-r--r--Userland/Libraries/LibGUI/Toolbar.cpp26
-rw-r--r--Userland/Libraries/LibGUI/Toolbar.h2
-rw-r--r--Userland/Libraries/LibGUI/UndoStack.cpp10
-rw-r--r--Userland/Libraries/LibGUI/UndoStack.h2
15 files changed, 78 insertions, 78 deletions
diff --git a/Userland/Libraries/LibGUI/CommandPalette.cpp b/Userland/Libraries/LibGUI/CommandPalette.cpp
index 7f9bf8de60..c18eb3215d 100644
--- a/Userland/Libraries/LibGUI/CommandPalette.cpp
+++ b/Userland/Libraries/LibGUI/CommandPalette.cpp
@@ -243,11 +243,11 @@ void CommandPalette::collect_actions(GUI::Window& parent_window)
};
Function<void(Menu&)> collect_actions_from_menu = [&](Menu& menu) {
- for (auto menu_item : menu.items()) {
- if (menu_item.submenu())
- collect_actions_from_menu(*menu_item.submenu());
+ for (auto& menu_item : menu.items()) {
+ if (menu_item->submenu())
+ collect_actions_from_menu(*menu_item->submenu());
- auto* action = menu_item.action();
+ auto* action = menu_item->action();
if (should_show_action(action))
actions.set(*action);
}
diff --git a/Userland/Libraries/LibGUI/EditingEngine.cpp b/Userland/Libraries/LibGUI/EditingEngine.cpp
index 984690e3ab..6a18ded445 100644
--- a/Userland/Libraries/LibGUI/EditingEngine.cpp
+++ b/Userland/Libraries/LibGUI/EditingEngine.cpp
@@ -171,7 +171,7 @@ void EditingEngine::move_one_left()
m_editor->set_cursor(m_editor->cursor().line(), new_column);
} else if (m_editor->cursor().line() > 0) {
auto new_line = m_editor->cursor().line() - 1;
- auto new_column = m_editor->lines()[new_line].length();
+ auto new_column = m_editor->lines()[new_line]->length();
m_editor->set_cursor(new_line, new_column);
}
}
@@ -362,7 +362,7 @@ void EditingEngine::move_to_first_line()
void EditingEngine::move_to_last_line()
{
- m_editor->set_cursor(m_editor->line_count() - 1, m_editor->lines()[m_editor->line_count() - 1].length());
+ m_editor->set_cursor(m_editor->line_count() - 1, m_editor->lines()[m_editor->line_count() - 1]->length());
};
void EditingEngine::get_selection_line_boundaries(Badge<MoveLineUpOrDownCommand>, size_t& first_line, size_t& last_line)
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp
index d1d2e18e64..ca1027f81e 100644
--- a/Userland/Libraries/LibGUI/FileSystemModel.cpp
+++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp
@@ -33,7 +33,7 @@ ModelIndex FileSystemModel::Node::index(int column) const
if (!m_parent)
return {};
for (size_t row = 0; row < m_parent->m_children.size(); ++row) {
- if (&m_parent->m_children[row] == this)
+ if (m_parent->m_children[row] == this)
return m_model.create_index(row, column, const_cast<Node*>(this));
}
VERIFY_NOT_REACHED();
@@ -111,8 +111,8 @@ void FileSystemModel::Node::traverse_if_needed()
}
quick_sort(child_names);
- NonnullOwnPtrVector<Node> directory_children;
- NonnullOwnPtrVector<Node> file_children;
+ Vector<NonnullOwnPtr<Node>> directory_children;
+ Vector<NonnullOwnPtr<Node>> file_children;
for (auto& child_name : child_names) {
auto maybe_child = create_child(child_name);
@@ -229,7 +229,7 @@ Optional<FileSystemModel::Node const&> FileSystemModel::node_for_path(Deprecated
resolved_path = path;
LexicalPath lexical_path(resolved_path);
- Node const* node = m_root->m_parent_of_root ? &m_root->m_children.first() : m_root;
+ Node const* node = m_root->m_parent_of_root ? m_root->m_children.first() : m_root.ptr();
if (lexical_path.string() == "/")
return *node;
@@ -238,9 +238,9 @@ Optional<FileSystemModel::Node const&> FileSystemModel::node_for_path(Deprecated
auto& part = parts[i];
bool found = false;
for (auto& child : node->m_children) {
- if (child.name == part) {
- const_cast<Node&>(child).reify_if_needed();
- node = &child;
+ if (child->name == part) {
+ const_cast<Node&>(*child).reify_if_needed();
+ node = child;
found = true;
if (i == parts.size() - 1)
return *node;
@@ -494,7 +494,7 @@ ModelIndex FileSystemModel::index(int row, int column, ModelIndex const& parent)
const_cast<Node&>(node).reify_if_needed();
if (static_cast<size_t>(row) >= node.m_children.size())
return {};
- return create_index(row, column, &node.m_children[row]);
+ return create_index(row, column, node.m_children[row].ptr());
}
ModelIndex FileSystemModel::parent_index(ModelIndex const& index) const
@@ -801,9 +801,9 @@ Vector<ModelIndex> FileSystemModel::matches(StringView searching, unsigned flags
node.reify_if_needed();
Vector<ModelIndex> found_indices;
for (auto& child : node.m_children) {
- if (string_matches(child.name, searching, flags)) {
- const_cast<Node&>(child).reify_if_needed();
- found_indices.append(child.index(Column::Name));
+ if (string_matches(child->name, searching, flags)) {
+ const_cast<Node&>(*child).reify_if_needed();
+ found_indices.append(child->index(Column::Name));
if (flags & FirstMatchOnly)
break;
}
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.h b/Userland/Libraries/LibGUI/FileSystemModel.h
index 6f4ac96f6f..6bf5d48c31 100644
--- a/Userland/Libraries/LibGUI/FileSystemModel.h
+++ b/Userland/Libraries/LibGUI/FileSystemModel.h
@@ -83,7 +83,7 @@ public:
FileSystemModel& m_model;
Node* m_parent { nullptr };
- NonnullOwnPtrVector<Node> m_children;
+ Vector<NonnullOwnPtr<Node>> m_children;
bool m_has_traversed { false };
bool m_selected { false };
diff --git a/Userland/Libraries/LibGUI/Menu.cpp b/Userland/Libraries/LibGUI/Menu.cpp
index 3a5869264e..8ba2f57fe4 100644
--- a/Userland/Libraries/LibGUI/Menu.cpp
+++ b/Userland/Libraries/LibGUI/Menu.cpp
@@ -68,7 +68,7 @@ void Menu::add_action(NonnullRefPtr<Action> action)
void Menu::remove_all_actions()
{
for (auto& item : m_items) {
- ConnectionToWindowServer::the().async_remove_menu_item(m_menu_id, item.identifier());
+ ConnectionToWindowServer::the().async_remove_menu_item(m_menu_id, item->identifier());
}
m_items.clear();
}
@@ -142,7 +142,7 @@ int Menu::realize_menu(RefPtr<Action> default_action)
m_current_default_action = default_action;
for (size_t i = 0; i < m_items.size(); ++i) {
- realize_menu_item(m_items[i], i);
+ realize_menu_item(*m_items[i], i);
}
all_menus().set(m_menu_id, this);
@@ -168,14 +168,14 @@ Action* Menu::action_at(size_t index)
{
if (index >= m_items.size())
return nullptr;
- return m_items[index].action();
+ return m_items[index]->action();
}
void Menu::set_children_actions_enabled(bool enabled)
{
for (auto& item : m_items) {
- if (item.action())
- item.action()->set_enabled(enabled);
+ if (item->action())
+ item->action()->set_enabled(enabled);
}
}
diff --git a/Userland/Libraries/LibGUI/Menu.h b/Userland/Libraries/LibGUI/Menu.h
index c3abdb0003..859f8b661a 100644
--- a/Userland/Libraries/LibGUI/Menu.h
+++ b/Userland/Libraries/LibGUI/Menu.h
@@ -61,7 +61,7 @@ public:
bool is_visible() const { return m_visible; }
- NonnullOwnPtrVector<MenuItem> const& items() const { return m_items; }
+ Vector<NonnullOwnPtr<MenuItem>> const& items() const { return m_items; }
private:
friend class Menubar;
@@ -77,7 +77,7 @@ private:
int m_menu_id { -1 };
DeprecatedString m_name;
RefPtr<Gfx::Bitmap const> m_icon;
- NonnullOwnPtrVector<MenuItem> m_items;
+ Vector<NonnullOwnPtr<MenuItem>> m_items;
WeakPtr<Action> m_current_default_action;
bool m_visible { false };
diff --git a/Userland/Libraries/LibGUI/RegularEditingEngine.cpp b/Userland/Libraries/LibGUI/RegularEditingEngine.cpp
index 347e42007b..4e0639088d 100644
--- a/Userland/Libraries/LibGUI/RegularEditingEngine.cpp
+++ b/Userland/Libraries/LibGUI/RegularEditingEngine.cpp
@@ -61,7 +61,7 @@ void RegularEditingEngine::sort_selected_lines()
auto end = lines.begin() + (int)last_line + 1;
quick_sort(start, end, [](auto& a, auto& b) {
- return strcmp_utf32(a.code_points(), b.code_points(), min(a.length(), b.length())) < 0;
+ return strcmp_utf32(a->code_points(), b->code_points(), min(a->length(), b->length())) < 0;
});
m_editor->did_change();
diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp
index c29c2e3220..3633c2d0f9 100644
--- a/Userland/Libraries/LibGUI/TextDocument.cpp
+++ b/Userland/Libraries/LibGUI/TextDocument.cpp
@@ -462,7 +462,7 @@ void TextDocument::update_regex_matches(StringView needle)
Vector<RegexStringView> views;
for (size_t line = 0; line < m_lines.size(); ++line) {
- views.append(m_lines.at(line).view());
+ views.append(m_lines[line]->view());
}
re.search(views, m_regex_result);
m_regex_needs_update = false;
diff --git a/Userland/Libraries/LibGUI/TextDocument.h b/Userland/Libraries/LibGUI/TextDocument.h
index a79073b7d9..f6c16f7a74 100644
--- a/Userland/Libraries/LibGUI/TextDocument.h
+++ b/Userland/Libraries/LibGUI/TextDocument.h
@@ -70,15 +70,15 @@ public:
virtual ~TextDocument() = default;
size_t line_count() const { return m_lines.size(); }
- TextDocumentLine const& line(size_t line_index) const { return m_lines[line_index]; }
- TextDocumentLine& line(size_t line_index) { return m_lines[line_index]; }
+ TextDocumentLine const& line(size_t line_index) const { return *m_lines[line_index]; }
+ TextDocumentLine& line(size_t line_index) { return *m_lines[line_index]; }
void set_spans(u32 span_collection_index, Vector<TextDocumentSpan> spans);
bool set_text(StringView, AllowCallback = AllowCallback::Yes);
- NonnullOwnPtrVector<TextDocumentLine> const& lines() const { return m_lines; }
- NonnullOwnPtrVector<TextDocumentLine>& lines() { return m_lines; }
+ Vector<NonnullOwnPtr<TextDocumentLine>> const& lines() const { return m_lines; }
+ Vector<NonnullOwnPtr<TextDocumentLine>>& lines() { return m_lines; }
bool has_spans() const { return !m_spans.is_empty(); }
Vector<TextDocumentSpan>& spans() { return m_spans; }
@@ -163,7 +163,7 @@ protected:
private:
void merge_span_collections();
- NonnullOwnPtrVector<TextDocumentLine> m_lines;
+ Vector<NonnullOwnPtr<TextDocumentLine>> m_lines;
HashMap<u32, Vector<TextDocumentSpan>> m_span_collections;
Vector<TextDocumentSpan> m_spans;
Vector<TextDocumentFoldingRegion> m_folding_regions;
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp
index 9cb591c8b7..68a47520e5 100644
--- a/Userland/Libraries/LibGUI/TextEditor.cpp
+++ b/Userland/Libraries/LibGUI/TextEditor.cpp
@@ -133,8 +133,8 @@ void TextEditor::update_content_size()
int content_width = 0;
int content_height = 0;
for (auto& line : m_line_visual_data) {
- content_width = max(line.visual_rect.width(), content_width);
- content_height += line.visual_rect.height();
+ content_width = max(line->visual_rect.width(), content_width);
+ content_height += line->visual_rect.height();
}
content_width += m_horizontal_content_padding * 2;
if (is_right_text_alignment(m_text_alignment))
@@ -167,7 +167,7 @@ TextPosition TextEditor::text_position_at_content_position(Gfx::IntPoint content
if (!document().line_is_visible(i))
continue;
- auto& rect = m_line_visual_data[i].visual_rect;
+ auto& rect = m_line_visual_data[i]->visual_rect;
if (position.y() >= rect.top() && position.y() <= rect.bottom()) {
line_index = i;
break;
@@ -634,7 +634,7 @@ void TextEditor::paint_event(PaintEvent& event)
first_visual_line_with_selection = visual_line_containing(line_index, selection.start().column());
if (selection.end().line() > line_index)
- last_visual_line_with_selection = m_line_visual_data[line_index].visual_lines.size();
+ last_visual_line_with_selection = m_line_visual_data[line_index]->visual_lines.size();
else
last_visual_line_with_selection = visual_line_containing(line_index, selection.end().column());
}
@@ -1441,7 +1441,7 @@ Gfx::IntRect TextEditor::line_content_rect(size_t line_index) const
line_rect.center_vertically_within({ {}, frame_inner_rect().size() });
return line_rect;
}
- return m_line_visual_data[line_index].visual_rect;
+ return m_line_visual_data[line_index]->visual_rect;
}
void TextEditor::set_cursor_and_focus_line(size_t line, size_t column)
@@ -1451,8 +1451,8 @@ void TextEditor::set_cursor_and_focus_line(size_t line, size_t column)
if (line > 1 && line < index_max) {
int headroom = frame_inner_rect().height() / 3;
do {
- auto line_data = m_line_visual_data[line];
- headroom -= line_data.visual_rect.height();
+ auto const& line_data = m_line_visual_data[line];
+ headroom -= line_data->visual_rect.height();
line--;
} while (line > 0 && headroom > 0);
@@ -1481,8 +1481,8 @@ void TextEditor::set_cursor(TextPosition const& a_position)
if (position.line() >= line_count())
position.set_line(line_count() - 1);
- if (position.column() > lines()[position.line()].length())
- position.set_column(lines()[position.line()].length());
+ if (position.column() > lines()[position.line()]->length())
+ position.set_column(lines()[position.line()]->length());
if (m_cursor != position && is_visual_data_up_to_date()) {
// NOTE: If the old cursor is no longer valid, repaint everything just in case.
@@ -1972,8 +1972,8 @@ void TextEditor::recompute_all_visual_lines()
auto folded_region_iterator = folded_regions.begin();
for (size_t line_index = 0; line_index < line_count(); ++line_index) {
recompute_visual_lines(line_index, folded_region_iterator);
- m_line_visual_data[line_index].visual_rect.set_y(y_offset);
- y_offset += m_line_visual_data[line_index].visual_rect.height();
+ m_line_visual_data[line_index]->visual_rect.set_y(y_offset);
+ y_offset += m_line_visual_data[line_index]->visual_rect.height();
}
update_content_size();
@@ -2008,7 +2008,7 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
size_t line_width_so_far = 0;
auto& visual_data = m_line_visual_data[line_index];
- visual_data.visual_lines.clear_with_capacity();
+ visual_data->visual_lines.clear_with_capacity();
auto available_width = visible_text_rect_in_inner_coordinates().width();
auto glyph_spacing = font().glyph_spacing();
@@ -2034,7 +2034,7 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
if (line_width_so_far + glyph_width + glyph_spacing > available_width) {
auto start_of_next_visual_line = line.view().iterator_offset(it_before_computing_glyph_width);
- visual_data.visual_lines.append(line.view().substring_view(start_of_visual_line, start_of_next_visual_line - start_of_visual_line));
+ visual_data->visual_lines.append(line.view().substring_view(start_of_visual_line, start_of_next_visual_line - start_of_visual_line));
line_width_so_far = 0;
start_of_visual_line = start_of_next_visual_line;
}
@@ -2042,7 +2042,7 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
line_width_so_far += glyph_width + glyph_spacing;
}
- visual_data.visual_lines.append(line.view().substring_view(start_of_visual_line, line.view().length() - start_of_visual_line));
+ visual_data->visual_lines.append(line.view().substring_view(start_of_visual_line, line.view().length() - start_of_visual_line));
};
auto wrap_visual_lines_at_words = [&]() {
@@ -2057,7 +2057,7 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
auto word_width = font().width(word);
if (line_width_so_far + word_width + glyph_spacing > available_width) {
- visual_data.visual_lines.append(line.view().substring_view(start_of_visual_line, last_boundary - start_of_visual_line));
+ visual_data->visual_lines.append(line.view().substring_view(start_of_visual_line, last_boundary - start_of_visual_line));
line_width_so_far = 0;
start_of_visual_line = last_boundary;
}
@@ -2068,13 +2068,13 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
return IterationDecision::Continue;
});
- visual_data.visual_lines.append(line.view().substring_view(start_of_visual_line, line.view().length() - start_of_visual_line));
+ visual_data->visual_lines.append(line.view().substring_view(start_of_visual_line, line.view().length() - start_of_visual_line));
};
if (line_is_visible) {
switch (wrapping_mode()) {
case WrappingMode::NoWrap:
- visual_data.visual_lines.append(line.view());
+ visual_data->visual_lines.append(line.view());
break;
case WrappingMode::WrapAnywhere:
wrap_visual_lines_anywhere();
@@ -2086,9 +2086,9 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
}
if (is_wrapping_enabled())
- visual_data.visual_rect = { m_horizontal_content_padding, 0, available_width, static_cast<int>(visual_data.visual_lines.size()) * line_height() };
+ visual_data->visual_rect = { m_horizontal_content_padding, 0, available_width, static_cast<int>(visual_data->visual_lines.size()) * line_height() };
else
- visual_data.visual_rect = { m_horizontal_content_padding, 0, text_width_for_font(line.view(), font()), line_height() };
+ visual_data->visual_rect = { m_horizontal_content_padding, 0, text_width_for_font(line.view(), font()), line_height() };
}
template<typename Callback>
@@ -2100,10 +2100,10 @@ void TextEditor::for_each_visual_line(size_t line_index, Callback callback) cons
auto& line = document().line(line_index);
auto& visual_data = m_line_visual_data[line_index];
- for (auto visual_line_view : visual_data.visual_lines) {
+ for (auto visual_line_view : visual_data->visual_lines) {
Gfx::IntRect visual_line_rect {
- visual_data.visual_rect.x(),
- visual_data.visual_rect.y() + ((int)visual_line_index * line_height()),
+ visual_data->visual_rect.x(),
+ visual_data->visual_rect.y() + ((int)visual_line_index * line_height()),
text_width_for_font(visual_line_view, font()) + font().glyph_spacing(),
line_height()
};
@@ -2115,7 +2115,7 @@ void TextEditor::for_each_visual_line(size_t line_index, Callback callback) cons
visual_line_rect.translate_by(icon_size() + icon_padding(), 0);
}
size_t start_of_line = visual_line_view.code_points() - line.code_points();
- if (callback(visual_line_rect, visual_line_view, start_of_line, visual_line_index == visual_data.visual_lines.size() - 1) == IterationDecision::Break)
+ if (callback(visual_line_rect, visual_line_view, start_of_line, visual_line_index == visual_data->visual_lines.size() - 1) == IterationDecision::Break)
break;
++visual_line_index;
}
diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h
index 54d55cabe9..e6a3b1c846 100644
--- a/Userland/Libraries/LibGUI/TextEditor.h
+++ b/Userland/Libraries/LibGUI/TextEditor.h
@@ -121,8 +121,8 @@ public:
size_t line_count() const { return document().line_count(); }
TextDocumentLine& line(size_t index) { return document().line(index); }
TextDocumentLine const& line(size_t index) const { return document().line(index); }
- NonnullOwnPtrVector<TextDocumentLine>& lines() { return document().lines(); }
- NonnullOwnPtrVector<TextDocumentLine> const& lines() const { return document().lines(); }
+ Vector<NonnullOwnPtr<TextDocumentLine>>& lines() { return document().lines(); }
+ Vector<NonnullOwnPtr<TextDocumentLine>> const& lines() const { return document().lines(); }
int line_height() const;
TextPosition cursor() const { return m_cursor; }
TextRange normalized_selection() const { return m_selection.normalized(); }
@@ -432,7 +432,7 @@ private:
Gfx::IntRect visual_rect;
};
- NonnullOwnPtrVector<LineVisualData> m_line_visual_data;
+ Vector<NonnullOwnPtr<LineVisualData>> m_line_visual_data;
OwnPtr<Syntax::Highlighter> m_highlighter;
OwnPtr<AutocompleteProvider> m_autocomplete_provider;
diff --git a/Userland/Libraries/LibGUI/Toolbar.cpp b/Userland/Libraries/LibGUI/Toolbar.cpp
index 50c2cd9aed..4947b93e1a 100644
--- a/Userland/Libraries/LibGUI/Toolbar.cpp
+++ b/Userland/Libraries/LibGUI/Toolbar.cpp
@@ -111,7 +111,7 @@ ErrorOr<NonnullRefPtr<GUI::Button>> Toolbar::try_add_action(Action& action)
item->widget->set_fixed_size(m_button_size, m_button_size);
m_items.unchecked_append(move(item));
- return *static_cast<Button*>(m_items.last().widget.ptr());
+ return *static_cast<Button*>(m_items.last()->widget.ptr());
}
GUI::Button& Toolbar::add_action(Action& action)
@@ -196,12 +196,12 @@ ErrorOr<void> Toolbar::update_overflow_menu()
for (size_t i = 0; i < m_items.size() - 1; ++i) {
auto& item = m_items.at(i);
- auto item_size = is_horizontal ? item.widget->width() : item.widget->height();
+ auto item_size = is_horizontal ? item->widget->width() : item->widget->height();
if (position + item_size + margin > toolbar_size) {
marginal_index = i;
break;
}
- item.widget->set_visible(true);
+ item->widget->set_visible(true);
position += item_size + spacing;
}
@@ -216,10 +216,10 @@ ErrorOr<void> Toolbar::update_overflow_menu()
if (marginal_index.value() > 0) {
for (size_t i = marginal_index.value() - 1; i > 0; --i) {
auto& item = m_items.at(i);
- auto item_size = is_horizontal ? item.widget->width() : item.widget->height();
+ auto item_size = is_horizontal ? item->widget->width() : item->widget->height();
if (position + m_button_size + spacing + margin <= toolbar_size)
break;
- item.widget->set_visible(false);
+ item->widget->set_visible(false);
position -= item_size + spacing;
marginal_index = i;
}
@@ -228,9 +228,9 @@ ErrorOr<void> Toolbar::update_overflow_menu()
if (m_grouped) {
for (size_t i = marginal_index.value(); i > 0; --i) {
auto& item = m_items.at(i);
- if (item.type == Item::Type::Separator)
+ if (item->type == Item::Type::Separator)
break;
- item.widget->set_visible(false);
+ item->widget->set_visible(false);
marginal_index = i;
}
}
@@ -247,17 +247,17 @@ ErrorOr<void> Toolbar::update_overflow_menu()
auto& item = m_items.at(i);
Item* peek_item;
if (i > 0) {
- peek_item = &m_items.at(i - 1);
+ peek_item = m_items[i - 1];
if (peek_item->type == Item::Type::Separator)
peek_item->widget->set_visible(false);
}
if (i < m_items.size() - 1) {
- item.widget->set_visible(false);
- peek_item = &m_items.at(i + 1);
- if (item.action)
- TRY(m_overflow_menu->try_add_action(*item.action));
+ item->widget->set_visible(false);
+ peek_item = m_items[i + 1];
+ if (item->action)
+ TRY(m_overflow_menu->try_add_action(*item->action));
}
- if (item.action && peek_item->type == Item::Type::Separator)
+ if (item->action && peek_item->type == Item::Type::Separator)
TRY(m_overflow_menu->try_add_separator());
}
diff --git a/Userland/Libraries/LibGUI/Toolbar.h b/Userland/Libraries/LibGUI/Toolbar.h
index 8a9ec2cf1b..b1f2170975 100644
--- a/Userland/Libraries/LibGUI/Toolbar.h
+++ b/Userland/Libraries/LibGUI/Toolbar.h
@@ -53,7 +53,7 @@ private:
RefPtr<Action> action;
RefPtr<Widget> widget;
};
- NonnullOwnPtrVector<Item> m_items;
+ Vector<NonnullOwnPtr<Item>> m_items;
RefPtr<Menu> m_overflow_menu;
RefPtr<Action> m_overflow_action;
RefPtr<Button> m_overflow_button;
diff --git a/Userland/Libraries/LibGUI/UndoStack.cpp b/Userland/Libraries/LibGUI/UndoStack.cpp
index 34272f7f67..596a94b427 100644
--- a/Userland/Libraries/LibGUI/UndoStack.cpp
+++ b/Userland/Libraries/LibGUI/UndoStack.cpp
@@ -28,7 +28,7 @@ void UndoStack::undo()
return;
auto& command = m_stack[--m_stack_index];
- command.undo();
+ command->undo();
if (on_state_change)
on_state_change();
@@ -40,7 +40,7 @@ void UndoStack::redo()
return;
auto& command = m_stack[m_stack_index++];
- command.redo();
+ command->redo();
if (on_state_change)
on_state_change();
@@ -56,7 +56,7 @@ ErrorOr<void> UndoStack::try_push(NonnullOwnPtr<Command> command)
m_clean_index = {};
if (!m_stack.is_empty() && is_current_modified()) {
- if (m_stack.last().merge_with(*command))
+ if (m_stack.last()->merge_with(*command))
return {};
}
@@ -114,14 +114,14 @@ Optional<DeprecatedString> UndoStack::undo_action_text() const
{
if (!can_undo())
return {};
- return m_stack[m_stack_index - 1].action_text();
+ return m_stack[m_stack_index - 1]->action_text();
}
Optional<DeprecatedString> UndoStack::redo_action_text() const
{
if (!can_redo())
return {};
- return m_stack[m_stack_index].action_text();
+ return m_stack[m_stack_index]->action_text();
}
}
diff --git a/Userland/Libraries/LibGUI/UndoStack.h b/Userland/Libraries/LibGUI/UndoStack.h
index e37a1acce2..02b1658baf 100644
--- a/Userland/Libraries/LibGUI/UndoStack.h
+++ b/Userland/Libraries/LibGUI/UndoStack.h
@@ -41,7 +41,7 @@ public:
Function<void()> on_state_change;
private:
- NonnullOwnPtrVector<Command> m_stack;
+ Vector<NonnullOwnPtr<Command>> m_stack;
size_t m_stack_index { 0 };
Optional<size_t> m_clean_index;
Optional<Time> m_last_unmodified_timestamp;