2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-28 23:21:12 -03:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2020-02-06 16:33:02 -03:00
|
|
|
#include <LibGUI/Painter.h>
|
|
|
|
|
#include <LibGUI/ResizeCorner.h>
|
|
|
|
|
#include <LibGUI/Window.h>
|
2020-09-18 04:49:51 -03:00
|
|
|
#include <LibGfx/CharacterBitmap.h>
|
|
|
|
|
#include <LibGfx/Palette.h>
|
2019-05-02 20:38:24 -03:00
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
namespace GUI {
|
|
|
|
|
|
2022-02-28 23:21:12 -03:00
|
|
|
static constexpr Gfx::CharacterBitmap s_resize_corner_shadows_bitmap {
|
|
|
|
|
|
2020-02-16 03:03:23 -03:00
|
|
|
" "
|
|
|
|
|
" ## "
|
|
|
|
|
" # "
|
|
|
|
|
" "
|
|
|
|
|
" ## ## "
|
|
|
|
|
" # # "
|
|
|
|
|
" "
|
|
|
|
|
" ## ## ## "
|
|
|
|
|
" # # # "
|
|
|
|
|
" "
|
|
|
|
|
" ## ## ## ## "
|
|
|
|
|
" # # # # "
|
|
|
|
|
" "
|
|
|
|
|
" ## ## ## ## ## "
|
|
|
|
|
" # # # # # "
|
2022-02-28 23:21:12 -03:00
|
|
|
" ",
|
|
|
|
|
16, 16
|
2020-02-16 03:03:23 -03:00
|
|
|
};
|
|
|
|
|
|
2022-02-28 23:21:12 -03:00
|
|
|
static constexpr Gfx::CharacterBitmap s_resize_corner_highlights_bitmap {
|
2020-02-16 03:03:23 -03:00
|
|
|
" "
|
|
|
|
|
" "
|
|
|
|
|
" # "
|
|
|
|
|
" "
|
|
|
|
|
" "
|
|
|
|
|
" # # "
|
|
|
|
|
" "
|
|
|
|
|
" "
|
|
|
|
|
" # # # "
|
|
|
|
|
" "
|
|
|
|
|
" "
|
|
|
|
|
" # # # # "
|
|
|
|
|
" "
|
|
|
|
|
" "
|
|
|
|
|
" # # # # # "
|
2022-02-28 23:21:12 -03:00
|
|
|
" ",
|
|
|
|
|
16, 16
|
2020-02-16 03:03:23 -03:00
|
|
|
};
|
|
|
|
|
|
2020-02-23 08:07:13 -03:00
|
|
|
ResizeCorner::ResizeCorner()
|
2019-05-02 20:38:24 -03:00
|
|
|
{
|
2020-09-11 09:47:38 -03:00
|
|
|
set_override_cursor(Gfx::StandardCursor::ResizeDiagonalTLBR);
|
2019-12-24 16:57:54 -03:00
|
|
|
set_background_role(ColorRole::Button);
|
2020-12-29 21:23:32 -03:00
|
|
|
set_fixed_size(16, 18);
|
2019-05-02 20:38:24 -03:00
|
|
|
}
|
|
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
void ResizeCorner::paint_event(PaintEvent& event)
|
2019-05-02 20:38:24 -03:00
|
|
|
{
|
2020-02-02 11:07:41 -03:00
|
|
|
Painter painter(*this);
|
2019-05-02 20:38:24 -03:00
|
|
|
painter.add_clip_rect(event.rect());
|
2019-12-24 16:57:54 -03:00
|
|
|
painter.fill_rect(rect(), palette().color(background_role()));
|
2020-02-16 03:03:23 -03:00
|
|
|
|
2022-02-28 23:21:12 -03:00
|
|
|
painter.draw_bitmap({ 0, 2 }, s_resize_corner_shadows_bitmap, palette().threed_shadow1());
|
|
|
|
|
painter.draw_bitmap({ 0, 2 }, s_resize_corner_highlights_bitmap, palette().threed_highlight());
|
2020-02-16 03:03:23 -03:00
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
Widget::paint_event(event);
|
2019-05-02 20:38:24 -03:00
|
|
|
}
|
|
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
void ResizeCorner::mousedown_event(MouseEvent& event)
|
2019-05-02 20:38:24 -03:00
|
|
|
{
|
2021-10-27 08:20:27 -03:00
|
|
|
if (event.button() == MouseButton::Primary)
|
2021-02-01 07:23:54 -03:00
|
|
|
window()->start_interactive_resize();
|
2020-02-02 11:07:41 -03:00
|
|
|
Widget::mousedown_event(event);
|
2019-05-02 20:38:24 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|