Skip to content

Commit 961eb30

Browse files
committed
typed handles for StackPanel widget
1 parent 3af7b07 commit 961eb30

File tree

31 files changed

+116
-73
lines changed

31 files changed

+116
-73
lines changed

editor/src/audio/preview.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use crate::{
4242
Message,
4343
};
4444
use fyrox::gui::button::Button;
45+
use fyrox::gui::stack_panel::StackPanel;
4546

4647
pub struct AudioPreviewPanel {
4748
pub root_widget: Handle<UiNode>,
@@ -55,7 +56,7 @@ pub struct AudioPreviewPanel {
5556
}
5657

5758
impl AudioPreviewPanel {
58-
pub fn new(inspector_head: Handle<UiNode>, ctx: &mut BuildContext) -> Self {
59+
pub fn new(inspector_head: Handle<StackPanel>, ctx: &mut BuildContext) -> Self {
5960
let preview;
6061
let play;
6162
let pause;
@@ -166,7 +167,7 @@ impl AudioPreviewPanel {
166167
.build(ctx);
167168

168169
ctx.inner()
169-
.send(root_widget, WidgetMessage::LinkWith(inspector_head));
170+
.send(root_widget, WidgetMessage::link_with(inspector_head));
170171

171172
Self {
172173
root_widget,

editor/src/export/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ use crate::{
6565
};
6666
use cargo_metadata::camino::Utf8Path;
6767
use fyrox::gui::button::Button;
68+
use fyrox::gui::stack_panel::StackPanel;
6869
use fyrox::gui::text::Text;
6970
use fyrox::gui::window::{Window, WindowAlignment};
7071
use std::{
@@ -123,7 +124,7 @@ pub type BuildResult = Result<BuildOutput, String>;
123124

124125
pub struct ExportWindow {
125126
pub window: Handle<Window>,
126-
log: Handle<UiNode>,
127+
log: Handle<StackPanel>,
127128
export: Handle<Button>,
128129
cancel: Handle<Button>,
129130
log_scroll_viewer: Handle<UiNode>,
@@ -589,7 +590,7 @@ impl ExportWindow {
589590
}
590591

591592
fn clear_log(&self, ui: &UserInterface) {
592-
for child in ui.node(self.log).children() {
593+
for child in ui[self.log].children() {
593594
ui.send(*child, WidgetMessage::Remove);
594595
}
595596
}
@@ -721,7 +722,7 @@ impl ExportWindow {
721722
.with_text(format!("> {}", message.content))
722723
.build(ctx);
723724

724-
ui.send(entry, WidgetMessage::LinkWith(self.log));
725+
ui.send(entry, WidgetMessage::link_with(self.log));
725726
ui.send(self.log_scroll_viewer, ScrollViewerMessage::ScrollToEnd);
726727
}
727728
}

editor/src/mesh.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{
3131
utils::make_simple_tooltip,
3232
widget::WidgetBuilder,
3333
window::{WindowBuilder, WindowMessage, WindowTitle},
34-
BuildContext, Thickness, UiNode,
34+
BuildContext, Thickness,
3535
},
3636
scene::{
3737
base::BaseBuilder,
@@ -55,11 +55,12 @@ use crate::{
5555
Message,
5656
};
5757
use fyrox::gui::button::Button;
58+
use fyrox::gui::stack_panel::StackPanel;
5859
use fyrox::gui::widget::WidgetMessage;
5960
use fyrox::gui::window::{Window, WindowAlignment};
6061

6162
pub struct MeshControlPanel {
62-
pub root_widget: Handle<UiNode>,
63+
pub root_widget: Handle<StackPanel>,
6364
create_trimesh_collider: Handle<Button>,
6465
create_convex_collider: Handle<Button>,
6566
create_trimesh_rigid_body: Handle<Button>,
@@ -91,7 +92,7 @@ fn meshes_iter<'a>(
9192
}
9293

9394
impl MeshControlPanel {
94-
pub fn new(inspector_head: Handle<UiNode>, ctx: &mut BuildContext) -> Self {
95+
pub fn new(inspector_head: Handle<StackPanel>, ctx: &mut BuildContext) -> Self {
9596
let create_trimesh_collider = make_button(
9697
"Create Trimesh Collider",
9798
"Creates a new trimesh collider and attaches it to the selected mesh(es)",
@@ -134,7 +135,7 @@ impl MeshControlPanel {
134135
.build(ctx);
135136

136137
ctx.inner()
137-
.send(root_widget, WidgetMessage::LinkWith(inspector_head));
138+
.send(root_widget, WidgetMessage::link_with(inspector_head));
138139

139140
Self {
140141
root_widget,

editor/src/particle.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// SOFTWARE.
2020

2121
use fyrox::gui::button::Button;
22+
use fyrox::gui::stack_panel::StackPanel;
2223
use fyrox::gui::widget::WidgetMessage;
2324

2425
use crate::fyrox::graph::SceneGraph;
@@ -56,7 +57,7 @@ pub struct ParticleSystemPreviewControlPanel {
5657
}
5758

5859
impl ParticleSystemPreviewControlPanel {
59-
pub fn new(inspector_head: Handle<UiNode>, ctx: &mut BuildContext) -> Self {
60+
pub fn new(inspector_head: Handle<StackPanel>, ctx: &mut BuildContext) -> Self {
6061
let preview;
6162
let play;
6263
let pause;
@@ -196,7 +197,7 @@ impl ParticleSystemPreviewControlPanel {
196197
.build(ctx);
197198

198199
ctx.inner()
199-
.send(root_widget, WidgetMessage::LinkWith(inspector_head));
200+
.send(root_widget, WidgetMessage::link_with(inspector_head));
200201

201202
Self {
202203
root_widget,

editor/src/plugins/absm/node.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use crate::fyrox::{
2323
color::Color, pool::Handle, reflect::prelude::*, type_traits::prelude::*, uuid::uuid,
2424
visitor::prelude::*,
2525
},
26-
graph::SceneGraph,
2726
gui::{
2827
border::{BorderBuilder, BorderMessage},
2928
brush::Brush,
@@ -38,10 +37,10 @@ use crate::fyrox::{
3837
},
3938
};
4039
use crate::plugins::absm::selectable::{Selectable, SelectableMessage};
41-
4240
use fyrox::gui::border::Border;
4341
use fyrox::gui::button::Button;
4442
use fyrox::gui::message::MessageData;
43+
use fyrox::gui::stack_panel::StackPanel;
4544
use fyrox::gui::style::resource::StyleResourceExt;
4645
use fyrox::gui::style::{Style, StyledProperty};
4746
use fyrox::gui::text::Text;
@@ -71,7 +70,7 @@ where
7170
#[component(include)]
7271
pub base: AbsmBaseNode,
7372
pub add_input: Handle<Button>,
74-
input_sockets_panel: Handle<UiNode>,
73+
input_sockets_panel: Handle<StackPanel>,
7574
normal_brush: StyledProperty<Brush>,
7675
selected_brush: StyledProperty<Brush>,
7776
name: Handle<Text>,
@@ -193,12 +192,12 @@ where
193192
match msg {
194193
AbsmNodeMessage::InputSockets(input_sockets) => {
195194
if input_sockets != &self.base.input_sockets {
196-
for &child in ui.node(self.input_sockets_panel).children() {
195+
for &child in ui[self.input_sockets_panel].children() {
197196
ui.send(child, WidgetMessage::Remove);
198197
}
199198

200199
for &socket in input_sockets {
201-
ui.send(socket, WidgetMessage::LinkWith(self.input_sockets_panel));
200+
ui.send(socket, WidgetMessage::link_with(self.input_sockets_panel));
202201
}
203202

204203
self.base.input_sockets.clone_from(input_sockets);

editor/src/plugins/absm/toolbar.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ use crate::{
5656
},
5757
};
5858
use fyrox::gui::button::Button;
59+
use fyrox::gui::stack_panel::StackPanel;
5960
use fyrox::gui::style::resource::StyleResourceExt;
6061
use fyrox::gui::style::Style;
6162
use fyrox::gui::utils::make_dropdown_list_option;
6263
use fyrox::gui::window::WindowAlignment;
6364
use std::any::TypeId;
6465

6566
pub struct Toolbar {
66-
pub panel: Handle<UiNode>,
67+
pub panel: Handle<StackPanel>,
6768
pub preview: Handle<UiNode>,
6869
pub layers: Handle<UiNode>,
6970
pub layer_name: Handle<TextBox>,

editor/src/plugins/collider/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ impl EditorPlugin for ColliderPlugin {
756756
let inspector = editor.plugins.get::<InspectorPlugin>();
757757
let ui = editor.engine.user_interfaces.first_mut();
758758
let panel = ColliderControlPanel::new(&mut ui.build_ctx());
759-
ui.send(panel.root_widget, WidgetMessage::LinkWith(inspector.head));
759+
ui.send(panel.root_widget, WidgetMessage::link_with(inspector.head));
760760
self.panel = Some(panel);
761761
} else if !needs_panel {
762762
if let Some(panel) = self.panel.take() {

editor/src/plugins/collider/panel.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::{
3030
stack_panel::StackPanelBuilder,
3131
utils::make_simple_tooltip,
3232
widget::{WidgetBuilder, WidgetMessage},
33-
BuildContext, HorizontalAlignment, Orientation, UiNode, UserInterface,
33+
BuildContext, HorizontalAlignment, Orientation, UserInterface,
3434
},
3535
scene::{
3636
collider::{Collider, ColliderShape},
@@ -43,9 +43,10 @@ use crate::{
4343
Message,
4444
};
4545
use fyrox::gui::button::Button;
46+
use fyrox::gui::stack_panel::StackPanel;
4647

4748
pub struct ColliderControlPanel {
48-
pub root_widget: Handle<UiNode>,
49+
pub root_widget: Handle<StackPanel>,
4950
fit: Handle<Button>,
5051
edit: Handle<Button>,
5152
}

editor/src/plugins/inspector/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use crate::{
6161
Editor, Message, WidgetMessage, WrapMode,
6262
};
6363
use fyrox::gui::button::Button;
64+
use fyrox::gui::stack_panel::StackPanel;
6465
use fyrox::gui::text::Text;
6566
use fyrox::gui::window::Window;
6667
use std::{any::Any, sync::mpsc::Sender, sync::Arc};
@@ -117,7 +118,7 @@ impl InspectorEnvironment for EditorEnvironment {
117118
pub struct InspectorPlugin {
118119
pub(crate) window: Handle<Window>,
119120
pub inspector: Handle<UiNode>,
120-
pub head: Handle<UiNode>,
121+
pub head: Handle<StackPanel>,
121122
pub footer: Handle<UiNode>,
122123
warning_text: Handle<Text>,
123124
type_name_text: Handle<Text>,
@@ -417,7 +418,7 @@ impl EditorPlugin for InspectorPlugin {
417418
need_clear = false;
418419
}
419420

420-
for widget in [self.inspector, self.head] {
421+
for widget in [self.inspector, self.head.to_base()] {
421422
ui.send(widget, WidgetMessage::Enabled(!read_only));
422423
}
423424
},

editor/src/plugins/material/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ use crate::{
8989
},
9090
Editor, Engine, Message,
9191
};
92+
use fyrox::gui::stack_panel::StackPanel;
9293
use fyrox::gui::window::Window;
9394
use std::{
9495
path::PathBuf,
@@ -113,7 +114,7 @@ struct ResourceView {
113114

114115
pub struct MaterialEditor {
115116
pub window: Handle<Window>,
116-
properties_panel: Handle<UiNode>,
117+
properties_panel: Handle<StackPanel>,
117118
resource_views: Vec<ResourceView>,
118119
preview: PreviewPanel,
119120
material: Option<MaterialResource>,
@@ -473,7 +474,7 @@ impl MaterialEditor {
473474

474475
ui.send_sync(
475476
view.container,
476-
WidgetMessage::LinkWith(self.properties_panel),
477+
WidgetMessage::link_with(self.properties_panel),
477478
);
478479

479480
self.resource_views.push(view);
@@ -526,7 +527,8 @@ impl MaterialEditor {
526527
.with_margin(Thickness::uniform(2.0))
527528
.with_children(property_containers.iter().cloned()),
528529
)
529-
.build(ctx);
530+
.build(ctx)
531+
.to_base();
530532

531533
ResourceView {
532534
container: make_item_container(ctx, name.as_str(), panel),

0 commit comments

Comments
 (0)