mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:47:45 +00:00
Everywhere: Replace Vector<T*> with nonnull entries with Vector<T&>
This commit is contained in:
parent
3d94b5051d
commit
7ac196974d
22 changed files with 92 additions and 94 deletions
|
@ -362,8 +362,8 @@ void ColorPicker::create_color_button(Widget& container, unsigned rgb)
|
|||
auto& widget = container.add<ColorButton>(*this, color);
|
||||
widget.on_click = [this](Color color) {
|
||||
for (auto& value : m_color_widgets) {
|
||||
value->set_selected(false);
|
||||
value->update();
|
||||
value.set_selected(false);
|
||||
value.update();
|
||||
}
|
||||
|
||||
m_color = color;
|
||||
|
@ -375,7 +375,7 @@ void ColorPicker::create_color_button(Widget& container, unsigned rgb)
|
|||
widget.set_selected(true);
|
||||
}
|
||||
|
||||
m_color_widgets.append(&widget);
|
||||
m_color_widgets.append(widget);
|
||||
}
|
||||
|
||||
ColorButton::ColorButton(ColorPicker& picker, Color color)
|
||||
|
|
|
@ -37,7 +37,7 @@ private:
|
|||
Color m_color;
|
||||
bool m_color_has_alpha_channel { true };
|
||||
|
||||
Vector<ColorButton*> m_color_widgets;
|
||||
Vector<ColorButton&> m_color_widgets;
|
||||
RefPtr<CustomColorWidget> m_custom_color;
|
||||
RefPtr<ColorPreview> m_preview_widget;
|
||||
RefPtr<TextBox> m_html_text;
|
||||
|
|
|
@ -155,7 +155,7 @@ void Splitter::recompute_grabbables()
|
|||
m_hovered_index = {};
|
||||
|
||||
auto child_widgets = this->child_widgets();
|
||||
child_widgets.remove_all_matching([&](auto& widget) { return !widget->is_visible(); });
|
||||
child_widgets.remove_all_matching([&](auto& widget) { return !widget.is_visible(); });
|
||||
|
||||
if (child_widgets.size() < 2)
|
||||
return;
|
||||
|
@ -164,8 +164,8 @@ void Splitter::recompute_grabbables()
|
|||
size_t end_index = 1;
|
||||
|
||||
while (end_index < child_widgets.size()) {
|
||||
auto const& first_widget = *child_widgets[start_index];
|
||||
auto const& second_widget = *child_widgets[end_index];
|
||||
auto const& first_widget = child_widgets[start_index];
|
||||
auto const& second_widget = child_widgets[end_index];
|
||||
m_grabbables.append(Grabbable {
|
||||
.index = m_grabbables.size(),
|
||||
.grabbable_rect = rect_between_widgets(first_widget, second_widget, true),
|
||||
|
|
|
@ -851,14 +851,14 @@ void Widget::focus_previous_widget(FocusSource source, bool siblings_only)
|
|||
{
|
||||
auto focusable_widgets = window()->focusable_widgets(source);
|
||||
if (siblings_only)
|
||||
focusable_widgets.remove_all_matching([this](auto& entry) { return entry->parent() != parent(); });
|
||||
focusable_widgets.remove_all_matching([this](auto& entry) { return entry.parent() != parent(); });
|
||||
for (int i = focusable_widgets.size() - 1; i >= 0; --i) {
|
||||
if (focusable_widgets[i] != this)
|
||||
if (&focusable_widgets[i] != this)
|
||||
continue;
|
||||
if (i > 0)
|
||||
focusable_widgets[i - 1]->set_focus(true, source);
|
||||
focusable_widgets[i - 1].set_focus(true, source);
|
||||
else
|
||||
focusable_widgets.last()->set_focus(true, source);
|
||||
focusable_widgets.last().set_focus(true, source);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -866,24 +866,24 @@ void Widget::focus_next_widget(FocusSource source, bool siblings_only)
|
|||
{
|
||||
auto focusable_widgets = window()->focusable_widgets(source);
|
||||
if (siblings_only)
|
||||
focusable_widgets.remove_all_matching([this](auto& entry) { return entry->parent() != parent(); });
|
||||
focusable_widgets.remove_all_matching([this](auto& entry) { return entry.parent() != parent(); });
|
||||
for (size_t i = 0; i < focusable_widgets.size(); ++i) {
|
||||
if (focusable_widgets[i] != this)
|
||||
if (&focusable_widgets[i] != this)
|
||||
continue;
|
||||
if (i < focusable_widgets.size() - 1)
|
||||
focusable_widgets[i + 1]->set_focus(true, source);
|
||||
focusable_widgets[i + 1].set_focus(true, source);
|
||||
else
|
||||
focusable_widgets.first()->set_focus(true, source);
|
||||
focusable_widgets.first().set_focus(true, source);
|
||||
}
|
||||
}
|
||||
|
||||
Vector<Widget*> Widget::child_widgets() const
|
||||
Vector<Widget&> Widget::child_widgets() const
|
||||
{
|
||||
Vector<Widget*> widgets;
|
||||
Vector<Widget&> widgets;
|
||||
widgets.ensure_capacity(children().size());
|
||||
for (auto& child : const_cast<Widget*>(this)->children()) {
|
||||
if (is<Widget>(child))
|
||||
widgets.append(static_cast<Widget*>(&child));
|
||||
widgets.append(static_cast<Widget&>(child));
|
||||
}
|
||||
return widgets;
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ public:
|
|||
});
|
||||
}
|
||||
|
||||
Vector<Widget*> child_widgets() const;
|
||||
Vector<Widget&> child_widgets() const;
|
||||
|
||||
void do_layout();
|
||||
|
||||
|
|
|
@ -843,13 +843,13 @@ void Window::start_interactive_resize()
|
|||
WindowServerConnection::the().async_start_window_resize(m_window_id);
|
||||
}
|
||||
|
||||
Vector<Widget*> Window::focusable_widgets(FocusSource source) const
|
||||
Vector<Widget&> Window::focusable_widgets(FocusSource source) const
|
||||
{
|
||||
if (!m_main_widget)
|
||||
return {};
|
||||
|
||||
HashTable<Widget*> seen_widgets;
|
||||
Vector<Widget*> collected_widgets;
|
||||
Vector<Widget&> collected_widgets;
|
||||
|
||||
Function<void(Widget&)> collect_focusable_widgets = [&](auto& widget) {
|
||||
bool widget_accepts_focus = false;
|
||||
|
@ -868,7 +868,7 @@ Vector<Widget*> Window::focusable_widgets(FocusSource source) const
|
|||
if (widget_accepts_focus) {
|
||||
auto& effective_focus_widget = widget.focus_proxy() ? *widget.focus_proxy() : widget;
|
||||
if (seen_widgets.set(&effective_focus_widget) == AK::HashSetResult::InsertedNewEntry)
|
||||
collected_widgets.append(&effective_focus_widget);
|
||||
collected_widgets.append(effective_focus_widget);
|
||||
}
|
||||
widget.for_each_child_widget([&](auto& child) {
|
||||
if (!child.is_visible())
|
||||
|
@ -1056,7 +1056,7 @@ void Window::focus_a_widget_if_possible(FocusSource source)
|
|||
{
|
||||
auto focusable_widgets = this->focusable_widgets(source);
|
||||
if (!focusable_widgets.is_empty())
|
||||
set_focused_widget(focusable_widgets[0], source);
|
||||
set_focused_widget(&focusable_widgets[0], source);
|
||||
}
|
||||
|
||||
void Window::did_disable_focused_widget(Badge<Widget>)
|
||||
|
|
|
@ -172,7 +172,7 @@ public:
|
|||
void apply_icon();
|
||||
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
||||
|
||||
Vector<Widget*> focusable_widgets(FocusSource) const;
|
||||
Vector<Widget&> focusable_widgets(FocusSource) const;
|
||||
|
||||
void schedule_relayout();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue