Merge X and Y scale factors into a vector
This commit is contained in:
parent
c72094bfd3
commit
47f2c2d4ef
@ -67,13 +67,9 @@ impl Widget for Frontpanel<'_> {
|
||||
dbg!(fp_rect);
|
||||
let painter = Painter::new(ui.ctx().clone(), ui.layer_id(), ui.clip_rect().intersect(resp.rect));
|
||||
painter.image(self.textures.fp.id(), painter.clip_rect(), NULL_UV, NULL_TINT);
|
||||
let x_scale = painter.clip_rect().width() / 800.0;
|
||||
let y_scale = painter.clip_rect().height() / 333.0;
|
||||
let scale_vec = painter.clip_rect().size() / vec2(800.0, 333.0);
|
||||
for led in &LEDS {
|
||||
let mut pos = led.pos;
|
||||
pos.x *= x_scale;
|
||||
pos.y *= y_scale;
|
||||
pos += fp_rect.left_top().to_vec2();
|
||||
let pos = (led.pos.to_vec2() * scale_vec).to_pos2() + fp_rect.left_top().to_vec2();
|
||||
let led_data = 0xAAAA;
|
||||
let led_on = (led_data & led.mask) > 0;
|
||||
ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(16.0, 16.0)), |ui| {
|
||||
@ -84,10 +80,7 @@ impl Widget for Frontpanel<'_> {
|
||||
// 1..17: A/D left to right
|
||||
// 17..25: Action left to right
|
||||
for (i, switch) in SWITCHES.iter().enumerate() {
|
||||
let mut pos = switch.pos;
|
||||
pos.x *= x_scale;
|
||||
pos.y *= y_scale;
|
||||
pos += fp_rect.left_top().to_vec2();
|
||||
let pos = (switch.pos.to_vec2() * scale_vec).to_pos2() + fp_rect.left_top().to_vec2();
|
||||
if i == 0 {
|
||||
ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(11.0, 25.0)), |ui| {
|
||||
let mut power_inv = !state.power;
|
||||
|
Loading…
Reference in New Issue
Block a user