Add native Midra layout appearance preview

This commit is contained in:
Dandaedre 2026-11-13 11:24:19 +01:00
parent 31456b31a1
commit 6cd65d3ac5
7 changed files with 373 additions and 3 deletions

7
Cargo.lock generated
View File

@ -2391,6 +2391,13 @@ dependencies = [
"paste",
]
[[package]]
name = "midra-layout"
version = "0.3.0"
dependencies = [
"eframe",
]
[[package]]
name = "miniz_oxide"
version = "0.8.9"

View File

@ -1,5 +1,5 @@
[workspace]
members = ["crates/pptx-reporter", "crates/rundown-converter", "crates/ascii-names"]
members = ["crates/pptx-reporter", "crates/rundown-converter", "crates/ascii-names", "crates/midra-layout"]
default-members = ["crates/pptx-reporter"]
resolver = "3"

View File

@ -47,7 +47,7 @@ opening reports, and reading video timings.
- [ASCII filename cleaner](docs/ascii-names.md)
- [Document exports](docs/exporter.md)
- [Rundown converter](docs/rundown-converter.md) · [Sample findings](docs/rundown-corpus.md)
- [Midra layout helper: plan and visual proposals](docs/midra-layout-plan.md) (design stage)
- [Midra layout appearance preview](docs/midra-layout.md) · [Plan and visual proposals](docs/midra-layout-plan.md)
- [Development](docs/development.md) · [CI and coverage](docs/ci.md)
- [Cross builds and portable releases](docs/releases.md)
- [MPC-HC Companion module development](companion-modules/media-player-classic/README.md)

View File

@ -0,0 +1,10 @@
[package]
name = "midra-layout"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "Offline Midra layer layout helper — appearance preview"
[dependencies]
eframe = { version = "0.31", default-features = false, features = ["default_fonts", "glow", "x11", "wayland"] }

View File

