2020-04-23 17:44:49 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-23 17:44:49 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibGUI/BoxLayout.h>
|
|
|
|
|
#include <LibGUI/Painter.h>
|
2021-04-13 16:18:20 +02:00
|
|
|
#include <LibGUI/ToolbarContainer.h>
|
2020-04-23 17:44:49 +02:00
|
|
|
#include <LibGfx/Palette.h>
|
|
|
|
|
#include <LibGfx/StylePainter.h>
|
|
|
|
|
|
2021-04-13 16:18:20 +02:00
|
|
|
REGISTER_WIDGET(GUI, ToolbarContainer)
|
2021-01-02 16:30:13 -07:00
|
|
|
|
2020-04-23 17:44:49 +02:00
|
|
|
namespace GUI {
|
|
|
|
|
|
2021-04-13 16:18:20 +02:00
|
|
|
ToolbarContainer::ToolbarContainer(Gfx::Orientation orientation)
|
2020-04-23 17:44:49 +02:00
|
|
|
: m_orientation(orientation)
|
|
|
|
|
{
|
|
|
|
|
set_fill_with_background_color(true);
|
2023-04-29 16:47:52 -04:00
|
|
|
set_frame_style(Gfx::FrameStyle::SunkenBox);
|
2023-02-16 21:07:06 +00:00
|
|
|
set_layout<VerticalBoxLayout>(GUI::Margins {}, 2);
|
2021-01-04 18:21:05 +01:00
|
|
|
set_shrink_to_fit(true);
|
2020-04-23 17:44:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-13 16:18:20 +02:00
|
|
|
void ToolbarContainer::paint_event(GUI::PaintEvent& event)
|
2020-04-23 17:44:49 +02:00
|
|
|
{
|
|
|
|
|
Painter painter(*this);
|
|
|
|
|
painter.add_clip_rect(event.rect());
|
|
|
|
|
|
2021-02-25 12:56:47 -05:00
|
|
|
for_each_child_widget([&](auto& widget) {
|
|
|
|
|
if (widget.is_visible()) {
|
|
|
|
|
auto rect = widget.relative_rect();
|
2023-05-22 00:41:18 +02:00
|
|
|
painter.draw_line(rect.top_left().moved_up(1), rect.top_right().translated(-1), palette().threed_highlight());
|
|
|
|
|
painter.draw_line(rect.bottom_left(), rect.bottom_right().moved_left(1), palette().threed_shadow1());
|
2021-01-04 18:21:05 +01:00
|
|
|
}
|
|
|
|
|
return IterationDecision::Continue;
|
|
|
|
|
});
|
2020-04-23 17:44:49 +02:00
|
|
|
|
|
|
|
|
Frame::paint_event(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|