From c3d6596aa4334f0f19a74b7edd478481860a447a Mon Sep 17 00:00:00 2001 From: Imbris Date: Sun, 24 Mar 2019 22:15:29 -0400 Subject: [PATCH] fix inconsistent text cursor height Former-commit-id: da08c7ef8679a6f4626bf5fec0ec66ab5da9cad0 --- voxygen/src/menu/main/ui.rs | 1 - voxygen/src/ui/mod.rs | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 9b4726ba1a..8f360b552e 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -170,7 +170,6 @@ impl MainMenuUi { .w_h(337.0, 67.0) .middle_of(ui_widgets.window) .set(self.ids.username_bg, ui_widgets); - // TODO: figure out why cursor is rendered inconsistently for event in TextBox::new(&self.username) .w_h(580.0 / 2.0, 60.0 / 2.0) .mid_bottom_with_margin_on(self.ids.username_bg, 44.0 / 2.0) diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index de433133dd..1fb9475027 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -440,7 +440,7 @@ impl Ui { PrimitiveKind::Rectangle { color } => { // TODO: consider gamma/linear conversion.... let color = color.to_fsa(); - // Don't draw a transparent rectangle (they exist) + // Don't draw a transparent rectangle if color[3] == 0.0 { continue; } @@ -468,17 +468,25 @@ impl Ui { switch_to_plain_state!(); for tri in triangles { - // TODO: this code is repeated above, put it in a single location - let triangle = [ - [vx(tri[2][0]), vy(tri[2][1])], - [vx(tri[1][0]), vy(tri[1][1])], - [vx(tri[0][0]), vy(tri[0][1])], - ]; + let p1 = Vec2::new(vx(tri[0][0]), vy(tri[0][1])); + let p2 = Vec2::new(vx(tri[1][0]), vy(tri[1][1])); + let p3 = Vec2::new(vx(tri[2][0]), vy(tri[2][1])); + // If triangle is clockwise reverse it + let (v1, v2): (Vec3, Vec3) = ((p2 - p1).into(), (p3 - p1).into()); + let triangle = if v1.cross(v2).z > 0.0 {[ + p1.into_array(), + p2.into_array(), + p3.into_array(), + ]} else {[ + p2.into_array(), + p1.into_array(), + p3.into_array(), + ]}; push_ui_tri_to_mesh( &mut mesh, triangle, [[0.0; 2]; 3], - [1.0, 1.0, 1.0, 1.0], + color, UiMode::Geometry, ); }