Forgor to commit

This commit is contained in:
Luke Street
2026-04-27 01:15:19 -06:00
parent b3dee825e8
commit 025cb58493
3 changed files with 83 additions and 1 deletions
+1 -1
+53
View File
@@ -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
+29
View File
@@ -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