mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
Merge branch 'master' into bbcode
# Conflicts: # project-manager/src/main.rs
This commit is contained in:
+14
-32
@@ -934,12 +934,8 @@ impl AssetBrowser {
|
||||
}
|
||||
|
||||
pub fn locate_path(&mut self, ui: &UserInterface, path: PathBuf) {
|
||||
ui.send_message(FileBrowserMessage::path(
|
||||
self.folder_browser,
|
||||
MessageDirection::ToWidget,
|
||||
path.parent().map(|p| p.to_path_buf()).unwrap_or_default(),
|
||||
));
|
||||
|
||||
let folder = path.parent().map(|p| p.to_path_buf()).unwrap_or_default();
|
||||
ui.send(self.folder_browser, FileBrowserMessage::Path(folder));
|
||||
self.item_to_select = Some(path);
|
||||
}
|
||||
|
||||
@@ -991,11 +987,10 @@ impl AssetBrowser {
|
||||
}
|
||||
|
||||
pub fn on_mode_changed(&mut self, ui: &UserInterface, mode: &Mode) {
|
||||
ui.send_message(WidgetMessage::enabled(
|
||||
ui.send(
|
||||
window_content(self.window, ui),
|
||||
MessageDirection::ToWidget,
|
||||
mode.is_edit(),
|
||||
));
|
||||
WidgetMessage::Enabled(mode.is_edit()),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn on_message(
|
||||
@@ -1012,11 +1007,10 @@ impl AssetBrowser {
|
||||
for &item_handle in self.items.iter() {
|
||||
let item = some_or_continue!(ui.try_get_of_type::<AssetItem>(item_handle));
|
||||
|
||||
ui.send_message(AssetItemMessage::select(
|
||||
ui.send(
|
||||
item_handle,
|
||||
MessageDirection::ToWidget,
|
||||
selection.contains(&item.path),
|
||||
));
|
||||
AssetItemMessage::Select(selection.contains(&item.path)),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(inspector_plugin) =
|
||||
@@ -1105,30 +1099,18 @@ impl AssetBrowser {
|
||||
}
|
||||
}
|
||||
}
|
||||
engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.send_message(WidgetMessage::visibility(
|
||||
inspector_addon.preview.root,
|
||||
MessageDirection::ToWidget,
|
||||
has_preview,
|
||||
));
|
||||
engine.user_interfaces.first_mut().send(
|
||||
inspector_addon.preview.root,
|
||||
WidgetMessage::Visibility(has_preview),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
for &item in self.items.iter() {
|
||||
ui.send_message(AssetItemMessage::select(
|
||||
item,
|
||||
MessageDirection::ToWidget,
|
||||
false,
|
||||
))
|
||||
ui.send(item, AssetItemMessage::Select(false))
|
||||
}
|
||||
|
||||
if let Some(inspector_addon) = self.inspector_addon.take() {
|
||||
ui.send_message(WidgetMessage::remove(
|
||||
inspector_addon.root,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
|
||||
ui.send(inspector_addon.root, WidgetMessage::Remove);
|
||||
inspector_addon.preview.destroy(engine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ use crate::{
|
||||
core::{futures::executor::block_on, parking_lot::Mutex, pool::Handle, SafeLock, Uuid},
|
||||
engine::Engine,
|
||||
fxhash::FxHashMap,
|
||||
gui::{message::MessageDirection, UiNode},
|
||||
gui::UiNode,
|
||||
},
|
||||
load_image,
|
||||
};
|
||||
@@ -119,15 +119,14 @@ impl AssetPreviewCache {
|
||||
if let Some(preview) =
|
||||
self.preview_for(&resource, generators, force_update, &mut generated, engine)
|
||||
{
|
||||
let ui = engine.user_interfaces.first();
|
||||
|
||||
ui.send_message(AssetItemMessage::icon(
|
||||
engine.user_interfaces.first().send(
|
||||
widget_handle,
|
||||
MessageDirection::ToWidget,
|
||||
Some(preview.texture),
|
||||
preview.flip_y,
|
||||
preview.color,
|
||||
));
|
||||
AssetItemMessage::Icon {
|
||||
texture: Some(preview.texture),
|
||||
flip_y: preview.flip_y,
|
||||
color: preview.color,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if generated >= self.throughput {
|
||||
|
||||
+5
-20
@@ -93,26 +93,14 @@ impl Control for AudioBusView {
|
||||
|
||||
let items = make_items(buses, &mut ui.build_ctx());
|
||||
|
||||
ui.send_message(DropdownListMessage::items(
|
||||
self.parent_bus_selector,
|
||||
MessageDirection::ToWidget,
|
||||
items,
|
||||
))
|
||||
ui.send(self.parent_bus_selector, DropdownListMessage::Items(items))
|
||||
}
|
||||
AudioBusViewMessage::EffectNames(names) => {
|
||||
let items = make_effect_names(names, &mut ui.build_ctx());
|
||||
ui.send_message(ListViewMessage::items(
|
||||
self.effect_names_list,
|
||||
MessageDirection::ToWidget,
|
||||
items,
|
||||
));
|
||||
ui.send(self.effect_names_list, ListViewMessage::Items(items));
|
||||
}
|
||||
AudioBusViewMessage::Name(new_name) => {
|
||||
ui.send_message(TextMessage::text(
|
||||
self.name,
|
||||
MessageDirection::ToWidget,
|
||||
new_name.clone(),
|
||||
));
|
||||
ui.send(self.name, TextMessage::Text(new_name.clone()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,11 +109,8 @@ impl Control for AudioBusView {
|
||||
if let Some(DropdownListMessage::SelectionChanged(Some(selection))) =
|
||||
message.data_from(self.parent_bus_selector)
|
||||
{
|
||||
ui.send_message(AudioBusViewMessage::change_parent(
|
||||
self.handle,
|
||||
MessageDirection::FromWidget,
|
||||
self.possible_parent_buses[*selection],
|
||||
));
|
||||
let parent = self.possible_parent_buses[*selection];
|
||||
ui.post(self.handle, AudioBusViewMessage::ChangeParent(parent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,10 +659,9 @@ impl AudioPanel {
|
||||
}
|
||||
|
||||
pub fn on_mode_changed(&mut self, ui: &UserInterface, mode: &Mode) {
|
||||
ui.send_message(WidgetMessage::enabled(
|
||||
ui.send(
|
||||
window_content(self.window, ui),
|
||||
MessageDirection::ToWidget,
|
||||
mode.is_edit(),
|
||||
));
|
||||
WidgetMessage::Enabled(mode.is_edit()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-30
@@ -18,28 +18,26 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use fyrox::gui::widget::WidgetMessage;
|
||||
|
||||
use crate::fyrox::graph::SceneGraph;
|
||||
use crate::fyrox::{
|
||||
core::pool::Handle,
|
||||
engine::Engine,
|
||||
gui::{
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
check_box::{CheckBoxBuilder, CheckBoxMessage},
|
||||
grid::{Column, GridBuilder, Row},
|
||||
message::{MessageDirection, UiMessage},
|
||||
scroll_bar::{ScrollBarBuilder, ScrollBarMessage},
|
||||
text::TextBuilder,
|
||||
widget::WidgetBuilder,
|
||||
BuildContext, Thickness, UiNode, VerticalAlignment,
|
||||
},
|
||||
scene::{
|
||||
node::Node,
|
||||
sound::{Sound, Status},
|
||||
},
|
||||
};
|
||||
use crate::{
|
||||
fyrox::{
|
||||
core::pool::Handle,
|
||||
engine::Engine,
|
||||
graph::SceneGraph,
|
||||
gui::{
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
check_box::{CheckBoxBuilder, CheckBoxMessage},
|
||||
grid::{Column, GridBuilder, Row},
|
||||
message::{MessageDirection, UiMessage},
|
||||
scroll_bar::{ScrollBarBuilder, ScrollBarMessage},
|
||||
text::TextBuilder,
|
||||
widget::{WidgetBuilder, WidgetMessage},
|
||||
BuildContext, Thickness, UiNode, VerticalAlignment,
|
||||
},
|
||||
scene::{
|
||||
node::Node,
|
||||
sound::{Sound, Status},
|
||||
},
|
||||
},
|
||||
scene::{GameScene, Selection},
|
||||
send_sync_message, Message,
|
||||
};
|
||||
@@ -205,14 +203,10 @@ impl AudioPreviewPanel {
|
||||
.nodes
|
||||
.iter()
|
||||
.any(|n| scene.graph.try_get_of_type::<Sound>(*n).is_some());
|
||||
engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.send_message(WidgetMessage::visibility(
|
||||
self.root_widget,
|
||||
MessageDirection::ToWidget,
|
||||
any_sound_selected,
|
||||
));
|
||||
engine.user_interfaces.first_mut().send(
|
||||
self.root_widget,
|
||||
WidgetMessage::Visibility(any_sound_selected),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,7 +276,7 @@ impl AudioPreviewPanel {
|
||||
|
||||
send_sync_message(
|
||||
engine.user_interfaces.first(),
|
||||
CheckBoxMessage::checked(self.preview, MessageDirection::ToWidget, Some(false)),
|
||||
UiMessage::for_widget(self.preview, CheckBoxMessage::Check(Some(false))),
|
||||
);
|
||||
|
||||
scene.graph.sound_context.state().destroy_sound_sources();
|
||||
|
||||
+13
-18
@@ -126,27 +126,22 @@ impl CameraPreviewControlPanel {
|
||||
.any(|n| scene.graph.try_get_of_type::<Camera>(*n).is_some())
|
||||
});
|
||||
if any_camera {
|
||||
engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.send_message(WindowMessage::open_and_align(
|
||||
self.window,
|
||||
MessageDirection::ToWidget,
|
||||
self.scene_viewer_frame,
|
||||
HorizontalAlignment::Right,
|
||||
VerticalAlignment::Top,
|
||||
Thickness::top_right(5.0),
|
||||
false,
|
||||
false,
|
||||
));
|
||||
engine.user_interfaces.first_mut().send(
|
||||
self.window,
|
||||
WindowMessage::OpenAndAlign {
|
||||
relative_to: self.scene_viewer_frame,
|
||||
horizontal_alignment: HorizontalAlignment::Right,
|
||||
vertical_alignment: VerticalAlignment::Top,
|
||||
margin: Thickness::top_right(5.0),
|
||||
modal: false,
|
||||
focus_content: false,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.send_message(WindowMessage::close(
|
||||
self.window,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
.send(self.window, WindowMessage::Close);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,7 +215,7 @@ impl CameraPreviewControlPanel {
|
||||
[
|
||||
// Don't keep the render target alive after the preview mode is off.
|
||||
ImageMessage::texture(self.preview_frame, MessageDirection::ToWidget, None),
|
||||
CheckBoxMessage::checked(self.preview, MessageDirection::ToWidget, Some(false)),
|
||||
UiMessage::for_widget(self.preview, CheckBoxMessage::Check(Some(false))),
|
||||
WidgetMessage::visibility(self.preview_frame, MessageDirection::ToWidget, false),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -186,10 +186,9 @@ impl CommandStackViewer {
|
||||
}
|
||||
|
||||
pub fn on_mode_changed(&mut self, ui: &UserInterface, mode: &Mode) {
|
||||
ui.send_message(WidgetMessage::enabled(
|
||||
ui.send(
|
||||
window_content(self.window, ui),
|
||||
MessageDirection::ToWidget,
|
||||
mode.is_edit(),
|
||||
));
|
||||
WidgetMessage::Enabled(mode.is_edit()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+17
-39
@@ -47,7 +47,7 @@ use crate::{
|
||||
InspectorContext, InspectorContextArgs, InspectorMessage, PropertyAction,
|
||||
},
|
||||
list_view::{ListViewBuilder, ListViewMessage},
|
||||
message::{MessageDirection, UiMessage},
|
||||
message::UiMessage,
|
||||
scroll_viewer::{ScrollViewerBuilder, ScrollViewerMessage},
|
||||
stack_panel::StackPanelBuilder,
|
||||
style::{resource::StyleResourceExt, Style},
|
||||
@@ -562,12 +562,13 @@ impl ExportWindow {
|
||||
}
|
||||
|
||||
pub fn open(&self, ui: &UserInterface) {
|
||||
ui.send_message(WindowMessage::open_modal(
|
||||
ui.send(
|
||||
self.window,
|
||||
MessageDirection::ToWidget,
|
||||
true,
|
||||
true,
|
||||
));
|
||||
WindowMessage::OpenModal {
|
||||
center: true,
|
||||
focus_content: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn kill_child_processes(&mut self) {
|
||||
@@ -577,14 +578,8 @@ impl ExportWindow {
|
||||
}
|
||||
|
||||
pub fn close_and_destroy(&mut self, ui: &UserInterface) {
|
||||
ui.send_message(WindowMessage::close(
|
||||
self.window,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
ui.send_message(WidgetMessage::remove(
|
||||
self.window,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
ui.send(self.window, WindowMessage::Close);
|
||||
ui.send(self.window, WidgetMessage::Remove);
|
||||
self.log_message_receiver = None;
|
||||
self.build_result_receiver = None;
|
||||
self.kill_child_processes();
|
||||
@@ -592,7 +587,7 @@ impl ExportWindow {
|
||||
|
||||
fn clear_log(&self, ui: &UserInterface) {
|
||||
for child in ui.node(self.log).children() {
|
||||
ui.send_message(WidgetMessage::remove(*child, MessageDirection::ToWidget));
|
||||
ui.send(*child, WidgetMessage::Remove);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,11 +609,7 @@ impl ExportWindow {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
self.build_result_receiver = Some(rx);
|
||||
|
||||
ui.send_message(WidgetMessage::enabled(
|
||||
self.export,
|
||||
MessageDirection::ToWidget,
|
||||
false,
|
||||
));
|
||||
ui.send(self.export, WidgetMessage::Enabled(false));
|
||||
|
||||
self.clear_log(ui);
|
||||
|
||||
@@ -668,11 +659,10 @@ impl ExportWindow {
|
||||
.map(|name| make_dropdown_list_option(&mut ui.build_ctx(), name))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
ui.send_message(DropdownListMessage::items(
|
||||
ui.send(
|
||||
self.build_targets_selector,
|
||||
MessageDirection::ToWidget,
|
||||
ui_items,
|
||||
));
|
||||
DropdownListMessage::Items(ui_items),
|
||||
);
|
||||
}
|
||||
} else if let Some(InspectorMessage::PropertyChanged(args)) =
|
||||
message.data_from(self.inspector)
|
||||
@@ -728,16 +718,8 @@ impl ExportWindow {
|
||||
.with_text(format!("> {}", message.content))
|
||||
.build(ctx);
|
||||
|
||||
ui.send_message(WidgetMessage::link(
|
||||
entry,
|
||||
MessageDirection::ToWidget,
|
||||
self.log,
|
||||
));
|
||||
|
||||
ui.send_message(ScrollViewerMessage::scroll_to_end(
|
||||
self.log_scroll_viewer,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
ui.send(entry, WidgetMessage::LinkWith(self.log));
|
||||
ui.send(self.log_scroll_viewer, ScrollViewerMessage::ScrollToEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,11 +733,7 @@ impl ExportWindow {
|
||||
Err(err) => Log::err(format!("Build failed! Reason: {err}")),
|
||||
}
|
||||
|
||||
ui.send_message(WidgetMessage::enabled(
|
||||
self.export,
|
||||
MessageDirection::ToWidget,
|
||||
true,
|
||||
));
|
||||
ui.send(self.export, WidgetMessage::Enabled(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,19 +184,15 @@ impl NavmeshPanel {
|
||||
engine
|
||||
.user_interfaces
|
||||
.first()
|
||||
.send_message(WindowMessage::close(
|
||||
self.window,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
.send(self.window, WindowMessage::Close);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_mode_changed(&mut self, ui: &UserInterface, mode: &Mode) {
|
||||
ui.send_message(WidgetMessage::enabled(
|
||||
ui.send(
|
||||
window_content(self.window, ui),
|
||||
MessageDirection::ToWidget,
|
||||
mode.is_edit(),
|
||||
));
|
||||
WidgetMessage::Enabled(mode.is_edit()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use crate::{
|
||||
TypeUuidProvider,
|
||||
},
|
||||
graph::BaseSceneGraph,
|
||||
gui::{message::MessageDirection, widget::WidgetMessage, BuildContext, UiNode},
|
||||
gui::{BuildContext, UiNode},
|
||||
scene::node::Node,
|
||||
},
|
||||
interaction::{make_interaction_mode_button, InteractionMode},
|
||||
@@ -37,6 +37,7 @@ use crate::{
|
||||
world::selection::GraphSelection,
|
||||
Engine,
|
||||
};
|
||||
use fyrox::gui::widget::WidgetMessage;
|
||||
|
||||
pub struct SelectInteractionMode {
|
||||
preview: Handle<UiNode>,
|
||||
@@ -79,27 +80,15 @@ impl InteractionMode for SelectInteractionMode {
|
||||
_settings: &Settings,
|
||||
) {
|
||||
self.click_pos = mouse_pos;
|
||||
let ui = &mut engine.user_interfaces.first_mut();
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
engine.user_interfaces.first().send_many(
|
||||
self.selection_frame,
|
||||
MessageDirection::ToWidget,
|
||||
true,
|
||||
));
|
||||
ui.send_message(WidgetMessage::desired_position(
|
||||
self.selection_frame,
|
||||
MessageDirection::ToWidget,
|
||||
mouse_pos,
|
||||
));
|
||||
ui.send_message(WidgetMessage::width(
|
||||
self.selection_frame,
|
||||
MessageDirection::ToWidget,
|
||||
0.0,
|
||||
));
|
||||
ui.send_message(WidgetMessage::height(
|
||||
self.selection_frame,
|
||||
MessageDirection::ToWidget,
|
||||
0.0,
|
||||
));
|
||||
[
|
||||
WidgetMessage::Visibility(true),
|
||||
WidgetMessage::DesiredPosition(mouse_pos),
|
||||
WidgetMessage::Width(0.0),
|
||||
WidgetMessage::Height(0.0),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
fn on_left_mouse_button_up(
|
||||
@@ -161,12 +150,8 @@ impl InteractionMode for SelectInteractionMode {
|
||||
}
|
||||
engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.send_message(WidgetMessage::visibility(
|
||||
self.selection_frame,
|
||||
MessageDirection::ToWidget,
|
||||
false,
|
||||
));
|
||||
.first()
|
||||
.send(self.selection_frame, WidgetMessage::Visibility(false));
|
||||
}
|
||||
|
||||
fn on_mouse_move(
|
||||
@@ -195,21 +180,14 @@ impl InteractionMode for SelectInteractionMode {
|
||||
self.click_pos.y
|
||||
},
|
||||
);
|
||||
ui.send_message(WidgetMessage::desired_position(
|
||||
ui.send_many(
|
||||
self.selection_frame,
|
||||
MessageDirection::ToWidget,
|
||||
position,
|
||||
));
|
||||
ui.send_message(WidgetMessage::width(
|
||||
self.selection_frame,
|
||||
MessageDirection::ToWidget,
|
||||
width.abs(),
|
||||
));
|
||||
ui.send_message(WidgetMessage::height(
|
||||
self.selection_frame,
|
||||
MessageDirection::ToWidget,
|
||||
height.abs(),
|
||||
));
|
||||
[
|
||||
WidgetMessage::DesiredPosition(position),
|
||||
WidgetMessage::Width(width.abs()),
|
||||
WidgetMessage::Height(height.abs()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
fn update(
|
||||
|
||||
@@ -448,11 +448,8 @@ impl InteractionMode for TerrainInteractionMode {
|
||||
|
||||
engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.send_message(WindowMessage::close(
|
||||
self.brush_panel.window,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
.first()
|
||||
.send(self.brush_panel.window, WindowMessage::Close);
|
||||
}
|
||||
|
||||
fn handle_ui_message(
|
||||
@@ -472,11 +469,8 @@ impl InteractionMode for TerrainInteractionMode {
|
||||
fn on_drop(&mut self, engine: &mut Engine) {
|
||||
engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.send_message(WidgetMessage::remove(
|
||||
self.brush_panel.window,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
.first()
|
||||
.send(self.brush_panel.window, WidgetMessage::Remove);
|
||||
}
|
||||
|
||||
fn on_hot_key_pressed(
|
||||
|
||||
@@ -282,7 +282,7 @@ impl ParticleSystemPreviewControlPanel {
|
||||
|
||||
send_sync_message(
|
||||
engine.user_interfaces.first(),
|
||||
CheckBoxMessage::checked(self.preview, MessageDirection::ToWidget, Some(false)),
|
||||
UiMessage::for_widget(self.preview, CheckBoxMessage::Check(Some(false))),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -295,11 +295,7 @@ impl AbsmEditor {
|
||||
{
|
||||
assert!(self.preview_mode_data.is_none());
|
||||
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
self.toolbar.preview,
|
||||
MessageDirection::ToWidget,
|
||||
Some(true),
|
||||
));
|
||||
ui.send(self.toolbar.preview, CheckBoxMessage::Check(Some(true)));
|
||||
|
||||
// Allow the engine to update the nodes affected by animations.
|
||||
for &target in &animation_targets {
|
||||
@@ -327,11 +323,7 @@ impl AbsmEditor {
|
||||
G: SceneGraph<Node = N, Prefab = P>,
|
||||
N: SceneGraphNode<SceneGraph = G, ResourceData = P>,
|
||||
{
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
self.toolbar.preview,
|
||||
MessageDirection::ToWidget,
|
||||
Some(false),
|
||||
));
|
||||
ui.send(self.toolbar.preview, CheckBoxMessage::Check(Some(false)));
|
||||
|
||||
let preview_data = self
|
||||
.preview_mode_data
|
||||
|
||||
@@ -903,10 +903,9 @@ impl AnimationEditor {
|
||||
);
|
||||
send_sync_message(
|
||||
ui,
|
||||
CheckBoxMessage::checked(
|
||||
UiMessage::for_widget(
|
||||
self.toolbar.preview,
|
||||
MessageDirection::ToWidget,
|
||||
Some(self.preview_mode_data.is_some()),
|
||||
CheckBoxMessage::Check(Some(self.preview_mode_data.is_some())),
|
||||
),
|
||||
);
|
||||
send_sync_message(
|
||||
|
||||
@@ -18,61 +18,58 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::fyrox::{
|
||||
asset::manager::ResourceManager,
|
||||
core::{
|
||||
algebra::Vector2, futures::executor::block_on, log::Log, math::Rect, pool::ErasedHandle,
|
||||
pool::Handle,
|
||||
},
|
||||
generic_animation::{Animation, AnimationContainer, RootMotionSettings},
|
||||
graph::{BaseSceneGraph, PrefabData, SceneGraph, SceneGraphNode},
|
||||
gui::{
|
||||
border::BorderBuilder,
|
||||
button::{Button, ButtonBuilder, ButtonMessage},
|
||||
check_box::{CheckBoxBuilder, CheckBoxMessage},
|
||||
dropdown_list::{DropdownList, DropdownListBuilder, DropdownListMessage},
|
||||
file_browser::{FileSelectorBuilder, FileSelectorMessage, Filter},
|
||||
grid::{Column, GridBuilder, Row},
|
||||
image::ImageBuilder,
|
||||
message::{MessageDirection, UiMessage},
|
||||
numeric::{NumericUpDownBuilder, NumericUpDownMessage},
|
||||
popup::{Placement, PopupBuilder, PopupMessage},
|
||||
stack_panel::StackPanelBuilder,
|
||||
text::{TextBuilder, TextMessage},
|
||||
text_box::{TextBox, TextBoxBuilder},
|
||||
utils::{make_cross, make_simple_tooltip},
|
||||
vector_image::{Primitive, VectorImageBuilder},
|
||||
widget::{WidgetBuilder, WidgetMessage},
|
||||
window::{WindowBuilder, WindowMessage, WindowTitle},
|
||||
BuildContext, HorizontalAlignment, Orientation, Thickness, UiNode, UserInterface,
|
||||
VerticalAlignment,
|
||||
},
|
||||
resource::model::AnimationSource,
|
||||
};
|
||||
use crate::plugins::animation::{
|
||||
command::{
|
||||
AddAnimationCommand, RemoveAnimationCommand, ReplaceAnimationCommand,
|
||||
SetAnimationEnabledCommand, SetAnimationLoopingCommand, SetAnimationNameCommand,
|
||||
SetAnimationRootMotionSettingsCommand, SetAnimationSpeedCommand,
|
||||
SetAnimationTimeSliceCommand,
|
||||
},
|
||||
selection::AnimationSelection,
|
||||
};
|
||||
use crate::scene::selector::AllowedType;
|
||||
use crate::{
|
||||
command::{Command, CommandGroup},
|
||||
fyrox::{
|
||||
asset::manager::ResourceManager,
|
||||
core::{
|
||||
algebra::Vector2, futures::executor::block_on, log::Log, math::Rect,
|
||||
pool::ErasedHandle, pool::Handle,
|
||||
},
|
||||
generic_animation::{Animation, AnimationContainer, RootMotionSettings},
|
||||
graph::{BaseSceneGraph, PrefabData, SceneGraph, SceneGraphNode},
|
||||
gui::{
|
||||
border::BorderBuilder,
|
||||
button::{Button, ButtonBuilder, ButtonMessage},
|
||||
check_box::{CheckBoxBuilder, CheckBoxMessage},
|
||||
dropdown_list::{DropdownList, DropdownListBuilder, DropdownListMessage},
|
||||
file_browser::{FileSelectorBuilder, FileSelectorMessage, Filter},
|
||||
grid::{Column, GridBuilder, Row},
|
||||
image::ImageBuilder,
|
||||
message::{MessageDirection, UiMessage},
|
||||
numeric::{NumericUpDownBuilder, NumericUpDownMessage},
|
||||
popup::{Placement, PopupBuilder, PopupMessage},
|
||||
stack_panel::StackPanelBuilder,
|
||||
style::{resource::StyleResourceExt, Style},
|
||||
text::{TextBuilder, TextMessage},
|
||||
text_box::{TextBox, TextBoxBuilder},
|
||||
utils::{make_cross, make_dropdown_list_option_universal, make_simple_tooltip},
|
||||
vector_image::{Primitive, VectorImageBuilder},
|
||||
widget::{WidgetBuilder, WidgetMessage},
|
||||
window::{WindowBuilder, WindowMessage, WindowTitle},
|
||||
BuildContext, HorizontalAlignment, Orientation, Thickness, UiNode, UserInterface,
|
||||
VerticalAlignment,
|
||||
},
|
||||
resource::model::AnimationSource,
|
||||
},
|
||||
load_image,
|
||||
message::MessageSender,
|
||||
plugins::animation::{
|
||||
command::{
|
||||
AddAnimationCommand, RemoveAnimationCommand, ReplaceAnimationCommand,
|
||||
SetAnimationEnabledCommand, SetAnimationLoopingCommand, SetAnimationNameCommand,
|
||||
SetAnimationRootMotionSettingsCommand, SetAnimationSpeedCommand,
|
||||
SetAnimationTimeSliceCommand,
|
||||
},
|
||||
selection::AnimationSelection,
|
||||
},
|
||||
scene::{
|
||||
commands::ChangeSelectionCommand,
|
||||
selector::{HierarchyNode, NodeSelectorMessage, NodeSelectorWindowBuilder},
|
||||
selector::{AllowedType, HierarchyNode, NodeSelectorMessage, NodeSelectorWindowBuilder},
|
||||
Selection,
|
||||
},
|
||||
send_sync_message,
|
||||
};
|
||||
use fyrox::gui::style::resource::StyleResourceExt;
|
||||
use fyrox::gui::style::Style;
|
||||
use fyrox::gui::utils::make_dropdown_list_option_universal;
|
||||
use std::any::TypeId;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -358,7 +355,7 @@ impl RootMotionDropdownArea {
|
||||
fn sync_checked(ui: &UserInterface, check_box: Handle<UiNode>, checked: bool) {
|
||||
send_sync_message(
|
||||
ui,
|
||||
CheckBoxMessage::checked(check_box, MessageDirection::ToWidget, Some(checked)),
|
||||
UiMessage::for_widget(check_box, CheckBoxMessage::Check(Some(checked))),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1284,19 +1281,17 @@ impl Toolbar {
|
||||
|
||||
send_sync_message(
|
||||
ui,
|
||||
CheckBoxMessage::checked(
|
||||
UiMessage::for_widget(
|
||||
self.looping,
|
||||
MessageDirection::ToWidget,
|
||||
Some(animation.is_loop()),
|
||||
CheckBoxMessage::Check(Some(animation.is_loop())),
|
||||
),
|
||||
);
|
||||
|
||||
send_sync_message(
|
||||
ui,
|
||||
CheckBoxMessage::checked(
|
||||
UiMessage::for_widget(
|
||||
self.enabled,
|
||||
MessageDirection::ToWidget,
|
||||
Some(animation.is_enabled()),
|
||||
CheckBoxMessage::Check(Some(animation.is_enabled())),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -359,11 +359,10 @@ impl Control for TrackView {
|
||||
if self.track_enabled != *enabled {
|
||||
self.track_enabled = *enabled;
|
||||
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
ui.send(
|
||||
self.track_enabled_switch,
|
||||
MessageDirection::ToWidget,
|
||||
Some(*enabled),
|
||||
));
|
||||
CheckBoxMessage::Check(Some(*enabled)),
|
||||
);
|
||||
|
||||
ui.send_message(message.reverse());
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ mat_ui_view!(Matrix2<f32>, Matrix3<f32>, Matrix4<f32>);
|
||||
|
||||
impl UiView for bool {
|
||||
fn into_message(self, item: Handle<UiNode>) -> UiMessage {
|
||||
CheckBoxMessage::checked(item, MessageDirection::ToWidget, Some(self))
|
||||
UiMessage::for_widget(item, CheckBoxMessage::Check(Some(self)))
|
||||
}
|
||||
fn make_view(self, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
CheckBoxBuilder::new(WidgetBuilder::new())
|
||||
|
||||
@@ -666,18 +666,16 @@ impl BrushMacro for AutoTileMacro {
|
||||
settings.widgets.value_field.sync(value, prop, ui);
|
||||
send_sync_message(
|
||||
ui,
|
||||
CheckBoxMessage::checked(
|
||||
UiMessage::for_widget(
|
||||
settings.widgets.adjacent_toggle,
|
||||
MessageDirection::ToWidget,
|
||||
adjacent,
|
||||
CheckBoxMessage::Check(adjacent),
|
||||
),
|
||||
);
|
||||
send_sync_message(
|
||||
ui,
|
||||
CheckBoxMessage::checked(
|
||||
UiMessage::for_widget(
|
||||
settings.widgets.diagonal_toggle,
|
||||
MessageDirection::ToWidget,
|
||||
diagonal,
|
||||
CheckBoxMessage::Check(diagonal),
|
||||
),
|
||||
);
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
|
||||
@@ -73,11 +73,7 @@ fn send_visibility(ui: &UserInterface, destination: Handle<UiNode>, visible: boo
|
||||
|
||||
fn highlight_tool_button(button: Handle<UiNode>, highlight: bool, ui: &UserInterface) {
|
||||
let decorator = *ui.try_get_of_type::<Button>(button).unwrap().decorator;
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
highlight,
|
||||
));
|
||||
ui.send(decorator, DecoratorMessage::Select(highlight));
|
||||
}
|
||||
|
||||
pub struct TileColliderEditor {
|
||||
|
||||
@@ -66,11 +66,7 @@ const DEFAULT_PAGE: Vector2<i32> = Vector2::new(0, 0);
|
||||
|
||||
fn highlight_tool_button(button: Handle<UiNode>, highlight: bool, ui: &UserInterface) {
|
||||
let decorator = *ui.try_get_of_type::<Button>(button).unwrap().decorator;
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
highlight,
|
||||
));
|
||||
ui.send(decorator, DecoratorMessage::Select(highlight));
|
||||
}
|
||||
|
||||
fn make_resource_chooser(
|
||||
|
||||
@@ -466,11 +466,7 @@ fn highlight_tool_button(button: Handle<UiNode>, highlight: bool, ui: &UserInter
|
||||
return;
|
||||
}
|
||||
let decorator = *ui.try_get_of_type::<Button>(button).unwrap().decorator;
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
highlight,
|
||||
));
|
||||
ui.send(decorator, DecoratorMessage::Select(highlight));
|
||||
}
|
||||
|
||||
fn send_visibility(ui: &UserInterface, destination: Handle<UiNode>, visible: bool) {
|
||||
|
||||
@@ -782,26 +782,15 @@ fn apply_specs_to_nine(specs: &NineButtonSpec, handle: Handle<UiNode>, ui: &mut
|
||||
MessageDirection::ToWidget,
|
||||
specs.foreground_brush().into(),
|
||||
));
|
||||
ui.send_message(DecoratorMessage::selected_brush(
|
||||
ui.send_many(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
specs.selected_brush().into(),
|
||||
));
|
||||
ui.send_message(DecoratorMessage::normal_brush(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
specs.normal_brush().into(),
|
||||
));
|
||||
ui.send_message(DecoratorMessage::pressed_brush(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
specs.pressed_brush().into(),
|
||||
));
|
||||
ui.send_message(DecoratorMessage::hover_brush(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
specs.hover_brush().into(),
|
||||
));
|
||||
[
|
||||
DecoratorMessage::SelectedBrush(specs.selected_brush().into()),
|
||||
DecoratorMessage::NormalBrush(specs.normal_brush().into()),
|
||||
DecoratorMessage::PressedBrush(specs.pressed_brush().into()),
|
||||
DecoratorMessage::HoverBrush(specs.hover_brush().into()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Use [`ButtonBuilder`] to create a buttons to represent one of the nine buttons
|
||||
|
||||
@@ -596,11 +596,10 @@ impl TileSetEditor {
|
||||
.try_get_of_type::<Button>(self.pick_button)
|
||||
.unwrap()
|
||||
.decorator;
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
ui.send(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
self.state.lock().drawing_mode == DrawingMode::Pick,
|
||||
));
|
||||
DecoratorMessage::Select(self.state.lock().drawing_mode == DrawingMode::Pick),
|
||||
);
|
||||
let cell_position = self.cell_position();
|
||||
ui.send_message(TextMessage::text(
|
||||
self.cell_position,
|
||||
|
||||
@@ -658,10 +658,9 @@ impl BrushMacro for WfcMacro {
|
||||
self.frequency_list.sync(frequency_id, tile_set, ui);
|
||||
send_sync_message(
|
||||
ui,
|
||||
CheckBoxMessage::checked(
|
||||
UiMessage::for_widget(
|
||||
self.edges_toggle,
|
||||
MessageDirection::ToWidget,
|
||||
Some(instance.constrain_edges),
|
||||
CheckBoxMessage::Check(Some(instance.constrain_edges)),
|
||||
),
|
||||
);
|
||||
send_sync_message(
|
||||
|
||||
@@ -211,24 +211,21 @@ impl GridSnappingMenu {
|
||||
match message {
|
||||
SettingsMessage::Changed => {
|
||||
if let Some(button) = ui.try_get_of_type::<Button>(self.button) {
|
||||
ui.send_message(DecoratorMessage::selected_brush(
|
||||
ui.send_many(
|
||||
*button.decorator,
|
||||
MessageDirection::ToWidget,
|
||||
ui.style.property(Style::BRUSH_BRIGHT_BLUE),
|
||||
));
|
||||
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
*button.decorator,
|
||||
MessageDirection::ToWidget,
|
||||
settings.move_mode_settings.grid_snapping,
|
||||
));
|
||||
[
|
||||
DecoratorMessage::SelectedBrush(
|
||||
ui.style.property(Style::BRUSH_BRIGHT_BLUE),
|
||||
),
|
||||
DecoratorMessage::Select(settings.move_mode_settings.grid_snapping),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
ui.send(
|
||||
self.enabled,
|
||||
MessageDirection::ToWidget,
|
||||
Some(settings.move_mode_settings.grid_snapping),
|
||||
));
|
||||
CheckBoxMessage::Check(Some(settings.move_mode_settings.grid_snapping)),
|
||||
);
|
||||
|
||||
ui.send_message(NumericUpDownMessage::value(
|
||||
self.x_step,
|
||||
@@ -618,14 +615,10 @@ impl SceneViewer {
|
||||
.unwrap()
|
||||
.decorator;
|
||||
|
||||
engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.send_message(DecoratorMessage::select(
|
||||
decorator,
|
||||
MessageDirection::ToWidget,
|
||||
mode_button == active_button,
|
||||
));
|
||||
engine.user_interfaces.first().send(
|
||||
decorator,
|
||||
DecoratorMessage::Select(mode_button == active_button),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,11 +184,7 @@ fn colorize(handle: Handle<UiNode>, ui: &UserInterface, index: &mut usize) {
|
||||
};
|
||||
|
||||
if *decorator.normal_brush != new_brush {
|
||||
ui.send_message(DecoratorMessage::normal_brush(
|
||||
handle,
|
||||
MessageDirection::ToWidget,
|
||||
new_brush,
|
||||
));
|
||||
ui.send(handle, DecoratorMessage::NormalBrush(new_brush));
|
||||
}
|
||||
|
||||
*index += 1;
|
||||
|
||||
+15
-59
@@ -32,9 +32,8 @@ use crate::{
|
||||
algebra::Vector2, color::Color, pool::Handle, reflect::prelude::*, type_traits::prelude::*,
|
||||
variable::InheritableVariable, visitor::prelude::*,
|
||||
},
|
||||
define_constructor,
|
||||
grid::{Column, GridBuilder, Row},
|
||||
message::{KeyCode, MessageDirection, UiMessage},
|
||||
message::{KeyCode, UiMessage},
|
||||
style::{resource::StyleResourceExt, Style},
|
||||
vector_image::{Primitive, VectorImageBuilder},
|
||||
widget::{Widget, WidgetBuilder, WidgetMessage},
|
||||
@@ -52,13 +51,6 @@ pub enum CheckBoxMessage {
|
||||
}
|
||||
impl MessageData for CheckBoxMessage {}
|
||||
|
||||
impl CheckBoxMessage {
|
||||
define_constructor!(
|
||||
/// Creates [`CheckBoxMessage::checked`] message.
|
||||
CheckBoxMessage:Check => fn checked(Option<bool>)
|
||||
);
|
||||
}
|
||||
|
||||
/// Checkbox is a UI widget that have three states - `Checked`, `Unchecked` and `Undefined`. In most cases it is used
|
||||
/// only with two values which fits in `bool` type. Third, undefined, state is used for specific situations when your
|
||||
/// data have such state.
|
||||
@@ -221,35 +213,24 @@ impl Control for CheckBox {
|
||||
|
||||
if let Some(value) = *self.checked {
|
||||
// Invert state if it is defined.
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
Some(!value),
|
||||
));
|
||||
ui.send(self.handle(), CheckBoxMessage::Check(Some(!value)));
|
||||
} else {
|
||||
// Switch from undefined state to checked.
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
Some(true),
|
||||
));
|
||||
ui.send(self.handle(), CheckBoxMessage::Check(Some(true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
WidgetMessage::KeyDown(key_code) => {
|
||||
if !message.handled() && *key_code == KeyCode::Space {
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
self.handle,
|
||||
MessageDirection::ToWidget,
|
||||
self.checked.map(|checked| !checked),
|
||||
));
|
||||
let checked = self.checked.map(|checked| !checked);
|
||||
ui.send(self.handle, CheckBoxMessage::Check(checked));
|
||||
message.set_handled(true);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
} else if let Some(&CheckBoxMessage::Check(value)) = message.data::<CheckBoxMessage>() {
|
||||
if message.is_for(self.handle()) && *self.checked != value {
|
||||
} else if let Some(&CheckBoxMessage::Check(value)) = message.data_for(self.handle) {
|
||||
if *self.checked != value {
|
||||
self.checked.set_value_and_mark_modified(value);
|
||||
|
||||
ui.send_message(message.reverse());
|
||||
@@ -257,38 +238,14 @@ impl Control for CheckBox {
|
||||
if self.check_mark.is_some() {
|
||||
match value {
|
||||
None => {
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
*self.check_mark,
|
||||
MessageDirection::ToWidget,
|
||||
false,
|
||||
));
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
*self.uncheck_mark,
|
||||
MessageDirection::ToWidget,
|
||||
false,
|
||||
));
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
*self.undefined_mark,
|
||||
MessageDirection::ToWidget,
|
||||
true,
|
||||
));
|
||||
ui.send(*self.check_mark, WidgetMessage::Visibility(false));
|
||||
ui.send(*self.uncheck_mark, WidgetMessage::Visibility(false));
|
||||
ui.send(*self.undefined_mark, WidgetMessage::Visibility(true));
|
||||
}
|
||||
Some(value) => {
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
*self.check_mark,
|
||||
MessageDirection::ToWidget,
|
||||
value,
|
||||
));
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
*self.uncheck_mark,
|
||||
MessageDirection::ToWidget,
|
||||
!value,
|
||||
));
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
*self.undefined_mark,
|
||||
MessageDirection::ToWidget,
|
||||
false,
|
||||
));
|
||||
ui.send(*self.check_mark, WidgetMessage::Visibility(value));
|
||||
ui.send(*self.uncheck_mark, WidgetMessage::Visibility(!value));
|
||||
ui.send(*self.undefined_mark, WidgetMessage::Visibility(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,9 +445,9 @@ impl CheckBoxBuilder {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::message::UiMessage;
|
||||
use crate::{
|
||||
check_box::{CheckBoxBuilder, CheckBoxMessage},
|
||||
message::MessageDirection,
|
||||
widget::WidgetBuilder,
|
||||
UserInterface,
|
||||
};
|
||||
@@ -507,8 +464,7 @@ mod test {
|
||||
assert_eq!(ui.poll_message(), None);
|
||||
|
||||
// Check messages
|
||||
let input_message =
|
||||
CheckBoxMessage::checked(check_box, MessageDirection::ToWidget, Some(true));
|
||||
let input_message = UiMessage::for_widget(check_box, CheckBoxMessage::Check(Some(true)));
|
||||
|
||||
ui.send_message(input_message.clone());
|
||||
|
||||
|
||||
+37
-77
@@ -23,26 +23,19 @@
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use crate::style::resource::StyleResourceExt;
|
||||
use crate::style::{Style, StyledProperty};
|
||||
use crate::widget::WidgetBuilder;
|
||||
use crate::{
|
||||
border::{Border, BorderBuilder},
|
||||
brush::Brush,
|
||||
core::{
|
||||
algebra::Vector2, pool::Handle, reflect::prelude::*, type_traits::prelude::*,
|
||||
visitor::prelude::*,
|
||||
uuid_provider, variable::InheritableVariable, visitor::prelude::*,
|
||||
},
|
||||
define_constructor,
|
||||
draw::DrawingContext,
|
||||
message::{MessageDirection, UiMessage},
|
||||
widget::{Widget, WidgetMessage},
|
||||
message::{MessageData, UiMessage},
|
||||
style::{resource::StyleResourceExt, Style, StyledProperty},
|
||||
widget::{Widget, WidgetBuilder, WidgetMessage},
|
||||
BuildContext, Control, UiNode, UserInterface,
|
||||
};
|
||||
|
||||
use crate::message::MessageData;
|
||||
use fyrox_core::uuid_provider;
|
||||
use fyrox_core::variable::InheritableVariable;
|
||||
use fyrox_graph::constructor::{ConstructorProvider, GraphNodeConstructor};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
@@ -62,29 +55,6 @@ pub enum DecoratorMessage {
|
||||
}
|
||||
impl MessageData for DecoratorMessage {}
|
||||
|
||||
impl DecoratorMessage {
|
||||
define_constructor!(
|
||||
/// Creates a [`DecoratorMessage::Select`] message.
|
||||
DecoratorMessage:Select => fn select(bool)
|
||||
);
|
||||
define_constructor!(
|
||||
/// Creates a [`DecoratorMessage::HoverBrush`] message.
|
||||
DecoratorMessage:HoverBrush => fn hover_brush(StyledProperty<Brush>)
|
||||
);
|
||||
define_constructor!(
|
||||
/// Creates a [`DecoratorMessage::NormalBrush`] message.
|
||||
DecoratorMessage:NormalBrush => fn normal_brush(StyledProperty<Brush>)
|
||||
);
|
||||
define_constructor!(
|
||||
/// Creates a [`DecoratorMessage::PressedBrush`] message.
|
||||
DecoratorMessage:PressedBrush => fn pressed_brush(StyledProperty<Brush>)
|
||||
);
|
||||
define_constructor!(
|
||||
/// Creates a [`DecoratorMessage::SelectedBrush`] message.
|
||||
DecoratorMessage:SelectedBrush => fn selected_brush(StyledProperty<Brush>)
|
||||
);
|
||||
}
|
||||
|
||||
/// A visual element that is used to highlight standard states of interactive widgets. It has "pressed", "hover",
|
||||
/// "selected", "normal" appearances (only one can be active at a time):
|
||||
///
|
||||
@@ -190,35 +160,32 @@ impl Control for Decorator {
|
||||
if *self.is_selected != value {
|
||||
self.is_selected.set_value_and_mark_modified(value);
|
||||
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
if *self.is_selected {
|
||||
WidgetMessage::Background(if *self.is_selected {
|
||||
(*self.selected_brush).clone()
|
||||
} else {
|
||||
(*self.normal_brush).clone()
|
||||
},
|
||||
));
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
DecoratorMessage::HoverBrush(brush) => {
|
||||
self.hover_brush.set_value_and_mark_modified(brush.clone());
|
||||
if self.has_descendant(ui.picked_node, ui) {
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
(*self.hover_brush).clone(),
|
||||
));
|
||||
WidgetMessage::Background((*self.hover_brush).clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
DecoratorMessage::NormalBrush(brush) => {
|
||||
self.normal_brush.set_value_and_mark_modified(brush.clone());
|
||||
if !*self.is_selected && !self.has_descendant(ui.picked_node, ui) {
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
(*self.normal_brush).clone(),
|
||||
));
|
||||
WidgetMessage::Background((*self.normal_brush).clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
DecoratorMessage::PressedBrush(brush) => {
|
||||
@@ -229,11 +196,10 @@ impl Control for Decorator {
|
||||
self.selected_brush
|
||||
.set_value_and_mark_modified(brush.clone());
|
||||
if *self.is_selected {
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
(*self.selected_brush).clone(),
|
||||
));
|
||||
WidgetMessage::Background((*self.selected_brush).clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,56 +209,50 @@ impl Control for Decorator {
|
||||
{
|
||||
match msg {
|
||||
WidgetMessage::MouseLeave => {
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
if *self.is_selected {
|
||||
WidgetMessage::Background(if *self.is_selected {
|
||||
(*self.selected_brush).clone()
|
||||
} else {
|
||||
(*self.normal_brush).clone()
|
||||
},
|
||||
));
|
||||
}),
|
||||
);
|
||||
}
|
||||
WidgetMessage::MouseEnter => {
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
if *self.is_selected {
|
||||
WidgetMessage::Background(if *self.is_selected {
|
||||
(*self.selected_brush).clone()
|
||||
} else {
|
||||
(*self.hover_brush).clone()
|
||||
},
|
||||
));
|
||||
}),
|
||||
);
|
||||
}
|
||||
WidgetMessage::MouseDown { .. } if *self.is_pressable => {
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
(*self.pressed_brush).clone(),
|
||||
));
|
||||
WidgetMessage::Background((*self.pressed_brush).clone()),
|
||||
);
|
||||
}
|
||||
WidgetMessage::MouseUp { .. } => {
|
||||
if *self.is_selected {
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
(*self.selected_brush).clone(),
|
||||
));
|
||||
WidgetMessage::Background((*self.selected_brush).clone()),
|
||||
);
|
||||
} else {
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
(*self.normal_brush).clone(),
|
||||
));
|
||||
WidgetMessage::Background((*self.normal_brush).clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
WidgetMessage::ResetVisual => {
|
||||
self.is_selected.set_value_and_mark_modified(false);
|
||||
ui.send_message(WidgetMessage::background(
|
||||
ui.send(
|
||||
self.handle(),
|
||||
MessageDirection::ToWidget,
|
||||
(*self.normal_brush).clone(),
|
||||
));
|
||||
WidgetMessage::Background((*self.normal_brush).clone()),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -191,11 +191,7 @@ impl Control for Expander {
|
||||
if let Some(&ExpanderMessage::Expand(expand)) = message.data::<ExpanderMessage>() {
|
||||
if message.is_for(self.handle()) && *self.is_expanded != expand {
|
||||
// Switch state of expander.
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
*self.expander,
|
||||
MessageDirection::ToWidget,
|
||||
Some(expand),
|
||||
));
|
||||
ui.send(*self.expander, CheckBoxMessage::Check(Some(expand)));
|
||||
// Show or hide content.
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
*self.content,
|
||||
|
||||
@@ -63,10 +63,9 @@ impl PropertyEditorDefinition for BoolPropertyEditorDefinition {
|
||||
ctx: PropertyEditorMessageContext,
|
||||
) -> Result<Option<UiMessage>, InspectorError> {
|
||||
let value = ctx.property_info.cast_value::<bool>()?;
|
||||
Ok(Some(CheckBoxMessage::checked(
|
||||
Ok(Some(UiMessage::for_widget(
|
||||
ctx.instance,
|
||||
MessageDirection::ToWidget,
|
||||
Some(*value),
|
||||
CheckBoxMessage::Check(Some(*value)),
|
||||
)))
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,12 @@ use crate::{
|
||||
core::{
|
||||
combine_uuids,
|
||||
pool::Handle,
|
||||
reflect::prelude::*,
|
||||
reflect::Reflect,
|
||||
reflect::{prelude::*, Reflect},
|
||||
uuid::{uuid, Uuid},
|
||||
visitor::prelude::*,
|
||||
TypeUuidProvider,
|
||||
ComponentProvider, TypeUuidProvider,
|
||||
},
|
||||
decorator::DecoratorBuilder,
|
||||
define_constructor,
|
||||
dropdown_list::{DropdownList, DropdownListBuilder, DropdownListMessage},
|
||||
inspector::{
|
||||
editors::{
|
||||
@@ -39,18 +37,15 @@ use crate::{
|
||||
PropertyEditorMessageContext, PropertyEditorTranslationContext,
|
||||
},
|
||||
make_expander_container, FieldKind, Inspector, InspectorBuilder, InspectorContext,
|
||||
InspectorEnvironment, InspectorError, InspectorMessage, PropertyChanged, PropertyFilter,
|
||||
InspectorContextArgs, InspectorEnvironment, InspectorError, InspectorMessage,
|
||||
PropertyChanged, PropertyFilter,
|
||||
},
|
||||
message::{MessageDirection, UiMessage},
|
||||
message::{MessageData, MessageDirection, UiMessage},
|
||||
text::TextBuilder,
|
||||
widget::{Widget, WidgetBuilder},
|
||||
BuildContext, Control, HorizontalAlignment, Thickness, UiNode, UserInterface,
|
||||
VerticalAlignment,
|
||||
};
|
||||
|
||||
use crate::inspector::InspectorContextArgs;
|
||||
use crate::message::MessageData;
|
||||
use fyrox_core::ComponentProvider;
|
||||
use fyrox_graph::BaseSceneGraph;
|
||||
use std::{
|
||||
any::TypeId,
|
||||
@@ -74,11 +69,6 @@ pub enum EnumPropertyEditorMessage {
|
||||
}
|
||||
impl MessageData for EnumPropertyEditorMessage {}
|
||||
|
||||
impl EnumPropertyEditorMessage {
|
||||
define_constructor!(EnumPropertyEditorMessage:Variant => fn variant(usize));
|
||||
define_constructor!(EnumPropertyEditorMessage:PropertyChanged => fn property_changed(PropertyChanged));
|
||||
}
|
||||
|
||||
#[derive(Visit, Reflect, ComponentProvider)]
|
||||
#[reflect(derived_type = "UiNode")]
|
||||
pub struct EnumPropertyEditor<T: InspectableEnum> {
|
||||
@@ -173,62 +163,41 @@ impl<T: InspectableEnum> Control for EnumPropertyEditor<T> {
|
||||
fn handle_routed_message(&mut self, ui: &mut UserInterface, message: &mut UiMessage) {
|
||||
self.widget.handle_routed_message(ui, message);
|
||||
|
||||
if let Some(EnumPropertyEditorMessage::Variant(variant)) =
|
||||
message.data::<EnumPropertyEditorMessage>()
|
||||
{
|
||||
if message.is_for(self.handle) {
|
||||
let variant = (self.definition.variant_generator)(*variant);
|
||||
if let Some(EnumPropertyEditorMessage::Variant(variant)) = message.data_for(self.handle) {
|
||||
let variant = (self.definition.variant_generator)(*variant);
|
||||
|
||||
let ctx = InspectorContext::from_object(InspectorContextArgs {
|
||||
object: &variant,
|
||||
ctx: &mut ui.build_ctx(),
|
||||
definition_container: self.definition_container.clone(),
|
||||
environment: self.environment.clone(),
|
||||
sync_flag: self.sync_flag,
|
||||
layer_index: self.layer_index,
|
||||
generate_property_string_values: self.generate_property_string_values,
|
||||
filter: self.filter.clone(),
|
||||
name_column_width: self.name_column_width,
|
||||
base_path: self.base_path.clone(),
|
||||
has_parent_object: self.has_parent_object,
|
||||
});
|
||||
let ctx = InspectorContext::from_object(InspectorContextArgs {
|
||||
object: &variant,
|
||||
ctx: &mut ui.build_ctx(),
|
||||
definition_container: self.definition_container.clone(),
|
||||
environment: self.environment.clone(),
|
||||
sync_flag: self.sync_flag,
|
||||
layer_index: self.layer_index,
|
||||
generate_property_string_values: self.generate_property_string_values,
|
||||
filter: self.filter.clone(),
|
||||
name_column_width: self.name_column_width,
|
||||
base_path: self.base_path.clone(),
|
||||
has_parent_object: self.has_parent_object,
|
||||
});
|
||||
|
||||
ui.send_message(InspectorMessage::context(
|
||||
self.inspector,
|
||||
MessageDirection::ToWidget,
|
||||
ctx,
|
||||
));
|
||||
|
||||
ui.send_message(message.reverse());
|
||||
}
|
||||
ui.send(self.inspector, InspectorMessage::Context(ctx));
|
||||
ui.send_message(message.reverse());
|
||||
} else if let Some(InspectorMessage::PropertyChanged(property_changed)) =
|
||||
message.data::<InspectorMessage>()
|
||||
message.data_from(self.inspector)
|
||||
{
|
||||
if message.destination() == self.inspector
|
||||
&& message.direction() == MessageDirection::FromWidget
|
||||
{
|
||||
ui.send_message(EnumPropertyEditorMessage::property_changed(
|
||||
self.handle,
|
||||
MessageDirection::FromWidget,
|
||||
property_changed.clone(),
|
||||
))
|
||||
}
|
||||
ui.post(
|
||||
self.handle,
|
||||
EnumPropertyEditorMessage::PropertyChanged(property_changed.clone()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn preview_message(&self, ui: &UserInterface, message: &mut UiMessage) {
|
||||
if message.direction() == MessageDirection::FromWidget
|
||||
&& message.destination() == self.variant_selector
|
||||
&& message.flags != LOCAL_SYNC_FLAG
|
||||
{
|
||||
if message.flags != LOCAL_SYNC_FLAG {
|
||||
if let Some(DropdownListMessage::SelectionChanged(Some(index))) =
|
||||
message.data::<DropdownListMessage>()
|
||||
message.data_from(self.variant_selector)
|
||||
{
|
||||
ui.send_message(EnumPropertyEditorMessage::variant(
|
||||
self.handle,
|
||||
MessageDirection::ToWidget,
|
||||
*index,
|
||||
));
|
||||
ui.send(self.handle, EnumPropertyEditorMessage::Variant(*index));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -581,13 +550,11 @@ where
|
||||
EnumPropertyEditorMessage::PropertyChanged(property_changed) => {
|
||||
Some(PropertyChanged {
|
||||
name: ctx.name.to_string(),
|
||||
|
||||
value: FieldKind::Inspectable(Box::new(property_changed.clone())),
|
||||
})
|
||||
}
|
||||
EnumPropertyEditorMessage::Variant(index) => Some(PropertyChanged {
|
||||
name: ctx.name.to_string(),
|
||||
|
||||
value: FieldKind::object((self.variant_generator)(*index)),
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -21,15 +21,12 @@
|
||||
//! Property editor for [`InheritableVariable`]. It acts like a proxy to inner property, but also
|
||||
//! adds special "revert" button that is used to revert value to its parent's value.
|
||||
|
||||
use crate::message::MessageData;
|
||||
use crate::resources::REVERT_ICON;
|
||||
use crate::{
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
core::{
|
||||
pool::Handle, reflect::prelude::*, reflect::FieldValue, type_traits::prelude::*,
|
||||
uuid_provider, variable::InheritableVariable, visitor::prelude::*, PhantomDataSendSync,
|
||||
},
|
||||
define_constructor,
|
||||
grid::{Column, GridBuilder, Row},
|
||||
image::ImageBuilder,
|
||||
inspector::{
|
||||
@@ -39,7 +36,8 @@ use crate::{
|
||||
},
|
||||
FieldKind, InheritableAction, InspectorError, PropertyChanged,
|
||||
},
|
||||
message::UiMessage,
|
||||
message::{MessageData, UiMessage},
|
||||
resources::REVERT_ICON,
|
||||
style::{resource::StyleResourceExt, Style},
|
||||
utils::make_simple_tooltip,
|
||||
widget::WidgetBuilder,
|
||||
@@ -60,11 +58,6 @@ pub enum InheritablePropertyEditorMessage {
|
||||
}
|
||||
impl MessageData for InheritablePropertyEditorMessage {}
|
||||
|
||||
impl InheritablePropertyEditorMessage {
|
||||
define_constructor!(InheritablePropertyEditorMessage:Revert => fn revert());
|
||||
define_constructor!(InheritablePropertyEditorMessage:Modified => fn modified(bool));
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Visit, Reflect, ComponentProvider)]
|
||||
#[reflect(derived_type = "UiNode")]
|
||||
pub struct InheritablePropertyEditor {
|
||||
@@ -93,20 +86,11 @@ impl Control for InheritablePropertyEditor {
|
||||
fn handle_routed_message(&mut self, ui: &mut UserInterface, message: &mut UiMessage) {
|
||||
self.widget.handle_routed_message(ui, message);
|
||||
|
||||
if let Some(ButtonMessage::Click) = message.data() {
|
||||
if message.destination() == self.revert {
|
||||
ui.send_message(InheritablePropertyEditorMessage::revert(
|
||||
self.handle,
|
||||
MessageDirection::FromWidget,
|
||||
));
|
||||
}
|
||||
if let Some(ButtonMessage::Click) = message.data_from(self.revert) {
|
||||
ui.post(self.handle, InheritablePropertyEditorMessage::Revert);
|
||||
} else if let Some(InheritablePropertyEditorMessage::Modified(modified)) = message.data() {
|
||||
if message.destination() == self.handle {
|
||||
ui.send_message(WidgetMessage::visibility(
|
||||
self.revert,
|
||||
MessageDirection::ToWidget,
|
||||
*modified,
|
||||
));
|
||||
ui.send(self.revert, WidgetMessage::Visibility(*modified));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,16 +310,15 @@ where
|
||||
.cast::<InheritablePropertyEditor>()
|
||||
.unwrap();
|
||||
|
||||
ctx.ui
|
||||
.send_message(InheritablePropertyEditorMessage::modified(
|
||||
instance.handle,
|
||||
MessageDirection::ToWidget,
|
||||
ctx.has_parent_object
|
||||
&& ctx
|
||||
.property_info
|
||||
.cast_value::<InheritableVariable<T>>()?
|
||||
.is_modified(),
|
||||
));
|
||||
let is_modified = ctx.has_parent_object
|
||||
&& ctx
|
||||
.property_info
|
||||
.cast_value::<InheritableVariable<T>>()?
|
||||
.is_modified();
|
||||
ctx.ui.send(
|
||||
instance.handle,
|
||||
InheritablePropertyEditorMessage::Modified(is_modified),
|
||||
);
|
||||
|
||||
let property_info = ctx.property_info;
|
||||
|
||||
@@ -382,7 +365,6 @@ where
|
||||
if let Some(InheritablePropertyEditorMessage::Revert) = ctx.message.data() {
|
||||
return Some(PropertyChanged {
|
||||
name: ctx.name.to_string(),
|
||||
|
||||
value: FieldKind::Inheritable(InheritableAction::Revert),
|
||||
});
|
||||
}
|
||||
@@ -397,7 +379,6 @@ where
|
||||
PropertyEditorTranslationContext {
|
||||
environment: ctx.environment.clone(),
|
||||
name: ctx.name,
|
||||
|
||||
message: ctx.message,
|
||||
definition_container: ctx.definition_container.clone(),
|
||||
},
|
||||
|
||||
@@ -151,23 +151,14 @@ impl Control for StyledPropertySelector {
|
||||
self.style_property_name = self.property_list[*selected_index].clone();
|
||||
}
|
||||
}
|
||||
} else if let Some(ButtonMessage::Click) = message.data() {
|
||||
if message.destination() == self.ok {
|
||||
ui.send_message(StyledPropertySelectorMessage::property_name(
|
||||
self.handle,
|
||||
MessageDirection::FromWidget,
|
||||
self.style_property_name.clone(),
|
||||
));
|
||||
ui.send_message(WindowMessage::close(
|
||||
self.handle,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
} else if message.destination() == self.cancel {
|
||||
ui.send_message(WindowMessage::close(
|
||||
self.handle,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
}
|
||||
} else if let Some(ButtonMessage::Click) = message.data_from(self.ok) {
|
||||
ui.post(
|
||||
self.handle,
|
||||
StyledPropertySelectorMessage::PropertyName(self.style_property_name.clone()),
|
||||
);
|
||||
ui.send(self.handle, WindowMessage::Close);
|
||||
} else if let Some(ButtonMessage::Click) = message.data_from(self.cancel) {
|
||||
ui.send(self.handle, WindowMessage::Close);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,11 +358,10 @@ impl Control for StyledPropertyEditor {
|
||||
if let Some(StyledPropertySelectorMessage::PropertyName(name)) =
|
||||
message.data_from(self.selector)
|
||||
{
|
||||
ui.send_message(StyledPropertyEditorMessage::bind_property(
|
||||
ui.post(
|
||||
self.handle,
|
||||
MessageDirection::FromWidget,
|
||||
name.clone(),
|
||||
))
|
||||
StyledPropertyEditorMessage::BindProperty(name.clone()),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use crate::{
|
||||
visitor::prelude::*,
|
||||
},
|
||||
decorator::DecoratorBuilder,
|
||||
define_constructor, define_widget_deref,
|
||||
define_widget_deref,
|
||||
draw::{CommandTexture, Draw, DrawingContext},
|
||||
grid::{Column, GridBuilder, Row},
|
||||
inspector::{
|
||||
@@ -70,10 +70,6 @@ pub enum TextureSliceEditorMessage {
|
||||
}
|
||||
impl MessageData for TextureSliceEditorMessage {}
|
||||
|
||||
impl TextureSliceEditorMessage {
|
||||
define_constructor!(TextureSliceEditorMessage:Slice => fn slice(TextureSlice));
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
struct DragContext {
|
||||
initial_position: Vector2<f32>,
|
||||
@@ -114,11 +110,10 @@ impl TextureSliceEditor {
|
||||
(self.slice_min_thumb, self.slice.margin_min()),
|
||||
(self.slice_max_thumb, self.slice.margin_max()),
|
||||
] {
|
||||
ui.send_message(WidgetMessage::desired_position(
|
||||
ui.send(
|
||||
thumb,
|
||||
MessageDirection::ToWidget,
|
||||
position.cast::<f32>(),
|
||||
))
|
||||
WidgetMessage::DesiredPosition(position.cast::<f32>()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,21 +363,19 @@ impl Control for TextureSliceEditor {
|
||||
}
|
||||
ThumbMessage::DragCompleted { .. } => {
|
||||
self.drag_context = None;
|
||||
ui.send_message(TextureSliceEditorMessage::slice(
|
||||
ui.post(
|
||||
self.handle(),
|
||||
MessageDirection::FromWidget,
|
||||
self.slice.clone(),
|
||||
));
|
||||
TextureSliceEditorMessage::Slice(self.slice.clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if let Some(WidgetMessage::MouseWheel { amount, .. }) = message.data() {
|
||||
self.scale = (self.scale + 0.1 * *amount).clamp(1.0, 10.0);
|
||||
|
||||
ui.send_message(WidgetMessage::layout_transform(
|
||||
ui.send(
|
||||
self.handle,
|
||||
MessageDirection::ToWidget,
|
||||
Matrix3::new_scaling(self.scale),
|
||||
));
|
||||
WidgetMessage::LayoutTransform(Matrix3::new_scaling(self.scale)),
|
||||
);
|
||||
|
||||
for thumb in [
|
||||
self.slice_min_thumb,
|
||||
@@ -390,16 +383,8 @@ impl Control for TextureSliceEditor {
|
||||
self.region_min_thumb,
|
||||
self.region_max_thumb,
|
||||
] {
|
||||
ui.send_message(WidgetMessage::width(
|
||||
thumb,
|
||||
MessageDirection::ToWidget,
|
||||
self.handle_size / self.scale,
|
||||
));
|
||||
ui.send_message(WidgetMessage::height(
|
||||
thumb,
|
||||
MessageDirection::ToWidget,
|
||||
self.handle_size / self.scale,
|
||||
));
|
||||
ui.send(thumb, WidgetMessage::Width(self.handle_size / self.scale));
|
||||
ui.send(thumb, WidgetMessage::Height(self.handle_size / self.scale));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -500,11 +485,10 @@ pub struct TextureSliceEditorWindow {
|
||||
|
||||
impl TextureSliceEditorWindow {
|
||||
fn on_slice_changed(&self, ui: &UserInterface) {
|
||||
ui.send_message(RectEditorMessage::value(
|
||||
ui.send(
|
||||
self.region,
|
||||
MessageDirection::ToWidget,
|
||||
*self.texture_slice.texture_region,
|
||||
));
|
||||
RectEditorMessage::Value(*self.texture_slice.texture_region),
|
||||
);
|
||||
|
||||
for (widget, value) in [
|
||||
(self.left_margin, &self.texture_slice.left_margin),
|
||||
@@ -512,19 +496,14 @@ impl TextureSliceEditorWindow {
|
||||
(self.top_margin, &self.texture_slice.top_margin),
|
||||
(self.bottom_margin, &self.texture_slice.bottom_margin),
|
||||
] {
|
||||
ui.send_message(NumericUpDownMessage::value(
|
||||
widget,
|
||||
MessageDirection::ToWidget,
|
||||
**value,
|
||||
));
|
||||
ui.send(widget, NumericUpDownMessage::Value(**value));
|
||||
}
|
||||
|
||||
// Send the slice to the parent editor.
|
||||
ui.send_message(TextureSliceEditorMessage::slice(
|
||||
ui.send(
|
||||
self.parent_editor,
|
||||
MessageDirection::ToWidget,
|
||||
self.texture_slice.clone(),
|
||||
));
|
||||
TextureSliceEditorMessage::Slice(self.texture_slice.clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,11 +566,10 @@ impl Control for TextureSliceEditorWindow {
|
||||
if message.is_for(self.handle()) && &self.texture_slice != slice {
|
||||
self.texture_slice = slice.clone();
|
||||
|
||||
ui.send_message(TextureSliceEditorMessage::slice(
|
||||
ui.send(
|
||||
self.slice_editor,
|
||||
MessageDirection::ToWidget,
|
||||
self.texture_slice.clone(),
|
||||
));
|
||||
TextureSliceEditorMessage::Slice(self.texture_slice.clone()),
|
||||
);
|
||||
|
||||
self.on_slice_changed(ui);
|
||||
}
|
||||
@@ -614,11 +592,7 @@ impl Control for TextureSliceEditorWindow {
|
||||
}
|
||||
}
|
||||
if target.is_some() {
|
||||
ui.send_message(TextureSliceEditorMessage::slice(
|
||||
self.handle,
|
||||
MessageDirection::ToWidget,
|
||||
slice,
|
||||
));
|
||||
ui.send(self.handle, TextureSliceEditorMessage::Slice(slice));
|
||||
}
|
||||
}
|
||||
} else if let Some(RectEditorMessage::Value(value)) =
|
||||
@@ -626,11 +600,7 @@ impl Control for TextureSliceEditorWindow {
|
||||
{
|
||||
let mut slice = self.texture_slice.clone();
|
||||
slice.texture_region.set_value_and_mark_modified(*value);
|
||||
ui.send_message(TextureSliceEditorMessage::slice(
|
||||
self.handle,
|
||||
MessageDirection::ToWidget,
|
||||
slice,
|
||||
));
|
||||
ui.send(self.handle, TextureSliceEditorMessage::Slice(slice));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,22 +759,23 @@ impl Control for TextureSliceFieldEditor {
|
||||
.with_texture_slice(self.texture_slice.clone())
|
||||
.build(self.handle, &mut ui.build_ctx());
|
||||
|
||||
ui.send_message(WindowMessage::open_modal(
|
||||
ui.send(
|
||||
self.editor,
|
||||
MessageDirection::ToWidget,
|
||||
true,
|
||||
true,
|
||||
));
|
||||
WindowMessage::OpenModal {
|
||||
center: true,
|
||||
focus_content: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if let Some(TextureSliceEditorMessage::Slice(slice)) = message.data() {
|
||||
if message.is_for(self.handle) && &self.texture_slice != slice {
|
||||
} else if let Some(TextureSliceEditorMessage::Slice(slice)) = message.data_for(self.handle)
|
||||
{
|
||||
if &self.texture_slice != slice {
|
||||
self.texture_slice = slice.clone();
|
||||
ui.send_message(message.reverse());
|
||||
ui.send_message(TextureSliceEditorMessage::slice(
|
||||
ui.send(
|
||||
self.editor,
|
||||
MessageDirection::ToWidget,
|
||||
self.texture_slice.clone(),
|
||||
));
|
||||
TextureSliceEditorMessage::Slice(self.texture_slice.clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -872,11 +843,10 @@ impl PropertyEditorDefinition for TextureSlicePropertyEditorDefinition {
|
||||
ctx: PropertyEditorMessageContext,
|
||||
) -> Result<Option<UiMessage>, InspectorError> {
|
||||
let value = ctx.property_info.cast_value::<TextureSlice>()?;
|
||||
Ok(Some(TextureSliceEditorMessage::slice(
|
||||
ctx.instance,
|
||||
MessageDirection::ToWidget,
|
||||
value.clone(),
|
||||
)))
|
||||
Ok(Some(
|
||||
UiMessage::with_data(TextureSliceEditorMessage::Slice(value.clone()))
|
||||
.with_destination(ctx.instance),
|
||||
))
|
||||
}
|
||||
|
||||
fn translate_message(&self, ctx: PropertyEditorTranslationContext) -> Option<PropertyChanged> {
|
||||
|
||||
@@ -324,11 +324,7 @@ impl ListView {
|
||||
if node.cast::<ListView>().is_some() {
|
||||
// Do nothing.
|
||||
} else if node.cast::<Decorator>().is_some() {
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
handle,
|
||||
MessageDirection::ToWidget,
|
||||
select,
|
||||
));
|
||||
ui.send(handle, DecoratorMessage::Select(select));
|
||||
} else {
|
||||
stack.extend_from_slice(node.children())
|
||||
}
|
||||
|
||||
@@ -690,17 +690,10 @@ impl Control for MenuItem {
|
||||
if *self.is_selected != *selected {
|
||||
self.is_selected.set_value_and_mark_modified(*selected);
|
||||
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
*self.decorator,
|
||||
MessageDirection::ToWidget,
|
||||
*selected,
|
||||
));
|
||||
ui.send(*self.decorator, DecoratorMessage::Select(*selected));
|
||||
|
||||
if *selected {
|
||||
ui.send_message(WidgetMessage::focus(
|
||||
self.handle,
|
||||
MessageDirection::ToWidget,
|
||||
));
|
||||
ui.send(self.handle, WidgetMessage::Focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,6 +384,16 @@ impl UiMessage {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new UI message with the given data for the specified widget.
|
||||
pub fn for_widget(
|
||||
handle: Handle<impl ObjectOrVariant<UiNode>>,
|
||||
data: impl MessageData,
|
||||
) -> Self {
|
||||
Self::with_data(data)
|
||||
.with_destination(handle.transmute())
|
||||
.with_direction(MessageDirection::ToWidget)
|
||||
}
|
||||
|
||||
/// Sets the desired destination of the message.
|
||||
pub fn with_destination(mut self, destination: Handle<UiNode>) -> Self {
|
||||
self.destination = destination;
|
||||
|
||||
@@ -373,11 +373,10 @@ impl TabControl {
|
||||
MessageDirection::ToWidget,
|
||||
active_tab == Some(existing_tab_index),
|
||||
));
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
ui.send(
|
||||
tab.decorator,
|
||||
MessageDirection::ToWidget,
|
||||
active_tab == Some(existing_tab_index),
|
||||
))
|
||||
DecoratorMessage::Select(active_tab == Some(existing_tab_index)),
|
||||
)
|
||||
}
|
||||
|
||||
self.active_tab = active_tab;
|
||||
|
||||
@@ -124,11 +124,7 @@ impl Control for ToggleButton {
|
||||
if self.is_toggled != *value {
|
||||
self.is_toggled = *value;
|
||||
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
self.decorator,
|
||||
MessageDirection::ToWidget,
|
||||
self.is_toggled,
|
||||
));
|
||||
ui.send(self.decorator, DecoratorMessage::Select(self.is_toggled));
|
||||
|
||||
ui.send_message(message.reverse());
|
||||
}
|
||||
|
||||
+5
-14
@@ -539,11 +539,10 @@ impl Control for Tree {
|
||||
WidgetMessage::DoubleClick { button } => {
|
||||
if *button == MouseButton::Left {
|
||||
// Mimic click on expander button to have uniform behavior.
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
ui.send(
|
||||
self.expander,
|
||||
MessageDirection::ToWidget,
|
||||
Some(!self.is_expanded),
|
||||
));
|
||||
CheckBoxMessage::Check(Some(!self.is_expanded)),
|
||||
);
|
||||
|
||||
message.set_handled(true);
|
||||
}
|
||||
@@ -566,11 +565,7 @@ impl Control for Tree {
|
||||
self.is_expanded,
|
||||
));
|
||||
|
||||
ui.send_message(CheckBoxMessage::checked(
|
||||
self.expander,
|
||||
MessageDirection::ToWidget,
|
||||
Some(expand),
|
||||
));
|
||||
ui.send(self.expander, CheckBoxMessage::Check(Some(expand)));
|
||||
|
||||
match expansion_strategy {
|
||||
TreeExpansionStrategy::RecursiveDescendants => {
|
||||
@@ -651,11 +646,7 @@ impl Control for Tree {
|
||||
&TreeMessage::Select(state) => {
|
||||
if self.is_selected != state.0 {
|
||||
self.is_selected = state.0;
|
||||
ui.send_message(DecoratorMessage::select(
|
||||
self.background,
|
||||
MessageDirection::ToWidget,
|
||||
self.is_selected,
|
||||
));
|
||||
ui.send(self.background, DecoratorMessage::Select(self.is_selected));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-21
@@ -29,27 +29,24 @@ mod upgrade;
|
||||
mod utils;
|
||||
|
||||
use crate::{manager::ProjectManager, settings::DATA_DIR, utils::make_button};
|
||||
use fyrox::asset::io::FsResourceIo;
|
||||
use fyrox::core::Uuid;
|
||||
use fyrox::engine::ApplicationLoopController;
|
||||
use fyrox::gui::font::FontStyles;
|
||||
use fyrox::{
|
||||
asset::{manager::ResourceManager, untyped::ResourceKind},
|
||||
asset::{io::FsResourceIo, manager::ResourceManager, untyped::ResourceKind},
|
||||
core::{
|
||||
algebra::Matrix3,
|
||||
log::{Log, MessageKind},
|
||||
task::TaskPool,
|
||||
Uuid,
|
||||
},
|
||||
dpi::PhysicalSize,
|
||||
engine::{
|
||||
Engine, EngineInitParams, GraphicsContext, GraphicsContextParams, SerializationContext,
|
||||
ApplicationLoopController, Engine, EngineInitParams, GraphicsContext,
|
||||
GraphicsContextParams, SerializationContext,
|
||||
},
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
gui::{
|
||||
constructor::new_widget_constructor_container,
|
||||
font::{Font, FontResource},
|
||||
message::MessageDirection,
|
||||
font::{Font, FontResource, FontStyles},
|
||||
widget::WidgetMessage,
|
||||
UserInterface,
|
||||
},
|
||||
@@ -63,11 +60,10 @@ use std::{
|
||||
|
||||
fn set_ui_scaling(ui: &UserInterface, scale: f32) {
|
||||
// High-DPI screen support
|
||||
ui.send_message(WidgetMessage::render_transform(
|
||||
ui.send(
|
||||
ui.root(),
|
||||
MessageDirection::ToWidget,
|
||||
Matrix3::new_scaling(scale),
|
||||
));
|
||||
WidgetMessage::RenderTransform(Matrix3::new_scaling(scale)),
|
||||
);
|
||||
}
|
||||
|
||||
#[allow(clippy::unnecessary_to_owned)]
|
||||
@@ -220,16 +216,13 @@ fn main() {
|
||||
|
||||
let logical_size = size.to_logical(window.scale_factor());
|
||||
let ui = engine.user_interfaces.first_mut();
|
||||
ui.send_message(WidgetMessage::width(
|
||||
ui.send_many(
|
||||
project_manager.root_grid,
|
||||
MessageDirection::ToWidget,
|
||||
logical_size.width,
|
||||
));
|
||||
ui.send_message(WidgetMessage::height(
|
||||
project_manager.root_grid,
|
||||
MessageDirection::ToWidget,
|
||||
logical_size.height,
|
||||
));
|
||||
[
|
||||
WidgetMessage::Width(logical_size.width),
|
||||
WidgetMessage::Height(logical_size.height),
|
||||
],
|
||||
);
|
||||
}
|
||||
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
||||
let ui = engine.user_interfaces.first_mut();
|
||||
|
||||
Reference in New Issue
Block a user