Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
//! A small collection of default widgets
//! These widgets can be useful as default widgets for debugging purposes.
//! Kayak recommends that you use these widgets as a guide for building your own widgets.
//! Some of the widgets are useful regardless. A list:
//!
//! - KayakApp
//! - Background
//! - Clip
//! - Element
//! - Image
//! - NinePatch
//! - TextBox
//! - Text
//! - Texture Atlas
//! - Scroll
//!
//! Widgets like:
//! - Window
//! - Button
//!
//! Should be a guide for creating your own set of widgets.
use bevy::prelude::*;
#[cfg(feature = "svg")]
mod accordion;
mod app;
mod background;
mod button;
mod clip;
mod element;
#[cfg(feature = "svg")]
mod icons;
mod image;
mod modal;
mod nine_patch;
mod scroll;
#[cfg(feature = "svg")]
mod svg;
mod text;
mod text_box;
mod texture_atlas;
mod transition;
mod window;
mod window_context_provider;
#[cfg(feature = "svg")]
pub use accordion::*;
pub use app::{KayakApp, KayakAppBundle};
pub use background::{Background, BackgroundBundle};
pub use button::{ButtonState, KButton, KButtonBundle};
pub use clip::{Clip, ClipBundle};
pub use element::{Element, ElementBundle};
#[cfg(feature = "svg")]
pub use icons::*;
pub use image::{KImage, KImageBundle};
pub use modal::{Modal, ModalBundle};
pub use nine_patch::{NinePatch, NinePatchBundle};
pub use scroll::{
scroll_bar::{ScrollBarBundle, ScrollBarProps},
scroll_box::{ScrollBoxBundle, ScrollBoxProps},
scroll_content::{ScrollContentBundle, ScrollContentProps},
scroll_context::{
ScrollContext, ScrollContextProvider, ScrollContextProviderBundle, ScrollMode,
},
};
#[cfg(feature = "svg")]
pub use svg::{KSvg, KSvgBundle, Svg};
pub use text::{TextProps, TextWidgetBundle};
pub use text_box::{TextBoxBundle, TextBoxProps, TextBoxState};
pub use texture_atlas::{TextureAtlasBundle, TextureAtlasProps};
pub use transition::{
create_transition, Transition, TransitionBundle, TransitionEasing, TransitionProps,
TransitionState,
};
pub use window::{KWindow, KWindowState, WindowBundle};
pub use window_context_provider::{
WindowContext, WindowContextProvider, WindowContextProviderBundle,
};
use app::{app_render, app_update};
use background::background_render;
use button::button_render;
use clip::clip_render;
use element::element_render;
use image::image_render;
use nine_patch::nine_patch_render;
use scroll::{
scroll_bar::scroll_bar_render, scroll_box::scroll_box_render,
scroll_content::scroll_content_render, scroll_context::scroll_context_render,
};
#[cfg(feature = "svg")]
use svg::svg_render;
use text::text_render;
use text_box::text_box_render;
use texture_atlas::texture_atlas_render;
use window::window_render;
use crate::{
context::{update_widgets_sys, KayakRootContext},
widget::{widget_update, widget_update_with_context, EmptyState, Widget},
KayakUIPlugin,
};
use self::window_context_provider::window_context_render;
pub struct KayakWidgets;
impl Plugin for KayakWidgets {
fn build(&self, app: &mut bevy::prelude::App) {
#[cfg(feature = "svg")]
app.add_plugins(icons::IconsPlugin);
app.add_systems(
PostUpdate,
transition::update_transitions.after(update_widgets_sys),
)
.add_systems(Update, text_box::cursor_animation_system);
}
}
pub struct KayakWidgetsContextPlugin;
impl KayakUIPlugin for KayakWidgetsContextPlugin {
fn build(&self, context: &mut KayakRootContext) {
#[cfg(feature = "svg")]
context.add_plugin(AccordionPlugin);
context.add_widget_data::<KayakApp, EmptyState>();
context.add_widget_data::<KButton, ButtonState>();
context.add_widget_data::<TextProps, EmptyState>();
context.add_widget_data::<KWindow, KWindowState>();
context.add_widget_data::<WindowContextProvider, EmptyState>();
context.add_widget_data::<Background, EmptyState>();
context.add_widget_data::<Clip, EmptyState>();
context.add_widget_data::<KImage, EmptyState>();
context.add_widget_data::<TextureAtlasProps, EmptyState>();
context.add_widget_data::<NinePatch, EmptyState>();
#[cfg(feature = "svg")]
context.add_widget_data::<KSvg, EmptyState>();
context.add_widget_data::<Element, EmptyState>();
context.add_widget_data::<ScrollBarProps, EmptyState>();
context.add_widget_data::<ScrollContentProps, EmptyState>();
context.add_widget_data::<ScrollBoxProps, EmptyState>();
context.add_widget_data::<ScrollContextProvider, EmptyState>();
context.add_widget_data::<TextBoxProps, TextBoxState>();
context.add_widget_data::<TransitionProps, TransitionState>();
context.add_widget_data::<Modal, TransitionState>();
context.add_widget_system(KayakApp.get_name(), app_update, app_render);
context.add_widget_system(
KButton::default().get_name(),
widget_update::<KButton, ButtonState>,
button_render,
);
context.add_widget_system(
TextProps::default().get_name(),
widget_update::<TextProps, EmptyState>,
text_render,
);
context.add_widget_system(
WindowContextProvider.get_name(),
widget_update::<WindowContextProvider, EmptyState>,
window_context_render,
);
context.add_widget_system(
KWindow::default().get_name(),
widget_update_with_context::<KWindow, KWindowState, WindowContext>,
window_render,
);
context.add_widget_system(
Background.get_name(),
widget_update::<Background, EmptyState>,
background_render,
);
context.add_widget_system(
Clip.get_name(),
widget_update::<Clip, EmptyState>,
clip_render,
);
context.add_widget_system(
KImage::default().get_name(),
widget_update::<KImage, EmptyState>,
image_render,
);
context.add_widget_system(
TextureAtlasProps::default().get_name(),
widget_update::<TextureAtlasProps, EmptyState>,
texture_atlas_render,
);
context.add_widget_system(
NinePatch::default().get_name(),
widget_update::<NinePatch, EmptyState>,
nine_patch_render,
);
#[cfg(feature = "svg")]
context.add_widget_system(
KSvg::default().get_name(),
widget_update::<KSvg, EmptyState>,
svg_render,
);
context.add_widget_system(
Element.get_name(),
widget_update::<Element, EmptyState>,
element_render,
);
context.add_widget_system(
ScrollBarProps::default().get_name(),
widget_update_with_context::<ScrollBarProps, EmptyState, ScrollContext>,
scroll_bar_render,
);
context.add_widget_system(
ScrollContentProps.get_name(),
widget_update_with_context::<ScrollContentProps, EmptyState, ScrollContext>,
scroll_content_render,
);
context.add_widget_system(
ScrollBoxProps::default().get_name(),
widget_update_with_context::<ScrollBoxProps, EmptyState, ScrollContext>,
scroll_box_render,
);
context.add_widget_system(
ScrollContextProvider::default().get_name(),
widget_update::<ScrollContextProvider, EmptyState>,
scroll_context_render,
);
context.add_widget_system(
TextBoxProps::default().get_name(),
widget_update::<TextBoxProps, TextBoxState>,
text_box_render,
);
context.add_widget_system(
TransitionProps::default().get_name(),
widget_update::<TransitionProps, TransitionState>,
transition::render,
);
context.add_widget_system(
Modal::default().get_name(),
widget_update::<Modal, TransitionState>,
modal::render,
);
}
}