2020-12-31 11:56:19 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
2022-02-26 10:50:04 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-12-31 11:56:19 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-31 11:56:19 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibGUI/AbstractSlider.h>
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
class OpacitySlider : public AbstractSlider {
|
|
|
|
C_OBJECT(OpacitySlider);
|
|
|
|
|
|
|
|
public:
|
2022-02-26 10:50:04 -07:00
|
|
|
virtual ~OpacitySlider() override = default;
|
2020-12-31 11:56:19 +01:00
|
|
|
|
2023-01-01 02:16:46 +01:00
|
|
|
void set_base_color(Gfx::Color);
|
|
|
|
Gfx::Color base_color() { return m_base_color; }
|
|
|
|
|
2020-12-31 11:56:19 +01:00
|
|
|
protected:
|
2022-12-07 23:40:36 +01:00
|
|
|
explicit OpacitySlider(Gfx::Orientation);
|
|
|
|
|
2020-12-31 11:56:19 +01:00
|
|
|
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;
|
|
|
|
|
2023-01-01 02:16:46 +01:00
|
|
|
Gfx::Color m_base_color { 0, 0, 0 };
|
|
|
|
|
2022-12-07 23:38:36 +01:00
|
|
|
virtual Optional<UISize> calculated_min_size() const override;
|
|
|
|
virtual Optional<UISize> calculated_preferred_size() const override;
|
|
|
|
|
2022-12-06 20:27:44 +00:00
|
|
|
int value_at(Gfx::IntPoint) const;
|
2020-12-31 11:56:19 +01:00
|
|
|
|
|
|
|
bool m_dragging { false };
|
|
|
|
};
|
|
|
|
|
2022-12-07 23:40:36 +01:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-31 11:56:19 +01:00
|
|
|
}
|