blob: f00cd242a8e568793c6c06e0600ead1423d0ee3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/AbstractSlider.h>
namespace GUI {
class OpacitySlider : public AbstractSlider {
C_OBJECT(OpacitySlider);
public:
virtual ~OpacitySlider() override = default;
void set_base_color(Gfx::Color);
Gfx::Color base_color() { return m_base_color; }
protected:
explicit OpacitySlider(Gfx::Orientation);
virtual void paint_event(PaintEvent&) override;
virtual void mousedown_event(MouseEvent&) override;
virtual void mousemove_event(MouseEvent&) override;
virtual void mouseup_event(MouseEvent&) override;
virtual void mousewheel_event(MouseEvent&) override;
private:
Gfx::IntRect frame_inner_rect() const;
Gfx::Color m_base_color { 0, 0, 0 };
virtual Optional<UISize> calculated_min_size() const override;
virtual Optional<UISize> calculated_preferred_size() const override;
int value_at(Gfx::IntPoint) const;
bool m_dragging { false };
};
class VerticalOpacitySlider final : public OpacitySlider {
C_OBJECT(VerticalOpacitySlider);
public:
virtual ~VerticalOpacitySlider() override = default;
private:
VerticalOpacitySlider()
: OpacitySlider(Orientation::Vertical)
{
}
};
class HorizontalOpacitySlider final : public OpacitySlider {
C_OBJECT(HorizontalOpacitySlider);
public:
virtual ~HorizontalOpacitySlider() override = default;
private:
HorizontalOpacitySlider()
: OpacitySlider(Orientation::Horizontal)
{
}
};
}
|