Serenity Operating System
1/*
2 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <LibGUI/BoxLayout.h>
8#include <LibGUI/Painter.h>
9#include <LibGUI/ToolbarContainer.h>
10#include <LibGfx/Palette.h>
11#include <LibGfx/StylePainter.h>
12
13REGISTER_WIDGET(GUI, ToolbarContainer)
14
15namespace GUI {
16
17ToolbarContainer::ToolbarContainer(Gfx::Orientation orientation)
18 : m_orientation(orientation)
19{
20 set_fill_with_background_color(true);
21
22 set_frame_thickness(2);
23 set_frame_shape(Gfx::FrameShape::Box);
24 set_frame_shadow(Gfx::FrameShadow::Sunken);
25
26 set_layout<VerticalBoxLayout>(GUI::Margins {}, 2);
27 set_shrink_to_fit(true);
28}
29
30void ToolbarContainer::paint_event(GUI::PaintEvent& event)
31{
32 Painter painter(*this);
33 painter.add_clip_rect(event.rect());
34
35 for_each_child_widget([&](auto& widget) {
36 if (widget.is_visible()) {
37 auto rect = widget.relative_rect();
38 painter.draw_line(rect.top_left().translated(0, -1), rect.top_right().translated(0, -1), palette().threed_highlight());
39 painter.draw_line(rect.bottom_left().translated(0, 1), rect.bottom_right().translated(0, 1), palette().threed_shadow1());
40 }
41 return IterationDecision::Continue;
42 });
43
44 Frame::paint_event(event);
45}
46
47}