Skip to content

Commit

Permalink
Made the remaining types from bevy_ui to reflect the Default trait if… (
Browse files Browse the repository at this point in the history
bevyengine#11199)

# Objective

- Fixes bevyengine#11197

## Solution

- Made the remaining types from bevy_ui that do not reflect the Default
trait to do it if possible.
  • Loading branch information
Ato2207 authored Jan 3, 2024
1 parent 41c3620 commit 3f535d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_ui/src/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bevy_ecs::{
};
use bevy_input::{mouse::MouseButton, touch::Touches, ButtonInput};
use bevy_math::{Rect, Vec2};
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{camera::NormalizedRenderTarget, prelude::Camera, view::ViewVisibility};
use bevy_transform::components::GlobalTransform;

Expand All @@ -34,7 +34,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
/// Note that you can also control the visibility of a node using the [`Display`](crate::ui_node::Display) property,
/// which fully collapses it during layout calculations.
#[derive(Component, Copy, Clone, Eq, PartialEq, Debug, Reflect)]
#[reflect(Component, PartialEq)]
#[reflect(Component, Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -67,7 +67,7 @@ impl Default for Interaction {
///
/// It can be used alongside interaction to get the position of the press.
#[derive(Component, Copy, Clone, Default, PartialEq, Debug, Reflect)]
#[reflect(Component, PartialEq)]
#[reflect(Component, Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand All @@ -92,7 +92,7 @@ impl RelativeCursorPosition {

/// Describes whether the node should block interactions with lower nodes
#[derive(Component, Copy, Clone, Eq, PartialEq, Debug, Reflect)]
#[reflect(Component, PartialEq)]
#[reflect(Component, Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down
7 changes: 5 additions & 2 deletions crates/bevy_ui/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bevy_math::Vec2;
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use std::ops::Neg;
use std::ops::{Div, DivAssign, Mul, MulAssign};
Expand All @@ -11,8 +12,9 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
///
/// This enum allows specifying values for various [`Style`](crate::Style) properties in different units,
/// such as logical pixels, percentages, or automatically determined values.
#[derive(Copy, Clone, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -245,8 +247,9 @@ impl Val {
/// bottom: Val::Px(40.0),
/// };
/// ```
#[derive(Copy, Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down
36 changes: 18 additions & 18 deletions crates/bevy_ui/src/ui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl Default for Style {
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-items>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -512,7 +512,7 @@ impl Default for AlignItems {
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -549,7 +549,7 @@ impl Default for JustifyItems {
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-self>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -592,7 +592,7 @@ impl Default for AlignSelf {
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -629,7 +629,7 @@ impl Default for JustifySelf {
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/align-content>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -676,7 +676,7 @@ impl Default for AlignContent {
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -721,7 +721,7 @@ impl Default for JustifyContent {
///
/// For example, English is written LTR (left-to-right) while Arabic is written RTL (right-to-left).
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -750,7 +750,7 @@ impl Default for Direction {
///
/// Part of the [`Style`] component.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -780,7 +780,7 @@ impl Default for Display {

/// Defines how flexbox items are ordered within a flexbox
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -809,7 +809,7 @@ impl Default for FlexDirection {

/// Whether to show or hide overflowing items
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -874,7 +874,7 @@ impl Default for Overflow {

/// Whether to show or hide overflowing items
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -904,7 +904,7 @@ impl Default for OverflowAxis {

/// The strategy used to position this node
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand All @@ -929,7 +929,7 @@ impl Default for PositionType {

/// Defines if flexbox items appear on a single line or on multiple lines
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -963,7 +963,7 @@ impl Default for FlexWrap {
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow>
#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -1042,7 +1042,7 @@ pub enum MaxTrackSizingFunction {
/// A [`GridTrack`] is a Row or Column of a CSS Grid. This struct specifies what size the track should be.
/// See below for the different "track sizing functions" you can specify.
#[derive(Copy, Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -1375,7 +1375,7 @@ impl From<RepeatedGridTrack> for Vec<RepeatedGridTrack> {
}

#[derive(Copy, Clone, PartialEq, Eq, Debug, Reflect)]
#[reflect(PartialEq)]
#[reflect(Default, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -1768,7 +1768,7 @@ impl From<Handle<Image>> for UiImage {

/// The calculated clip of the node
#[derive(Component, Default, Copy, Clone, Debug, Reflect)]
#[reflect(Component)]
#[reflect(Component, Default)]
pub struct CalculatedClip {
/// The rect of the clip
pub clip: Rect,
Expand All @@ -1788,7 +1788,7 @@ pub struct CalculatedClip {
///
/// Nodes without this component will be treated as if they had a value of `ZIndex::Local(0)`.
#[derive(Component, Copy, Clone, Debug, Reflect)]
#[reflect(Component)]
#[reflect(Component, Default)]
pub enum ZIndex {
/// Indicates the order in which this node should be rendered relative to its siblings.
Local(i32),
Expand Down

0 comments on commit 3f535d5

Please sign in to comment.