From 66381c02bd4a21939d78d700929c5dc1db130d7a Mon Sep 17 00:00:00 2001 From: mahulst Date: Sat, 17 Sep 2022 13:37:53 +0200 Subject: [PATCH 01/13] Fixes UI interaction after inverting Y-axis --- crates/bevy_ui/src/focus.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index f83054b2a8a14..8efd28c4fa51c 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -123,6 +123,8 @@ pub fn ui_focus_system( .find_map(|window| window.cursor_position()) .or_else(|| touches_input.first_pressed_position()); + let window_height = windows.get_primary().expect("No primary window").height(); + let mut moused_over_z_sorted_nodes = node_query .iter_mut() .filter_map( @@ -155,7 +157,7 @@ pub fn ui_focus_system( // clicking let contains_cursor = if let Some(cursor_position) = cursor_position { (min.x..max.x).contains(&cursor_position.x) - && (min.y..max.y).contains(&cursor_position.y) + && (min.y..max.y).contains(&(window_height - cursor_position.y)) } else { false }; From d689ac8e15d6982dbbb1e738f7445658ed09d7ec Mon Sep 17 00:00:00 2001 From: mahulst Date: Sat, 17 Sep 2022 13:38:14 +0200 Subject: [PATCH 02/13] Fixes uvs for UI after inverting Y-axis --- crates/bevy_ui/src/render/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index d0da7a14c33db..956c3ba680d8c 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -464,24 +464,23 @@ pub fn prepare_uinodes( } } - // Clip UVs (Note: y is reversed in UV space) let atlas_extent = extracted_uinode.atlas_size.unwrap_or(uinode_rect.max); let uvs = [ Vec2::new( - uinode_rect.min.x + positions_diff[0].x, - uinode_rect.max.y - positions_diff[0].y, - ), - Vec2::new( - uinode_rect.max.x + positions_diff[1].x, - uinode_rect.max.y - positions_diff[1].y, + uinode_rect.min.x + positions_diff[3].x, + uinode_rect.min.y - positions_diff[3].y, ), Vec2::new( uinode_rect.max.x + positions_diff[2].x, uinode_rect.min.y - positions_diff[2].y, ), Vec2::new( - uinode_rect.min.x + positions_diff[3].x, - uinode_rect.min.y - positions_diff[3].y, + uinode_rect.max.x + positions_diff[1].x, + uinode_rect.max.y - positions_diff[1].y, + ), + Vec2::new( + uinode_rect.min.x + positions_diff[0].x, + uinode_rect.max.y - positions_diff[0].y, ), ] .map(|pos| pos / atlas_extent); From 8a87928fca249630c8028435113102ac9129a6c7 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sat, 17 Sep 2022 13:35:52 +0200 Subject: [PATCH 03/13] Fixes baseline of text after inverting Y axis for UI --- crates/bevy_text/src/glyph_brush.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/bevy_text/src/glyph_brush.rs b/crates/bevy_text/src/glyph_brush.rs index 592cd0c26dc61..d0227648b6301 100644 --- a/crates/bevy_text/src/glyph_brush.rs +++ b/crates/bevy_text/src/glyph_brush.rs @@ -73,15 +73,11 @@ impl GlyphBrush { }) .collect::, _>>()?; - let mut max_y = std::f32::MIN; let mut min_x = std::f32::MAX; for sg in &glyphs { let glyph = &sg.glyph; - let scaled_font = sections_data[sg.section_index].3; - max_y = max_y.max(glyph.position.y - scaled_font.descent()); min_x = min_x.min(glyph.position.x); } - max_y = max_y.floor(); min_x = min_x.floor(); let mut positioned_glyphs = Vec::new(); @@ -119,7 +115,7 @@ impl GlyphBrush { let size = Vec2::new(glyph_rect.width(), glyph_rect.height()); let x = bounds.min.x + size.x / 2.0 - min_x; - let y = max_y - bounds.max.y + size.y / 2.0; + let y = bounds.max.y - size.y / 2.0; let position = adjust.position(Vec2::new(x, y)); positioned_glyphs.push(PositionedGlyph { From c0c8011165a435c868236bc168eec19a454ae48a Mon Sep 17 00:00:00 2001 From: mahulst Date: Sat, 17 Sep 2022 14:03:35 +0200 Subject: [PATCH 04/13] Fixes linting --- crates/bevy_text/src/glyph_brush.rs | 2 +- crates/bevy_ui/src/render/mod.rs | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/bevy_text/src/glyph_brush.rs b/crates/bevy_text/src/glyph_brush.rs index d0227648b6301..b93af74b098c1 100644 --- a/crates/bevy_text/src/glyph_brush.rs +++ b/crates/bevy_text/src/glyph_brush.rs @@ -1,4 +1,4 @@ -use ab_glyph::{Font as _, FontArc, Glyph, ScaleFont as _}; +use ab_glyph::{Font as _, FontArc, Glyph}; use bevy_asset::{Assets, Handle}; use bevy_math::Vec2; use bevy_render::texture::Image; diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 956c3ba680d8c..a611be84c38fa 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -12,7 +12,7 @@ use bevy_ecs::prelude::*; use bevy_math::{Mat4, Rect, UVec4, Vec2, Vec3, Vec4Swizzles}; use bevy_reflect::TypeUuid; use bevy_render::{ - camera::{Camera, CameraProjection, OrthographicProjection, WindowOrigin}, + camera::Camera, color::Color, render_asset::RenderAssets, render_graph::{RenderGraph, RunGraphOnViewNode, SlotInfo, SlotType}, @@ -243,12 +243,8 @@ pub fn extract_default_ui_camera_view( camera.physical_viewport_rect(), camera.physical_viewport_size(), ) { - let mut projection = OrthographicProjection { - far: UI_CAMERA_FAR, - window_origin: WindowOrigin::BottomLeft, - ..Default::default() - }; - projection.update(logical_size.x, logical_size.y); + let projection_matrix = + Mat4::orthographic_rh(0.0, logical_size.x, logical_size.y, 0.0, 0.0, UI_CAMERA_FAR); let default_camera_view = commands .spawn(ExtractedView { projection: projection.get_projection_matrix(), From 8429b6d6ca8a3de0ba2774b294861fad4916e268 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sun, 25 Sep 2022 13:00:57 +0200 Subject: [PATCH 05/13] Invert Y axis of all cursor interaction instead of only UI --- crates/bevy_ui/src/focus.rs | 4 +--- crates/bevy_ui/src/render/mod.rs | 2 +- crates/bevy_winit/src/lib.rs | 14 +++----------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index 8efd28c4fa51c..f83054b2a8a14 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -123,8 +123,6 @@ pub fn ui_focus_system( .find_map(|window| window.cursor_position()) .or_else(|| touches_input.first_pressed_position()); - let window_height = windows.get_primary().expect("No primary window").height(); - let mut moused_over_z_sorted_nodes = node_query .iter_mut() .filter_map( @@ -157,7 +155,7 @@ pub fn ui_focus_system( // clicking let contains_cursor = if let Some(cursor_position) = cursor_position { (min.x..max.x).contains(&cursor_position.x) - && (min.y..max.y).contains(&(window_height - cursor_position.y)) + && (min.y..max.y).contains(&cursor_position.y) } else { false }; diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index a611be84c38fa..6b6a973c3e742 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -247,7 +247,7 @@ pub fn extract_default_ui_camera_view( Mat4::orthographic_rh(0.0, logical_size.x, logical_size.y, 0.0, 0.0, UI_CAMERA_FAR); let default_camera_view = commands .spawn(ExtractedView { - projection: projection.get_projection_matrix(), + projection: projection_matrix, transform: GlobalTransform::from_xyz( 0.0, 0.0, diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 66804c5a426b4..0107a83e58e67 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -149,12 +149,9 @@ fn change_window( } bevy_window::WindowCommand::SetCursorPosition { position } => { let window = winit_windows.get_window(id).unwrap(); - let inner_size = window.inner_size().to_logical::(window.scale_factor()); + window - .set_cursor_position(LogicalPosition::new( - position.x, - inner_size.height - position.y, - )) + .set_cursor_position(LogicalPosition::new(position.x, position.y)) .unwrap_or_else(|e| error!("Unable to set cursor position: {}", e)); } bevy_window::WindowCommand::SetMaximized { maximized } => { @@ -431,13 +428,8 @@ pub fn winit_runner_with(mut app: App) { } WindowEvent::CursorMoved { position, .. } => { let mut cursor_moved_events = world.resource_mut::>(); - let winit_window = winit_windows.get_window(window_id).unwrap(); - let inner_size = winit_window.inner_size(); - - // move origin to bottom left - let y_position = inner_size.height as f64 - position.y; - let physical_position = DVec2::new(position.x, y_position); + let physical_position = DVec2::new(position.x, position.y); window .update_cursor_physical_position_from_backend(Some(physical_position)); From 070d794e9229399b53178484a5421e8519570a9e Mon Sep 17 00:00:00 2001 From: mahulst Date: Sun, 25 Sep 2022 13:19:27 +0200 Subject: [PATCH 06/13] Fix ui.rs example after inverting y axis --- crates/bevy_ui/src/flex/convert.rs | 5 ++--- crates/bevy_ui/src/ui_node.rs | 4 ++-- examples/ui/ui.rs | 15 +++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/crates/bevy_ui/src/flex/convert.rs b/crates/bevy_ui/src/flex/convert.rs index 6fe1a2739336d..c959aa9dba0b2 100644 --- a/crates/bevy_ui/src/flex/convert.rs +++ b/crates/bevy_ui/src/flex/convert.rs @@ -10,9 +10,8 @@ pub fn from_rect( taffy::geometry::Rect { start: from_val(scale_factor, rect.left), end: from_val(scale_factor, rect.right), - // NOTE: top and bottom are intentionally flipped. stretch has a flipped y-axis - top: from_val(scale_factor, rect.bottom), - bottom: from_val(scale_factor, rect.top), + top: from_val(scale_factor, rect.top), + bottom: from_val(scale_factor, rect.bottom), } } diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index a8d3776e01f8f..73d6ba4a6c189 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -303,11 +303,11 @@ pub enum FlexDirection { /// Same way as text direction along the main axis #[default] Row, - /// Flex from bottom to top + /// Flex from top to bottom Column, /// Opposite way as text direction along the main axis RowReverse, - /// Flex from top to bottom + /// Flex from bottom to top ColumnReverse, } diff --git a/examples/ui/ui.rs b/examples/ui/ui.rs index fb627071bb1fe..5bfa60882f56f 100644 --- a/examples/ui/ui.rs +++ b/examples/ui/ui.rs @@ -49,7 +49,7 @@ fn setup(mut commands: Commands, asset_server: Res) { .spawn(NodeBundle { style: Style { size: Size::new(Val::Percent(100.0), Val::Percent(100.0)), - align_items: AlignItems::FlexEnd, + align_items: AlignItems::FlexStart, ..default() }, background_color: Color::rgb(0.15, 0.15, 0.15).into(), @@ -77,7 +77,7 @@ fn setup(mut commands: Commands, asset_server: Res) { parent .spawn(NodeBundle { style: Style { - flex_direction: FlexDirection::ColumnReverse, + flex_direction: FlexDirection::Column, justify_content: JustifyContent::Center, size: Size::new(Val::Px(200.0), Val::Percent(100.0)), ..default() @@ -110,7 +110,7 @@ fn setup(mut commands: Commands, asset_server: Res) { parent .spawn(NodeBundle { style: Style { - flex_direction: FlexDirection::ColumnReverse, + flex_direction: FlexDirection::Column, align_self: AlignSelf::Center, size: Size::new(Val::Percent(100.0), Val::Percent(50.0)), overflow: Overflow::Hidden, @@ -125,7 +125,7 @@ fn setup(mut commands: Commands, asset_server: Res) { .spawn(( NodeBundle { style: Style { - flex_direction: FlexDirection::ColumnReverse, + flex_direction: FlexDirection::Column, flex_grow: 1.0, max_size: Size::UNDEFINED, ..default() @@ -163,7 +163,6 @@ fn setup(mut commands: Commands, asset_server: Res) { }); }); }); - // absolute positioning parent .spawn(NodeBundle { style: Style { @@ -280,7 +279,7 @@ fn setup(mut commands: Commands, asset_server: Res) { size: Size::new(Val::Percent(100.0), Val::Percent(100.0)), position_type: PositionType::Absolute, justify_content: JustifyContent::Center, - align_items: AlignItems::FlexEnd, + align_items: AlignItems::FlexStart, ..default() }, background_color: Color::NONE.into(), @@ -322,8 +321,8 @@ fn mouse_scroll( MouseScrollUnit::Line => mouse_wheel_event.y * 20., MouseScrollUnit::Pixel => mouse_wheel_event.y, }; - scrolling_list.position += dy; - scrolling_list.position = scrolling_list.position.clamp(-max_scroll, 0.); + scrolling_list.position -= dy; + scrolling_list.position = scrolling_list.position.clamp(0., max_scroll); style.position.top = Val::Px(scrolling_list.position); } } From 6542cddb89e5d5d061ca35396eb215a2b0847a62 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sun, 25 Sep 2022 13:28:07 +0200 Subject: [PATCH 07/13] Fix text.rs example after inverting y axis --- examples/ui/text.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/ui/text.rs b/examples/ui/text.rs index de70f9a88982c..509517bf9f983 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -44,7 +44,6 @@ fn setup(mut commands: Commands, asset_server: Res) { .with_text_alignment(TextAlignment::TOP_CENTER) // Set the style of the TextBundle itself. .with_style(Style { - align_self: AlignSelf::FlexEnd, position_type: PositionType::Absolute, position: UiRect { bottom: Val::Px(5.0), @@ -74,7 +73,7 @@ fn setup(mut commands: Commands, asset_server: Res) { }), ]) .with_style(Style { - align_self: AlignSelf::FlexEnd, + align_self: AlignSelf::FlexStart, ..default() }), FpsText, From c3fd6056c1c5ba092f9bd7b294ef250163221336 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sun, 25 Sep 2022 13:57:49 +0200 Subject: [PATCH 08/13] Update documentation regarding flexbox and Inverted Y axis --- crates/bevy_ui/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index 62b5e70cf2dbe..380a00ed00b06 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -1,7 +1,7 @@ //! This crate contains Bevy's UI system, which can be used to create UI for both 2D and 3D games //! # Basic usage //! Spawn UI elements with [`entity::ButtonBundle`], [`entity::ImageBundle`], [`entity::TextBundle`] and [`entity::NodeBundle`] -//! This UI is laid out with the Flexbox paradigm (see ) except the vertical axis is inverted +//! This UI is laid out with the Flexbox paradigm (see ) mod flex; mod focus; mod geometry; From 8c8ffc55e19dbb39902b9664ce2f5fd3b9856c31 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sun, 25 Sep 2022 13:56:04 +0200 Subject: [PATCH 09/13] Fix font_atlas_debug.rs example after inverting y axis --- examples/ui/font_atlas_debug.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/examples/ui/font_atlas_debug.rs b/examples/ui/font_atlas_debug.rs index 4190987d57915..c8d8b034b4f9c 100644 --- a/examples/ui/font_atlas_debug.rs +++ b/examples/ui/font_atlas_debug.rs @@ -82,12 +82,27 @@ fn setup(mut commands: Commands, asset_server: Res, mut state: ResM let font_handle = asset_server.load("fonts/FiraSans-Bold.ttf"); state.handle = font_handle.clone(); commands.spawn(Camera2dBundle::default()); - commands.spawn(TextBundle::from_section( - "a", - TextStyle { - font: font_handle, - font_size: 60.0, - color: Color::YELLOW, - }, - )); + commands + .spawn(NodeBundle { + background_color: Color::NONE.into(), + style: Style { + position_type: PositionType::Absolute, + position: UiRect { + bottom: Val::Px(0.0), + ..default() + }, + ..default() + }, + ..default() + }) + .with_children(|parent| { + parent.spawn(TextBundle::from_section( + "a", + TextStyle { + font: font_handle, + font_size: 60.0, + color: Color::YELLOW, + }, + )); + }); } From 9aa25036085d0c367702f6553427f88f1c11ca72 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sun, 25 Sep 2022 13:37:48 +0200 Subject: [PATCH 10/13] Fix issue with centered text and font positioning --- crates/bevy_text/src/glyph_brush.rs | 9 +++++++-- examples/ui/text_debug.rs | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/bevy_text/src/glyph_brush.rs b/crates/bevy_text/src/glyph_brush.rs index b93af74b098c1..e9961d3e49f4c 100644 --- a/crates/bevy_text/src/glyph_brush.rs +++ b/crates/bevy_text/src/glyph_brush.rs @@ -1,4 +1,4 @@ -use ab_glyph::{Font as _, FontArc, Glyph}; +use ab_glyph::{Font as _, FontArc, Glyph, ScaleFont as _}; use bevy_asset::{Assets, Handle}; use bevy_math::Vec2; use bevy_render::texture::Image; @@ -74,11 +74,16 @@ impl GlyphBrush { .collect::, _>>()?; let mut min_x = std::f32::MAX; + let mut min_y = std::f32::MAX; for sg in &glyphs { let glyph = &sg.glyph; + + let scaled_font = sections_data[sg.section_index].3; min_x = min_x.min(glyph.position.x); + min_y = min_y.min(glyph.position.y - scaled_font.ascent()); } min_x = min_x.floor(); + min_y = min_y.floor(); let mut positioned_glyphs = Vec::new(); for sg in glyphs { @@ -115,7 +120,7 @@ impl GlyphBrush { let size = Vec2::new(glyph_rect.width(), glyph_rect.height()); let x = bounds.min.x + size.x / 2.0 - min_x; - let y = bounds.max.y - size.y / 2.0; + let y = bounds.min.y + size.y / 2.0 - min_y; let position = adjust.position(Vec2::new(x, y)); positioned_glyphs.push(PositionedGlyph { diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index f12f8382cd08e..f5441819325ef 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -35,7 +35,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { }, ) .with_style(Style { - align_self: AlignSelf::FlexEnd, + align_self: AlignSelf::FlexStart, position_type: PositionType::Absolute, position: UiRect { top: Val::Px(5.0), @@ -55,7 +55,6 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { ) .with_text_alignment(TextAlignment::CENTER) .with_style(Style { - align_self: AlignSelf::FlexEnd, position_type: PositionType::Absolute, position: UiRect { top: Val::Px(5.0), @@ -115,7 +114,6 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { ), ]) .with_style(Style { - align_self: AlignSelf::FlexEnd, position_type: PositionType::Absolute, position: UiRect { bottom: Val::Px(5.0), From 4a2446bb511caa01ad55525e065973c2ed1e1a28 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sun, 9 Oct 2022 12:59:32 +0200 Subject: [PATCH 11/13] Add comment to UI projection matrix --- crates/bevy_ui/src/render/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 6b6a973c3e742..0bee20aade2c2 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -243,6 +243,7 @@ pub fn extract_default_ui_camera_view( camera.physical_viewport_rect(), camera.physical_viewport_size(), ) { + // use a projection matrix with the origin in the top left instead of the bottom left that comes with OrthographicProjection let projection_matrix = Mat4::orthographic_rh(0.0, logical_size.x, logical_size.y, 0.0, 0.0, UI_CAMERA_FAR); let default_camera_view = commands From 840f3b2dc8d45d9463106d73a32bb8aaa92eb473 Mon Sep 17 00:00:00 2001 From: mahulst Date: Sun, 9 Oct 2022 13:07:36 +0200 Subject: [PATCH 12/13] Remove redundant style in UI examples --- examples/ui/text.rs | 6 +----- examples/ui/text_debug.rs | 1 - examples/ui/ui.rs | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/ui/text.rs b/examples/ui/text.rs index 509517bf9f983..ddfaf940fb0b6 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -71,11 +71,7 @@ fn setup(mut commands: Commands, asset_server: Res) { font_size: 60.0, color: Color::GOLD, }), - ]) - .with_style(Style { - align_self: AlignSelf::FlexStart, - ..default() - }), + ]), FpsText, )); } diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index f5441819325ef..1426e7a3bb619 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -35,7 +35,6 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { }, ) .with_style(Style { - align_self: AlignSelf::FlexStart, position_type: PositionType::Absolute, position: UiRect { top: Val::Px(5.0), diff --git a/examples/ui/ui.rs b/examples/ui/ui.rs index 5bfa60882f56f..074bfd3117a9d 100644 --- a/examples/ui/ui.rs +++ b/examples/ui/ui.rs @@ -49,7 +49,6 @@ fn setup(mut commands: Commands, asset_server: Res) { .spawn(NodeBundle { style: Style { size: Size::new(Val::Percent(100.0), Val::Percent(100.0)), - align_items: AlignItems::FlexStart, ..default() }, background_color: Color::rgb(0.15, 0.15, 0.15).into(), From e94c848fe3c21c793ff81e0acbe36befd440948d Mon Sep 17 00:00:00 2001 From: mahulst Date: Tue, 11 Oct 2022 08:13:01 +0200 Subject: [PATCH 13/13] Fix game_menu.rs example --- examples/games/game_menu.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/games/game_menu.rs b/examples/games/game_menu.rs index 2997c36bc45fa..11e0c704fb927 100644 --- a/examples/games/game_menu.rs +++ b/examples/games/game_menu.rs @@ -152,9 +152,8 @@ mod game { style: Style { // This will center the current node margin: UiRect::all(Val::Auto), - // This will display its children in a column, from top to bottom. Unlike - // in Flexbox, Bevy origin is on bottom left, so the vertical axis is reversed - flex_direction: FlexDirection::ColumnReverse, + // This will display its children in a column, from top to bottom + flex_direction: FlexDirection::Column, // `align_items` will align children on the cross axis. Here the main axis is // vertical (column), so the cross axis is horizontal. This will center the // children @@ -420,7 +419,7 @@ mod menu { NodeBundle { style: Style { margin: UiRect::all(Val::Auto), - flex_direction: FlexDirection::ColumnReverse, + flex_direction: FlexDirection::Column, align_items: AlignItems::Center, ..default() }, @@ -533,7 +532,7 @@ mod menu { NodeBundle { style: Style { margin: UiRect::all(Val::Auto), - flex_direction: FlexDirection::ColumnReverse, + flex_direction: FlexDirection::Column, align_items: AlignItems::Center, ..default() }, @@ -587,7 +586,7 @@ mod menu { NodeBundle { style: Style { margin: UiRect::all(Val::Auto), - flex_direction: FlexDirection::ColumnReverse, + flex_direction: FlexDirection::Column, align_items: AlignItems::Center, ..default() }, @@ -678,7 +677,7 @@ mod menu { NodeBundle { style: Style { margin: UiRect::all(Val::Auto), - flex_direction: FlexDirection::ColumnReverse, + flex_direction: FlexDirection::Column, align_items: AlignItems::Center, ..default() },