ladybird/Userland/Services/WindowServer/Button.h
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

53 lines
1.2 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <AK/Weakable.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Forward.h>
#include <LibGfx/Rect.h>
namespace WindowServer {
class MouseEvent;
class WindowFrame;
class Button : public Weakable<Button> {
public:
Button(WindowFrame&, Function<void(Button&)>&& on_click_handler);
~Button();
Gfx::IntRect relative_rect() const { return m_relative_rect; }
void set_relative_rect(const Gfx::IntRect& rect) { m_relative_rect = rect; }
Gfx::IntRect rect() const { return { {}, m_relative_rect.size() }; }
Gfx::IntRect screen_rect() const;
void paint(Gfx::Painter&);
void on_mouse_event(const MouseEvent&);
Function<void(Button&)> on_click;
Function<void(Button&)> on_right_click;
Function<void(Button&)> on_middle_click;
bool is_visible() const { return m_visible; }
void set_icon(const Gfx::Bitmap& icon) { m_icon = icon; }
private:
WindowFrame& m_frame;
Gfx::IntRect m_relative_rect;
RefPtr<Gfx::Bitmap> m_icon;
bool m_pressed { false };
bool m_visible { true };
bool m_hovered { false };
};
}