@ -0,0 +1,321 @@
//! Appearance-only desktop study. All geometry and controls are illustrative.
use eframe::egui::{self, Align2, Color32, FontId, Pos2, Rect, Stroke, StrokeKind, Vec2};
const BG: Color32 = Color32::from_rgb(17, 23, 32);
const PANEL: Color32 = Color32::from_rgb(27, 35, 48);
const FIELD: Color32 = Color32::from_rgb(18, 26, 37);
const LINE: Color32 = Color32::from_rgb(53, 68, 88);
const TEXT: Color32 = Color32::from_rgb(237, 243, 252);
const MUTED: Color32 = Color32::from_rgb(165, 181, 201);
const CYAN: Color32 = Color32::from_rgb(102, 219, 239);
const AMBER: Color32 = Color32::from_rgb(246, 197, 119);
const PURPLE: Color32 = Color32::from_rgb(102, 85, 217);
fn main() -> eframe::Result {
eframe::run_native(
"Midra Layout · Appearance preview",
eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([1440.0, 940.0])
.with_min_inner_size([1000.0, 720.0]),
..Default::default()
},
Box::new(|cc| {
cc.egui_ctx.set_visuals(egui::Visuals::dark());
Ok(Box::new(Appearance))
}),
)
}
struct Appearance;
/// Draw in local logical points; viewport artwork alone uses a fitted scale.
struct Ink {
painter: egui::Painter,
origin: Pos2,
scale: f32,
}
impl Ink {
fn new(ui: &egui::Ui, rect: Rect) -> Self {
Self {
painter: ui.painter_at(rect),
origin: rect.min,
scale: 1.0,
}
}
fn point(&self, x: f32, y: f32) -> Pos2 {
self.origin + Vec2::new(x, y) * self.scale
}
fn rect(&self, x: f32, y: f32, w: f32, h: f32, fill: Color32) {
self.painter.rect_filled(
Rect::from_min_size(self.point(x, y), Vec2::new(w, h) * self.scale),
0.0,
fill,
);
}
fn card(&self, x: f32, y: f32, w: f32, h: f32, fill: Color32, border: Color32) {
self.painter.rect(
Rect::from_min_size(self.point(x, y), Vec2::new(w, h) * self.scale),
5.0,
fill,
Stroke::new(1.0_f32, border),
StrokeKind::Inside,
);
}
fn text(&self, x: f32, y: f32, text: &str, size: f32, color: Color32) {
self.painter.text(
self.point(x, y),
Align2::LEFT_TOP,
text,
FontId::proportional(size * self.scale),
color,
);
}
fn line(&self, from: [f32; 2], to: [f32; 2], color: Color32) {
self.painter.line_segment(
[self.point(from[0], from[1]), self.point(to[0], to[1])],
Stroke::new(1.0_f32, color),
);
}
fn button(&self, x: f32, y: f32, w: f32, label: &str, primary: bool) {
self.card(x, y, w, 34.0, if primary { PURPLE } else { FIELD }, LINE);
self.text(x + 12.0, y + 9.0, label, 13.0, TEXT);
}
fn chevron(&self, x: f32, y: f32) {
self.line([x, y], [x + 4.0, y + 4.0], MUTED);
self.line([x + 4.0, y + 4.0], [x + 8.0, y], MUTED);
}
fn field(&self, x: f32, y: f32, w: f32, label: &str, value: &str) {
self.text(x, y, label, 12.0, MUTED);
self.card(x, y + 23.0, w, 42.0, FIELD, LINE);
self.text(x + 12.0, y + 34.0, value, 18.0, TEXT);
}
}
impl eframe::App for Appearance {
fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
egui::TopBottomPanel::top("header")
.exact_height(64.0)
.frame(egui::Frame::NONE.fill(PANEL))
.show(ctx, |ui| {
let r = ui.max_rect();
let ink = Ink::new(ui, r);
ink.text(24.0, 21.0, "MIDRA / LAYOUT", 21.0, TEXT);
ink.line([218.0, 22.0], [218.0, 43.0], LINE);
ink.text(238.0, 26.0, "Offline position helper", 13.0, MUTED);
ink.text(r.width() - 347.0, 27.0, "EIKOS 4K", 12.0, CYAN);
ink.button(r.width() - 212.0, 15.0, 188.0, "Copy coordinates", false);
ink.line([0.0, 63.0], [r.width(), 63.0], LINE);
});
egui::TopBottomPanel::bottom("status")
.exact_height(34.0)
.frame(egui::Frame::NONE.fill(PANEL))
.show(ctx, |ui| {
let r = ui.max_rect();
let ink = Ink::new(ui, r);
ink.painter.circle_filled(ink.point(24.0, 17.0), 3.0, CYAN);
ink.text(36.0, 10.0, "OFFLINE", 11.0, MUTED);
ink.text(
116.0,
10.0,
"Appearance preview · controls inactive",
12.0,
MUTED,
);
ink.text(
r.width() - 278.0,
10.0,
"Screen pixels / 1920 × 1080",
12.0,
MUTED,
);
});
egui::SidePanel::right("inspector")
.exact_width(392.0)
.resizable(false)
.frame(egui::Frame::NONE.fill(PANEL).inner_margin(24.0))
.show(ctx, |ui| {
egui::ScrollArea::vertical().show(ui, |ui| {
let (r, _) = ui.allocate_exact_size(
Vec2::new(ui.available_width(), 814.0),
egui::Sense::hover(),
);
inspector(&Ink::new(ui, r), r.width());
});
});
egui::CentralPanel::default()
.frame(egui::Frame::NONE.fill(BG))
.show(ctx, workspace);
}
}
fn inspector(ink: &Ink, w: f32) {
ink.text(0.0, 2.0, "LAYERS", 11.0, MUTED);
for (y, label, color, selected) in [
(28.0, "01 Presenter", AMBER, false),
(72.0, "02 Slides", CYAN, true),
] {
ink.card(0.0, y, w, 38.0, FIELD, if selected { CYAN } else { LINE });
ink.text(13.0, y + 10.0, label, 15.0, color);
ink.text(w - 59.0, y + 12.0, "Visible", 11.0, MUTED);
}
ink.line([0.0, 130.0], [w, 130.0], LINE);
ink.text(0.0, 150.0, "02 / Slides", 25.0, TEXT);
ink.text(0.0, 186.0, "Source format", 12.0, MUTED);
ink.card(0.0, 209.0, w, 34.0, FIELD, LINE);
ink.text(12.0, 218.0, "16:9 / 1920 × 1080", 13.0, TEXT);
ink.chevron(w - 24.0, 224.0);
ink.text(0.0, 264.0, "POSITION FROM SCREEN CORNER", 11.0, MUTED);
ink.card(0.0, 289.0, 94.0, 58.0, FIELD, LINE);
for (x, y) in [(9.0, 298.0), (85.0, 298.0), (9.0, 338.0), (85.0, 338.0)] {
ink.rect(
x - 3.0,
y - 3.0,
6.0,
6.0,
if x == 85.0 && y == 298.0 { CYAN } else { MUTED },
);
}
ink.text(112.0, 296.0, "Top right", 18.0, TEXT);
ink.text(112.0, 323.0, "Offsets inward", 12.0, MUTED);
let half = (w - 12.0) / 2.0;
ink.field(0.0, 367.0, half, "From right", "120 px");
ink.field(half + 12.0, 367.0, half, "From top", "180 px");
ink.field(0.0, 449.0, half, "Layer width", "640 px");
ink.field(half + 12.0, 449.0, half, "Layer height", "360 px");
ink.text(
0.0,
531.0,
"Changing corner keeps the layer in place.",
12.0,
MUTED,
);
ink.line([0.0, 559.0], [w, 559.0], LINE);
ink.text(0.0, 580.0, "WEBRCS / CENTER POSITION", 11.0, CYAN);
ink.field(0.0, 610.0, half, "Horizontal · from left", "1480 px");
ink.field(half + 12.0, 610.0, half, "Vertical · from top", "360 px");
ink.text(0.0, 690.0, "Size 640 × 360 px", 13.0, MUTED);
ink.button(0.0, 720.0, w, "Copy position values", true);
ink.text(0.0, 776.0, "Paste geometry…", 14.0, TEXT);
ink.text(
0.0,
799.0,
"Preview coordinates before applying.",
12.0,
MUTED,
);
}
fn workspace(ui: &mut egui::Ui) {
let r = ui.max_rect();
let ink = Ink::new(ui, r);
ink.button(24.0, 20.0, 185.0, "Screen 1 · Full HD", false);
ink.button(221.0, 20.0, 149.0, "Reference image", false);
ink.button(382.0, 20.0, 103.0, "Snap: off", false);
ink.button(24.0, 67.0, 103.0, "Fit screen", false);
ink.button(139.0, 67.0, 91.0, "Zoom", false);
ink.chevron(208.0, 82.0);
ink.text(25.0, 132.0, "YOUR SCREEN, PRECISELY PLACED", 12.0, CYAN);
ink.text(25.0, 157.0, "Two layers. One clear view.", 17.0, MUTED);
// Camera fit for this appearance study only; no editable layer geometry.
let scale = ((r.width() - 88.0) / 960.0).min((r.height() - 300.0) / 540.0);
let size = Vec2::new(960.0, 540.0) * scale;
let origin = r.min
+ Vec2::new(
(r.width() - size.x) / 2.0,
222.0 + (r.height() - 300.0 - size.y) / 2.0,
);
let screen = Ink {
painter: ui.painter_at(r),
origin,
scale,
};
screen_artwork(&screen);
ink.text(
24.0,
r.height() - 57.0,
"Reference: stage-layout.png · 1920 × 1080 · Locked",
12.0,
MUTED,
);
ink.text(
24.0,
r.height() - 31.0,
"Illustrative artwork and values · no files loaded",
12.0,
MUTED,
);
}
fn screen_artwork(ink: &Ink) {
ink.text(0.0, -29.0, "SCREEN 1", 12.0, MUTED);
ink.text(790.0, -29.0, "1920 × 1080 px", 13.0, MUTED);
ink.rect(0.0, 0.0, 960.0, 540.0, Color32::from_rgb(20, 45, 64));
ink.rect(0.0, 0.0, 960.0, 36.0, Color32::from_rgb(38, 69, 86));
ink.text(24.0, 10.0, "ANNUAL FORUM / MAIN STAGE", 13.0, MUTED);
for x in (0..=1920).step_by(240) {
ink.line(
[x as f32 / 2.0, 36.0],
[x as f32 / 2.0, 540.0],
Color32::from_rgb(39, 71, 90),
);
}
for y in (180..=1080).step_by(180) {
ink.line(
[0.0, y as f32 / 2.0],
[960.0, y as f32 / 2.0],
Color32::from_rgb(39, 71, 90),
);
}
ink.text(24.0, 462.0, "Ideas worth sharing.", 27.0, MUTED);
ink.text(
24.0,
503.0,
"Illustrative reference artwork · opacity 65%",
12.0,
MUTED,
);
for (x, color, label, selected) in [
(60.0, AMBER, "01 / PRESENTER", false),
(580.0, CYAN, "02 / SLIDES", true),
] {
ink.rect(x, 90.0, 320.0, 180.0, Color32::from_rgb(23, 59, 80));
ink.painter.rect_stroke(
Rect::from_min_size(ink.point(x, 90.0), Vec2::new(320.0, 180.0) * ink.scale),
0.0,
Stroke::new(1.0_f32, color),
StrokeKind::Inside,
);
ink.text(x + 15.0, 107.0, label, 15.0, color);
ink.text(x + 15.0, 242.0, "640 × 360 px", 14.0, TEXT);
if selected {
for (dx, dy) in [(0.0, 0.0), (320.0, 0.0), (0.0, 180.0), (320.0, 180.0)] {
ink.card(x + dx - 4.0, 86.0 + dy, 8.0, 8.0, PANEL, CYAN);
}
ink.line([x + 152.0, 180.0], [x + 168.0, 180.0], CYAN);
ink.line([x + 160.0, 172.0], [x + 160.0, 188.0], CYAN);
}
}
ink.line([916.0, 0.0], [916.0, 90.0], CYAN);
ink.line([910.0, 0.0], [922.0, 0.0], CYAN);
ink.line([910.0, 90.0], [922.0, 90.0], CYAN);
ink.text(923.0, 40.0, "180", 12.0, CYAN);
ink.line([900.0, 288.0], [960.0, 288.0], CYAN);
ink.text(900.0, 302.0, "120 px", 12.0, CYAN);
}

