Skip to content

Commit ab06751

Browse files
committed
CI
1 parent 54adb03 commit ab06751

File tree

14 files changed

+177
-257
lines changed

14 files changed

+177
-257
lines changed

crates/bevy_clipboard/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ impl ClipboardRead {
6161
pub struct ClipboardBasic(pub String);
6262
// TODO: remove ClipboardNotSupported , write into ClipboardBasic instead
6363

64-
6564
/// Resource providing access to the clipboard
6665
#[cfg(unix)]
6766
#[derive(Resource)]
@@ -153,7 +152,7 @@ impl Clipboard {
153152
use wasm_bindgen_futures::JsFuture;
154153

155154
let clipboard = web_sys::window()
156-
.and_then(|w| w.navigator().clipboard())
155+
.and_then(|w| Some(w.navigator().clipboard()))
157156
.ok_or(ClipboardError::ClipboardNotSupported)?;
158157

159158
let result = JsFuture::from(clipboard.read_text()).await;

crates/bevy_text/src/input/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
//!
3838
//! ## Copy-paste and clipboard support
3939
//!
40-
//! The clipboard support provided by this module is very basic, and only works within the `bevy` app,
41-
//! storing a simple [`String`].
42-
//!
43-
//! It can be accessed via the [`Clipboard`] resource.
40+
//! This module integrates clipboard support from [`bevy_clipboard`].
4441
4542
use bevy_ecs::schedule::SystemSet;
4643
pub use cosmic_text::Motion;

crates/bevy_text/src/input/text_edit.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub use cosmic_text::Motion;
1212
use cosmic_text::{Action, BorrowedWithFontSystem, Edit, Editor, Selection};
1313

1414
use crate::{
15-
get_cosmic_text_buffer_contents, CosmicFontSystem, TextInputAttributes,
16-
TextInputBuffer, TextInputFilter, TextInputValue,
15+
get_cosmic_text_buffer_contents, CosmicFontSystem, TextInputAttributes, TextInputBuffer,
16+
TextInputFilter, TextInputValue,
1717
};
1818

1919
/// Text input commands queue
@@ -198,7 +198,8 @@ pub fn apply_text_edits(
198198
clipboard.as_mut(),
199199
&action,
200200
) {
201-
commands.trigger_targets(TextInputEvent::InvalidEdit(error, action), entity);
201+
commands
202+
.trigger_targets(TextInputEvent::InvalidEdit(error, action), entity);
202203
}
203204
}
204205
}
@@ -231,15 +232,14 @@ pub fn apply_text_edit(
231232
clipboard: Option<&mut ResMut<Clipboard>>,
232233
edit: &TextEdit,
233234
) -> Result<(), InvalidTextEditError> {
234-
235235
editor.start_change();
236236

237237
match edit {
238238
TextEdit::Copy => {
239-
if let Some(text) = editor.copy_selection() {
240-
if let Some(clipboard) = clipboard {
241-
let _ = clipboard.set_text(text);
242-
}
239+
if let Some(text) = editor.copy_selection()
240+
&& let Some(clipboard) = clipboard
241+
{
242+
let _ = clipboard.set_text(text);
243243
}
244244
}
245245
TextEdit::Cut => {
@@ -379,7 +379,6 @@ pub fn apply_text_edit(
379379
Ok(())
380380
}
381381

382-
383382
/// Automatically propagated events that can be dispatched by a text input entity.
384383
#[derive(EntityEvent, Clone, Debug, Component)]
385384
#[entity_event(traversal = &'static ChildOf, auto_propagate)]

crates/bevy_text/src/lib.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,20 @@ impl Plugin for TextPlugin {
110110
)
111111
.add_systems(Last, trim_cosmic_cache);
112112

113-
app.init_resource::<TextCursorBlinkInterval>()
114-
.add_systems(
115-
PostUpdate,
116-
(
117-
update_text_input_buffers,
118-
apply_text_edits,
119-
update_password_masks,
120-
update_text_input_layouts,
121-
update_placeholder_layouts,
122-
)
123-
.chain()
124-
.in_set(TextInputSystems)
125-
.before(AssetEventSystems)
126-
.ambiguous_with(Text2dUpdateSystems)
127-
);
113+
app.init_resource::<TextCursorBlinkInterval>().add_systems(
114+
PostUpdate,
115+
(
116+
update_text_input_buffers,
117+
apply_text_edits,
118+
update_password_masks,
119+
update_text_input_layouts,
120+
update_placeholder_layouts,
121+
)
122+
.chain()
123+
.in_set(TextInputSystems)
124+
.before(AssetEventSystems)
125+
.ambiguous_with(Text2dUpdateSystems),
126+
);
128127

129128
#[cfg(feature = "default_font")]
130129
{

crates/bevy_text/src/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct TextEntity {
4040
#[derive(Component, Debug, Clone, Reflect)]
4141
#[reflect(Component, Debug, Default, Clone)]
4242
pub struct ComputedTextBlock {
43-
/// Buffer for managing text layout and creating [`TextLayoutInfo`](crate::pipeline::TextLayoutInfo).
43+
/// Buffer for managing text layout and creating [`crate::pipeline::TextLayoutInfo`].
4444
///
4545
/// This is private because buffer contents are always refreshed from ECS state when writing glyphs to
4646
/// `TextLayoutInfo`. If you want to control the buffer contents manually or use the `cosmic-text`

crates/bevy_ui/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ fn build_text_interop(app: &mut App) {
262262
.ambiguous_with(bevy_sprite::calculate_bounds_text2d)
263263
.ambiguous_with(bevy_text::update_password_masks)
264264
.ambiguous_with(bevy_text::update_placeholder_layouts)
265+
.ambiguous_with(bevy_text::update_text_input_buffers)
266+
.ambiguous_with(bevy_text::apply_text_edits)
265267
.ambiguous_with(bevy_text::update_text_input_layouts),
266268
),
267269
);

crates/bevy_ui/src/widget/event.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use bevy_ecs::{
2-
component::Component, entity::Entity, event::EntityEvent
3-
};
1+
use bevy_ecs::{component::Component, entity::Entity, event::EntityEvent};
42

53
/// Represents one or more text inputs in a form being submitted
64
#[derive(EntityEvent, Clone, Debug, Component)]

crates/bevy_ui/src/widget/text_box.rs

Lines changed: 66 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,42 @@
1-
use crate::widget::measure_lines;
2-
use crate::widget::update_text_field_attributes;
3-
use crate::widget::TextSubmission;
4-
use crate::ComputedNode;
5-
use crate::Node;
6-
use crate::UiGlobalTransform;
7-
use crate::UiScale;
8-
use crate::UiSystems;
9-
use bevy_app::Plugin;
10-
use bevy_app::PostUpdate;
11-
use bevy_color::palettes::tailwind::BLUE_900;
12-
use bevy_color::palettes::tailwind::GRAY_300;
13-
use bevy_color::palettes::tailwind::GRAY_400;
14-
use bevy_color::palettes::tailwind::GRAY_950;
15-
use bevy_color::palettes::tailwind::SKY_300;
16-
use bevy_color::Color;
17-
use bevy_derive::Deref;
18-
use bevy_derive::DerefMut;
19-
use bevy_ecs::change_detection::DetectChangesMut;
20-
use bevy_ecs::component::Component;
21-
use bevy_ecs::entity::Entity;
22-
use bevy_ecs::event::EventReader;
23-
use bevy_ecs::lifecycle::HookContext;
24-
use bevy_ecs::observer::Observer;
25-
use bevy_ecs::observer::On;
26-
use bevy_ecs::query::Has;
27-
use bevy_ecs::resource::Resource;
28-
use bevy_ecs::schedule::IntoScheduleConfigs;
29-
use bevy_ecs::system::Commands;
30-
use bevy_ecs::system::Query;
31-
use bevy_ecs::system::Res;
32-
use bevy_ecs::system::ResMut;
33-
use bevy_ecs::world::DeferredWorld;
34-
use bevy_input::keyboard::Key;
35-
use bevy_input::keyboard::KeyboardInput;
36-
use bevy_input::mouse::MouseScrollUnit;
37-
use bevy_input::mouse::MouseWheel;
38-
use bevy_input::ButtonInput;
39-
use bevy_input_focus::tab_navigation::NavAction;
40-
use bevy_input_focus::FocusedInput;
41-
use bevy_input_focus::InputFocus;
42-
use bevy_math::IVec2;
43-
use bevy_math::Rect;
44-
use bevy_math::Vec2;
45-
use bevy_picking::events::Click;
46-
use bevy_picking::events::Drag;
47-
use bevy_picking::events::Move;
48-
use bevy_picking::events::Pointer;
49-
use bevy_picking::events::Press;
50-
use bevy_picking::hover::HoverMap;
51-
use bevy_picking::pointer::PointerButton;
52-
use bevy_text::Justify;
53-
use bevy_text::LineBreak;
54-
use bevy_text::Motion;
55-
use bevy_text::TextFont;
56-
use bevy_text::TextEdit;
57-
use bevy_text::TextEdits;
58-
use bevy_text::TextInputAttributes;
59-
use bevy_text::TextInputBuffer;
60-
use bevy_text::TextInputSystems;
61-
use bevy_text::TextInputTarget;
1+
use crate::{
2+
widget::{measure_lines, update_text_field_attributes, TextSubmission},
3+
ComputedNode, Node, UiGlobalTransform, UiScale, UiSystems,
4+
};
5+
use bevy_app::{Plugin, PostUpdate};
6+
use bevy_color::{
7+
palettes::tailwind::{BLUE_900, GRAY_300, GRAY_400, GRAY_950, SKY_300},
8+
Color,
9+
};
10+
use bevy_derive::{Deref, DerefMut};
11+
use bevy_ecs::{
12+
change_detection::DetectChangesMut,
13+
component::Component,
14+
entity::Entity,
15+
event::EventReader,
16+
lifecycle::HookContext,
17+
observer::{Observer, On},
18+
query::Has,
19+
resource::Resource,
20+
schedule::IntoScheduleConfigs,
21+
system::{Commands, Query, Res, ResMut},
22+
world::DeferredWorld,
23+
};
24+
use bevy_input::{
25+
keyboard::{Key, KeyboardInput},
26+
mouse::{MouseScrollUnit, MouseWheel},
27+
ButtonInput,
28+
};
29+
use bevy_input_focus::{tab_navigation::NavAction, FocusedInput, InputFocus};
30+
use bevy_math::{IVec2, Rect, Vec2};
31+
use bevy_picking::{
32+
events::{Click, Drag, Move, Pointer, Press},
33+
hover::HoverMap,
34+
pointer::PointerButton,
35+
};
36+
use bevy_text::{
37+
Justify, LineBreak, Motion, TextEdit, TextEdits, TextFont, TextInputAttributes,
38+
TextInputBuffer, TextInputSystems, TextInputTarget,
39+
};
6240
use bevy_time::Time;
6341
use core::time::Duration;
6442

@@ -149,7 +127,7 @@ impl Default for TextUnderCursorColor {
149127
TextInputStyle,
150128
TextInputMultiClickCounter,
151129
TextInputBuffer,
152-
TextCursorBlinkTimer,
130+
TextCursorBlinkTimer
153131
)]
154132
#[component(
155133
on_add = on_add_text_input_node,
@@ -342,32 +320,31 @@ fn on_multi_click_set_selection(
342320
};
343321

344322
let now = time.elapsed_secs();
345-
if let Ok(mut multi_click_data) = multi_click_data.get_mut(click.entity()) {
346-
if now - multi_click_data.last_click_time
323+
if let Ok(mut multi_click_data) = multi_click_data.get_mut(click.entity())
324+
&& now - multi_click_data.last_click_time
347325
<= multi_click_delay.as_secs_f32() * multi_click_data.click_count as f32
348-
{
349-
let rect = Rect::from_center_size(transform.translation, node.size());
326+
{
327+
let rect = Rect::from_center_size(transform.translation, node.size());
350328

351-
let position =
352-
click.pointer_location.position * node.inverse_scale_factor().recip() - rect.min;
329+
let position =
330+
click.pointer_location.position * node.inverse_scale_factor().recip() - rect.min;
353331

354-
match multi_click_data.click_count {
355-
1 => {
356-
multi_click_data.click_count += 1;
357-
multi_click_data.last_click_time = now;
332+
match multi_click_data.click_count {
333+
1 => {
334+
multi_click_data.click_count += 1;
335+
multi_click_data.last_click_time = now;
358336

359-
actions.queue(TextEdit::DoubleClick(position.as_ivec2()));
360-
return;
361-
}
362-
2 => {
363-
actions.queue(TextEdit::TripleClick(position.as_ivec2()));
364-
if let Ok(mut entity) = commands.get_entity(click.entity()) {
365-
entity.try_remove::<TextInputMultiClickCounter>();
366-
}
367-
return;
337+
actions.queue(TextEdit::DoubleClick(position.as_ivec2()));
338+
return;
339+
}
340+
2 => {
341+
actions.queue(TextEdit::TripleClick(position.as_ivec2()));
342+
if let Ok(mut entity) = commands.get_entity(click.entity()) {
343+
entity.try_remove::<TextInputMultiClickCounter>();
368344
}
369-
_ => (),
345+
return;
370346
}
347+
_ => (),
371348
}
372349
}
373350
if let Ok(mut entity) = commands.get_entity(click.entity()) {
@@ -429,7 +406,12 @@ impl Default for NextFocus {
429406
pub fn on_focused_keyboard_input(
430407
mut trigger: On<FocusedInput<KeyboardInput>>,
431408
mut commands: Commands,
432-
mut query: Query<(&mut TextEdits, Has<SingleLineInputField>, &TextBox, &TextInputBuffer)>,
409+
mut query: Query<(
410+
&mut TextEdits,
411+
Has<SingleLineInputField>,
412+
&TextBox,
413+
&TextInputBuffer,
414+
)>,
433415
mut modifiers: Option<ResMut<GlobalTextInputState>>,
434416
keyboard_state: Res<ButtonInput<Key>>,
435417
) {
@@ -500,10 +482,7 @@ pub fn on_focused_keyboard_input(
500482
}
501483
}
502484
Key::Home => {
503-
actions.queue(TextEdit::motion(
504-
Motion::BufferStart,
505-
is_shift_pressed,
506-
));
485+
actions.queue(TextEdit::motion(Motion::BufferStart, is_shift_pressed));
507486
}
508487
Key::End => {
509488
actions.queue(TextEdit::motion(Motion::BufferEnd, is_shift_pressed));

0 commit comments

Comments
 (0)