2019-02-08 23:58:54 -05:00
|
|
|
// pathfinder/demo/src/ui.rs
|
|
|
|
//
|
|
|
|
// Copyright © 2019 The Pathfinder Project Developers.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2019-03-13 19:32:39 -04:00
|
|
|
use crate::{Mode, Options};
|
2019-03-08 19:52:47 -05:00
|
|
|
use crate::window::Window;
|
2019-02-08 23:58:54 -05:00
|
|
|
use pathfinder_geometry::basic::point::Point2DI32;
|
|
|
|
use pathfinder_geometry::basic::rect::RectI32;
|
2019-03-08 19:52:47 -05:00
|
|
|
use pathfinder_gpu::Device;
|
|
|
|
use pathfinder_gpu::resources::ResourceLoader;
|
2019-03-05 18:13:55 -05:00
|
|
|
use pathfinder_renderer::gpu::debug::DebugUI;
|
2019-03-06 21:25:08 -05:00
|
|
|
use pathfinder_ui::{BUTTON_HEIGHT, BUTTON_TEXT_OFFSET, BUTTON_WIDTH, FONT_ASCENT, PADDING};
|
2019-03-13 19:32:39 -04:00
|
|
|
use pathfinder_ui::{TEXT_COLOR, TOOLTIP_HEIGHT, WINDOW_COLOR};
|
2019-02-12 15:40:24 -05:00
|
|
|
use std::f32::consts::PI;
|
2019-02-09 00:08:03 -05:00
|
|
|
use std::path::PathBuf;
|
2019-02-08 23:58:54 -05:00
|
|
|
|
2019-02-12 15:40:24 -05:00
|
|
|
const SLIDER_WIDTH: i32 = 360;
|
|
|
|
const SLIDER_HEIGHT: i32 = 48;
|
|
|
|
const SLIDER_TRACK_HEIGHT: i32 = 24;
|
|
|
|
const SLIDER_KNOB_WIDTH: i32 = 12;
|
|
|
|
const SLIDER_KNOB_HEIGHT: i32 = 48;
|
|
|
|
|
|
|
|
const EFFECTS_PANEL_WIDTH: i32 = 550;
|
|
|
|
const EFFECTS_PANEL_HEIGHT: i32 = BUTTON_HEIGHT * 3 + PADDING * 4;
|
|
|
|
|
|
|
|
const ROTATE_PANEL_WIDTH: i32 = SLIDER_WIDTH + PADDING * 2;
|
|
|
|
const ROTATE_PANEL_HEIGHT: i32 = PADDING * 2 + SLIDER_HEIGHT;
|
2019-02-08 23:58:54 -05:00
|
|
|
|
2019-02-25 14:33:26 -05:00
|
|
|
static EFFECTS_PNG_NAME: &'static str = "demo-effects";
|
|
|
|
static OPEN_PNG_NAME: &'static str = "demo-open";
|
|
|
|
static ROTATE_PNG_NAME: &'static str = "demo-rotate";
|
|
|
|
static ZOOM_IN_PNG_NAME: &'static str = "demo-zoom-in";
|
|
|
|
static ZOOM_OUT_PNG_NAME: &'static str = "demo-zoom-out";
|
|
|
|
static BG_LIGHT_PNG_NAME: &'static str = "demo-bg-light";
|
|
|
|
static BG_DARK_PNG_NAME: &'static str = "demo-bg-dark";
|
|
|
|
static SCREENSHOT_PNG_NAME: &'static str = "demo-screenshot";
|
2019-02-08 23:58:54 -05:00
|
|
|
|
2019-03-04 17:55:32 -05:00
|
|
|
pub struct DemoUI<D> where D: Device {
|
|
|
|
effects_texture: D::Texture,
|
|
|
|
open_texture: D::Texture,
|
|
|
|
rotate_texture: D::Texture,
|
|
|
|
zoom_in_texture: D::Texture,
|
|
|
|
zoom_out_texture: D::Texture,
|
|
|
|
bg_light_texture: D::Texture,
|
|
|
|
bg_dark_texture: D::Texture,
|
|
|
|
screenshot_texture: D::Texture,
|
2019-02-12 15:40:24 -05:00
|
|
|
|
|
|
|
effects_panel_visible: bool,
|
|
|
|
rotate_panel_visible: bool,
|
2019-02-08 23:58:54 -05:00
|
|
|
|
2019-03-06 21:25:08 -05:00
|
|
|
// FIXME(pcwalton): Factor the below out into a model class.
|
|
|
|
|
2019-03-13 19:32:39 -04:00
|
|
|
pub mode: Mode,
|
2019-02-22 21:21:03 -05:00
|
|
|
pub dark_background_enabled: bool,
|
2019-02-08 23:58:54 -05:00
|
|
|
pub gamma_correction_effect_enabled: bool,
|
|
|
|
pub stem_darkening_effect_enabled: bool,
|
|
|
|
pub subpixel_aa_effect_enabled: bool,
|
2019-02-12 15:40:24 -05:00
|
|
|
pub rotation: i32,
|
2019-03-06 21:25:08 -05:00
|
|
|
pub message: String,
|
2019-03-06 22:35:57 -05:00
|
|
|
pub show_text_effects: bool,
|
2019-02-08 23:58:54 -05:00
|
|
|
}
|
|
|
|
|
2019-03-04 17:55:32 -05:00
|
|
|
impl<D> DemoUI<D> where D: Device {
|
2019-03-08 19:52:47 -05:00
|
|
|
pub fn new(device: &D, resources: &dyn ResourceLoader, options: Options) -> DemoUI<D> {
|
2019-03-04 17:55:32 -05:00
|
|
|
let effects_texture = device.create_texture_from_png(resources, EFFECTS_PNG_NAME);
|
|
|
|
let open_texture = device.create_texture_from_png(resources, OPEN_PNG_NAME);
|
|
|
|
let rotate_texture = device.create_texture_from_png(resources, ROTATE_PNG_NAME);
|
|
|
|
let zoom_in_texture = device.create_texture_from_png(resources, ZOOM_IN_PNG_NAME);
|
|
|
|
let zoom_out_texture = device.create_texture_from_png(resources, ZOOM_OUT_PNG_NAME);
|
|
|
|
let bg_light_texture = device.create_texture_from_png(resources, BG_LIGHT_PNG_NAME);
|
|
|
|
let bg_dark_texture = device.create_texture_from_png(resources, BG_DARK_PNG_NAME);
|
|
|
|
let screenshot_texture = device.create_texture_from_png(resources, SCREENSHOT_PNG_NAME);
|
2019-02-08 23:58:54 -05:00
|
|
|
|
|
|
|
DemoUI {
|
|
|
|
effects_texture,
|
|
|
|
open_texture,
|
2019-02-12 15:40:24 -05:00
|
|
|
rotate_texture,
|
2019-02-13 13:32:25 -05:00
|
|
|
zoom_in_texture,
|
|
|
|
zoom_out_texture,
|
2019-02-22 21:21:03 -05:00
|
|
|
bg_light_texture,
|
|
|
|
bg_dark_texture,
|
2019-02-25 14:33:26 -05:00
|
|
|
screenshot_texture,
|
2019-02-26 18:24:39 -05:00
|
|
|
|
2019-02-12 15:40:24 -05:00
|
|
|
effects_panel_visible: false,
|
2019-02-12 17:49:24 -05:00
|
|
|
rotate_panel_visible: false,
|
2019-02-26 18:24:39 -05:00
|
|
|
|
2019-03-13 19:32:39 -04:00
|
|
|
mode: options.mode,
|
2019-03-07 14:15:43 -05:00
|
|
|
dark_background_enabled: false,
|
2019-02-08 23:58:54 -05:00
|
|
|
gamma_correction_effect_enabled: false,
|
|
|
|
stem_darkening_effect_enabled: false,
|
|
|
|
subpixel_aa_effect_enabled: false,
|
2019-02-12 15:40:24 -05:00
|
|
|
rotation: SLIDER_WIDTH / 2,
|
2019-03-06 21:25:08 -05:00
|
|
|
message: String::new(),
|
2019-03-06 22:35:57 -05:00
|
|
|
show_text_effects: true,
|
2019-02-08 23:58:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-13 19:05:28 -05:00
|
|
|
fn rotation(&self) -> f32 {
|
2019-02-12 15:40:24 -05:00
|
|
|
(self.rotation as f32 / SLIDER_WIDTH as f32 * 2.0 - 1.0) * PI
|
|
|
|
}
|
|
|
|
|
2019-03-08 19:52:47 -05:00
|
|
|
pub fn update<W>(&mut self,
|
|
|
|
device: &D,
|
|
|
|
window: &W,
|
|
|
|
debug_ui: &mut DebugUI<D>,
|
|
|
|
action: &mut UIAction)
|
|
|
|
where W: Window {
|
2019-03-06 21:25:08 -05:00
|
|
|
// Draw message text.
|
|
|
|
|
|
|
|
self.draw_message_text(device, debug_ui);
|
|
|
|
|
|
|
|
// Draw button strip.
|
|
|
|
|
2019-03-05 18:13:55 -05:00
|
|
|
let bottom = debug_ui.ui.framebuffer_size().y() - PADDING;
|
2019-03-06 13:47:52 -05:00
|
|
|
let mut position = Point2DI32::new(PADDING, bottom - BUTTON_HEIGHT);
|
2019-02-08 23:58:54 -05:00
|
|
|
|
2019-03-06 14:33:59 -05:00
|
|
|
let button_size = Point2DI32::new(BUTTON_WIDTH, BUTTON_HEIGHT);
|
|
|
|
|
2019-03-06 22:35:57 -05:00
|
|
|
// Draw text effects button.
|
|
|
|
if self.show_text_effects {
|
|
|
|
if debug_ui.ui.draw_button(device, position, &self.effects_texture) {
|
|
|
|
self.effects_panel_visible = !self.effects_panel_visible;
|
|
|
|
}
|
|
|
|
if !self.effects_panel_visible {
|
|
|
|
debug_ui.ui.draw_tooltip(device,
|
|
|
|
"Text Effects",
|
|
|
|
RectI32::new(position, button_size));
|
|
|
|
}
|
|
|
|
position += Point2DI32::new(button_size.x() + PADDING, 0);
|
2019-03-06 14:33:59 -05:00
|
|
|
}
|
2019-02-08 23:58:54 -05:00
|
|
|
|
|
|
|
// Draw open button.
|
2019-03-06 14:33:59 -05:00
|
|
|
if debug_ui.ui.draw_button(device, position, &self.open_texture) {
|
2019-03-08 19:52:47 -05:00
|
|
|
// FIXME(pcwalton): This is not sufficient for Android, where we will need to take in
|
|
|
|
// the contents of the file.
|
|
|
|
if let Ok(file) = window.run_open_dialog("svg") {
|
|
|
|
*action = UIAction::OpenFile(file);
|
2019-02-09 00:08:03 -05:00
|
|
|
}
|
|
|
|
}
|
2019-03-06 14:33:59 -05:00
|
|
|
debug_ui.ui.draw_tooltip(device, "Open SVG", RectI32::new(position, button_size));
|
2019-03-06 13:47:52 -05:00
|
|
|
position += Point2DI32::new(BUTTON_WIDTH + PADDING, 0);
|
2019-02-08 23:58:54 -05:00
|
|
|
|
2019-02-25 14:33:26 -05:00
|
|
|
// Draw screenshot button.
|
2019-03-06 14:33:59 -05:00
|
|
|
if debug_ui.ui.draw_button(device, position, &self.screenshot_texture) {
|
2019-03-08 19:52:47 -05:00
|
|
|
// FIXME(pcwalton): This is not sufficient for Android, where we will need to take in
|
|
|
|
// the contents of the file.
|
|
|
|
if let Ok(file) = window.run_save_dialog("png") {
|
|
|
|
*action = UIAction::TakeScreenshot(file);
|
2019-02-25 14:33:26 -05:00
|
|
|
}
|
|
|
|
}
|
2019-03-06 14:33:59 -05:00
|
|
|
debug_ui.ui.draw_tooltip(device, "Take Screenshot", RectI32::new(position, button_size));
|
2019-03-06 13:47:52 -05:00
|
|
|
position += Point2DI32::new(BUTTON_WIDTH + PADDING, 0);
|
2019-02-25 14:33:26 -05:00
|
|
|
|
2019-03-13 19:32:39 -04:00
|
|
|
// Draw mode switch.
|
|
|
|
let new_mode = debug_ui.ui.draw_text_switch(device,
|
|
|
|
position,
|
|
|
|
&["2D", "3D", "VR"],
|
|
|
|
self.mode as u8);
|
|
|
|
if new_mode != self.mode as u8 {
|
|
|
|
self.mode = match new_mode {
|
|
|
|
0 => Mode::TwoD,
|
|
|
|
1 => Mode::ThreeD,
|
|
|
|
_ => Mode::VR,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
let mode_switch_width = debug_ui.ui.measure_switch(3);
|
|
|
|
let mode_switch_size = Point2DI32::new(mode_switch_width, BUTTON_HEIGHT);
|
|
|
|
debug_ui.ui.draw_tooltip(device,
|
|
|
|
"2D/3D/VR Mode",
|
|
|
|
RectI32::new(position, mode_switch_size));
|
|
|
|
position += Point2DI32::new(mode_switch_width + PADDING, 0);
|
2019-02-22 21:21:03 -05:00
|
|
|
|
|
|
|
// Draw background switch.
|
2019-03-05 18:36:07 -05:00
|
|
|
self.dark_background_enabled = debug_ui.ui.draw_image_switch(device,
|
2019-03-06 13:47:52 -05:00
|
|
|
position,
|
2019-03-05 18:36:07 -05:00
|
|
|
&self.bg_light_texture,
|
|
|
|
&self.bg_dark_texture,
|
|
|
|
self.dark_background_enabled);
|
2019-03-13 19:32:39 -04:00
|
|
|
let background_color_switch_width = debug_ui.ui.measure_switch(2);
|
|
|
|
let background_color_switch_size = Point2DI32::new(background_color_switch_width,
|
|
|
|
BUTTON_HEIGHT);
|
|
|
|
let background_color_switch_rect = RectI32::new(position, background_color_switch_size);
|
|
|
|
debug_ui.ui.draw_tooltip(device, "Background Color", background_color_switch_rect);
|
|
|
|
position += Point2DI32::new(background_color_switch_width + PADDING, 0);
|
2019-02-08 23:58:54 -05:00
|
|
|
|
2019-03-06 22:35:57 -05:00
|
|
|
// Draw effects panel, if necessary.
|
|
|
|
self.draw_effects_panel(device, debug_ui);
|
2019-02-13 13:32:25 -05:00
|
|
|
|
2019-03-06 22:35:57 -05:00
|
|
|
// Draw rotate and zoom buttons, if applicable.
|
2019-03-13 19:32:39 -04:00
|
|
|
if self.mode != Mode::TwoD {
|
2019-03-06 22:35:57 -05:00
|
|
|
return;
|
|
|
|
}
|
2019-02-13 13:32:25 -05:00
|
|
|
|
2019-03-06 22:35:57 -05:00
|
|
|
if debug_ui.ui.draw_button(device, position, &self.rotate_texture) {
|
|
|
|
self.rotate_panel_visible = !self.rotate_panel_visible;
|
|
|
|
}
|
|
|
|
if !self.rotate_panel_visible {
|
|
|
|
debug_ui.ui.draw_tooltip(device, "Rotate", RectI32::new(position, button_size));
|
2019-02-12 15:40:24 -05:00
|
|
|
}
|
2019-03-06 22:35:57 -05:00
|
|
|
self.draw_rotate_panel(device, debug_ui, position.x(), action);
|
|
|
|
position += Point2DI32::new(BUTTON_WIDTH + PADDING, 0);
|
2019-02-12 15:40:24 -05:00
|
|
|
|
2019-03-06 22:35:57 -05:00
|
|
|
if debug_ui.ui.draw_button(device, position, &self.zoom_in_texture) {
|
|
|
|
*action = UIAction::ZoomIn;
|
|
|
|
}
|
|
|
|
debug_ui.ui.draw_tooltip(device, "Zoom In", RectI32::new(position, button_size));
|
|
|
|
position += Point2DI32::new(BUTTON_WIDTH + PADDING, 0);
|
2019-02-12 15:40:24 -05:00
|
|
|
|
2019-03-06 22:35:57 -05:00
|
|
|
if debug_ui.ui.draw_button(device, position, &self.zoom_out_texture) {
|
|
|
|
*action = UIAction::ZoomOut;
|
|
|
|
}
|
|
|
|
debug_ui.ui.draw_tooltip(device, "Zoom Out", RectI32::new(position, button_size));
|
|
|
|
position += Point2DI32::new(BUTTON_WIDTH + PADDING, 0);
|
2019-02-08 23:58:54 -05:00
|
|
|
}
|
|
|
|
|
2019-03-06 21:25:08 -05:00
|
|
|
fn draw_message_text(&mut self, device: &D, debug_ui: &mut DebugUI<D>) {
|
|
|
|
if self.message.is_empty() {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let message_size = debug_ui.ui.measure_text(&self.message);
|
|
|
|
let window_origin = Point2DI32::new(PADDING, PADDING);
|
|
|
|
let window_size = Point2DI32::new(PADDING * 2 + message_size, TOOLTIP_HEIGHT);
|
|
|
|
debug_ui.ui.draw_solid_rounded_rect(device,
|
|
|
|
RectI32::new(window_origin, window_size),
|
|
|
|
WINDOW_COLOR);
|
|
|
|
debug_ui.ui.draw_text(device,
|
|
|
|
&self.message,
|
|
|
|
window_origin + Point2DI32::new(PADDING, PADDING + FONT_ASCENT),
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
2019-03-06 14:33:59 -05:00
|
|
|
fn draw_effects_panel(&mut self, device: &D, debug_ui: &mut DebugUI<D>) {
|
2019-02-12 15:40:24 -05:00
|
|
|
if !self.effects_panel_visible {
|
2019-02-08 23:58:54 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-05 18:13:55 -05:00
|
|
|
let bottom = debug_ui.ui.framebuffer_size().y() - PADDING;
|
2019-02-12 15:40:24 -05:00
|
|
|
let effects_panel_y = bottom - (BUTTON_HEIGHT + PADDING + EFFECTS_PANEL_HEIGHT);
|
2019-03-05 18:13:55 -05:00
|
|
|
debug_ui.ui.draw_solid_rounded_rect(device,
|
|
|
|
RectI32::new(Point2DI32::new(PADDING, effects_panel_y),
|
|
|
|
Point2DI32::new(EFFECTS_PANEL_WIDTH,
|
|
|
|
EFFECTS_PANEL_HEIGHT)),
|
|
|
|
WINDOW_COLOR);
|
2019-02-08 23:58:54 -05:00
|
|
|
|
|
|
|
self.gamma_correction_effect_enabled =
|
2019-03-04 17:55:32 -05:00
|
|
|
self.draw_effects_switch(device,
|
|
|
|
debug_ui,
|
2019-02-08 23:58:54 -05:00
|
|
|
"Gamma Correction",
|
|
|
|
0,
|
2019-02-12 15:40:24 -05:00
|
|
|
effects_panel_y,
|
2019-02-08 23:58:54 -05:00
|
|
|
self.gamma_correction_effect_enabled);
|
|
|
|
self.stem_darkening_effect_enabled =
|
2019-03-04 17:55:32 -05:00
|
|
|
self.draw_effects_switch(device,
|
|
|
|
debug_ui,
|
2019-02-08 23:58:54 -05:00
|
|
|
"Stem Darkening",
|
|
|
|
1,
|
2019-02-12 15:40:24 -05:00
|
|
|
effects_panel_y,
|
2019-02-08 23:58:54 -05:00
|
|
|
self.stem_darkening_effect_enabled);
|
|
|
|
self.subpixel_aa_effect_enabled =
|
2019-03-04 17:55:32 -05:00
|
|
|
self.draw_effects_switch(device,
|
|
|
|
debug_ui,
|
2019-02-08 23:58:54 -05:00
|
|
|
"Subpixel AA",
|
|
|
|
2,
|
2019-02-12 15:40:24 -05:00
|
|
|
effects_panel_y,
|
2019-02-08 23:58:54 -05:00
|
|
|
self.subpixel_aa_effect_enabled);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-03-06 22:35:57 -05:00
|
|
|
fn draw_rotate_panel(&mut self,
|
|
|
|
device: &D,
|
|
|
|
debug_ui: &mut DebugUI<D>,
|
|
|
|
rotate_panel_x: i32,
|
|
|
|
action: &mut UIAction) {
|
2019-02-12 15:40:24 -05:00
|
|
|
if !self.rotate_panel_visible {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-05 18:13:55 -05:00
|
|
|
let bottom = debug_ui.ui.framebuffer_size().y() - PADDING;
|
2019-02-12 15:40:24 -05:00
|
|
|
let rotate_panel_y = bottom - (BUTTON_HEIGHT + PADDING + ROTATE_PANEL_HEIGHT);
|
2019-03-06 22:35:57 -05:00
|
|
|
let rotate_panel_origin = Point2DI32::new(rotate_panel_x, rotate_panel_y);
|
2019-02-26 16:48:35 -05:00
|
|
|
let rotate_panel_size = Point2DI32::new(ROTATE_PANEL_WIDTH, ROTATE_PANEL_HEIGHT);
|
2019-03-05 18:13:55 -05:00
|
|
|
debug_ui.ui.draw_solid_rounded_rect(device,
|
|
|
|
RectI32::new(rotate_panel_origin, rotate_panel_size),
|
|
|
|
WINDOW_COLOR);
|
2019-02-12 15:40:24 -05:00
|
|
|
|
2019-03-06 22:35:57 -05:00
|
|
|
let (widget_x, widget_y) = (rotate_panel_x + PADDING, rotate_panel_y + PADDING);
|
2019-02-12 15:40:24 -05:00
|
|
|
let widget_rect = RectI32::new(Point2DI32::new(widget_x, widget_y),
|
|
|
|
Point2DI32::new(SLIDER_WIDTH, SLIDER_KNOB_HEIGHT));
|
2019-03-06 14:33:59 -05:00
|
|
|
if let Some(position) = debug_ui.ui
|
2019-03-13 19:32:39 -04:00
|
|
|
.event_queue
|
2019-03-06 14:33:59 -05:00
|
|
|
.handle_mouse_down_or_dragged_in_rect(widget_rect) {
|
2019-02-12 15:40:24 -05:00
|
|
|
self.rotation = position.x();
|
2019-02-13 19:05:28 -05:00
|
|
|
*action = UIAction::Rotate(self.rotation());
|
2019-02-12 15:40:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
let slider_track_y = rotate_panel_y + PADDING + SLIDER_KNOB_HEIGHT / 2 -
|
|
|
|
SLIDER_TRACK_HEIGHT / 2;
|
|
|
|
let slider_track_rect =
|
|
|
|
RectI32::new(Point2DI32::new(widget_x, slider_track_y),
|
|
|
|
Point2DI32::new(SLIDER_WIDTH, SLIDER_TRACK_HEIGHT));
|
2019-03-05 18:13:55 -05:00
|
|
|
debug_ui.ui.draw_rect_outline(device, slider_track_rect, TEXT_COLOR);
|
2019-02-12 15:40:24 -05:00
|
|
|
|
|
|
|
let slider_knob_x = widget_x + self.rotation - SLIDER_KNOB_WIDTH / 2;
|
|
|
|
let slider_knob_rect =
|
|
|
|
RectI32::new(Point2DI32::new(slider_knob_x, widget_y),
|
|
|
|
Point2DI32::new(SLIDER_KNOB_WIDTH, SLIDER_KNOB_HEIGHT));
|
2019-03-05 18:13:55 -05:00
|
|
|
debug_ui.ui.draw_solid_rect(device, slider_knob_rect, TEXT_COLOR);
|
2019-02-12 15:40:24 -05:00
|
|
|
}
|
|
|
|
|
2019-02-08 23:58:54 -05:00
|
|
|
fn draw_effects_switch(&self,
|
2019-03-04 17:55:32 -05:00
|
|
|
device: &D,
|
|
|
|
debug_ui: &mut DebugUI<D>,
|
2019-02-08 23:58:54 -05:00
|
|
|
text: &str,
|
|
|
|
index: i32,
|
|
|
|
window_y: i32,
|
|
|
|
value: bool)
|
|
|
|
-> bool {
|
|
|
|
let text_x = PADDING * 2;
|
|
|
|
let text_y = window_y + PADDING + BUTTON_TEXT_OFFSET + (BUTTON_HEIGHT + PADDING) * index;
|
2019-03-05 18:13:55 -05:00
|
|
|
debug_ui.ui.draw_text(device, text, Point2DI32::new(text_x, text_y), false);
|
2019-02-08 23:58:54 -05:00
|
|
|
|
2019-03-13 19:32:39 -04:00
|
|
|
let switch_width = debug_ui.ui.measure_switch(2);
|
|
|
|
let switch_x = PADDING + EFFECTS_PANEL_WIDTH - (switch_width + PADDING);
|
2019-02-08 23:58:54 -05:00
|
|
|
let switch_y = window_y + PADDING + (BUTTON_HEIGHT + PADDING) * index;
|
2019-03-06 14:33:59 -05:00
|
|
|
let switch_position = Point2DI32::new(switch_x, switch_y);
|
2019-03-13 19:32:39 -04:00
|
|
|
debug_ui.ui.draw_text_switch(device, switch_position, &["Off", "On"], value as u8) != 0
|
2019-02-08 23:58:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-13 13:32:25 -05:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub enum UIAction {
|
|
|
|
None,
|
|
|
|
OpenFile(PathBuf),
|
2019-02-25 14:33:26 -05:00
|
|
|
TakeScreenshot(PathBuf),
|
2019-02-13 13:32:25 -05:00
|
|
|
ZoomIn,
|
|
|
|
ZoomOut,
|
2019-02-13 19:05:28 -05:00
|
|
|
Rotate(f32),
|
2019-02-13 13:32:25 -05:00
|
|
|
}
|