View File

@ -1,6 +1,9 @@
# Midra layout helper: plan and visual proposals
Status: design only. No application, device connection or REST calls implemented.
Status: a [Rust/egui appearance preview](midra-layout.md) is available. Its controls
and sample values are illustrative; positioning, crop logic, device connection
and REST calls are not implemented. The implementation checklist below remains
open until those behaviors and acceptance gates are complete.
Target: Analog Way Eikos 4K, running the latest firmware according to the user.
Record the actual installed version during compatibility checks; do not infer it
from a different Midra generation's documentation. Working name: **Midra Layout**.

29
docs/midra-layout.md Normal file
View File

@ -0,0 +1,29 @@
# Midra Layout appearance preview
A native Rust/egui visual draft of Concept A: dark operator workspace, fitted
screen artwork, two sample layers, selection markers, dimension guides and a
right-hand inspector. The inspector includes source format, corner offsets,
layer dimensions and illustrative WebRCS values.
Run from the repository root:
```sh
cargo run --locked -p midra-layout
```
This is **appearance only**. Buttons, fields, layer selection, copy/paste,
zoom and movement are inactive. The screen artwork is drawn into the preview;
`stage-layout.png` is an illustrative label, not a loaded file. All displayed
coordinates are fixed sample values, not computed device settings. There is no
device connection, file import, clipboard access or persistent configuration.
The window can be resized; the screen retains its aspect ratio and the right
inspector scrolls on shorter windows. The minimum window size is 1000 × 720
logical points. Native desktop launch requires a graphical session.
The crate is a Cargo workspace member, so existing workspace lint, tests, docs
and coverage commands include it. It has no positioning/cropping logic to test
yet; visual review is the relevant acceptance check for this draft.
See the [project plan and SVG concepts](midra-layout-plan.md) and
[resolution/cropping specification](midra-layout-resolutions.md) for future work.