Tweak debug UI

This commit is contained in:
Patrick Walton 2019-02-26 15:24:39 -08:00
parent 18e0a06df8
commit dc69d1197e
5 changed files with 19 additions and 11 deletions

View File

@ -55,7 +55,7 @@ const MOUSELOOK_ROTATION_SPEED: f32 = 0.007;
const CAMERA_VELOCITY: f32 = 1000.0; const CAMERA_VELOCITY: f32 = 1000.0;
// How much the scene is scaled when a scale gesture is performed. // How much the scene is scaled when a scale gesture is performed.
const CAMERA_SCALE_SPEED_2D: f32 = 2.0; const CAMERA_SCALE_SPEED_2D: f32 = 6.0;
// How much the scene is scaled when a zoom button is clicked. // How much the scene is scaled when a zoom button is clicked.
const CAMERA_ZOOM_AMOUNT_2D: f32 = 0.1; const CAMERA_ZOOM_AMOUNT_2D: f32 = 0.1;

View File

@ -14,6 +14,7 @@ use pathfinder_geometry::basic::point::Point2DI32;
use pathfinder_geometry::basic::rect::RectI32; use pathfinder_geometry::basic::rect::RectI32;
use pathfinder_gl::debug::{DebugUI, PADDING, TEXT_COLOR, WINDOW_COLOR}; use pathfinder_gl::debug::{DebugUI, PADDING, TEXT_COLOR, WINDOW_COLOR};
use pathfinder_gl::device::{Device, Texture}; use pathfinder_gl::device::{Device, Texture};
use pathfinder_renderer::paint::ColorU;
use std::f32::consts::PI; use std::f32::consts::PI;
use std::path::PathBuf; use std::path::PathBuf;
@ -44,6 +45,9 @@ const ROTATE_PANEL_X: i32 = PADDING + (BUTTON_WIDTH + PADDING) * 3 + (PADDING +
const ROTATE_PANEL_WIDTH: i32 = SLIDER_WIDTH + PADDING * 2; const ROTATE_PANEL_WIDTH: i32 = SLIDER_WIDTH + PADDING * 2;
const ROTATE_PANEL_HEIGHT: i32 = PADDING * 2 + SLIDER_HEIGHT; const ROTATE_PANEL_HEIGHT: i32 = PADDING * 2 + SLIDER_HEIGHT;
static BUTTON_ICON_COLOR: ColorU = ColorU { r: 255, g: 255, b: 255, a: 255 };
static OUTLINE_COLOR: ColorU = ColorU { r: 255, g: 255, b: 255, a: 192 };
static EFFECTS_PNG_NAME: &'static str = "demo-effects"; static EFFECTS_PNG_NAME: &'static str = "demo-effects";
static OPEN_PNG_NAME: &'static str = "demo-open"; static OPEN_PNG_NAME: &'static str = "demo-open";
static ROTATE_PNG_NAME: &'static str = "demo-rotate"; static ROTATE_PNG_NAME: &'static str = "demo-rotate";
@ -94,10 +98,12 @@ impl DemoUI {
bg_light_texture, bg_light_texture,
bg_dark_texture, bg_dark_texture,
screenshot_texture, screenshot_texture,
three_d_enabled: options.three_d,
dark_background_enabled: true,
effects_panel_visible: false, effects_panel_visible: false,
rotate_panel_visible: false, rotate_panel_visible: false,
three_d_enabled: options.three_d,
dark_background_enabled: true,
gamma_correction_effect_enabled: false, gamma_correction_effect_enabled: false,
stem_darkening_effect_enabled: false, stem_darkening_effect_enabled: false,
subpixel_aa_effect_enabled: false, subpixel_aa_effect_enabled: false,
@ -268,8 +274,10 @@ impl DemoUI {
-> bool { -> bool {
let button_rect = RectI32::new(origin, Point2DI32::new(BUTTON_WIDTH, BUTTON_HEIGHT)); let button_rect = RectI32::new(origin, Point2DI32::new(BUTTON_WIDTH, BUTTON_HEIGHT));
debug_ui.draw_solid_rounded_rect(button_rect, WINDOW_COLOR); debug_ui.draw_solid_rounded_rect(button_rect, WINDOW_COLOR);
debug_ui.draw_rounded_rect_outline(button_rect, TEXT_COLOR); debug_ui.draw_rounded_rect_outline(button_rect, OUTLINE_COLOR);
debug_ui.draw_texture(origin + Point2DI32::new(PADDING, PADDING), texture, TEXT_COLOR); debug_ui.draw_texture(origin + Point2DI32::new(PADDING, PADDING),
texture,
BUTTON_ICON_COLOR);
event.handle_mouse_down_in_rect(button_rect).is_some() event.handle_mouse_down_in_rect(button_rect).is_some()
} }
@ -355,7 +363,7 @@ impl DemoUI {
} }
debug_ui.draw_solid_rounded_rect(widget_rect, WINDOW_COLOR); debug_ui.draw_solid_rounded_rect(widget_rect, WINDOW_COLOR);
debug_ui.draw_rounded_rect_outline(widget_rect, TEXT_COLOR); debug_ui.draw_rounded_rect_outline(widget_rect, OUTLINE_COLOR);
let highlight_size = Point2DI32::new(SWITCH_HALF_SIZE, BUTTON_HEIGHT); let highlight_size = Point2DI32::new(SWITCH_HALF_SIZE, BUTTON_HEIGHT);
if !value { if !value {

View File

@ -41,13 +41,13 @@ pub const PADDING: i32 = 12;
pub static TEXT_COLOR: ColorU = ColorU { r: 255, g: 255, b: 255, a: 255 }; pub static TEXT_COLOR: ColorU = ColorU { r: 255, g: 255, b: 255, a: 255 };
pub static WINDOW_COLOR: ColorU = ColorU { r: 0, g: 0, b: 0, a: 255 - 90 }; pub static WINDOW_COLOR: ColorU = ColorU { r: 0, g: 0, b: 0, a: 255 - 90 };
static INVERTED_TEXT_COLOR: ColorU = ColorU { r: 0, g: 0, b: 0, a: 255 };
const PERF_WINDOW_WIDTH: i32 = 375; const PERF_WINDOW_WIDTH: i32 = 375;
const PERF_WINDOW_HEIGHT: i32 = LINE_HEIGHT * 6 + PADDING + 2; const PERF_WINDOW_HEIGHT: i32 = LINE_HEIGHT * 6 + PADDING + 2;
const FONT_ASCENT: i32 = 28; const FONT_ASCENT: i32 = 28;
const LINE_HEIGHT: i32 = 42; const LINE_HEIGHT: i32 = 42;
static INVERTED_TEXT_COLOR: ColorU = ColorU { r: 0, g: 0, b: 0, a: 255 };
static FONT_JSON_FILENAME: &'static str = "debug-font.json"; static FONT_JSON_FILENAME: &'static str = "debug-font.json";
static FONT_PNG_NAME: &'static str = "debug-font"; static FONT_PNG_NAME: &'static str = "debug-font";

View File

@ -17,5 +17,5 @@ uniform vec4 uColor;
out vec4 oFragColor; out vec4 oFragColor;
void main() { void main() {
oFragColor = uColor; oFragColor = vec4(uColor.rgb, 1.0) * uColor.a;
} }

View File

@ -20,6 +20,6 @@ in vec2 vTexCoord;
out vec4 oFragColor; out vec4 oFragColor;
void main() { void main() {
float alpha = texture(uTexture, vTexCoord).r; float alpha = texture(uTexture, vTexCoord).r * uColor.a;
oFragColor = uColor * alpha; oFragColor = alpha * vec4(uColor.rgb, 1.0);
} }