diff --git a/examples/basic_ui.rs b/examples/basic_ui.rs index 663028375c25063e0ad588afff05714d6fb73282..1688f79c194544722144347ce889810f07ba33fc 100644 --- a/examples/basic_ui.rs +++ b/examples/basic_ui.rs @@ -1,7 +1,7 @@ use bevy::{core_pipeline::clear_color::ClearColorConfig, prelude::*, window::PrimaryWindow}; use bevy_cosmic_edit::{ - AttrsOwned, CosmicAttrs, CosmicEditBundle, CosmicEditPlugin, CosmicEditUiBundle, CosmicEditor, - CosmicFontConfig, CosmicMetrics, CosmicText, CosmicTextPosition, Focus, + AttrsOwned, CosmicAttrs, CosmicEditBundle, CosmicEditPlugin, CosmicEditor, CosmicFontConfig, + CosmicMetrics, CosmicText, CosmicTextPosition, Focus, }; fn setup(mut commands: Commands, windows: Query<&Window, With<PrimaryWindow>>) { @@ -32,16 +32,15 @@ fn setup(mut commands: Commands, windows: Query<&Window, With<PrimaryWindow>>) { text_setter: CosmicText::OneStyle("馃榾馃榾馃榾 x => y".to_string()), ..default() }, - CosmicEditUiBundle { - node_bundle: NodeBundle { - style: Style { - width: Val::Percent(100.), - height: Val::Percent(100.), - ..default() - }, - background_color: Color::WHITE.into(), + // Use buttonbundle for layout + ButtonBundle { + style: Style { + width: Val::Percent(100.), + height: Val::Percent(100.), ..default() }, + // Needs to be set to prevent a bug where nothing is displayed + background_color: Color::WHITE.into(), ..default() }, ); diff --git a/examples/bevy_api_testing.rs b/examples/bevy_api_testing.rs index 4d1b1a872000a8d5e7271094e2f09c8710c9fb51..892ccb08c48dc9833d7e089c5232b2a77c6456e8 100644 --- a/examples/bevy_api_testing.rs +++ b/examples/bevy_api_testing.rs @@ -13,20 +13,17 @@ fn setup(mut commands: Commands) { max_lines: CosmicMaxLines(1), ..default() }) - .insert(CosmicEditUiBundle { - node_bundle: NodeBundle { - style: Style { - // Size and position of text box - width: Val::Px(300.), - height: Val::Px(50.), - left: Val::Px(100.), - top: Val::Px(100.), - ..default() - }, + .insert(ButtonBundle { + style: Style { + // Size and position of text box + width: Val::Px(300.), + height: Val::Px(50.), + left: Val::Px(100.), + top: Val::Px(100.), // needs to be set to prevent a bug where nothing is displayed - background_color: BackgroundColor(Color::WHITE), ..default() }, + background_color: BackgroundColor(Color::WHITE), ..default() }) .insert(CosmicEditPlaceholderBundle { diff --git a/examples/every_option.rs b/examples/every_option.rs index edc58f29331db5dfa00be72f9843e811b8eb3c18..28dbbae701d38926fb70e5683938f9a979c997e7 100644 --- a/examples/every_option.rs +++ b/examples/every_option.rs @@ -28,21 +28,18 @@ fn setup(mut commands: Commands, windows: Query<&Window, With<PrimaryWindow>>) { mode: CosmicMode::Wrap, canvas: Default::default(), }) - .insert(CosmicEditUiBundle { - node_bundle: NodeBundle { - border_color: Color::LIME_GREEN.into(), - style: Style { - // Size and position of text box - border: UiRect::all(Val::Px(4.)), - width: Val::Percent(20.), - height: Val::Px(50.), - left: Val::Percent(40.), - top: Val::Px(100.), - ..default() - }, - background_color: Color::WHITE.into(), + .insert(ButtonBundle { + border_color: Color::LIME_GREEN.into(), + style: Style { + // Size and position of text box + border: UiRect::all(Val::Px(4.)), + width: Val::Percent(20.), + height: Val::Px(50.), + left: Val::Percent(40.), + top: Val::Px(100.), ..default() }, + background_color: Color::WHITE.into(), ..default() }) .insert(CosmicEditPlaceholderBundle { diff --git a/examples/font_per_widget.rs b/examples/font_per_widget.rs index fa74f1e11d09a4bec30607baa8d5831d92b6d900..a5cc79f70a11134e9992e8a7144345d30cb52268 100644 --- a/examples/font_per_widget.rs +++ b/examples/font_per_widget.rs @@ -219,16 +219,13 @@ fn setup(mut commands: Commands, windows: Query<&Window, With<PrimaryWindow>>) { text_setter: CosmicText::MultiStyle(lines), ..default() }, - CosmicEditUiBundle { - node_bundle: NodeBundle { - style: Style { - width: Val::Percent(50.), - height: Val::Percent(100.), - ..default() - }, - background_color: BackgroundColor(Color::WHITE), + ButtonBundle { + style: Style { + width: Val::Percent(50.), + height: Val::Percent(100.), ..default() }, + background_color: BackgroundColor(Color::WHITE), ..default() }, ); @@ -249,14 +246,11 @@ fn setup(mut commands: Commands, windows: Query<&Window, With<PrimaryWindow>>) { text_setter: CosmicText::OneStyle("Widget 2.\nClick on me =>".to_string()), ..default() }, - CosmicEditUiBundle { - node_bundle: NodeBundle { - background_color: BackgroundColor(Color::WHITE.with_a(0.8)), - style: Style { - width: Val::Percent(50.), - height: Val::Percent(100.), - ..default() - }, + ButtonBundle { + background_color: BackgroundColor(Color::WHITE.with_a(0.8)), + style: Style { + width: Val::Percent(50.), + height: Val::Percent(100.), ..default() }, ..default() diff --git a/examples/image_background.rs b/examples/image_background.rs index 8f2d994a75221744da1b6caf241d86a32bd76fd8..8d700ae94948aff58409939d025b369b1c34e6a1 100644 --- a/examples/image_background.rs +++ b/examples/image_background.rs @@ -14,19 +14,16 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { background_image: CosmicBackground(Some(bg_image_handle)), ..default() }) - .insert(CosmicEditUiBundle { - node_bundle: NodeBundle { - style: Style { - // Size and position of text box - width: Val::Px(300.), - height: Val::Px(50.), - left: Val::Px(100.), - top: Val::Px(100.), - ..default() - }, - background_color: Color::WHITE.into(), + .insert(ButtonBundle { + style: Style { + // Size and position of text box + width: Val::Px(300.), + height: Val::Px(50.), + left: Val::Px(100.), + top: Val::Px(100.), ..default() }, + background_color: Color::WHITE.into(), ..default() }) .id(); diff --git a/examples/readonly.rs b/examples/readonly.rs index 118cdfe6001ac0f984a162ac7c70edc7690d2dad..e218b099058122cb8bf36eb563f9532d55fe0a27 100644 --- a/examples/readonly.rs +++ b/examples/readonly.rs @@ -32,16 +32,13 @@ fn setup(mut commands: Commands, windows: Query<&Window, With<PrimaryWindow>>) { text_setter: CosmicText::OneStyle("馃榾馃榾馃榾 x => y\nRead only widget".to_string()), ..default() }, - CosmicEditUiBundle { - node_bundle: NodeBundle { - style: Style { - width: Val::Percent(100.), - height: Val::Percent(100.), - ..default() - }, - background_color: BackgroundColor(Color::WHITE), + ButtonBundle { + style: Style { + width: Val::Percent(100.), + height: Val::Percent(100.), ..default() }, + background_color: BackgroundColor(Color::WHITE), ..default() }, ); diff --git a/examples/text_input.rs b/examples/text_input.rs index 0b0f45ec045683ece8da63a4e3839be8bbb28294..7ba06f178d7668a5c9f19cc742d9724296306973 100644 --- a/examples/text_input.rs +++ b/examples/text_input.rs @@ -24,20 +24,17 @@ fn create_editable_widget(commands: &mut Commands, scale_factor: f32, text: Stri mode: CosmicMode::InfiniteLine, ..default() }, - CosmicEditUiBundle { - node_bundle: NodeBundle { - border_color: Color::hex("#ededed").unwrap().into(), - style: Style { - border: UiRect::all(Val::Px(3.)), - width: Val::Percent(20.), - height: Val::Px(50.), - left: Val::Percent(40.), - top: Val::Px(100.), - ..default() - }, - background_color: Color::WHITE.into(), + ButtonBundle { + border_color: Color::hex("#ededed").unwrap().into(), + style: Style { + border: UiRect::all(Val::Px(3.)), + width: Val::Percent(20.), + height: Val::Px(50.), + left: Val::Percent(40.), + top: Val::Px(100.), ..default() }, + background_color: Color::WHITE.into(), ..default() }, CosmicEditPlaceholderBundle { @@ -65,20 +62,17 @@ fn create_readonly_widget(commands: &mut Commands, scale_factor: f32, text: Stri mode: CosmicMode::AutoHeight, ..default() }, - CosmicEditUiBundle { - node_bundle: NodeBundle { - border_color: Color::hex("#ededed").unwrap().into(), - style: Style { - border: UiRect::all(Val::Px(3.)), - width: Val::Percent(20.), - height: Val::Px(50.), - left: Val::Percent(40.), - top: Val::Px(100.), - ..default() - }, - background_color: Color::WHITE.into(), + ButtonBundle { + border_color: Color::hex("#ededed").unwrap().into(), + style: Style { + border: UiRect::all(Val::Px(3.)), + width: Val::Percent(20.), + height: Val::Px(50.), + left: Val::Percent(40.), + top: Val::Px(100.), ..default() }, + background_color: Color::WHITE.into(), ..default() }, ReadOnly, diff --git a/src/lib.rs b/src/lib.rs index 9cc36b28c82d0c74dced55f7b4007d81219425d7..a13ee14e62e7c271609c4c77b066df407fe742e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -232,26 +232,6 @@ pub struct CosmicEditBundle { pub canvas: CosmicCanvas, } -#[derive(Bundle)] -pub struct CosmicEditUiBundle { - pub node_bundle: NodeBundle, - pub image: UiImage, - pub interaction: Interaction, -} - -impl Default for CosmicEditUiBundle { - fn default() -> Self { - Self { - node_bundle: NodeBundle { - background_color: BackgroundColor(Color::WHITE), - ..default() - }, - image: Default::default(), - interaction: Default::default(), - } - } -} - #[derive(Bundle)] pub struct CosmicEditPlaceholderBundle { /// set this to update placeholder text