mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-01 16:29:55 -04:00
Forgor to commit
This commit is contained in:
Vendored
+1
-1
Submodule extern/aurora updated: fa03533986...a2d024e006
@@ -0,0 +1,53 @@
|
||||
#include "control_surface.hpp"
|
||||
|
||||
#include <RmlUi/Core/Element.h>
|
||||
|
||||
namespace dusk::ui {
|
||||
|
||||
ControlSurfaceStyle control_surface_style(ControlSurfaceTone tone) {
|
||||
switch (tone) {
|
||||
case ControlSurfaceTone::Primary:
|
||||
return {
|
||||
.accent = theme::Primary,
|
||||
.inactiveBorderOpacity = 112,
|
||||
.inactiveBackgroundOpacity = 28,
|
||||
.activeBorderOpacity = 255,
|
||||
.activeBackgroundOpacity = 116,
|
||||
};
|
||||
case ControlSurfaceTone::Secondary:
|
||||
return {
|
||||
.accent = theme::Secondary,
|
||||
.inactiveBorderOpacity = 112,
|
||||
.inactiveBackgroundOpacity = 28,
|
||||
.activeBorderOpacity = 255,
|
||||
.activeBackgroundOpacity = 116,
|
||||
};
|
||||
case ControlSurfaceTone::Quiet:
|
||||
default:
|
||||
return {
|
||||
.accent = theme::Elevated,
|
||||
.inactiveBorderOpacity = 86,
|
||||
.inactiveBackgroundOpacity = 0,
|
||||
.activeBorderOpacity = 150,
|
||||
.activeBackgroundOpacity = 68,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void apply_control_surface_style(Rml::Element* element, const ControlSurfaceStyle& style,
|
||||
bool active) {
|
||||
if (element == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
element->SetProperty("border-color",
|
||||
active ? theme::rgba(style.accent, style.activeBorderOpacity) :
|
||||
theme::rgba(theme::ElevatedBorder,
|
||||
style.inactiveBorderOpacity));
|
||||
element->SetProperty("background-color",
|
||||
theme::rgba(style.accent,
|
||||
active ? style.activeBackgroundOpacity :
|
||||
style.inactiveBackgroundOpacity));
|
||||
}
|
||||
|
||||
} // namespace dusk::ui
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "theme.hpp"
|
||||
|
||||
namespace Rml {
|
||||
class Element;
|
||||
}
|
||||
|
||||
namespace dusk::ui {
|
||||
|
||||
enum class ControlSurfaceTone {
|
||||
Primary,
|
||||
Secondary,
|
||||
Quiet,
|
||||
};
|
||||
|
||||
struct ControlSurfaceStyle {
|
||||
theme::Color accent = theme::Primary;
|
||||
int inactiveBorderOpacity = 86;
|
||||
int inactiveBackgroundOpacity = 0;
|
||||
int activeBorderOpacity = 150;
|
||||
int activeBackgroundOpacity = 68;
|
||||
};
|
||||
|
||||
ControlSurfaceStyle control_surface_style(ControlSurfaceTone tone);
|
||||
void apply_control_surface_style(Rml::Element* element, const ControlSurfaceStyle& style,
|
||||
bool active);
|
||||
|
||||
} // namespace dusk::ui
|
||||
Reference in New Issue
Block a user