2020-04-23 18:44:49 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-23 18:44:49 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibGUI/BoxLayout.h>
|
|
|
|
#include <LibGUI/Painter.h>
|
2021-04-13 17:18:20 +03:00
|
|
|
#include <LibGUI/ToolbarContainer.h>
|
2020-04-23 18:44:49 +03:00
|
|
|
#include <LibGfx/Palette.h>
|
|
|
|
#include <LibGfx/StylePainter.h>
|
|
|
|
|
2021-04-13 17:18:20 +03:00
|
|
|
REGISTER_WIDGET(GUI, ToolbarContainer)
|
2021-01-03 02:30:13 +03:00
|
|
|
|
2020-04-23 18:44:49 +03:00
|
|
|
namespace GUI {
|
|
|
|
|
2021-04-13 17:18:20 +03:00
|
|
|
ToolbarContainer::ToolbarContainer(Gfx::Orientation orientation)
|
2020-04-23 18:44:49 +03:00
|
|
|
: m_orientation(orientation)
|
|
|
|
{
|
|
|
|
set_fill_with_background_color(true);
|
|
|
|
|
|
|
|
set_frame_thickness(2);
|
|
|
|
set_frame_shape(Gfx::FrameShape::Box);
|
|
|
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
|
|
|
|
|
|
|
auto& layout = set_layout<VerticalBoxLayout>();
|
|
|
|
layout.set_spacing(2);
|
|
|
|
layout.set_margins({ 2, 2, 2, 2 });
|
2021-01-04 20:21:05 +03:00
|
|
|
|
|
|
|
set_shrink_to_fit(true);
|
2020-04-23 18:44:49 +03:00
|
|
|
}
|
|
|
|
|
2021-04-13 17:18:20 +03:00
|
|
|
void ToolbarContainer::paint_event(GUI::PaintEvent& event)
|
2020-04-23 18:44:49 +03:00
|
|
|
{
|
|
|
|
Painter painter(*this);
|
|
|
|
painter.add_clip_rect(event.rect());
|
|
|
|
|
2021-02-25 20:56:47 +03:00
|
|
|
for_each_child_widget([&](auto& widget) {
|
|
|
|
if (widget.is_visible()) {
|
|
|
|
auto rect = widget.relative_rect();
|
2021-01-04 20:21:05 +03:00
|
|
|
painter.draw_line(rect.top_left().translated(0, -1), rect.top_right().translated(0, -1), palette().threed_highlight());
|
|
|
|
painter.draw_line(rect.bottom_left().translated(0, 1), rect.bottom_right().translated(0, 1), palette().threed_shadow1());
|
|
|
|
}
|
|
|
|
return IterationDecision::Continue;
|
|
|
|
});
|
2020-04-23 18:44:49 +03:00
|
|
|
|
|
|
|
Frame::paint_event(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|