Skip to content

Commit 5b6143b

Browse files
committed
fix(programmer): highlight doesn't override content of programmer
1 parent 75dc7d5 commit 5b6143b

File tree

5 files changed

+76
-16
lines changed

5 files changed

+76
-16
lines changed

crates/api/src/mappings/sequencer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ impl From<mizer_fixtures::FixturePriority> for FixturePriority {
250250
use mizer_fixtures::LTPPriority::*;
251251

252252
match priority {
253-
mizer_fixtures::FixturePriority::Programmer => {
253+
mizer_fixtures::FixturePriority::Programmer |
254+
mizer_fixtures::FixturePriority::Highlight => {
254255
unreachable!("Programmer priority is not exposed to frontend")
255256
}
256257
mizer_fixtures::FixturePriority::HTP => Self::PriorityHtp,

crates/components/fixtures/src/color_mixer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use serde::Serialize;
66

77
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
88
pub struct ColorMixer {
9-
red: ChannelValue,
10-
green: ChannelValue,
11-
blue: ChannelValue,
9+
pub(crate) red: ChannelValue,
10+
pub(crate) green: ChannelValue,
11+
pub(crate) blue: ChannelValue,
1212
virtual_dimmer: Option<ChannelValue>,
1313
}
1414

crates/components/fixtures/src/debug_ui_pane.rs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,36 @@ impl<TUi: DebugUi> DebugUiPane<TUi> for FixturesDebugUiPane {
3333
columns[0].label("Channel");
3434
columns[1].label(fixture.channel.to_string());
3535
});
36-
ui.collapsing_header(format!("Mode: {}", fixture.current_mode.name), |_ui| {});
36+
ui.collapsing_header(format!("Mode: {}", fixture.current_mode.name), |ui| {
37+
if let Some(ref color_mixer) = fixture.current_mode.color_mixer {
38+
ui.collapsing_header("Color Mixer", |ui| {
39+
ui.collapsing_header(format!("Red: {}", color_mixer.rgb().red), |ui| {
40+
ui.columns(2, |columns| {
41+
for (priority, value) in &color_mixer.red.values {
42+
columns[0].label(value.to_string());
43+
columns[1].label(priority.to_string());
44+
}
45+
});
46+
});
47+
ui.collapsing_header(format!("Green: {}", color_mixer.rgb().green), |ui| {
48+
ui.columns(2, |columns| {
49+
for (priority, value) in &color_mixer.green.values {
50+
columns[0].label(value.to_string());
51+
columns[1].label(priority.to_string());
52+
}
53+
});
54+
});
55+
ui.collapsing_header(format!("Blue: {}", color_mixer.rgb().blue), |ui| {
56+
ui.columns(2, |columns| {
57+
for (priority, value) in &color_mixer.blue.values {
58+
columns[0].label(value.to_string());
59+
columns[1].label(priority.to_string());
60+
}
61+
});
62+
});
63+
});
64+
}
65+
});
3766
ui.collapsing_header("Configuration", |ui| {
3867
ui.columns(2, |columns| {
3968
columns[0].label("Invert Pan");
@@ -89,12 +118,17 @@ impl<TUi: DebugUi> DebugUiPane<TUi> for FixturesDebugUiPane {
89118
});
90119
});
91120
ui.collapsing_header("Channel Values", |ui| {
92-
ui.columns(2, |columns| {
93-
for (channel, value) in fixture.channel_values.iter() {
94-
columns[0].label(channel);
95-
columns[1].label(value.to_string());
96-
}
97-
});
121+
for (channel, value) in fixture.channel_values.iter() {
122+
ui.collapsing_header(format!("{channel}: {value}"), |ui| {
123+
ui.columns(2, |columns| {
124+
let values = fixture.channel_values.get_priorities(channel).unwrap();
125+
for (priority, value) in &values.values {
126+
columns[0].label(value.to_string());
127+
columns[1].label(priority.to_string());
128+
}
129+
});
130+
});
131+
}
98132
});
99133
ui.collapsing_header("Faders", |ui| {
100134
ui.columns(3, |columns| {

crates/components/fixtures/src/fixture.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(crate) struct ChannelValues {
3636

3737
#[derive(Debug, Clone, PartialEq, Serialize)]
3838
pub(crate) struct ChannelValue {
39-
values: Vec<(FixturePriority, f64)>,
39+
pub(crate) values: Vec<(FixturePriority, f64)>,
4040
}
4141

4242
impl Default for ChannelValue {
@@ -58,6 +58,14 @@ impl ChannelValue {
5858
&format!("values: {}", self.values.len())
5959
);
6060

61+
if let Some((_, value)) = self
62+
.values
63+
.iter()
64+
.find(|(priority, _)| priority.is_highlight())
65+
{
66+
return Some(*value);
67+
}
68+
6169
if let Some((_, value)) = self
6270
.values
6371
.iter()
@@ -123,6 +131,10 @@ impl ChannelValues {
123131
}
124132
}
125133

134+
pub(crate) fn get_priorities(&self, channel: &str) -> Option<&ChannelValue> {
135+
self.values.get(channel)
136+
}
137+
126138
pub(crate) fn write(&mut self, name: &String, value: f64) {
127139
self.write_priority(name, value, Default::default());
128140
}
@@ -507,21 +519,21 @@ pub trait IFixtureMut: IFixture {
507519
);
508520

509521
fn highlight(&mut self) {
510-
self.write_fader_control(FixtureFaderControl::Intensity, 1f64, FixturePriority::HTP);
522+
self.write_fader_control(FixtureFaderControl::Intensity, 1f64, FixturePriority::Highlight);
511523
self.write_fader_control(
512524
FixtureFaderControl::ColorMixer(ColorChannel::Red),
513525
1f64,
514-
FixturePriority::HTP,
526+
FixturePriority::Highlight,
515527
);
516528
self.write_fader_control(
517529
FixtureFaderControl::ColorMixer(ColorChannel::Green),
518530
1f64,
519-
FixturePriority::HTP,
531+
FixturePriority::Highlight,
520532
);
521533
self.write_fader_control(
522534
FixtureFaderControl::ColorMixer(ColorChannel::Blue),
523535
1f64,
524-
FixturePriority::HTP,
536+
FixturePriority::Highlight,
525537
);
526538
}
527539
}

crates/components/fixtures/src/priority.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ use serde::{Deserialize, Serialize};
77
#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
88
#[repr(u8)]
99
pub enum FixturePriority {
10+
/**
11+
* Highlight overrides programmer
12+
*/
13+
Highlight = 11,
1014
/**
1115
* Programmer always overrides everything else
1216
*/
@@ -27,6 +31,7 @@ impl Sequence for FixturePriority {
2731

2832
fn next(&self) -> Option<Self> {
2933
match self {
34+
Self::Highlight => None,
3035
Self::Programmer => None,
3136
Self::HTP => Some(Self::LTP(LTPPriority::Highest)),
3237
Self::LTP(LTPPriority::Highest) => Some(Self::LTP(LTPPriority::High)),
@@ -39,6 +44,7 @@ impl Sequence for FixturePriority {
3944

4045
fn previous(&self) -> Option<Self> {
4146
match self {
47+
Self::Highlight => None,
4248
Self::Programmer => None,
4349
Self::HTP => None,
4450
Self::LTP(LTPPriority::Highest) => Some(Self::HTP),
@@ -64,6 +70,10 @@ impl FixturePriority {
6470
pub const LOW: Self = Self::LTP(LTPPriority::Low);
6571
pub const LOWEST: Self = Self::LTP(LTPPriority::Lowest);
6672

73+
pub fn is_highlight(&self) -> bool {
74+
matches!(self, Self::Highlight)
75+
}
76+
6777
pub fn is_programmer(&self) -> bool {
6878
matches!(self, Self::Programmer)
6979
}
@@ -116,6 +126,7 @@ impl From<LTPPriority> for FixturePriority {
116126
impl From<FixturePriority> for u8 {
117127
fn from(value: FixturePriority) -> Self {
118128
match value {
129+
FixturePriority::Highlight => 11,
119130
FixturePriority::Programmer => 10,
120131
FixturePriority::HTP => 5,
121132
FixturePriority::LTP(LTPPriority::Highest) => 4,
@@ -132,6 +143,7 @@ impl TryFrom<u8> for FixturePriority {
132143

133144
fn try_from(value: u8) -> Result<Self, Self::Error> {
134145
match value {
146+
11 => Ok(Self::Highlight),
135147
10 => Ok(Self::Programmer),
136148
5 => Ok(Self::HTP),
137149
4 => Ok(Self::LTP(LTPPriority::Highest)),
@@ -158,6 +170,7 @@ impl Error for InvalidFixturePriorityError {}
158170
impl Display for FixturePriority {
159171
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
160172
match self {
173+
Self::Highlight => write!(f, "Highlight"),
161174
Self::Programmer => write!(f, "Programmer"),
162175
Self::HTP => write!(f, "HTP"),
163176
Self::LTP(level) => write!(f, "LTP {:?}", level),

0 commit comments

Comments
 (0)