-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split UI Overflow
by axis
#8095
Merged
alice-i-cecile
merged 17 commits into
bevyengine:main
from
ickshonpe:split-overflow-by-axes
Apr 17, 2023
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c3c44b7
changes:
ickshonpe 2fa9401
changes:
ickshonpe 8ef59f3
simplified match statement in `update`
ickshonpe c72213f
cargo fmt
ickshonpe 2b1c527
Some renamings for clarity and to remove shadowing
ickshonpe 8653609
cargo fmt
ickshonpe 8284671
changes:
ickshonpe 2a3e129
Changed match statement into a nested if-let statement
ickshonpe 131650d
* Renamed `overflow_debug` example to `overflow`
ickshonpe 8c65e33
put back change detection guard
ickshonpe 648ac48
Merge branch 'main' into split-overflow-by-axes
ickshonpe 44c170f
changes:
ickshonpe cf840ce
build-templated-pages + fmt
ickshonpe 4938380
Merge branch 'main' into split-overflow-by-axes
ickshonpe cafed54
cargo fmt
ickshonpe 48ef027
build-templated-pages
ickshonpe e8d8fec
Merge branch 'split-overflow-by-axes' of /~https://github.com/ickshonpe…
ickshonpe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
//! Simple example demonstrating overflow behavior. | ||
|
||
use bevy::{prelude::*, winit::WinitSettings}; | ||
|
||
fn main() { | ||
App::new() | ||
.add_plugins(DefaultPlugins) | ||
// Only run the app when there is user input. This will significantly reduce CPU/GPU use. | ||
.insert_resource(WinitSettings::desktop_app()) | ||
.add_systems(Startup, setup) | ||
.run(); | ||
} | ||
|
||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { | ||
commands.spawn(Camera2dBundle::default()); | ||
|
||
let text_style = TextStyle { | ||
font: asset_server.load("fonts/FiraMono-Medium.ttf"), | ||
font_size: 20.0, | ||
color: Color::WHITE, | ||
}; | ||
|
||
let image = asset_server.load("branding/icon.png"); | ||
|
||
commands | ||
.spawn(NodeBundle { | ||
style: Style { | ||
align_items: AlignItems::Center, | ||
justify_content: JustifyContent::Center, | ||
size: Size::width(Val::Percent(100.)), | ||
..Default::default() | ||
}, | ||
background_color: Color::ANTIQUE_WHITE.into(), | ||
..Default::default() | ||
}) | ||
.with_children(|parent| { | ||
for overflow in [ | ||
Overflow::visible(), | ||
Overflow::clip_x(), | ||
Overflow::clip_y(), | ||
Overflow::clip(), | ||
] { | ||
parent | ||
.spawn(NodeBundle { | ||
style: Style { | ||
flex_direction: FlexDirection::Column, | ||
align_items: AlignItems::Center, | ||
margin: UiRect::horizontal(Val::Px(25.)), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}) | ||
.with_children(|parent| { | ||
let label = format!("{overflow:#?}"); | ||
parent | ||
.spawn(NodeBundle { | ||
style: Style { | ||
padding: UiRect::all(Val::Px(10.)), | ||
margin: UiRect::bottom(Val::Px(25.)), | ||
..Default::default() | ||
}, | ||
background_color: Color::DARK_GRAY.into(), | ||
..Default::default() | ||
}) | ||
.with_children(|parent| { | ||
parent.spawn(TextBundle { | ||
text: Text::from_section(label, text_style.clone()), | ||
..Default::default() | ||
}); | ||
}); | ||
parent | ||
.spawn(NodeBundle { | ||
style: Style { | ||
size: Size::all(Val::Px(100.)), | ||
padding: UiRect { | ||
left: Val::Px(25.), | ||
top: Val::Px(25.), | ||
..Default::default() | ||
}, | ||
overflow, | ||
..Default::default() | ||
}, | ||
background_color: Color::GRAY.into(), | ||
..Default::default() | ||
}) | ||
.with_children(|parent| { | ||
parent.spawn(ImageBundle { | ||
image: UiImage::new(image.clone()), | ||
style: Style { | ||
min_size: Size::all(Val::Px(100.)), | ||
..Default::default() | ||
}, | ||
background_color: Color::WHITE.into(), | ||
..Default::default() | ||
}); | ||
}); | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see you have already done this.