Skip to content

Commit 28aa08f

Browse files
committed
feat: add rendering for auxiliary objects
1 parent 830a746 commit 28aa08f

File tree

2 files changed

+97
-15
lines changed

2 files changed

+97
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ The lists below only apply to version 3 of the VT specification. There are 3 sta
122122
- :white_circle: OutputArchedBarGraph
123123
- :green_circle: PictureGraphic
124124
- :green_circle: ObjectPointer
125-
- :white_circle: Auxiliary Function Type 2
126-
- :white_circle: Auxiliary Input Type 2
127-
- :white_circle: Auxiliary Control Designator Type 2 Object Pointer
125+
- :yellow_circle: Auxiliary Function Type 2
126+
- :yellow_circle: Auxiliary Input Type 2
127+
- :yellow_circle: Auxiliary Control Designator Type 2 Object Pointer
128128

129129

130130
## Installation

src/object_rendering.rs

Lines changed: 94 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ fn render_object_refs(ui: &mut egui::Ui, pool: &ObjectPool, object_refs: &Vec<Ob
143143

144144
impl RenderableObject for WorkingSet {
145145
fn render(&self, ui: &mut egui::Ui, pool: &ObjectPool, _: Point<i16>) {
146-
if !self.selectable {
147-
// The working set is not visible
148-
return;
149-
}
150-
151146
ui.painter().rect_filled(
152147
ui.available_rect_before_wrap(),
153148
0.0,
@@ -567,7 +562,7 @@ impl RenderableObject for InputList {
567562

568563
impl RenderableObject for Key {
569564
fn render(&self, ui: &mut egui::Ui, pool: &ObjectPool, position: Point<i16>) {
570-
let rect = create_relative_rect(ui, position, egui::Vec2::new(100.0, 100.0));
565+
let rect = create_relative_rect(ui, position, egui::Vec2::INFINITY); // TODO: set size to softkey area
571566

572567
ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
573568
render_object_refs(ui, pool, &self.object_refs);
@@ -1260,21 +1255,108 @@ impl RenderableObject for PictureGraphic {
12601255

12611256
impl RenderableObject for AuxiliaryFunctionType2 {
12621257
fn render(&self, ui: &mut egui::Ui, pool: &ObjectPool, position: Point<i16>) {
1263-
ui.colored_label(Color32::RED, "AuxiliaryFunctionType2 not implemented");
1258+
let rect = create_relative_rect(ui, position, egui::Vec2::INFINITY); // TODO: set size to softkey area
1259+
1260+
ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
1261+
// Draw background colour
1262+
let background_colour = pool.color_by_index(self.background_colour).convert();
1263+
ui.painter().rect_filled(rect, 0.0, background_colour);
1264+
1265+
// Render child objects (the function designator content)
1266+
render_object_refs(ui, pool, &self.object_refs);
1267+
});
12641268
}
12651269
}
12661270

12671271
impl RenderableObject for AuxiliaryInputType2 {
12681272
fn render(&self, ui: &mut egui::Ui, pool: &ObjectPool, position: Point<i16>) {
1269-
ui.colored_label(Color32::RED, "AuxiliaryInputType2 not implemented");
1273+
let rect = create_relative_rect(ui, position, egui::Vec2::INFINITY); // TODO: set size to softkey area
1274+
1275+
ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
1276+
// Draw background colour
1277+
let background_colour = pool.color_by_index(self.background_colour).convert();
1278+
ui.painter().rect_filled(rect, 0.0, background_colour);
1279+
1280+
// Render child objects (the input designator content)
1281+
render_object_refs(ui, pool, &self.object_refs);
1282+
});
12701283
}
12711284
}
12721285

12731286
impl RenderableObject for AuxiliaryControlDesignatorType2 {
12741287
fn render(&self, ui: &mut egui::Ui, pool: &ObjectPool, position: Point<i16>) {
1275-
ui.colored_label(
1276-
Color32::RED,
1277-
"AuxiliaryControlDesignatorType2 not implemented",
1278-
);
1288+
let rect = create_relative_rect(ui, position, egui::Vec2::INFINITY); // TODO: set size to softkey area
1289+
1290+
ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
1291+
// Determine what to display based on pointer_type
1292+
match self.pointer_type {
1293+
0 => {
1294+
// Pointer type 0: Points to Auxiliary Object referenced by auxiliary_object_id
1295+
// Display the auxiliary object designator
1296+
if let Some(aux_obj_id) = self.auxiliary_object_id.0 {
1297+
match pool.object_by_id(aux_obj_id) {
1298+
Some(Object::AuxiliaryFunctionType2(aux_func)) => {
1299+
// Render the auxiliary function designator
1300+
render_object_refs(ui, pool, &aux_func.object_refs);
1301+
}
1302+
Some(Object::AuxiliaryInputType2(aux_input)) => {
1303+
// Render the auxiliary input designator
1304+
render_object_refs(ui, pool, &aux_input.object_refs);
1305+
}
1306+
Some(_) => {
1307+
ui.colored_label(
1308+
Color32::RED,
1309+
format!("Invalid aux object type: {:?}", aux_obj_id),
1310+
);
1311+
}
1312+
None => {
1313+
ui.colored_label(
1314+
Color32::RED,
1315+
format!("Missing aux object: {:?}", aux_obj_id),
1316+
);
1317+
}
1318+
}
1319+
}
1320+
}
1321+
1 => {
1322+
// Pointer type 1: Points to Auxiliary Function/Input that is assigned to the auxiliary object
1323+
// In a real VT, this would show the assigned auxiliary object designator.
1324+
// Since we don't have runtime assignment info, we show a placeholder.
1325+
ui.painter()
1326+
.rect_filled(rect, 0.0, Color32::from_rgb(220, 220, 255));
1327+
ui.colored_label(Color32::DARK_BLUE, "Assigned\nAux Obj");
1328+
}
1329+
2 => {
1330+
// Pointer type 2: Points to Working Set object for the owner of this pointer
1331+
if let Some(ws) = pool.objects().iter().find_map(|obj| {
1332+
if let Object::WorkingSet(ws) = obj {
1333+
Some(ws)
1334+
} else {
1335+
None
1336+
}
1337+
}) {
1338+
// Render working set designator
1339+
ws.render(ui, pool, Point { x: 0, y: 0 });
1340+
} else {
1341+
ui.colored_label(Color32::RED, "No working set object defined");
1342+
}
1343+
}
1344+
3 => {
1345+
// Pointer type 3: Points to Working Set object for the WS that owns the assigned aux object
1346+
// In a real VT, this would show the working set designator of the assigned object's owner.
1347+
// Since we don't have runtime assignment info, we show a placeholder.
1348+
ui.painter()
1349+
.rect_filled(rect, 0.0, Color32::from_rgb(255, 220, 220));
1350+
ui.colored_label(Color32::DARK_RED, "Assigned\nWS");
1351+
}
1352+
_ => {
1353+
// Invalid pointer type
1354+
ui.colored_label(
1355+
Color32::RED,
1356+
format!("Invalid pointer type: {}", self.pointer_type),
1357+
);
1358+
}
1359+
}
1360+
});
12791361
}
12801362
}

0 commit comments

Comments
 (0)