mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
typed handles for Button widget
This commit is contained in:
@@ -43,14 +43,15 @@ use crate::{
|
||||
message::MessageSender,
|
||||
Message,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub struct ResourceCreator {
|
||||
pub window: Handle<UiNode>,
|
||||
resource_constructors_list: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
name: Handle<UiNode>,
|
||||
selected: Option<usize>,
|
||||
supported_resource_data_uuids: Vec<Uuid>,
|
||||
|
||||
@@ -40,13 +40,14 @@ use crate::fyrox::{
|
||||
},
|
||||
};
|
||||
use fyrox::asset::manager::ResourceManager;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
|
||||
pub struct DependencyViewer {
|
||||
pub window: Handle<UiNode>,
|
||||
tree_root: Handle<UiNode>,
|
||||
close: Handle<UiNode>,
|
||||
copy_to_clipboard: Handle<UiNode>,
|
||||
close: Handle<Button>,
|
||||
copy_to_clipboard: Handle<Button>,
|
||||
resource_graph: Option<ResourceDependencyGraph>,
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ use std::{
|
||||
ops::{Deref, DerefMut},
|
||||
path::PathBuf,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
#[derive(Clone, Visit, Reflect, Debug, ComponentProvider, TypeUuidProvider)]
|
||||
#[reflect(derived_type = "UiNode")]
|
||||
@@ -66,8 +67,8 @@ use std::{
|
||||
struct AssetRenameDialog {
|
||||
window: Window,
|
||||
name_field: Handle<UiNode>,
|
||||
rename: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
rename: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
old_file_name: String,
|
||||
new_file_name: String,
|
||||
extension: String,
|
||||
|
||||
@@ -145,8 +145,8 @@ fn make_unique_path(parent: &Path, stem: &str, ext: &str) -> PathBuf {
|
||||
|
||||
struct InspectorAddon {
|
||||
root: Handle<UiNode>,
|
||||
apply: Handle<UiNode>,
|
||||
revert: Handle<UiNode>,
|
||||
apply: Handle<Button>,
|
||||
revert: Handle<Button>,
|
||||
preview: PreviewPanel,
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ pub struct AssetBrowser {
|
||||
folder_browser: Handle<UiNode>,
|
||||
scroll_panel: Handle<UiNode>,
|
||||
search_bar: Handle<UiNode>,
|
||||
add_resource: Handle<UiNode>,
|
||||
refresh: Handle<UiNode>,
|
||||
add_resource: Handle<Button>,
|
||||
refresh: Handle<Button>,
|
||||
items: Vec<Handle<UiNode>>,
|
||||
item_to_select: Option<PathBuf>,
|
||||
context_menu: AssetItemContextMenu,
|
||||
@@ -173,7 +173,7 @@ pub struct AssetBrowser {
|
||||
pub preview_generators: AssetPreviewGeneratorsCollection,
|
||||
inspector_addon: Option<InspectorAddon>,
|
||||
resource_event_receiver: Receiver<ResourceEvent>,
|
||||
resave_resources: Handle<UiNode>,
|
||||
resave_resources: Handle<Button>,
|
||||
}
|
||||
|
||||
fn is_path_in_registry(path: &Path, resource_manager: &ResourceManager) -> bool {
|
||||
|
||||
@@ -576,7 +576,7 @@ impl<'a> AssetSelectorWindowBuilder<'a> {
|
||||
#[derive(Reflect, Visit, Debug)]
|
||||
pub struct AssetSelectorMixin<T: TypedResourceData> {
|
||||
pub selector: Cell<Handle<UiNode>>,
|
||||
pub select: Handle<UiNode>,
|
||||
pub select: Handle<Button>,
|
||||
#[visit(skip)]
|
||||
#[reflect(hidden)]
|
||||
pub icon_request_sender: Sender<IconRequest>,
|
||||
@@ -602,7 +602,7 @@ impl<T: TypedResourceData> Clone for AssetSelectorMixin<T> {
|
||||
|
||||
impl<T: TypedResourceData> AssetSelectorMixin<T> {
|
||||
pub fn new(
|
||||
select: Handle<UiNode>,
|
||||
select: Handle<Button>,
|
||||
icon_request_sender: Sender<IconRequest>,
|
||||
resource_manager: ResourceManager,
|
||||
) -> Self {
|
||||
|
||||
@@ -63,6 +63,7 @@ use crate::{
|
||||
ChangeSelectionCommand, Command, GameScene, GridBuilder, MessageDirection, Mode, Selection,
|
||||
UserInterface,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use std::{cmp::Ordering, sync::mpsc::Sender};
|
||||
use strum::VariantNames;
|
||||
|
||||
@@ -178,8 +179,8 @@ impl SelectionContainer for AudioBusSelection {
|
||||
|
||||
pub struct AudioPanel {
|
||||
pub window: Handle<UiNode>,
|
||||
add_bus: Handle<UiNode>,
|
||||
remove_bus: Handle<UiNode>,
|
||||
add_bus: Handle<Button>,
|
||||
remove_bus: Handle<Button>,
|
||||
audio_buses: Handle<UiNode>,
|
||||
distance_model: Handle<UiNode>,
|
||||
renderer: Handle<UiNode>,
|
||||
|
||||
@@ -41,14 +41,15 @@ use crate::{
|
||||
scene::{GameScene, Selection},
|
||||
Message,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
pub struct AudioPreviewPanel {
|
||||
pub root_widget: Handle<UiNode>,
|
||||
preview: Handle<UiNode>,
|
||||
play: Handle<UiNode>,
|
||||
pause: Handle<UiNode>,
|
||||
stop: Handle<UiNode>,
|
||||
rewind: Handle<UiNode>,
|
||||
play: Handle<Button>,
|
||||
pause: Handle<Button>,
|
||||
stop: Handle<Button>,
|
||||
rewind: Handle<Button>,
|
||||
time: Handle<UiNode>,
|
||||
sounds_state: Vec<(Handle<Node>, Node)>,
|
||||
}
|
||||
|
||||
@@ -41,14 +41,15 @@ use crate::{
|
||||
utils::window_content,
|
||||
Message, Mode,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
pub struct CommandStackViewer {
|
||||
pub window: Handle<UiNode>,
|
||||
list: Handle<UiNode>,
|
||||
sender: MessageSender,
|
||||
undo: Handle<UiNode>,
|
||||
redo: Handle<UiNode>,
|
||||
clear: Handle<UiNode>,
|
||||
undo: Handle<Button>,
|
||||
redo: Handle<Button>,
|
||||
clear: Handle<Button>,
|
||||
}
|
||||
|
||||
impl CommandStackViewer {
|
||||
|
||||
@@ -47,6 +47,7 @@ use crate::{
|
||||
message::MessageSender,
|
||||
Engine, Message,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
#[derive(Default, Eq, PartialEq, Visit)]
|
||||
@@ -59,8 +60,8 @@ pub const HISTORY_PATH: &str = "history.bin";
|
||||
pub struct Configurator {
|
||||
pub window: Handle<UiNode>,
|
||||
work_dir_browser: Handle<UiNode>,
|
||||
select_work_dir: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
select_work_dir: Handle<Button>,
|
||||
ok: Handle<Button>,
|
||||
sender: MessageSender,
|
||||
work_dir: PathBuf,
|
||||
tb_work_dir: Handle<UiNode>,
|
||||
|
||||
@@ -64,6 +64,7 @@ use crate::{
|
||||
Message,
|
||||
};
|
||||
use cargo_metadata::camino::Utf8Path;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use std::{
|
||||
io::{BufRead, BufReader},
|
||||
@@ -122,8 +123,8 @@ pub type BuildResult = Result<BuildOutput, String>;
|
||||
pub struct ExportWindow {
|
||||
pub window: Handle<UiNode>,
|
||||
log: Handle<UiNode>,
|
||||
export: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
export: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
log_scroll_viewer: Handle<UiNode>,
|
||||
cancel_flag: Arc<AtomicBool>,
|
||||
log_message_receiver: Option<Receiver<LogMessage>>,
|
||||
|
||||
@@ -36,7 +36,7 @@ use crate::{
|
||||
style::{resource::StyleResourceExt, Style},
|
||||
utils::make_simple_tooltip,
|
||||
widget::WidgetBuilder,
|
||||
BuildContext, Thickness, UiNode,
|
||||
BuildContext, Thickness,
|
||||
},
|
||||
scene::{camera::Projection, graph::Graph, node::Node},
|
||||
},
|
||||
@@ -48,6 +48,7 @@ use crate::{
|
||||
};
|
||||
use fyrox::core::define_as_any_trait;
|
||||
use fyrox::core::pool::ObjectOrVariant;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::scene::camera::Camera;
|
||||
|
||||
pub mod gizmo;
|
||||
@@ -197,7 +198,7 @@ pub trait InteractionMode: InteractionModeAsAny {
|
||||
false
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode>;
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button>;
|
||||
|
||||
fn uuid(&self) -> Uuid;
|
||||
}
|
||||
@@ -207,7 +208,7 @@ pub fn make_interaction_mode_button(
|
||||
image: &[u8],
|
||||
tooltip: &str,
|
||||
selected: bool,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_tooltip(make_simple_tooltip(ctx, tooltip))
|
||||
|
||||
@@ -32,7 +32,7 @@ use crate::{
|
||||
},
|
||||
fxhash::FxHashSet,
|
||||
graph::SceneGraph,
|
||||
gui::{BuildContext, UiNode},
|
||||
gui::BuildContext,
|
||||
scene::{camera::Projection, graph::Graph, node::Node, Scene},
|
||||
},
|
||||
interaction::{
|
||||
@@ -50,6 +50,7 @@ use crate::{
|
||||
Engine, Message,
|
||||
};
|
||||
use fyrox::core::some_or_return;
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
struct Entry {
|
||||
node: Handle<Node>,
|
||||
@@ -501,7 +502,7 @@ impl InteractionMode for MoveInteractionMode {
|
||||
self.move_gizmo.set_visible(graph, false);
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
let move_mode_tooltip =
|
||||
"Move Object(s) - Shortcut: [2]\n\nMovement interaction mode allows you to move selected \
|
||||
objects. Keep in mind that movement always works in local coordinates!\n\n\
|
||||
|
||||
@@ -68,6 +68,7 @@ use crate::{
|
||||
utils::window_content,
|
||||
Mode,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -75,7 +76,7 @@ pub mod selection;
|
||||
|
||||
pub struct NavmeshPanel {
|
||||
pub window: Handle<UiNode>,
|
||||
connect_edges: Handle<UiNode>,
|
||||
connect_edges: Handle<Button>,
|
||||
sender: MessageSender,
|
||||
scene_frame: Handle<UiNode>,
|
||||
}
|
||||
@@ -677,7 +678,7 @@ impl InteractionMode for EditNavmeshMode {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
let navmesh_mode_tooltip =
|
||||
"Edit Navmesh - Shortcut: [5]\n\nNavmesh edit mode allows you to modify selected \
|
||||
navigational mesh.";
|
||||
|
||||
@@ -30,7 +30,7 @@ use crate::{
|
||||
uuid::{uuid, Uuid},
|
||||
TypeUuidProvider,
|
||||
},
|
||||
gui::{BuildContext, UiNode},
|
||||
gui::BuildContext,
|
||||
},
|
||||
interaction::{
|
||||
gizmo::rotate_gizmo::RotationGizmo, make_interaction_mode_button, InteractionMode,
|
||||
@@ -45,6 +45,7 @@ use crate::{
|
||||
world::selection::GraphSelection,
|
||||
Engine,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
pub struct RotateInteractionMode {
|
||||
initial_rotations: Vec<UnitQuaternion<f32>>,
|
||||
@@ -288,7 +289,7 @@ impl InteractionMode for RotateInteractionMode {
|
||||
self.rotation_gizmo.set_visible(graph, false);
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
let rotate_mode_tooltip =
|
||||
"Rotate Object(s) - Shortcut: [3]\n\nRotation interaction mode allows you to rotate selected \
|
||||
objects. Keep in mind that rotation always works in local coordinates!\n\n\
|
||||
|
||||
@@ -29,7 +29,7 @@ use crate::{
|
||||
uuid::{uuid, Uuid},
|
||||
TypeUuidProvider,
|
||||
},
|
||||
gui::{BuildContext, UiNode},
|
||||
gui::BuildContext,
|
||||
},
|
||||
interaction::{gizmo::scale_gizmo::ScaleGizmo, make_interaction_mode_button, InteractionMode},
|
||||
message::MessageSender,
|
||||
@@ -42,6 +42,7 @@ use crate::{
|
||||
world::selection::GraphSelection,
|
||||
Engine,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
pub struct ScaleInteractionMode {
|
||||
initial_scales: Vec<Vector3<f32>>,
|
||||
@@ -263,7 +264,7 @@ impl InteractionMode for ScaleInteractionMode {
|
||||
self.scale_gizmo.set_visible(graph, false);
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
let scale_mode_tooltip =
|
||||
"Scale Object(s) - Shortcut: [4]\n\nScaling interaction mode allows you to scale selected \
|
||||
objects. Keep in mind that scaling always works in local coordinates!\n\n\
|
||||
|
||||
@@ -37,6 +37,7 @@ use crate::{
|
||||
world::selection::GraphSelection,
|
||||
Engine,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::widget::WidgetMessage;
|
||||
|
||||
pub struct SelectInteractionMode {
|
||||
@@ -199,7 +200,7 @@ impl InteractionMode for SelectInteractionMode {
|
||||
) {
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
let select_mode_tooltip = "Select Object(s) - Shortcut: [1]\n\nSelection interaction mode \
|
||||
allows you to select an object by a single left mouse button click or multiple objects using either \
|
||||
frame selection (click and drag) or by holding Ctrl+Click";
|
||||
|
||||
@@ -75,6 +75,7 @@ use crate::{
|
||||
settings::Settings,
|
||||
};
|
||||
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::inspector::InspectorContextArgs;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use fyrox::scene::mesh::Mesh;
|
||||
@@ -531,7 +532,7 @@ impl InteractionMode for TerrainInteractionMode {
|
||||
processed
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
let terrain_mode_tooltip =
|
||||
"Edit Terrain - Shortcut: [6]\n\nTerrain edit mode allows you to modify selected \
|
||||
terrain.";
|
||||
|
||||
+3
-2
@@ -39,6 +39,7 @@ use crate::fyrox::{
|
||||
},
|
||||
};
|
||||
use crate::{scene::GameScene, Engine};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::inspector::editors::PropertyEditorDefinitionContainer;
|
||||
use fyrox::gui::inspector::{Inspector, InspectorContextArgs};
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
@@ -83,7 +84,7 @@ impl Default for LightmapperSettings {
|
||||
struct ProgressWindow {
|
||||
window: Handle<UiNode>,
|
||||
progress_bar: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
cancel: Handle<Button>,
|
||||
text: Handle<UiNode>,
|
||||
progress_indicator: ProgressIndicator,
|
||||
cancellation_token: CancellationToken,
|
||||
@@ -198,7 +199,7 @@ impl ProgressWindow {
|
||||
pub struct LightPanel {
|
||||
pub window: Handle<UiNode>,
|
||||
inspector: Handle<UiNode>,
|
||||
generate: Handle<UiNode>,
|
||||
generate: Handle<Button>,
|
||||
settings: LightmapperSettings,
|
||||
progress_window: Option<ProgressWindow>,
|
||||
sender: Sender<Result<Lightmap, LightmapGenerationError>>,
|
||||
|
||||
+7
-6
@@ -54,19 +54,20 @@ use crate::{
|
||||
world::selection::GraphSelection,
|
||||
Message,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::widget::WidgetMessage;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
|
||||
pub struct MeshControlPanel {
|
||||
pub root_widget: Handle<UiNode>,
|
||||
create_trimesh_collider: Handle<UiNode>,
|
||||
create_convex_collider: Handle<UiNode>,
|
||||
create_trimesh_rigid_body: Handle<UiNode>,
|
||||
add_convex_collider: Handle<UiNode>,
|
||||
add_trimesh_collider: Handle<UiNode>,
|
||||
create_trimesh_collider: Handle<Button>,
|
||||
create_convex_collider: Handle<Button>,
|
||||
create_trimesh_rigid_body: Handle<Button>,
|
||||
add_convex_collider: Handle<Button>,
|
||||
add_trimesh_collider: Handle<Button>,
|
||||
}
|
||||
|
||||
fn make_button(text: &str, tooltip: &str, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_button(text: &str, tooltip: &str, ctx: &mut BuildContext) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_margin(Thickness::uniform(1.0))
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::widget::WidgetMessage;
|
||||
|
||||
use crate::fyrox::graph::SceneGraph;
|
||||
@@ -44,12 +45,12 @@ use crate::{
|
||||
pub struct ParticleSystemPreviewControlPanel {
|
||||
pub root_widget: Handle<UiNode>,
|
||||
preview: Handle<UiNode>,
|
||||
play: Handle<UiNode>,
|
||||
pause: Handle<UiNode>,
|
||||
stop: Handle<UiNode>,
|
||||
rewind: Handle<UiNode>,
|
||||
play: Handle<Button>,
|
||||
pause: Handle<Button>,
|
||||
stop: Handle<Button>,
|
||||
rewind: Handle<Button>,
|
||||
time: Handle<UiNode>,
|
||||
set_time: Handle<UiNode>,
|
||||
set_time: Handle<Button>,
|
||||
particle_systems_state: Vec<(Handle<Node>, Node)>,
|
||||
desired_playback_time: f32,
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ use crate::fyrox::{
|
||||
};
|
||||
use crate::plugins::absm::selectable::{Selectable, SelectableMessage};
|
||||
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use fyrox::gui::style::resource::StyleResourceExt;
|
||||
use fyrox::gui::style::{Style, StyledProperty};
|
||||
@@ -67,12 +68,12 @@ where
|
||||
pub model_handle: Handle<T>,
|
||||
#[component(include)]
|
||||
pub base: AbsmBaseNode,
|
||||
pub add_input: Handle<UiNode>,
|
||||
pub add_input: Handle<Button>,
|
||||
input_sockets_panel: Handle<UiNode>,
|
||||
normal_brush: StyledProperty<Brush>,
|
||||
selected_brush: StyledProperty<Brush>,
|
||||
name: Handle<UiNode>,
|
||||
edit: Handle<UiNode>,
|
||||
edit: Handle<Button>,
|
||||
}
|
||||
|
||||
impl<T: Reflect> Debug for AbsmNode<T> {
|
||||
|
||||
@@ -55,6 +55,7 @@ use crate::{
|
||||
Selection,
|
||||
},
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::style::resource::StyleResourceExt;
|
||||
use fyrox::gui::style::Style;
|
||||
use fyrox::gui::utils::make_dropdown_list_option;
|
||||
@@ -66,9 +67,9 @@ pub struct Toolbar {
|
||||
pub preview: Handle<UiNode>,
|
||||
pub layers: Handle<UiNode>,
|
||||
pub layer_name: Handle<UiNode>,
|
||||
pub add_layer: Handle<UiNode>,
|
||||
pub remove_layer: Handle<UiNode>,
|
||||
pub edit_mask: Handle<UiNode>,
|
||||
pub add_layer: Handle<Button>,
|
||||
pub remove_layer: Handle<Button>,
|
||||
pub edit_mask: Handle<Button>,
|
||||
pub node_selector: Handle<UiNode>,
|
||||
}
|
||||
|
||||
|
||||
@@ -78,33 +78,33 @@ enum ImportMode {
|
||||
|
||||
pub struct Toolbar {
|
||||
pub panel: Handle<UiNode>,
|
||||
pub play_pause: Handle<UiNode>,
|
||||
pub stop: Handle<UiNode>,
|
||||
pub play_pause: Handle<Button>,
|
||||
pub stop: Handle<Button>,
|
||||
pub speed: Handle<UiNode>,
|
||||
pub animations: Handle<UiNode>,
|
||||
pub add_animation: Handle<UiNode>,
|
||||
pub remove_current_animation: Handle<UiNode>,
|
||||
pub rename_current_animation: Handle<UiNode>,
|
||||
pub clone_current_animation: Handle<UiNode>,
|
||||
pub add_animation: Handle<Button>,
|
||||
pub remove_current_animation: Handle<Button>,
|
||||
pub rename_current_animation: Handle<Button>,
|
||||
pub clone_current_animation: Handle<Button>,
|
||||
pub animation_name: Handle<UiNode>,
|
||||
pub preview: Handle<UiNode>,
|
||||
pub time_slice_start: Handle<UiNode>,
|
||||
pub time_slice_end: Handle<UiNode>,
|
||||
pub import: Handle<UiNode>,
|
||||
pub reimport: Handle<UiNode>,
|
||||
pub import: Handle<Button>,
|
||||
pub reimport: Handle<Button>,
|
||||
pub node_selector: Handle<UiNode>,
|
||||
pub import_file_selector: Handle<UiNode>,
|
||||
pub selected_import_root: ErasedHandle,
|
||||
pub looping: Handle<UiNode>,
|
||||
pub enabled: Handle<UiNode>,
|
||||
root_motion_dropdown_area: RootMotionDropdownArea,
|
||||
pub root_motion: Handle<UiNode>,
|
||||
pub root_motion: Handle<Button>,
|
||||
import_mode: ImportMode,
|
||||
}
|
||||
|
||||
struct RootMotionDropdownArea {
|
||||
popup: Handle<UiNode>,
|
||||
select_node: Handle<UiNode>,
|
||||
select_node: Handle<Button>,
|
||||
enabled: Handle<UiNode>,
|
||||
ignore_x: Handle<UiNode>,
|
||||
ignore_y: Handle<UiNode>,
|
||||
@@ -357,7 +357,7 @@ impl RootMotionDropdownArea {
|
||||
sync_checked(ui, self.enabled, root_motion_enabled);
|
||||
|
||||
for widget in [
|
||||
self.select_node,
|
||||
self.select_node.to_base(),
|
||||
self.ignore_x,
|
||||
self.ignore_y,
|
||||
self.ignore_z,
|
||||
@@ -367,11 +367,7 @@ impl RootMotionDropdownArea {
|
||||
}
|
||||
|
||||
if let Some(settings) = animation.root_motion_settings_ref() {
|
||||
let content = *ui
|
||||
.node(self.select_node)
|
||||
.query_component::<Button>()
|
||||
.unwrap()
|
||||
.content;
|
||||
let content = *ui[self.select_node].content;
|
||||
ui.send_sync(
|
||||
content,
|
||||
TextMessage::Text(
|
||||
@@ -906,7 +902,7 @@ impl Toolbar {
|
||||
} else if message.destination() == self.root_motion {
|
||||
ui.send(
|
||||
self.root_motion_dropdown_area.popup,
|
||||
PopupMessage::Placement(Placement::LeftBottom(self.root_motion)),
|
||||
PopupMessage::Placement(Placement::LeftBottom(self.root_motion.to_base())),
|
||||
);
|
||||
ui.send(self.root_motion_dropdown_area.popup, PopupMessage::Open);
|
||||
} else if message.destination() == self.remove_current_animation {
|
||||
@@ -1235,14 +1231,14 @@ impl Toolbar {
|
||||
for widget in [
|
||||
self.preview,
|
||||
self.speed,
|
||||
self.rename_current_animation,
|
||||
self.remove_current_animation,
|
||||
self.rename_current_animation.to_base(),
|
||||
self.remove_current_animation.to_base(),
|
||||
self.time_slice_start,
|
||||
self.time_slice_end,
|
||||
self.clone_current_animation,
|
||||
self.clone_current_animation.to_base(),
|
||||
self.looping,
|
||||
self.enabled,
|
||||
self.root_motion,
|
||||
self.root_motion.to_base(),
|
||||
] {
|
||||
ui.send_sync(widget, WidgetMessage::Enabled(selected_animation_valid));
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ use crate::{
|
||||
utils,
|
||||
};
|
||||
use fyrox::asset::Resource;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use fyrox::resource::model::ModelResource;
|
||||
@@ -505,9 +506,9 @@ impl TrackViewBuilder {
|
||||
struct Toolbar {
|
||||
panel: Handle<UiNode>,
|
||||
search_text: Handle<UiNode>,
|
||||
clear_search_text: Handle<UiNode>,
|
||||
collapse_all: Handle<UiNode>,
|
||||
expand_all: Handle<UiNode>,
|
||||
clear_search_text: Handle<Button>,
|
||||
collapse_all: Handle<Button>,
|
||||
expand_all: Handle<Button>,
|
||||
}
|
||||
|
||||
impl Toolbar {
|
||||
@@ -601,10 +602,10 @@ pub struct TrackList {
|
||||
toolbar: Toolbar,
|
||||
pub panel: Handle<UiNode>,
|
||||
tree_root: Handle<UiNode>,
|
||||
add_track: Handle<UiNode>,
|
||||
add_position_track: Handle<UiNode>,
|
||||
add_rotation_track: Handle<UiNode>,
|
||||
add_scale_track: Handle<UiNode>,
|
||||
add_track: Handle<Button>,
|
||||
add_position_track: Handle<Button>,
|
||||
add_rotation_track: Handle<Button>,
|
||||
add_scale_track: Handle<Button>,
|
||||
node_selector: Handle<UiNode>,
|
||||
property_selector: Handle<UiNode>,
|
||||
selected_node: ErasedHandle,
|
||||
|
||||
@@ -52,7 +52,7 @@ use crate::{
|
||||
},
|
||||
engine::Engine,
|
||||
graph::{SceneGraph, SceneGraphNode},
|
||||
gui::{message::UiMessage, BuildContext, UiNode},
|
||||
gui::{message::UiMessage, BuildContext},
|
||||
material::{
|
||||
shader::{ShaderResource, ShaderResourceExtension},
|
||||
Material, MaterialResource,
|
||||
@@ -85,6 +85,7 @@ use crate::{
|
||||
settings::Settings,
|
||||
Editor, Message,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::widget::WidgetMessage;
|
||||
use fyrox::scene::camera::Camera;
|
||||
use fyrox::scene::pivot::Pivot;
|
||||
@@ -669,7 +670,7 @@ impl InteractionMode for ColliderShapeInteractionMode {
|
||||
self.set_visibility(controller, engine, false)
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
make_interaction_mode_button(
|
||||
ctx,
|
||||
include_bytes!("../../../resources/triangle.png"),
|
||||
|
||||
@@ -42,11 +42,12 @@ use crate::{
|
||||
scene::{commands::GameSceneContext, GameScene, Selection},
|
||||
Message,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
pub struct ColliderControlPanel {
|
||||
pub root_widget: Handle<UiNode>,
|
||||
fit: Handle<UiNode>,
|
||||
edit: Handle<UiNode>,
|
||||
fit: Handle<Button>,
|
||||
edit: Handle<Button>,
|
||||
}
|
||||
|
||||
fn set_property<T: Reflect>(
|
||||
|
||||
@@ -50,6 +50,7 @@ use crate::{
|
||||
};
|
||||
use fyrox::asset::manager::ResourceManager;
|
||||
use fyrox::core::some_or_return;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::file_browser::{FileSelectorMode, FileType};
|
||||
use fyrox::gui::style::resource::StyleResourceExt;
|
||||
use fyrox::gui::style::Style;
|
||||
@@ -106,8 +107,8 @@ struct Menu {
|
||||
pub struct CurveEditorWindow {
|
||||
window: Handle<UiNode>,
|
||||
curve_editor: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
curve_resource: Option<CurveResource>,
|
||||
command_stack: CommandStack,
|
||||
menu: Menu,
|
||||
|
||||
@@ -185,7 +185,8 @@ where
|
||||
Ok(PropertyEditorInstance::Simple {
|
||||
editor: ButtonBuilder::new(WidgetBuilder::new())
|
||||
.with_text("Open Animation Editor...")
|
||||
.build(ctx.build_context),
|
||||
.build(ctx.build_context)
|
||||
.to_base(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -241,7 +242,8 @@ where
|
||||
Ok(PropertyEditorInstance::Simple {
|
||||
editor: ButtonBuilder::new(WidgetBuilder::new())
|
||||
.with_text("Open ABSM Editor...")
|
||||
.build(ctx.build_context),
|
||||
.build(ctx.build_context)
|
||||
.to_base(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ use crate::{
|
||||
Message, UiMessage, UiNode, UserInterface, VerticalAlignment,
|
||||
};
|
||||
use fyrox::core::PhantomDataSendSync;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use std::{
|
||||
@@ -107,15 +108,15 @@ impl MessageData for HandlePropertyEditorHierarchyMessage {}
|
||||
pub struct HandlePropertyEditor<T: Reflect> {
|
||||
widget: Widget,
|
||||
text: Handle<UiNode>,
|
||||
locate: Handle<UiNode>,
|
||||
select: Handle<UiNode>,
|
||||
make_unassigned: Handle<UiNode>,
|
||||
locate: Handle<Button>,
|
||||
select: Handle<Button>,
|
||||
make_unassigned: Handle<Button>,
|
||||
value: Handle<T>,
|
||||
#[visit(skip)]
|
||||
#[reflect(hidden)]
|
||||
sender: MessageSender,
|
||||
selector: Handle<UiNode>,
|
||||
pick: Handle<UiNode>,
|
||||
pick: Handle<Button>,
|
||||
}
|
||||
|
||||
impl<T: Reflect> Debug for HandlePropertyEditor<T> {
|
||||
|
||||
@@ -53,6 +53,7 @@ use crate::{
|
||||
plugins::inspector::EditorEnvironment,
|
||||
utils, Message,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use fyrox::gui::utils::make_asset_preview_tooltip;
|
||||
use std::{
|
||||
@@ -126,7 +127,7 @@ where
|
||||
#[visit(skip)]
|
||||
#[reflect(hidden)]
|
||||
resource: Option<Resource<T>>,
|
||||
locate: Handle<UiNode>,
|
||||
locate: Handle<Button>,
|
||||
#[visit(skip)]
|
||||
#[reflect(hidden)]
|
||||
sender: MessageSender,
|
||||
|
||||
@@ -53,6 +53,7 @@ use crate::{
|
||||
DropdownListBuilder,
|
||||
};
|
||||
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::inspector::InspectorContextArgs;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use fyrox::gui::utils::make_dropdown_list_option;
|
||||
@@ -76,7 +77,7 @@ pub struct ScriptPropertyEditor {
|
||||
widget: Widget,
|
||||
inspector: Handle<UiNode>,
|
||||
variant_selector: Handle<UiNode>,
|
||||
open_in_ide_button: Handle<UiNode>,
|
||||
open_in_ide_button: Handle<Button>,
|
||||
selected_script_uuid: Option<Uuid>,
|
||||
need_context_update: Cell<bool>,
|
||||
}
|
||||
@@ -213,7 +214,7 @@ impl ScriptPropertyEditorBuilder {
|
||||
|
||||
pub fn build(
|
||||
self,
|
||||
open_in_ide_button: Handle<UiNode>,
|
||||
open_in_ide_button: Handle<Button>,
|
||||
variant_selector: Handle<UiNode>,
|
||||
script_uuid: Option<Uuid>,
|
||||
environment: Option<Arc<dyn InspectorEnvironment>>,
|
||||
|
||||
@@ -42,6 +42,7 @@ use crate::{
|
||||
ShaderSourceCodeEditor, ShaderSourceCodeEditorBuilder, ShaderSourceCodeEditorMessage,
|
||||
},
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use std::{any::TypeId, cell::RefCell};
|
||||
|
||||
#[derive(Default, Clone, Visit, Reflect, Debug, TypeUuidProvider, ComponentProvider)]
|
||||
@@ -49,7 +50,7 @@ use std::{any::TypeId, cell::RefCell};
|
||||
#[reflect(derived_type = "UiNode")]
|
||||
pub struct ShaderSourceCodeEditorField {
|
||||
widget: Widget,
|
||||
button: Handle<UiNode>,
|
||||
button: Handle<Button>,
|
||||
code: RefCell<ShaderSourceCode>,
|
||||
editor: Handle<ShaderSourceCodeEditor>,
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ use crate::fyrox::{
|
||||
};
|
||||
use crate::plugins::inspector::editors::spritesheet::window::SpriteSheetFramesEditorWindow;
|
||||
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use std::any::TypeId;
|
||||
@@ -63,7 +64,7 @@ impl MessageData for SpriteSheetFramesPropertyEditorMessage {}
|
||||
#[reflect(derived_type = "UiNode")]
|
||||
pub struct SpriteSheetFramesPropertyEditor {
|
||||
widget: Widget,
|
||||
edit_button: Handle<UiNode>,
|
||||
edit_button: Handle<Button>,
|
||||
container: SpriteSheetFramesContainer,
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ use crate::fyrox::{
|
||||
};
|
||||
use crate::plugins::inspector::editors::spritesheet::SpriteSheetFramesPropertyEditorMessage;
|
||||
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::style::resource::StyleResourceExt;
|
||||
use fyrox::gui::style::Style;
|
||||
use std::{
|
||||
@@ -58,8 +59,8 @@ pub struct SpriteSheetFramesEditorWindow {
|
||||
#[component(include)]
|
||||
window: Window,
|
||||
editor: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
width: Handle<UiNode>,
|
||||
height: Handle<UiNode>,
|
||||
grid: Handle<UiNode>,
|
||||
|
||||
@@ -57,6 +57,7 @@ use crate::{
|
||||
Message,
|
||||
};
|
||||
use fyrox::gui::brush::Brush;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use std::{any::TypeId, sync::mpsc::Sender};
|
||||
|
||||
@@ -72,7 +73,7 @@ impl MessageData for SurfaceDataPropertyEditorMessage {}
|
||||
#[allow(dead_code)]
|
||||
pub struct SurfaceDataPropertyEditor {
|
||||
widget: Widget,
|
||||
view: Handle<UiNode>,
|
||||
view: Handle<Button>,
|
||||
surface_resource: SurfaceResource,
|
||||
text: Handle<UiNode>,
|
||||
image: Handle<UiNode>,
|
||||
|
||||
@@ -60,6 +60,7 @@ use crate::{
|
||||
utils::{make_square_image_button_with_tooltip, window_content},
|
||||
Editor, Message, WidgetMessage, WrapMode,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use std::{any::Any, sync::mpsc::Sender, sync::Arc};
|
||||
|
||||
pub mod editors;
|
||||
@@ -118,7 +119,7 @@ pub struct InspectorPlugin {
|
||||
pub footer: Handle<UiNode>,
|
||||
warning_text: Handle<UiNode>,
|
||||
type_name_text: Handle<UiNode>,
|
||||
docs_button: Handle<UiNode>,
|
||||
docs_button: Handle<Button>,
|
||||
clipboard: Option<Box<dyn Reflect>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ use crate::{
|
||||
utils::make_pick_button,
|
||||
Message, MessageDirection,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use std::{
|
||||
any::TypeId,
|
||||
@@ -79,8 +80,8 @@ pub struct MaterialFieldEditor {
|
||||
#[reflect(hidden)]
|
||||
sender: MessageSender,
|
||||
text: Handle<UiNode>,
|
||||
edit: Handle<UiNode>,
|
||||
make_unique: Handle<UiNode>,
|
||||
edit: Handle<Button>,
|
||||
make_unique: Handle<Button>,
|
||||
material: MaterialResource,
|
||||
image: Handle<UiNode>,
|
||||
image_preview: Handle<UiNode>,
|
||||
|
||||
@@ -52,11 +52,12 @@ use crate::{
|
||||
Editor, Message,
|
||||
};
|
||||
use fyrox::core::reflect::Reflect;
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
pub struct ReflectionProbePreviewControlPanel {
|
||||
pub root_widget: Handle<UiNode>,
|
||||
update: Handle<UiNode>,
|
||||
adjust: Handle<UiNode>,
|
||||
update: Handle<Button>,
|
||||
adjust: Handle<Button>,
|
||||
}
|
||||
|
||||
impl ReflectionProbePreviewControlPanel {
|
||||
@@ -301,7 +302,7 @@ impl InteractionMode for ReflectionProbeInteractionMode {
|
||||
self.set_visible(controller, engine, false);
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
make_interaction_mode_button(
|
||||
ctx,
|
||||
include_bytes!("../../resources/triangle.png"),
|
||||
|
||||
@@ -67,6 +67,7 @@ use crate::{
|
||||
world::selection::GraphSelection,
|
||||
Editor,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::scene::joint::Joint;
|
||||
use fyrox::scene::ragdoll::Ragdoll;
|
||||
use std::{ops::Range, sync::Arc};
|
||||
@@ -1010,9 +1011,9 @@ pub struct RagdollWizard {
|
||||
pub window: Handle<UiNode>,
|
||||
pub preset: RagdollPreset,
|
||||
inspector: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
autofill: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
autofill: Handle<Button>,
|
||||
clipboard: Option<Box<dyn Reflect>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ use crate::{
|
||||
};
|
||||
use fyrox::core::{ok_or_return, uuid, Uuid};
|
||||
use fyrox::engine::GraphicsContext;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::text_box::EmptyTextPlaceholder;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use rust_fuzzy_search::fuzzy_compare;
|
||||
@@ -63,8 +64,8 @@ struct GroupName(String);
|
||||
|
||||
pub struct SettingsWindow {
|
||||
pub window: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
default: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
default: Handle<Button>,
|
||||
inspector: Handle<UiNode>,
|
||||
groups: Handle<UiNode>,
|
||||
scroll_viewer: Handle<UiNode>,
|
||||
@@ -226,6 +227,7 @@ impl SettingsWindow {
|
||||
))))
|
||||
.with_text(&entry.property_display_name)
|
||||
.build(ctx)
|
||||
.to_base()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
ui.send(self.groups, WidgetMessage::ReplaceChildren(groups));
|
||||
|
||||
@@ -65,8 +65,8 @@ fn send_visibility(ui: &UserInterface, destination: Handle<UiNode>, visible: boo
|
||||
ui.send(destination, WidgetMessage::Visibility(visible));
|
||||
}
|
||||
|
||||
fn highlight_tool_button(button: Handle<UiNode>, highlight: bool, ui: &UserInterface) {
|
||||
let decorator = *ui.try_get_of_type::<Button>(button).unwrap().decorator;
|
||||
fn highlight_tool_button(button: Handle<Button>, highlight: bool, ui: &UserInterface) {
|
||||
let decorator = *ui[button].decorator;
|
||||
ui.send(decorator, DecoratorMessage::Select(highlight));
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ pub struct TileColliderEditor {
|
||||
value: TileCollider,
|
||||
/// The button which actives this editor as a draw tool
|
||||
/// and allows the user to apply this value to other tiles.
|
||||
draw_button: Handle<UiNode>,
|
||||
draw_button: Handle<Button>,
|
||||
/// The button which toggles the visibility of the collider layer.
|
||||
show_button: Handle<UiNode>,
|
||||
show_button: Handle<Button>,
|
||||
/// The widget that shows the color of the collider layer.
|
||||
color_icon: Handle<UiNode>,
|
||||
/// The widget for the name of the collider layer.
|
||||
@@ -269,7 +269,7 @@ impl TileEditor for TileColliderEditor {
|
||||
self.handle
|
||||
}
|
||||
|
||||
fn draw_button(&self) -> Handle<UiNode> {
|
||||
fn draw_button(&self) -> Handle<Button> {
|
||||
self.draw_button
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ fn make_button(
|
||||
tooltip: &str,
|
||||
icon: Option<TextureResource>,
|
||||
ctx: &mut BuildContext,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_tab_index(tab_index)
|
||||
@@ -397,7 +397,7 @@ fn make_button(
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
fn make_draw_button(tab_index: Option<usize>, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_draw_button(tab_index: Option<usize>, ctx: &mut BuildContext) -> Handle<Button> {
|
||||
make_button(
|
||||
tab_index,
|
||||
0,
|
||||
@@ -407,7 +407,7 @@ fn make_draw_button(tab_index: Option<usize>, ctx: &mut BuildContext) -> Handle<
|
||||
)
|
||||
}
|
||||
|
||||
fn make_show_button(tab_index: Option<usize>, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_show_button(tab_index: Option<usize>, ctx: &mut BuildContext) -> Handle<Button> {
|
||||
make_button(
|
||||
tab_index,
|
||||
1,
|
||||
|
||||
@@ -41,6 +41,7 @@ use fyrox::scene::tilemap::{tileset::*, *};
|
||||
|
||||
use super::*;
|
||||
use commands::*;
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
/// This is the tab of the tile set editor that allows the user to modify the collider
|
||||
/// layers stored within the tile set. Layers can be created, deleted, renamed
|
||||
@@ -48,10 +49,10 @@ use commands::*;
|
||||
pub struct CollidersTab {
|
||||
handle: Handle<UiNode>,
|
||||
list: Handle<UiNode>,
|
||||
up_button: Handle<UiNode>,
|
||||
down_button: Handle<UiNode>,
|
||||
remove_button: Handle<UiNode>,
|
||||
add_button: Handle<UiNode>,
|
||||
up_button: Handle<Button>,
|
||||
down_button: Handle<Button>,
|
||||
remove_button: Handle<Button>,
|
||||
add_button: Handle<Button>,
|
||||
data_panel: Handle<UiNode>,
|
||||
name_field: Handle<UiNode>,
|
||||
color_field: Handle<UiNode>,
|
||||
@@ -62,7 +63,7 @@ fn make_arrow_button(
|
||||
dir: ArrowDirection,
|
||||
column: usize,
|
||||
row: usize,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
let arrow = make_arrow(ctx, dir, 16.0);
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
@@ -81,7 +82,7 @@ fn make_button(
|
||||
ctx: &mut BuildContext,
|
||||
column: usize,
|
||||
row: usize,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_column(column)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
use std::any::TypeId;
|
||||
|
||||
use super::*;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::inspector::FieldKind;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use fyrox::{
|
||||
@@ -83,7 +84,7 @@ impl MessageData for TileDefinitionHandleEditorMessage {}
|
||||
pub struct TileDefinitionHandleEditor {
|
||||
widget: Widget,
|
||||
field: Handle<UiNode>,
|
||||
button: Handle<UiNode>,
|
||||
button: Handle<Button>,
|
||||
value: Option<TileDefinitionHandle>,
|
||||
allow_none: bool,
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ pub struct TileHandleField {
|
||||
widget: Widget,
|
||||
value: Option<TileDefinitionHandle>,
|
||||
field: Handle<UiNode>,
|
||||
palette_button: Handle<UiNode>,
|
||||
goto_button: Handle<UiNode>,
|
||||
palette_button: Handle<Button>,
|
||||
goto_button: Handle<Button>,
|
||||
}
|
||||
|
||||
define_widget_deref!(TileHandleField);
|
||||
|
||||
@@ -20,7 +20,12 @@
|
||||
|
||||
//! The [`InteractionMode`] for editing a tile map.
|
||||
|
||||
use crate::{
|
||||
command::{Command, CommandGroup},
|
||||
make_color_material,
|
||||
};
|
||||
use commands::{MoveMapTileCommand, SetMapTilesCommand};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::{
|
||||
asset::untyped::UntypedResource,
|
||||
core::SafeLock,
|
||||
@@ -34,11 +39,6 @@ use fyrox::{
|
||||
},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
command::{Command, CommandGroup},
|
||||
make_color_material,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
const CURSOR_COLOR: Color = Color::from_rgba(255, 255, 255, 30);
|
||||
@@ -813,7 +813,7 @@ impl InteractionMode for TileMapInteractionMode {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
make_interaction_mode_button(
|
||||
ctx,
|
||||
include_bytes!("../../../resources/tile.png"),
|
||||
|
||||
@@ -82,7 +82,7 @@ struct ItemEditor {
|
||||
struct ItemHeader {
|
||||
handle: Handle<UiNode>,
|
||||
label: Handle<UiNode>,
|
||||
button: Handle<UiNode>,
|
||||
button: Handle<Button>,
|
||||
}
|
||||
|
||||
impl ItemEditor {
|
||||
@@ -99,12 +99,12 @@ impl ItemEditor {
|
||||
};
|
||||
Self { handle, header }
|
||||
}
|
||||
fn button(&self) -> Handle<UiNode> {
|
||||
fn button(&self) -> Handle<Button> {
|
||||
self.header.button
|
||||
}
|
||||
}
|
||||
|
||||
fn make_button(title: &str, tooltip: &str, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_button(title: &str, tooltip: &str, ctx: &mut BuildContext) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_column(1)
|
||||
@@ -116,11 +116,11 @@ fn make_button(title: &str, tooltip: &str, ctx: &mut BuildContext) -> Handle<UiN
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
fn make_add_button(ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_add_button(ctx: &mut BuildContext) -> Handle<Button> {
|
||||
make_button(ADD_BUTTON_LABEL, ADD_TOOLTIP, ctx)
|
||||
}
|
||||
|
||||
fn make_remove_button(ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_remove_button(ctx: &mut BuildContext) -> Handle<Button> {
|
||||
make_button(REMOVE_BUTTON_LABEL, REMOVE_TOOLTIP, ctx)
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ impl ItemHeader {
|
||||
} else {
|
||||
ADD_BUTTON_LABEL
|
||||
};
|
||||
let button = ui.node(self.button).cast::<Button>().unwrap();
|
||||
let button = &ui[self.button];
|
||||
ui.send(*button.content, TextMessage::Text(button_text.into()));
|
||||
let tooltip = if has_cell {
|
||||
REMOVE_TOOLTIP
|
||||
@@ -390,7 +390,7 @@ impl MacroInspector {
|
||||
let Some(cell_editor) = item.editor.as_ref() else {
|
||||
continue;
|
||||
};
|
||||
if cell_editor.button() == message.destination() {
|
||||
if message.destination() == cell_editor.button() {
|
||||
let Some(brush_macro) = macro_list.get_by_uuid_mut(&item.macro_id) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
use core::f32;
|
||||
|
||||
use brush::{BrushMacroData, TileMapBrushResource};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::{
|
||||
button::ButtonMessage,
|
||||
grid::*,
|
||||
@@ -36,7 +37,6 @@ use fyrox::gui::{
|
||||
utils::{make_arrow, ArrowDirection},
|
||||
HorizontalAlignment, VerticalAlignment,
|
||||
};
|
||||
|
||||
use fyrox::scene::tilemap::*;
|
||||
|
||||
use super::*;
|
||||
@@ -52,9 +52,9 @@ pub struct MacroTab {
|
||||
current_macro_id: Option<Uuid>,
|
||||
macro_panel: Handle<UiNode>,
|
||||
list: Handle<UiNode>,
|
||||
up_button: Handle<UiNode>,
|
||||
down_button: Handle<UiNode>,
|
||||
remove_button: Handle<UiNode>,
|
||||
up_button: Handle<Button>,
|
||||
down_button: Handle<Button>,
|
||||
remove_button: Handle<Button>,
|
||||
add_buttons: Box<[Handle<UiNode>]>,
|
||||
data_panel: Handle<UiNode>,
|
||||
name_field: Handle<UiNode>,
|
||||
@@ -65,7 +65,7 @@ fn make_arrow_button(
|
||||
dir: ArrowDirection,
|
||||
column: usize,
|
||||
row: usize,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
let arrow = make_arrow(ctx, dir, 16.0);
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
@@ -84,7 +84,7 @@ fn make_button(
|
||||
ctx: &mut BuildContext,
|
||||
column: usize,
|
||||
row: usize,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_column(column)
|
||||
@@ -159,7 +159,7 @@ fn make_instance_items(
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn make_add_button(title: &str, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_add_button(title: &str, ctx: &mut BuildContext) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_height(24.0)
|
||||
@@ -172,7 +172,7 @@ fn make_add_button(title: &str, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_add_buttons(ctx: &mut BuildContext, macros: &BrushMacroList) -> Box<[Handle<UiNode>]> {
|
||||
macros
|
||||
.iter()
|
||||
.map(|m| make_add_button(m.name(), ctx))
|
||||
.map(|m| make_add_button(m.name(), ctx).to_base())
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ use crate::{
|
||||
};
|
||||
use fyrox::asset::manager::ResourceManager;
|
||||
use fyrox::engine::ApplicationLoopController;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
@@ -224,7 +225,7 @@ fn make_drawing_mode_button(
|
||||
image: Option<TextureResource>,
|
||||
tooltip: &str,
|
||||
tab_index: Option<usize>,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_tab_index(tab_index)
|
||||
|
||||
@@ -64,8 +64,8 @@ use fyrox::gui::window::WindowAlignment;
|
||||
|
||||
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;
|
||||
fn highlight_tool_button(button: Handle<Button>, highlight: bool, ui: &UserInterface) {
|
||||
let decorator = *ui[button].decorator;
|
||||
ui.send(decorator, DecoratorMessage::Select(highlight));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ fn make_resource_chooser(
|
||||
tooltip: &str,
|
||||
tab_index: Option<usize>,
|
||||
column: usize,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_column(column)
|
||||
@@ -128,33 +128,33 @@ pub struct TileMapPanel {
|
||||
/// The palette widget that allows the user to select the tiles to draw with.
|
||||
palette: Handle<UiNode>,
|
||||
/// The button that switches the control to using the current brush, if there is one.
|
||||
brush_button: Handle<UiNode>,
|
||||
brush_button: Handle<Button>,
|
||||
/// The button that switches the control to using the current tile set.
|
||||
tile_set_button: Handle<UiNode>,
|
||||
tile_set_button: Handle<Button>,
|
||||
/// Tool selection button for the draw tool.
|
||||
draw_button: Handle<UiNode>,
|
||||
draw_button: Handle<Button>,
|
||||
/// Tool selection button for the erase tool.
|
||||
erase_button: Handle<UiNode>,
|
||||
erase_button: Handle<Button>,
|
||||
/// Tool selection button for the flood fill tool.
|
||||
flood_fill_button: Handle<UiNode>,
|
||||
flood_fill_button: Handle<Button>,
|
||||
/// Tool selection button for the pick tool.
|
||||
pick_button: Handle<UiNode>,
|
||||
pick_button: Handle<Button>,
|
||||
/// Tool selection button for the rectangle fill tool.
|
||||
rect_fill_button: Handle<UiNode>,
|
||||
rect_fill_button: Handle<Button>,
|
||||
/// Tool selection button for the nine slice fill tool.
|
||||
nine_slice_button: Handle<UiNode>,
|
||||
nine_slice_button: Handle<Button>,
|
||||
/// Tool selection button for the line tool.
|
||||
line_button: Handle<UiNode>,
|
||||
line_button: Handle<Button>,
|
||||
/// Button that toggles the tools into random mode.
|
||||
random_button: Handle<UiNode>,
|
||||
random_button: Handle<Button>,
|
||||
/// Button to rotate the selected tiles counter-clockwise by 90 degrees.
|
||||
left_button: Handle<UiNode>,
|
||||
left_button: Handle<Button>,
|
||||
/// Button to rotate the selected tiles clockwise by 90 degrees.
|
||||
right_button: Handle<UiNode>,
|
||||
right_button: Handle<Button>,
|
||||
/// Button to horizontally flip the selected tiles.
|
||||
flip_x_button: Handle<UiNode>,
|
||||
flip_x_button: Handle<Button>,
|
||||
/// Button to vertically flip the selected tiles.
|
||||
flip_y_button: Handle<UiNode>,
|
||||
flip_y_button: Handle<Button>,
|
||||
}
|
||||
|
||||
impl TileMapPanel {
|
||||
@@ -684,8 +684,8 @@ impl TileMapPanel {
|
||||
/// Use the given UI to update the panel after the data the [`TileDrawState`] may have changed.
|
||||
pub fn sync_to_state(&self, ui: &mut UserInterface) {
|
||||
fn highlight_all_except(
|
||||
button: Handle<UiNode>,
|
||||
buttons: &[Handle<UiNode>],
|
||||
button: Handle<Button>,
|
||||
buttons: &[Handle<Button>],
|
||||
highlight: bool,
|
||||
ui: &UserInterface,
|
||||
) {
|
||||
@@ -697,7 +697,7 @@ impl TileMapPanel {
|
||||
}
|
||||
}
|
||||
}
|
||||
fn highlight_all(buttons: &[Handle<UiNode>], highlight: bool, ui: &UserInterface) {
|
||||
fn highlight_all(buttons: &[Handle<Button>], highlight: bool, ui: &UserInterface) {
|
||||
for button in buttons {
|
||||
highlight_tool_button(*button, highlight, ui);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ use fyrox::{
|
||||
|
||||
use super::*;
|
||||
use commands::*;
|
||||
use fyrox::core::pool::ObjectOrVariant;
|
||||
|
||||
/// This is the tab of the tile set editor that allows the user to modify the property
|
||||
/// layers stored within the tile set. Layers can be created, deleted, renamed
|
||||
@@ -52,19 +53,19 @@ use commands::*;
|
||||
pub struct PropertiesTab {
|
||||
handle: Handle<UiNode>,
|
||||
list: Handle<UiNode>,
|
||||
up_button: Handle<UiNode>,
|
||||
down_button: Handle<UiNode>,
|
||||
remove_button: Handle<UiNode>,
|
||||
add_int_button: Handle<UiNode>,
|
||||
add_float_button: Handle<UiNode>,
|
||||
add_string_button: Handle<UiNode>,
|
||||
add_nine_button: Handle<UiNode>,
|
||||
up_button: Handle<Button>,
|
||||
down_button: Handle<Button>,
|
||||
remove_button: Handle<Button>,
|
||||
add_int_button: Handle<Button>,
|
||||
add_float_button: Handle<Button>,
|
||||
add_string_button: Handle<Button>,
|
||||
add_nine_button: Handle<Button>,
|
||||
name_field: Handle<UiNode>,
|
||||
name_list: Handle<UiNode>,
|
||||
name_up: Handle<UiNode>,
|
||||
name_down: Handle<UiNode>,
|
||||
name_add: Handle<UiNode>,
|
||||
name_remove: Handle<UiNode>,
|
||||
name_up: Handle<Button>,
|
||||
name_down: Handle<Button>,
|
||||
name_add: Handle<Button>,
|
||||
name_remove: Handle<Button>,
|
||||
data_panel: Handle<UiNode>,
|
||||
name_edit_panel: Handle<UiNode>,
|
||||
value_name_field: Handle<UiNode>,
|
||||
@@ -79,7 +80,7 @@ fn make_arrow_button(
|
||||
dir: ArrowDirection,
|
||||
column: usize,
|
||||
row: usize,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
let arrow = make_arrow(ctx, dir, 16.0);
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
@@ -98,7 +99,7 @@ fn make_button(
|
||||
ctx: &mut BuildContext,
|
||||
column: usize,
|
||||
row: usize,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_column(column)
|
||||
@@ -228,7 +229,11 @@ fn send_visibility(ui: &UserInterface, destination: Handle<UiNode>, visible: boo
|
||||
ui.send(destination, WidgetMessage::Visibility(visible));
|
||||
}
|
||||
|
||||
fn send_enabled(ui: &UserInterface, destination: Handle<UiNode>, enabled: bool) {
|
||||
fn send_enabled(
|
||||
ui: &UserInterface,
|
||||
destination: Handle<impl ObjectOrVariant<UiNode>>,
|
||||
enabled: bool,
|
||||
) {
|
||||
ui.send(destination, WidgetMessage::Enabled(enabled));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,10 +55,10 @@ pub struct TileBoundsEditor {
|
||||
pub left_bottom: Handle<UiNode>,
|
||||
pub right_top: Handle<UiNode>,
|
||||
pub right_bottom: Handle<UiNode>,
|
||||
pub button_left: Handle<UiNode>,
|
||||
pub button_right: Handle<UiNode>,
|
||||
pub button_flip_x: Handle<UiNode>,
|
||||
pub button_flip_y: Handle<UiNode>,
|
||||
pub button_left: Handle<Button>,
|
||||
pub button_right: Handle<Button>,
|
||||
pub button_flip_x: Handle<Button>,
|
||||
pub button_flip_y: Handle<Button>,
|
||||
}
|
||||
|
||||
define_widget_deref!(TileBoundsEditor);
|
||||
|
||||
@@ -27,6 +27,7 @@ use std::sync::mpsc::Sender;
|
||||
use super::*;
|
||||
use crate::asset::preview::cache::IconRequest;
|
||||
use commands::*;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::{
|
||||
fxhash::FxHashMap,
|
||||
gui::{
|
||||
@@ -48,7 +49,7 @@ pub trait TileEditor: Send {
|
||||
fn handle(&self) -> Handle<UiNode>;
|
||||
/// The handle of the button which actives this editor for drawing its value onto other
|
||||
/// tiles.
|
||||
fn draw_button(&self) -> Handle<UiNode>;
|
||||
fn draw_button(&self) -> Handle<Button>;
|
||||
/// Slice mode means that the tile set editor allows the user to click on one of nine
|
||||
/// areas within each tile, instead of just clicking on the whole of the tile.
|
||||
/// Normally slice mode is false, because most editors edit the whole of any tile,
|
||||
@@ -112,7 +113,7 @@ fn make_draw_button(
|
||||
tooltip: &str,
|
||||
ctx: &mut BuildContext,
|
||||
tab_index: Option<usize>,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_column(1)
|
||||
@@ -149,7 +150,7 @@ fn make_draw_button(
|
||||
|
||||
fn make_drawable_field(
|
||||
label: &str,
|
||||
draw_button: Handle<UiNode>,
|
||||
draw_button: Handle<Button>,
|
||||
field: Handle<UiNode>,
|
||||
ctx: &mut BuildContext,
|
||||
) -> Handle<UiNode> {
|
||||
@@ -177,7 +178,7 @@ pub struct TileMaterialEditor {
|
||||
material_line: Handle<UiNode>,
|
||||
material_field: Handle<UiNode>,
|
||||
bounds_field: Handle<UiNode>,
|
||||
draw_button: Handle<UiNode>,
|
||||
draw_button: Handle<Button>,
|
||||
material_bounds: TileMaterialBounds,
|
||||
}
|
||||
|
||||
@@ -339,7 +340,7 @@ impl TileEditor for TileMaterialEditor {
|
||||
fn handle(&self) -> Handle<UiNode> {
|
||||
self.handle
|
||||
}
|
||||
fn draw_button(&self) -> Handle<UiNode> {
|
||||
fn draw_button(&self) -> Handle<Button> {
|
||||
self.draw_button
|
||||
}
|
||||
fn sync_to_model(&mut self, _state: &TileEditorState, _ui: &mut UserInterface) {}
|
||||
@@ -428,7 +429,7 @@ impl TileEditor for TileMaterialEditor {
|
||||
pub struct TileColorEditor {
|
||||
handle: Handle<UiNode>,
|
||||
field: Handle<UiNode>,
|
||||
draw_button: Handle<UiNode>,
|
||||
draw_button: Handle<Button>,
|
||||
color: Color,
|
||||
}
|
||||
|
||||
@@ -480,7 +481,7 @@ impl TileEditor for TileColorEditor {
|
||||
fn handle(&self) -> Handle<UiNode> {
|
||||
self.handle
|
||||
}
|
||||
fn draw_button(&self) -> Handle<UiNode> {
|
||||
fn draw_button(&self) -> Handle<Button> {
|
||||
self.draw_button
|
||||
}
|
||||
fn sync_to_model(&mut self, _state: &TileEditorState, _ui: &mut UserInterface) {}
|
||||
@@ -588,7 +589,7 @@ impl TileEditor for TileHandleEditor {
|
||||
fn handle(&self) -> Handle<UiNode> {
|
||||
self.handle
|
||||
}
|
||||
fn draw_button(&self) -> Handle<UiNode> {
|
||||
fn draw_button(&self) -> Handle<Button> {
|
||||
Handle::NONE
|
||||
}
|
||||
fn sync_to_model(&mut self, _state: &TileEditorState, _ui: &mut UserInterface) {}
|
||||
|
||||
@@ -56,6 +56,7 @@ use std::sync::mpsc::Sender;
|
||||
use super::*;
|
||||
use crate::asset::preview::cache::IconRequest;
|
||||
use commands::*;
|
||||
use fyrox::core::pool::ObjectOrVariant;
|
||||
use palette::*;
|
||||
|
||||
pub const FIELD_LABEL_WIDTH: f32 = 100.0;
|
||||
@@ -441,7 +442,7 @@ fn make_button(
|
||||
row: usize,
|
||||
column: usize,
|
||||
ctx: &mut BuildContext,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_row(row)
|
||||
@@ -460,15 +461,19 @@ fn make_label(name: &str, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
fn highlight_tool_button(button: Handle<UiNode>, highlight: bool, ui: &UserInterface) {
|
||||
fn highlight_tool_button(button: Handle<Button>, highlight: bool, ui: &UserInterface) {
|
||||
if button.is_none() {
|
||||
return;
|
||||
}
|
||||
let decorator = *ui.try_get_of_type::<Button>(button).unwrap().decorator;
|
||||
let decorator = *ui[button].decorator;
|
||||
ui.send(decorator, DecoratorMessage::Select(highlight));
|
||||
}
|
||||
|
||||
fn send_visibility(ui: &UserInterface, destination: Handle<UiNode>, visible: bool) {
|
||||
fn send_visibility(
|
||||
ui: &UserInterface,
|
||||
destination: Handle<impl ObjectOrVariant<UiNode>>,
|
||||
visible: bool,
|
||||
) {
|
||||
ui.send(destination, WidgetMessage::Visibility(visible));
|
||||
}
|
||||
|
||||
@@ -734,17 +739,17 @@ pub struct TileInspector {
|
||||
/// The editor for changing the frame rate of an animation page.
|
||||
animation_speed_inspector: InspectorField,
|
||||
/// Button for creating a brush tile.
|
||||
create_tile: Handle<UiNode>,
|
||||
create_tile: Handle<Button>,
|
||||
/// Button for creating a brush page.
|
||||
create_page: Handle<UiNode>,
|
||||
create_page: Handle<Button>,
|
||||
/// Button for creating an atlas page in a tile set.
|
||||
create_atlas: Handle<UiNode>,
|
||||
create_atlas: Handle<Button>,
|
||||
/// Button for creating a freeform page in a tile set.
|
||||
create_free: Handle<UiNode>,
|
||||
create_free: Handle<Button>,
|
||||
/// Button for creating a transform set page in a tile set.
|
||||
create_transform: Handle<UiNode>,
|
||||
create_transform: Handle<Button>,
|
||||
/// Button for creating a animation page in a tile set.
|
||||
create_animation: Handle<UiNode>,
|
||||
create_animation: Handle<Button>,
|
||||
/// A list of tile editors.
|
||||
#[visit(skip)]
|
||||
#[reflect(hidden)]
|
||||
|
||||
@@ -93,7 +93,7 @@ pub struct TilePropertyEditor {
|
||||
value: TileSetPropertyOptionValue,
|
||||
/// The button to activate the editor draw tool that allows this property value
|
||||
/// to be applied to other tiles.
|
||||
draw_button: Handle<UiNode>,
|
||||
draw_button: Handle<Button>,
|
||||
/// The label showing the name of the layer.
|
||||
name_field: Handle<UiNode>,
|
||||
/// The field for editing the current value.
|
||||
@@ -104,7 +104,7 @@ pub struct TilePropertyEditor {
|
||||
/// The dropdown list of pre-defined values.
|
||||
list: Handle<UiNode>,
|
||||
/// The handles of the buttons in the 9-button grid.
|
||||
nine_buttons: Option<Box<[Handle<UiNode>; 9]>>,
|
||||
nine_buttons: Option<Box<[Handle<Button>; 9]>>,
|
||||
}
|
||||
|
||||
impl TilePropertyEditor {
|
||||
@@ -334,7 +334,7 @@ impl TilePropertyEditor {
|
||||
/// One of the nine buttons has been clicked, so set the corresponding element of the value.
|
||||
fn handle_nine_click(
|
||||
&mut self,
|
||||
handle: Handle<UiNode>,
|
||||
handle: Handle<Button>,
|
||||
state: &TileEditorState,
|
||||
ui: &mut UserInterface,
|
||||
sender: &MessageSender,
|
||||
@@ -452,7 +452,7 @@ impl TileEditor for TilePropertyEditor {
|
||||
fn handle(&self) -> Handle<UiNode> {
|
||||
self.handle
|
||||
}
|
||||
fn draw_button(&self) -> Handle<UiNode> {
|
||||
fn draw_button(&self) -> Handle<Button> {
|
||||
self.draw_button
|
||||
}
|
||||
fn slice_mode(&self) -> bool {
|
||||
@@ -574,7 +574,13 @@ impl TileEditor for TilePropertyEditor {
|
||||
return;
|
||||
}
|
||||
if let Some(ButtonMessage::Click) = message.data() {
|
||||
self.handle_nine_click(message.destination(), state, ui, sender, tile_book);
|
||||
self.handle_nine_click(
|
||||
message.destination().to_variant(),
|
||||
state,
|
||||
ui,
|
||||
sender,
|
||||
tile_book,
|
||||
);
|
||||
} else if let Some(TextMessage::Text(v)) = message.data() {
|
||||
if message.destination() == self.value_field {
|
||||
self.set_value_from_text(v.into());
|
||||
@@ -661,7 +667,7 @@ impl NineButtonSpec {
|
||||
const DRAW_BUTTON_WIDTH: f32 = 20.0;
|
||||
const DRAW_BUTTON_HEIGHT: f32 = 20.0;
|
||||
|
||||
fn make_draw_button(tab_index: Option<usize>, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
fn make_draw_button(tab_index: Option<usize>, ctx: &mut BuildContext) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_tab_index(tab_index)
|
||||
@@ -725,8 +731,8 @@ fn create_nine_specs(
|
||||
}
|
||||
|
||||
/// Send UI messages to update the one of nine buttons to match the given [`NineButtonSpec`].
|
||||
fn apply_specs_to_nine(specs: &NineButtonSpec, handle: Handle<UiNode>, ui: &mut UserInterface) {
|
||||
let button = ui.try_get_of_type::<Button>(handle).unwrap();
|
||||
fn apply_specs_to_nine(specs: &NineButtonSpec, handle: Handle<Button>, ui: &mut UserInterface) {
|
||||
let button = &ui[handle];
|
||||
let text = *button.content.clone();
|
||||
let decorator = *button.decorator.clone();
|
||||
ui.send(text, TextMessage::Text(specs.name.clone()));
|
||||
@@ -753,7 +759,7 @@ fn build_nine_button(
|
||||
y: usize,
|
||||
tab_index: Option<usize>,
|
||||
ctx: &mut BuildContext,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_column(x)
|
||||
@@ -784,8 +790,8 @@ fn build_nine_button(
|
||||
fn build_nine(
|
||||
specs: [NineButtonSpec; 9],
|
||||
ctx: &mut BuildContext,
|
||||
) -> (Handle<UiNode>, Box<[Handle<UiNode>; 9]>) {
|
||||
let mut buttons: Box<[Handle<UiNode>; 9]> = [Handle::NONE; 9].into();
|
||||
) -> (Handle<UiNode>, Box<[Handle<Button>; 9]>) {
|
||||
let mut buttons: Box<[Handle<Button>; 9]> = [Handle::NONE; 9].into();
|
||||
let mut tab_index = 0;
|
||||
for y in 0..3 {
|
||||
for x in 0..3 {
|
||||
@@ -794,13 +800,14 @@ fn build_nine(
|
||||
tab_index += 1;
|
||||
}
|
||||
}
|
||||
let nine = GridBuilder::new(WidgetBuilder::new().with_children(buttons.iter().copied()))
|
||||
.add_column(Column::stretch())
|
||||
.add_column(Column::stretch())
|
||||
.add_column(Column::stretch())
|
||||
.add_row(Row::auto())
|
||||
.add_row(Row::auto())
|
||||
.add_row(Row::auto())
|
||||
.build(ctx);
|
||||
let nine =
|
||||
GridBuilder::new(WidgetBuilder::new().with_children(buttons.iter().map(|h| h.to_base())))
|
||||
.add_column(Column::stretch())
|
||||
.add_column(Column::stretch())
|
||||
.add_column(Column::stretch())
|
||||
.add_row(Row::auto())
|
||||
.add_row(Row::auto())
|
||||
.add_row(Row::auto())
|
||||
.build(ctx);
|
||||
(nine, buttons)
|
||||
}
|
||||
|
||||
@@ -93,16 +93,16 @@ pub struct TileSetEditor {
|
||||
/// The palette widget for the actual tiles. This is the main work area of the editor.
|
||||
tiles_palette: Handle<UiNode>,
|
||||
/// A button to switch to the pick tool.
|
||||
pick_button: Handle<UiNode>,
|
||||
pick_button: Handle<Button>,
|
||||
/// A button to open the tile map control panel.
|
||||
/// It can sometimes be useful while editing a tile set or brush.
|
||||
open_control: Handle<UiNode>,
|
||||
open_control: Handle<Button>,
|
||||
/// A button to deleted the selected tiles or pages.
|
||||
remove: Handle<UiNode>,
|
||||
remove: Handle<Button>,
|
||||
/// A button to select all the pages of the current resource.
|
||||
all_pages: Handle<UiNode>,
|
||||
all_pages: Handle<Button>,
|
||||
/// A button to select all the tiles of the current page.
|
||||
all_tiles: Handle<UiNode>,
|
||||
all_tiles: Handle<Button>,
|
||||
/// When editing a brush, this is the area that allows the user to choose
|
||||
/// the tile set for the brush.
|
||||
tile_set_selector: Handle<UiNode>,
|
||||
@@ -140,7 +140,7 @@ fn make_button(
|
||||
row: usize,
|
||||
column: usize,
|
||||
ctx: &mut BuildContext,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.on_row(row)
|
||||
@@ -568,10 +568,7 @@ impl TileSetEditor {
|
||||
/// Update the widgets of this editor after the shared [`TileDrawState`] may have changed.
|
||||
pub fn sync_to_state(&mut self, ui: &mut UserInterface) {
|
||||
self.tile_inspector.sync_to_state(ui);
|
||||
let decorator = *ui
|
||||
.try_get_of_type::<Button>(self.pick_button)
|
||||
.unwrap()
|
||||
.decorator;
|
||||
let decorator = *ui[self.pick_button].decorator;
|
||||
ui.send(
|
||||
decorator,
|
||||
DecoratorMessage::Select(self.state.lock().drawing_mode == DrawingMode::Pick),
|
||||
|
||||
@@ -65,7 +65,7 @@ pub struct WfcMacro {
|
||||
attempts_field: Handle<UiNode>,
|
||||
terrain_list: Vec<TerrainWidgets>,
|
||||
value_field: MacroPropertyValueField,
|
||||
add_button: Handle<UiNode>,
|
||||
add_button: Handle<Button>,
|
||||
terrain_stack: Handle<UiNode>,
|
||||
current_terrain: TileTerrainId,
|
||||
}
|
||||
@@ -102,7 +102,7 @@ struct TerrainWidgets {
|
||||
color: Color,
|
||||
name: String,
|
||||
frequency_field: Handle<UiNode>,
|
||||
delete_button: Handle<UiNode>,
|
||||
delete_button: Handle<Button>,
|
||||
}
|
||||
|
||||
fn terrain_list_needs_rebuild(
|
||||
|
||||
@@ -54,6 +54,7 @@ use crate::{
|
||||
};
|
||||
use fyrox::core::num_traits::Zero;
|
||||
use fyrox::core::pool::ObjectOrVariant;
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::scene::camera::Camera;
|
||||
use fyrox::scene::pivot::Pivot;
|
||||
use std::path::Path;
|
||||
@@ -70,7 +71,7 @@ pub struct PreviewPanel {
|
||||
pub root: Handle<UiNode>,
|
||||
frame: Handle<UiNode>,
|
||||
camera_pivot: Handle<Pivot>,
|
||||
fit: Handle<UiNode>,
|
||||
fit: Handle<Button>,
|
||||
hinge: Handle<Pivot>,
|
||||
pub camera: Handle<Camera>,
|
||||
prev_mouse_pos: Vector2<f32>,
|
||||
|
||||
@@ -45,13 +45,14 @@ use crate::{
|
||||
},
|
||||
Message,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
|
||||
pub struct NodeRemovalDialog {
|
||||
pub window: Handle<UiNode>,
|
||||
info_text: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
}
|
||||
|
||||
impl NodeRemovalDialog {
|
||||
|
||||
@@ -41,6 +41,7 @@ use crate::fyrox::{
|
||||
BuildContext, Control, HorizontalAlignment, Orientation, Thickness, UiNode, UserInterface,
|
||||
},
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::control_trait_proxy_impls;
|
||||
use fyrox::gui::message::MessageData;
|
||||
use fyrox::gui::style::resource::StyleResourceExt;
|
||||
@@ -486,8 +487,8 @@ pub struct PropertySelectorWindow {
|
||||
#[component(include)]
|
||||
window: Window,
|
||||
selector: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
#[reflect(hidden)]
|
||||
#[visit(skip)]
|
||||
allowed_types: Option<FxHashSet<TypeId>>,
|
||||
|
||||
@@ -47,6 +47,7 @@ use crate::{
|
||||
},
|
||||
utils::make_node_name,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::control_trait_proxy_impls;
|
||||
use fyrox::gui::formatted_text::WrapMode;
|
||||
use fyrox::gui::message::{DeliveryMode, MessageData};
|
||||
@@ -430,8 +431,8 @@ pub struct NodeSelectorWindow {
|
||||
#[component(include)]
|
||||
window: Window,
|
||||
selector: Handle<UiNode>,
|
||||
ok: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
#[visit(skip)]
|
||||
#[reflect(hidden)]
|
||||
allowed_types: FxHashSet<AllowedType>,
|
||||
|
||||
@@ -84,7 +84,7 @@ pub enum GraphicsDebugSwitches {
|
||||
|
||||
struct GridSnappingMenu {
|
||||
menu: Handle<UiNode>,
|
||||
button: Handle<UiNode>,
|
||||
button: Handle<Button>,
|
||||
enabled: Handle<UiNode>,
|
||||
x_step: Handle<UiNode>,
|
||||
y_step: Handle<UiNode>,
|
||||
@@ -111,7 +111,7 @@ impl GridSnappingMenu {
|
||||
"Snapping Options",
|
||||
None,
|
||||
);
|
||||
button
|
||||
button.to_base()
|
||||
})
|
||||
.with_content(
|
||||
GridBuilder::new(
|
||||
@@ -207,17 +207,15 @@ impl GridSnappingMenu {
|
||||
for message in self.receiver.try_iter() {
|
||||
match message {
|
||||
SettingsMessage::Changed => {
|
||||
if let Ok(button) = ui.try_get_of_type::<Button>(self.button) {
|
||||
ui.send_many(
|
||||
*button.decorator,
|
||||
[
|
||||
DecoratorMessage::SelectedBrush(
|
||||
ui.style.property(Style::BRUSH_BRIGHT_BLUE),
|
||||
),
|
||||
DecoratorMessage::Select(settings.move_mode_settings.grid_snapping),
|
||||
],
|
||||
);
|
||||
}
|
||||
ui.send_many(
|
||||
*ui[self.button].decorator,
|
||||
[
|
||||
DecoratorMessage::SelectedBrush(
|
||||
ui.style.property(Style::BRUSH_BRIGHT_BLUE),
|
||||
),
|
||||
DecoratorMessage::Select(settings.move_mode_settings.grid_snapping),
|
||||
],
|
||||
);
|
||||
|
||||
ui.send(
|
||||
self.enabled,
|
||||
@@ -265,11 +263,11 @@ pub struct SceneViewer {
|
||||
frame: Handle<UiNode>,
|
||||
window: Handle<UiNode>,
|
||||
selection_frame: Handle<UiNode>,
|
||||
interaction_modes: FxHashMap<Uuid, Handle<UiNode>>,
|
||||
interaction_modes: FxHashMap<Uuid, Handle<Button>>,
|
||||
camera_projection: Handle<UiNode>,
|
||||
play: Handle<UiNode>,
|
||||
build: Handle<UiNode>,
|
||||
stop: Handle<UiNode>,
|
||||
play: Handle<Button>,
|
||||
build: Handle<Button>,
|
||||
stop: Handle<Button>,
|
||||
build_profile: Handle<UiNode>,
|
||||
sender: MessageSender,
|
||||
interaction_mode_panel: Handle<UiNode>,
|
||||
@@ -595,14 +593,7 @@ impl SceneViewer {
|
||||
if let Message::SetInteractionMode(mode) = message {
|
||||
if let Some(&active_button) = self.interaction_modes.get(mode) {
|
||||
for &mode_button in self.interaction_modes.values() {
|
||||
let decorator = *engine
|
||||
.user_interfaces
|
||||
.first_mut()
|
||||
.node(mode_button)
|
||||
.query_component::<Button>()
|
||||
.unwrap()
|
||||
.decorator;
|
||||
|
||||
let decorator = *engine.user_interfaces.first_mut()[mode_button].decorator;
|
||||
engine.user_interfaces.first().send(
|
||||
decorator,
|
||||
DecoratorMessage::Select(mode_button == active_button),
|
||||
|
||||
@@ -37,6 +37,7 @@ use crate::{
|
||||
settings::Settings,
|
||||
ui_scene::{UiScene, UiSelection},
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
pub mod move_mode;
|
||||
|
||||
@@ -211,7 +212,7 @@ impl InteractionMode for UiSelectInteractionMode {
|
||||
) {
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
let select_mode_tooltip = "Select Object(s) - Shortcut: [1]\n\nSelection interaction mode \
|
||||
allows you to select an object by a single left mouse button click or multiple objects using either \
|
||||
frame selection (click and drag) or by holding Ctrl+Click";
|
||||
|
||||
@@ -35,6 +35,7 @@ use crate::{
|
||||
settings::Settings,
|
||||
ui_scene::{commands::widget::MoveWidgetCommand, UiScene},
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
|
||||
struct Entry {
|
||||
widget: Handle<UiNode>,
|
||||
@@ -197,7 +198,7 @@ impl InteractionMode for MoveWidgetsInteractionMode {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<UiNode> {
|
||||
fn make_button(&mut self, ctx: &mut BuildContext, selected: bool) -> Handle<Button> {
|
||||
let move_mode_tooltip =
|
||||
"Move Object(s) - Shortcut: [2]\n\nMovement interaction mode allows you to move selected \
|
||||
objects. Keep in mind that movement always works in local coordinates!\n\n\
|
||||
|
||||
@@ -36,6 +36,7 @@ use crate::{
|
||||
},
|
||||
load_image,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::file_browser::{FileSelectorMode, FileType};
|
||||
use fyrox::gui::texture::TextureResource;
|
||||
use fyrox::gui::utils::make_image_button_with_tooltip;
|
||||
@@ -43,7 +44,7 @@ use std::{fs::File, path::Path};
|
||||
|
||||
pub mod doc;
|
||||
|
||||
pub fn make_pick_button(column: usize, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
pub fn make_pick_button(column: usize, ctx: &mut BuildContext) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_width(20.0)
|
||||
@@ -166,7 +167,7 @@ pub fn make_square_image_button_with_tooltip(
|
||||
image: Option<TextureResource>,
|
||||
tooltip: &str,
|
||||
tab_index: Option<usize>,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
make_image_button_with_tooltip(ctx, 18.0, 18.0, image, tooltip, tab_index)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ use crate::{
|
||||
world::item::{DropAnchor, SceneItem, SceneItemBuilder, SceneItemMessage},
|
||||
Mode, Settings,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::text_box::EmptyTextPlaceholder;
|
||||
use rust_fuzzy_search::fuzzy_compare;
|
||||
use std::{
|
||||
@@ -128,10 +129,10 @@ pub struct WorldViewer {
|
||||
/// this moment UI is completely built and we can do syncing.
|
||||
pub sync_selection: bool,
|
||||
node_path: Handle<UiNode>,
|
||||
breadcrumbs: HashMap<Handle<UiNode>, Handle<UiNode>>,
|
||||
collapse_all: Handle<UiNode>,
|
||||
expand_all: Handle<UiNode>,
|
||||
locate_selection: Handle<UiNode>,
|
||||
breadcrumbs: HashMap<Handle<Button>, Handle<UiNode>>,
|
||||
collapse_all: Handle<Button>,
|
||||
expand_all: Handle<Button>,
|
||||
locate_selection: Handle<Button>,
|
||||
scroll_view: Handle<UiNode>,
|
||||
pub item_context_menu: Option<Rc<RefCell<dyn WorldViewerItemContextMenu>>>,
|
||||
node_to_view_map: HashMap<ErasedHandle, Handle<UiNode>>,
|
||||
@@ -660,7 +661,7 @@ impl WorldViewer {
|
||||
} else if let Some(&WidgetMessage::Drop(node)) = message.data::<WidgetMessage>() {
|
||||
self.handle_drop(ui, data_provider, message.destination(), node);
|
||||
} else if let Some(ButtonMessage::Click) = message.data::<ButtonMessage>() {
|
||||
if let Some(&view) = self.breadcrumbs.get(&message.destination()) {
|
||||
if let Some(&view) = self.breadcrumbs.get(&message.destination().to_variant()) {
|
||||
if let Ok(graph_node) = ui.try_get_of_type::<SceneItem>(view) {
|
||||
data_provider.on_selection_changed(&[graph_node.entity_handle]);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
use fyrox_core::algebra::{Matrix3, Vector2};
|
||||
use fyrox_core::Uuid;
|
||||
use fyrox_resource::untyped::ResourceKind;
|
||||
use fyrox_ui::button::Button;
|
||||
use fyrox_ui::window::WindowAlignment;
|
||||
use fyrox_ui::{
|
||||
border::BorderBuilder,
|
||||
@@ -56,7 +57,7 @@ pub struct BuildWindow {
|
||||
changed: Arc<AtomicBool>,
|
||||
log: Arc<Mutex<String>>,
|
||||
log_text: Handle<UiNode>,
|
||||
stop: Handle<UiNode>,
|
||||
stop: Handle<Button>,
|
||||
scroll_viewer: Handle<UiNode>,
|
||||
progress_indicator: Handle<UiNode>,
|
||||
angle: f32,
|
||||
|
||||
@@ -25,7 +25,7 @@ use crate::{
|
||||
core::pool::Handle, font::FontResource, message::UiMessage, style::resource::StyleResource,
|
||||
Control, RestrictionEntry, UiNode, UserInterface,
|
||||
};
|
||||
use fyrox_core::pool::PoolError;
|
||||
use fyrox_core::pool::{ObjectOrVariant, PoolError};
|
||||
use fyrox_graph::SceneGraph;
|
||||
use std::{
|
||||
ops::{Index, IndexMut},
|
||||
@@ -92,17 +92,17 @@ pub struct BuildContext<'a> {
|
||||
pub style: StyleResource,
|
||||
}
|
||||
|
||||
impl Index<Handle<UiNode>> for BuildContext<'_> {
|
||||
type Output = UiNode;
|
||||
impl<U: ObjectOrVariant<UiNode>> Index<Handle<U>> for BuildContext<'_> {
|
||||
type Output = U;
|
||||
|
||||
fn index(&self, index: Handle<UiNode>) -> &Self::Output {
|
||||
&self.ui.nodes[index]
|
||||
fn index(&self, index: Handle<U>) -> &U {
|
||||
self.ui.try_get(index).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<Handle<UiNode>> for BuildContext<'_> {
|
||||
fn index_mut(&mut self, index: Handle<UiNode>) -> &mut Self::Output {
|
||||
&mut self.ui.nodes[index]
|
||||
impl<U: ObjectOrVariant<UiNode>> IndexMut<Handle<U>> for BuildContext<'_> {
|
||||
fn index_mut(&mut self, index: Handle<U>) -> &mut Self::Output {
|
||||
self.ui.try_get_mut(index).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ impl MessageData for ButtonMessage {}
|
||||
/// ```rust
|
||||
/// # use fyrox_ui::{
|
||||
/// # core::pool::Handle,
|
||||
/// # button::ButtonBuilder, widget::WidgetBuilder, UiNode, UserInterface
|
||||
/// # button::{ButtonBuilder, Button}, widget::WidgetBuilder, UiNode, UserInterface
|
||||
/// # };
|
||||
/// fn create_button(ui: &mut UserInterface) -> Handle<UiNode> {
|
||||
/// fn create_button(ui: &mut UserInterface) -> Handle<Button> {
|
||||
/// ButtonBuilder::new(WidgetBuilder::new())
|
||||
/// .with_text("Click me!")
|
||||
/// .build(&mut ui.build_ctx())
|
||||
@@ -141,6 +141,7 @@ impl ConstructorProvider<UiNode, UserInterface> for Button {
|
||||
.with_name("Button"),
|
||||
)
|
||||
.build(&mut ui.build_ctx())
|
||||
.to_base()
|
||||
.into()
|
||||
})
|
||||
.with_group("Input")
|
||||
@@ -433,9 +434,9 @@ impl ButtonBuilder {
|
||||
}
|
||||
|
||||
/// Finishes button build and adds to the user interface and returns its handle.
|
||||
pub fn build(self, ctx: &mut BuildContext) -> Handle<UiNode> {
|
||||
pub fn build(self, ctx: &mut BuildContext) -> Handle<Button> {
|
||||
let node = self.build_node(ctx);
|
||||
ctx.add_node(node)
|
||||
ctx.add_node(node).to_variant()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ use crate::{
|
||||
widget::{Widget, WidgetBuilder, WidgetMessage},
|
||||
BuildContext, Control, UiNode, UserInterface, VerticalAlignment,
|
||||
};
|
||||
use fyrox_core::pool::ObjectOrVariant;
|
||||
use fyrox_core::uuid_provider;
|
||||
use fyrox_core::variable::InheritableVariable;
|
||||
use fyrox_graph::constructor::{ConstructorProvider, GraphNodeConstructor};
|
||||
@@ -220,14 +221,14 @@ impl ExpanderBuilder {
|
||||
}
|
||||
|
||||
/// Sets the desired header of the expander.
|
||||
pub fn with_header(mut self, header: Handle<UiNode>) -> Self {
|
||||
self.header = header;
|
||||
pub fn with_header(mut self, header: Handle<impl ObjectOrVariant<UiNode>>) -> Self {
|
||||
self.header = header.to_base();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the desired content of the expander.
|
||||
pub fn with_content(mut self, content: Handle<UiNode>) -> Self {
|
||||
self.content = content;
|
||||
pub fn with_content(mut self, content: Handle<impl ObjectOrVariant<UiNode>>) -> Self {
|
||||
self.content = content.to_base();
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::{
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
control_trait_proxy_impls,
|
||||
@@ -46,8 +47,8 @@ pub struct FolderNameDialog {
|
||||
pub window: Window,
|
||||
pub folder_name_tb: Handle<UiNode>,
|
||||
pub folder_name: String,
|
||||
pub ok: Handle<UiNode>,
|
||||
pub cancel: Handle<UiNode>,
|
||||
pub ok: Handle<Button>,
|
||||
pub cancel: Handle<Button>,
|
||||
}
|
||||
|
||||
define_widget_deref_proxy!(FolderNameDialog, window);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::{
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
core::{
|
||||
@@ -53,7 +54,7 @@ pub struct FileSelectorField {
|
||||
widget: Widget,
|
||||
path: PathBuf,
|
||||
path_field: Handle<UiNode>,
|
||||
select: Handle<UiNode>,
|
||||
select: Handle<Button>,
|
||||
file_selector: Handle<UiNode>,
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ mod selector;
|
||||
#[cfg(test)]
|
||||
mod test;
|
||||
|
||||
use crate::button::Button;
|
||||
pub use field::*;
|
||||
pub use filter::*;
|
||||
pub use selector::*;
|
||||
@@ -103,8 +104,8 @@ impl MessageData for FsEventMessage {}
|
||||
pub struct FileBrowser {
|
||||
pub widget: Widget,
|
||||
pub tree_root: Handle<UiNode>,
|
||||
pub home_dir: Handle<UiNode>,
|
||||
pub desktop_dir: Handle<UiNode>,
|
||||
pub home_dir: Handle<Button>,
|
||||
pub desktop_dir: Handle<Button>,
|
||||
pub path_text: Handle<UiNode>,
|
||||
pub scroll_viewer: Handle<UiNode>,
|
||||
pub no_items_message: Handle<UiNode>,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::{
|
||||
border::BorderBuilder,
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
@@ -76,8 +77,8 @@ pub struct FileSelector {
|
||||
#[component(include)]
|
||||
pub window: Window,
|
||||
pub browser: Handle<UiNode>,
|
||||
pub ok: Handle<UiNode>,
|
||||
pub cancel: Handle<UiNode>,
|
||||
pub ok: Handle<Button>,
|
||||
pub cancel: Handle<Button>,
|
||||
pub selected_folder: PathBuf,
|
||||
pub mode: FileSelectorMode,
|
||||
pub file_name: Handle<UiNode>,
|
||||
|
||||
@@ -331,7 +331,7 @@ where
|
||||
ctx.layer_index,
|
||||
ctx.property_info.display_name,
|
||||
ctx.property_info.doc,
|
||||
Handle::NONE,
|
||||
Handle::<UiNode>::NONE,
|
||||
{
|
||||
editor = ArrayEditorBuilder::new(
|
||||
WidgetBuilder::new().with_margin(Thickness::uniform(1.0)),
|
||||
|
||||
@@ -41,6 +41,7 @@ use crate::{
|
||||
VerticalAlignment,
|
||||
};
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::{DeliveryMode, MessageData};
|
||||
use fyrox_graph::SceneGraph;
|
||||
use std::{
|
||||
@@ -54,7 +55,7 @@ use std::{
|
||||
#[derive(Clone, Debug, PartialEq, Default, Visit, Reflect)]
|
||||
pub struct Item {
|
||||
editor_instance: PropertyEditorInstance,
|
||||
remove: Handle<UiNode>,
|
||||
remove: Handle<Button>,
|
||||
}
|
||||
|
||||
pub trait CollectionItem: Clone + Reflect + Default + TypeUuidProvider + Send + 'static {}
|
||||
@@ -65,7 +66,7 @@ impl<T> CollectionItem for T where T: Clone + Reflect + Default + TypeUuidProvid
|
||||
#[reflect(derived_type = "UiNode")]
|
||||
pub struct CollectionEditor<T: CollectionItem> {
|
||||
pub widget: Widget,
|
||||
pub add: Handle<UiNode>,
|
||||
pub add: Handle<Button>,
|
||||
pub items: Vec<Item>,
|
||||
pub panel: Handle<UiNode>,
|
||||
#[visit(skip)]
|
||||
@@ -127,7 +128,7 @@ impl<T: CollectionItem> Control for CollectionEditor<T> {
|
||||
if let Some(index) = self
|
||||
.items
|
||||
.iter()
|
||||
.position(|i| i.remove == message.destination())
|
||||
.position(|i| message.destination() == i.remove)
|
||||
{
|
||||
ui.post(self.handle, CollectionChanged::Remove(index));
|
||||
}
|
||||
@@ -185,7 +186,7 @@ where
|
||||
collection: Option<I>,
|
||||
environment: Option<Arc<dyn InspectorEnvironment>>,
|
||||
definition_container: Option<Arc<PropertyEditorDefinitionContainer>>,
|
||||
add: Handle<UiNode>,
|
||||
add: Handle<Button>,
|
||||
layer_index: usize,
|
||||
generate_property_string_values: bool,
|
||||
filter: PropertyFilter,
|
||||
@@ -330,7 +331,7 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_add(mut self, add: Handle<UiNode>) -> Self {
|
||||
pub fn with_add(mut self, add: Handle<Button>) -> Self {
|
||||
self.add = add;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
//! 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::button::Button;
|
||||
use crate::{
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
core::{
|
||||
@@ -62,7 +63,7 @@ impl MessageData for InheritablePropertyEditorMessage {}
|
||||
#[reflect(derived_type = "UiNode")]
|
||||
pub struct InheritablePropertyEditor {
|
||||
widget: Widget,
|
||||
revert: Handle<UiNode>,
|
||||
revert: Handle<Button>,
|
||||
inner_editor: Handle<UiNode>,
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ use crate::{
|
||||
},
|
||||
message::{MessageDirection, UiMessage},
|
||||
widget::WidgetBuilder,
|
||||
UiNode,
|
||||
};
|
||||
use fyrox_core::pool::Handle;
|
||||
use fyrox_core::PhantomDataSendSync;
|
||||
@@ -107,7 +108,7 @@ where
|
||||
ctx.layer_index,
|
||||
ctx.property_info.display_name,
|
||||
ctx.property_info.doc,
|
||||
Handle::NONE,
|
||||
Handle::<UiNode>::NONE,
|
||||
{
|
||||
editor = InspectorBuilder::new(WidgetBuilder::new())
|
||||
.with_context(inspector_context)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
//! Property editor for [`StyledProperty`]. It acts like a proxy to inner property, but also
|
||||
//! adds a special "bind" button used to change style binding of the property.
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::MessageData;
|
||||
use crate::window::WindowAlignment;
|
||||
use crate::{
|
||||
@@ -82,8 +83,8 @@ pub struct StyledPropertySelector {
|
||||
window: Window,
|
||||
properties: Handle<UiNode>,
|
||||
property_list: Vec<ImmutableString>,
|
||||
ok: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
ok: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
style_property_name: ImmutableString,
|
||||
}
|
||||
|
||||
@@ -307,7 +308,7 @@ impl StyledPropertySelectorBuilder {
|
||||
#[reflect(derived_type = "UiNode")]
|
||||
pub struct StyledPropertyEditor {
|
||||
widget: Widget,
|
||||
bind: Handle<UiNode>,
|
||||
bind: Handle<Button>,
|
||||
inner_editor: Handle<UiNode>,
|
||||
selector: Handle<UiNode>,
|
||||
target_style: Option<StyleResource>,
|
||||
|
||||
@@ -57,6 +57,7 @@ use crate::{
|
||||
BuildContext, Control, Thickness, UiNode, UserInterface, VerticalAlignment,
|
||||
};
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::MessageData;
|
||||
use crate::window::WindowAlignment;
|
||||
use fyrox_texture::TextureKind;
|
||||
@@ -693,7 +694,7 @@ impl TextureSliceEditorWindowBuilder {
|
||||
pub struct TextureSliceFieldEditor {
|
||||
widget: Widget,
|
||||
texture_slice: TextureSlice,
|
||||
edit: Handle<UiNode>,
|
||||
edit: Handle<Button>,
|
||||
editor: Handle<UiNode>,
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ use crate::{
|
||||
BuildContext, Control, RcUiNodeHandle, Thickness, UiNode, UserInterface, VerticalAlignment,
|
||||
};
|
||||
use copypasta::ClipboardProvider;
|
||||
use fyrox_core::pool::ObjectOrVariant;
|
||||
use fyrox_core::{err, log::Log};
|
||||
use fyrox_graph::{
|
||||
constructor::{ConstructorProvider, GraphNodeConstructor},
|
||||
@@ -937,8 +938,8 @@ pub fn make_expander_container(
|
||||
layer_index: usize,
|
||||
property_name: &str,
|
||||
description: &str,
|
||||
header: Handle<UiNode>,
|
||||
content: Handle<UiNode>,
|
||||
header: Handle<impl ObjectOrVariant<UiNode>>,
|
||||
content: Handle<impl ObjectOrVariant<UiNode>>,
|
||||
width: f32,
|
||||
ctx: &mut BuildContext,
|
||||
) -> Handle<UiNode> {
|
||||
|
||||
+4
-4
@@ -1951,12 +1951,12 @@ impl UserInterface {
|
||||
/// is useful to understand if some event came from some node down by tree.
|
||||
pub fn is_node_child_of(
|
||||
&self,
|
||||
node_handle: Handle<UiNode>,
|
||||
root_handle: Handle<UiNode>,
|
||||
node_handle: Handle<impl ObjectOrVariant<UiNode>>,
|
||||
root_handle: Handle<impl ObjectOrVariant<UiNode>>,
|
||||
) -> bool {
|
||||
self.nodes
|
||||
.borrow(root_handle)
|
||||
.has_descendant(node_handle, self)
|
||||
.borrow(root_handle.to_base())
|
||||
.has_descendant(node_handle.to_base(), self)
|
||||
}
|
||||
|
||||
/// Checks if the specified node is a descendant of the hierarchy defined by a `root_handle` or
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::{
|
||||
border::BorderBuilder,
|
||||
button::ButtonMessage,
|
||||
@@ -96,7 +97,7 @@ impl ContextMenu {
|
||||
pub struct LogPanel {
|
||||
pub window: Handle<UiNode>,
|
||||
messages: Handle<UiNode>,
|
||||
clear: Handle<UiNode>,
|
||||
clear: Handle<Button>,
|
||||
receiver: Receiver<LogMessage>,
|
||||
severity: MessageKind,
|
||||
severity_list: Handle<UiNode>,
|
||||
|
||||
@@ -42,6 +42,7 @@ use crate::{
|
||||
UserInterface,
|
||||
};
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::MessageData;
|
||||
use crate::window::WindowAlignment;
|
||||
use fyrox_core::uuid_provider;
|
||||
@@ -172,11 +173,11 @@ pub struct MessageBox {
|
||||
/// Current set of buttons of the message box.
|
||||
pub buttons: InheritableVariable<MessageBoxButtons>,
|
||||
/// A handle of `Ok`/`Yes` buttons.
|
||||
pub ok_yes: InheritableVariable<Handle<UiNode>>,
|
||||
pub ok_yes: InheritableVariable<Handle<Button>>,
|
||||
/// A handle of `No` button.
|
||||
pub no: InheritableVariable<Handle<UiNode>>,
|
||||
pub no: InheritableVariable<Handle<Button>>,
|
||||
/// A handle of `Cancel` button.
|
||||
pub cancel: InheritableVariable<Handle<UiNode>>,
|
||||
pub cancel: InheritableVariable<Handle<Button>>,
|
||||
/// A handle of text widget.
|
||||
pub text: InheritableVariable<Handle<UiNode>>,
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ use crate::{
|
||||
VerticalAlignment,
|
||||
};
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::MessageData;
|
||||
use fyrox_core::variable::InheritableVariable;
|
||||
use fyrox_graph::constructor::{ConstructorProvider, GraphNodeConstructor};
|
||||
@@ -235,9 +236,9 @@ pub struct NumericUpDown<T: NumericType> {
|
||||
/// A handle of the input field (usually a [`TextBox`] instance).
|
||||
pub field: InheritableVariable<Handle<UiNode>>,
|
||||
/// A handle of the increase button.
|
||||
pub increase: InheritableVariable<Handle<UiNode>>,
|
||||
pub increase: InheritableVariable<Handle<Button>>,
|
||||
/// A handle of the decrease button.
|
||||
pub decrease: InheritableVariable<Handle<UiNode>>,
|
||||
pub decrease: InheritableVariable<Handle<Button>>,
|
||||
/// Current value of the widget.
|
||||
pub value: InheritableVariable<T>,
|
||||
/// Value of the widget with formatting applied.
|
||||
@@ -415,12 +416,8 @@ impl<T: NumericType> Control for NumericUpDown<T> {
|
||||
WidgetMessage::MouseDown { button, pos, .. } => {
|
||||
// We can activate dragging either by clicking on increase or decrease buttons.
|
||||
if *button == MouseButton::Left
|
||||
&& (ui
|
||||
.node(*self.increase)
|
||||
.has_descendant(message.destination(), ui)
|
||||
|| ui
|
||||
.node(*self.decrease)
|
||||
.has_descendant(message.destination(), ui))
|
||||
&& (ui[*self.increase].has_descendant(message.destination(), ui)
|
||||
|| ui[*self.decrease].has_descendant(message.destination(), ui))
|
||||
{
|
||||
self.drag_context = Some(DragContext::PreDrag {
|
||||
start_mouse_pos: pos.y,
|
||||
@@ -583,7 +580,7 @@ fn make_button(
|
||||
arrow: ArrowDirection,
|
||||
row: usize,
|
||||
editable: bool,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
let handle = ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_enabled(editable)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::file_browser::PathFilter;
|
||||
use crate::{
|
||||
button::{ButtonBuilder, ButtonMessage},
|
||||
@@ -80,7 +81,7 @@ pub struct PathEditor {
|
||||
/// A handle of the text field, that is used to show current path.
|
||||
pub text_field: InheritableVariable<Handle<UiNode>>,
|
||||
/// A button, that opens a file selection.
|
||||
pub select: InheritableVariable<Handle<UiNode>>,
|
||||
pub select: InheritableVariable<Handle<Button>>,
|
||||
/// Current file selector instance, could be [`Handle::NONE`] if the selector is closed.
|
||||
pub selector: InheritableVariable<Handle<UiNode>>,
|
||||
/// Current path.
|
||||
|
||||
@@ -35,6 +35,7 @@ use crate::{
|
||||
widget::{Widget, WidgetBuilder, WidgetMessage},
|
||||
BuildContext, Control, RestrictionEntry, Thickness, UiNode, UserInterface,
|
||||
};
|
||||
use fyrox_core::pool::ObjectOrVariant;
|
||||
use fyrox_graph::{
|
||||
constructor::{ConstructorProvider, GraphNodeConstructor},
|
||||
SceneGraph,
|
||||
@@ -560,8 +561,8 @@ impl PopupBuilder {
|
||||
}
|
||||
|
||||
/// Sets the content of the popup.
|
||||
pub fn with_content(mut self, content: Handle<UiNode>) -> Self {
|
||||
self.content = content;
|
||||
pub fn with_content(mut self, content: Handle<impl ObjectOrVariant<UiNode>>) -> Self {
|
||||
self.content = content.to_base();
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::{
|
||||
border::BorderBuilder,
|
||||
brush::Brush,
|
||||
@@ -149,9 +150,9 @@ pub struct ScrollBar {
|
||||
/// Internal mouse offset that is used for dragging purposes.
|
||||
pub offset: Vector2<f32>,
|
||||
/// A handle of the increase button.
|
||||
pub increase: InheritableVariable<Handle<UiNode>>,
|
||||
pub increase: InheritableVariable<Handle<Button>>,
|
||||
/// A handle of the decrease button.
|
||||
pub decrease: InheritableVariable<Handle<UiNode>>,
|
||||
pub decrease: InheritableVariable<Handle<Button>>,
|
||||
/// A handle of the indicator (thumb).
|
||||
pub indicator: InheritableVariable<Handle<UiNode>>,
|
||||
/// A handle of the canvas that is used for the thumb.
|
||||
@@ -396,8 +397,8 @@ pub struct ScrollBarBuilder {
|
||||
value: Option<f32>,
|
||||
step: Option<f32>,
|
||||
orientation: Option<Orientation>,
|
||||
increase: Option<Handle<UiNode>>,
|
||||
decrease: Option<Handle<UiNode>>,
|
||||
increase: Option<Handle<Button>>,
|
||||
decrease: Option<Handle<Button>>,
|
||||
indicator: Option<Handle<UiNode>>,
|
||||
body: Option<Handle<UiNode>>,
|
||||
show_value: bool,
|
||||
@@ -458,13 +459,13 @@ impl ScrollBarBuilder {
|
||||
}
|
||||
|
||||
/// Sets the new handle to a button, that is used to increase values of the scroll bar.
|
||||
pub fn with_increase(mut self, increase: Handle<UiNode>) -> Self {
|
||||
pub fn with_increase(mut self, increase: Handle<Button>) -> Self {
|
||||
self.increase = Some(increase);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the new handle to a button, that is used to decrease values of the scroll bar.
|
||||
pub fn with_decrease(mut self, decrease: Handle<UiNode>) -> Self {
|
||||
pub fn with_decrease(mut self, decrease: Handle<Button>) -> Self {
|
||||
self.decrease = Some(decrease);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ use crate::{
|
||||
VerticalAlignment,
|
||||
};
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::MessageData;
|
||||
use crate::text_box::EmptyTextPlaceholder;
|
||||
use fyrox_graph::constructor::{ConstructorProvider, GraphNodeConstructor};
|
||||
@@ -103,7 +104,7 @@ pub struct SearchBar {
|
||||
/// A handle of a text box widget used for text input.
|
||||
pub text_box: InheritableVariable<Handle<UiNode>>,
|
||||
/// A handle of a button, that is used to clear the text.
|
||||
pub clear: InheritableVariable<Handle<UiNode>>,
|
||||
pub clear: InheritableVariable<Handle<Button>>,
|
||||
}
|
||||
|
||||
impl ConstructorProvider<UiNode, UserInterface> for SearchBar {
|
||||
|
||||
@@ -33,6 +33,7 @@ use crate::{
|
||||
BuildContext, Control, Thickness, UiNode, UserInterface,
|
||||
};
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::MessageData;
|
||||
use fyrox_graph::constructor::{ConstructorProvider, GraphNodeConstructor};
|
||||
|
||||
@@ -56,8 +57,8 @@ pub struct Selector {
|
||||
items: InheritableVariable<Vec<Handle<UiNode>>>,
|
||||
items_panel: InheritableVariable<Handle<UiNode>>,
|
||||
current: InheritableVariable<Option<usize>>,
|
||||
prev: InheritableVariable<Handle<UiNode>>,
|
||||
next: InheritableVariable<Handle<UiNode>>,
|
||||
prev: InheritableVariable<Handle<Button>>,
|
||||
next: InheritableVariable<Handle<Button>>,
|
||||
}
|
||||
|
||||
impl ConstructorProvider<UiNode, UserInterface> for Selector {
|
||||
|
||||
@@ -45,9 +45,9 @@ use crate::{
|
||||
VerticalAlignment,
|
||||
};
|
||||
|
||||
use crate::button::Button;
|
||||
use fyrox_core::variable::InheritableVariable;
|
||||
use fyrox_graph::constructor::{ConstructorProvider, GraphNodeConstructor};
|
||||
use fyrox_graph::SceneGraph;
|
||||
use std::{
|
||||
any::Any,
|
||||
cmp::Ordering,
|
||||
@@ -122,11 +122,11 @@ pub struct Tab {
|
||||
/// Unique identifier of this tab.
|
||||
pub uuid: Uuid,
|
||||
/// A handle of the header button, that is used to switch tabs.
|
||||
pub header_button: Handle<UiNode>,
|
||||
pub header_button: Handle<Button>,
|
||||
/// Tab's content.
|
||||
pub content: Handle<UiNode>,
|
||||
/// A handle of a button, that is used to close the tab.
|
||||
pub close_button: Handle<UiNode>,
|
||||
pub close_button: Handle<Button>,
|
||||
/// A handle to a container widget, that holds the header.
|
||||
pub header_container: Handle<UiNode>,
|
||||
/// User-defined data.
|
||||
@@ -266,7 +266,7 @@ impl TabControl {
|
||||
let mut dragged_index = None;
|
||||
let mut target_index = None;
|
||||
for (tab_index, tab) in self.tabs.iter().enumerate() {
|
||||
let bounds = ui.node(tab.header_button).screen_bounds();
|
||||
let bounds = ui[tab.header_button].screen_bounds();
|
||||
let node_x = bounds.center().x;
|
||||
if bounds.contains(position) {
|
||||
if node_x < position.x {
|
||||
@@ -482,7 +482,7 @@ impl Control for TabControl {
|
||||
header_button: header.button,
|
||||
content: definition.content,
|
||||
close_button: header.close_button,
|
||||
header_container: header.button,
|
||||
header_container: header.button.to_base(),
|
||||
user_data: definition.user_data.clone(),
|
||||
decorator: header.decorator,
|
||||
header_content: header.content,
|
||||
@@ -516,8 +516,8 @@ pub struct TabDefinition {
|
||||
}
|
||||
|
||||
struct Header {
|
||||
button: Handle<UiNode>,
|
||||
close_button: Handle<UiNode>,
|
||||
button: Handle<Button>,
|
||||
close_button: Handle<Button>,
|
||||
decorator: Handle<UiNode>,
|
||||
content: Handle<UiNode>,
|
||||
}
|
||||
@@ -680,7 +680,7 @@ impl TabControlBuilder {
|
||||
|
||||
let headers_container = WrapPanelBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_children(tab_headers.iter().map(|h| h.button))
|
||||
.with_children(tab_headers.iter().map(|h| h.button.to_base()))
|
||||
.on_row(0),
|
||||
)
|
||||
.with_orientation(Orientation::Horizontal)
|
||||
@@ -728,7 +728,7 @@ impl TabControlBuilder {
|
||||
header_button: header.button,
|
||||
content: tab.content,
|
||||
close_button: header.close_button,
|
||||
header_container: header.button,
|
||||
header_container: header.button.to_base(),
|
||||
user_data: tab.user_data,
|
||||
decorator: header.decorator,
|
||||
header_content: header.content,
|
||||
|
||||
@@ -27,6 +27,7 @@ use crate::{
|
||||
BuildContext, Control, UiNode, UserInterface,
|
||||
};
|
||||
use fyrox_core::err;
|
||||
use fyrox_core::pool::ObjectOrVariant;
|
||||
use fyrox_graph::{SceneGraph, SceneGraphNode};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -213,7 +214,11 @@ impl UserInterfaceTestingExtension for UserInterface {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn test_widget_deletion(constructor: impl FnOnce(&mut BuildContext) -> Handle<UiNode>) {
|
||||
pub fn test_widget_deletion<F, U>(constructor: F)
|
||||
where
|
||||
F: FnOnce(&mut BuildContext) -> Handle<U>,
|
||||
U: ObjectOrVariant<UiNode>,
|
||||
{
|
||||
let screen_size = Vector2::new(100.0, 100.0);
|
||||
let mut ui = UserInterface::new(screen_size);
|
||||
let widget = constructor(&mut ui.build_ctx());
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::{
|
||||
border::BorderBuilder,
|
||||
button::ButtonBuilder,
|
||||
@@ -304,7 +305,7 @@ pub fn make_image_button_with_tooltip(
|
||||
image: Option<TextureResource>,
|
||||
tooltip: &str,
|
||||
tab_index: Option<usize>,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_tab_index(tab_index)
|
||||
@@ -337,7 +338,7 @@ pub fn make_text_and_image_button_with_tooltip(
|
||||
tab_index: Option<usize>,
|
||||
color: Color,
|
||||
font_size: f32,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
let margin = 3.0;
|
||||
ButtonBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
|
||||
@@ -34,6 +34,7 @@ use crate::{
|
||||
BuildContext, Control, Thickness, UiNode, UserInterface, VerticalAlignment,
|
||||
};
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::MessageData;
|
||||
use fyrox_core::uuid_provider;
|
||||
use fyrox_graph::constructor::{ConstructorProvider, GraphNodeConstructor};
|
||||
@@ -70,7 +71,7 @@ pub struct UuidEditor {
|
||||
widget: Widget,
|
||||
value: Uuid,
|
||||
text: Handle<UiNode>,
|
||||
generate: Handle<UiNode>,
|
||||
generate: Handle<Button>,
|
||||
}
|
||||
|
||||
impl ConstructorProvider<UiNode, UserInterface> for UuidEditor {
|
||||
|
||||
@@ -44,6 +44,7 @@ use crate::{
|
||||
BuildContext, HorizontalAlignment, LayoutEvent, MouseButton, MouseState, RcUiNodeHandle,
|
||||
Thickness, UiNode, UserInterface, VerticalAlignment,
|
||||
};
|
||||
use fyrox_core::pool::ObjectOrVariant;
|
||||
use fyrox_graph::SceneGraph;
|
||||
use fyrox_material::{Material, MaterialResource};
|
||||
use fyrox_resource::Resource;
|
||||
@@ -1913,9 +1914,9 @@ impl WidgetBuilder {
|
||||
}
|
||||
|
||||
/// Adds a child handle to the widget. [`Handle::NONE`] values are ignored.
|
||||
pub fn with_child(mut self, handle: Handle<UiNode>) -> Self {
|
||||
pub fn with_child(mut self, handle: Handle<impl ObjectOrVariant<UiNode>>) -> Self {
|
||||
if handle.is_some() {
|
||||
self.children.push(handle);
|
||||
self.children.push(handle.to_base());
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
+11
-10
@@ -21,6 +21,7 @@
|
||||
//! The Window widget provides a standard window that can contain another widget. See [`Window`] docs
|
||||
//! for more info and usage examples.
|
||||
|
||||
use crate::button::Button;
|
||||
use crate::message::MessageData;
|
||||
use crate::{
|
||||
border::BorderBuilder,
|
||||
@@ -240,11 +241,11 @@ pub struct Window {
|
||||
/// Handle of a header widget.
|
||||
pub header: Handle<UiNode>,
|
||||
/// Handle of a minimize button.
|
||||
pub minimize_button: Handle<UiNode>,
|
||||
pub minimize_button: Handle<Button>,
|
||||
/// Handle of a maximize button.
|
||||
pub maximize_button: Handle<UiNode>,
|
||||
pub maximize_button: Handle<Button>,
|
||||
/// Handle of a close button.
|
||||
pub close_button: Handle<UiNode>,
|
||||
pub close_button: Handle<Button>,
|
||||
/// A distance per each axis when the dragging starts.
|
||||
pub drag_delta: Vector2<f32>,
|
||||
/// Handle of a current content.
|
||||
@@ -882,11 +883,11 @@ pub struct WindowBuilder {
|
||||
/// Whether the window should be created open or not.
|
||||
pub open: bool,
|
||||
/// Optional custom closing button, if not specified, then a default button will be created.
|
||||
pub close_button: Option<Handle<UiNode>>,
|
||||
pub close_button: Option<Handle<Button>>,
|
||||
/// Optional custom minimization button, if not specified, then a default button will be created.
|
||||
pub minimize_button: Option<Handle<UiNode>>,
|
||||
pub minimize_button: Option<Handle<Button>>,
|
||||
/// Optional custom maximization button, if not specified, then a default button will be created.
|
||||
pub maximize_button: Option<Handle<UiNode>>,
|
||||
pub maximize_button: Option<Handle<Button>>,
|
||||
/// Whether the window should be created as modal or not. Warning: Any dependant builders must
|
||||
/// take this into account!
|
||||
pub modal: bool,
|
||||
@@ -1056,7 +1057,7 @@ fn make_mark(ctx: &mut BuildContext, button: HeaderButton) -> Handle<UiNode> {
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
fn make_header_button(ctx: &mut BuildContext, button: HeaderButton) -> Handle<UiNode> {
|
||||
fn make_header_button(ctx: &mut BuildContext, button: HeaderButton) -> Handle<Button> {
|
||||
ButtonBuilder::new(WidgetBuilder::new().with_margin(Thickness::uniform(2.0)))
|
||||
.with_back(
|
||||
DecoratorBuilder::new(
|
||||
@@ -1115,19 +1116,19 @@ impl WindowBuilder {
|
||||
}
|
||||
|
||||
/// Sets a desired minimization button.
|
||||
pub fn with_minimize_button(mut self, button: Handle<UiNode>) -> Self {
|
||||
pub fn with_minimize_button(mut self, button: Handle<Button>) -> Self {
|
||||
self.minimize_button = Some(button);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets a desired maximization button.
|
||||
pub fn with_maximize_button(mut self, button: Handle<UiNode>) -> Self {
|
||||
pub fn with_maximize_button(mut self, button: Handle<Button>) -> Self {
|
||||
self.minimize_button = Some(button);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets a desired closing button.
|
||||
pub fn with_close_button(mut self, button: Handle<UiNode>) -> Self {
|
||||
pub fn with_close_button(mut self, button: Handle<Button>) -> Self {
|
||||
self.close_button = Some(button);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ use crate::{
|
||||
upgrade::UpgradeTool,
|
||||
utils::{self, is_production_ready},
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::file_browser::{FileSelectorMode, PathFilter};
|
||||
use fyrox::gui::text_box::EmptyTextPlaceholder;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
@@ -123,16 +124,16 @@ pub struct ProjectSize {
|
||||
|
||||
pub struct ProjectManager {
|
||||
pub root_grid: Handle<UiNode>,
|
||||
create: Handle<UiNode>,
|
||||
import: Handle<UiNode>,
|
||||
create: Handle<Button>,
|
||||
import: Handle<Button>,
|
||||
projects: Handle<UiNode>,
|
||||
edit: Handle<UiNode>,
|
||||
run: Handle<UiNode>,
|
||||
delete: Handle<UiNode>,
|
||||
edit: Handle<Button>,
|
||||
run: Handle<Button>,
|
||||
delete: Handle<Button>,
|
||||
search_bar: Handle<UiNode>,
|
||||
project_controls: Handle<UiNode>,
|
||||
hot_reload: Handle<UiNode>,
|
||||
download: Handle<UiNode>,
|
||||
download: Handle<Button>,
|
||||
selection: Option<usize>,
|
||||
pub settings: Settings,
|
||||
project_wizard: Option<ProjectWizard>,
|
||||
@@ -141,19 +142,19 @@ pub struct ProjectManager {
|
||||
pub mode: Mode,
|
||||
search_text: String,
|
||||
log: LogPanel,
|
||||
open_log: Handle<UiNode>,
|
||||
open_log: Handle<Button>,
|
||||
message_count: Handle<UiNode>,
|
||||
deletion_confirmation_dialog: Handle<UiNode>,
|
||||
upgrade: Handle<UiNode>,
|
||||
locate: Handle<UiNode>,
|
||||
open_settings: Handle<UiNode>,
|
||||
open_help: Handle<UiNode>,
|
||||
open_ide: Handle<UiNode>,
|
||||
upgrade: Handle<Button>,
|
||||
locate: Handle<Button>,
|
||||
open_settings: Handle<Button>,
|
||||
open_help: Handle<Button>,
|
||||
open_ide: Handle<Button>,
|
||||
upgrade_tool: Option<UpgradeTool>,
|
||||
settings_window: Option<SettingsWindow>,
|
||||
no_projects_warning: Handle<UiNode>,
|
||||
exclude_project: Handle<UiNode>,
|
||||
clean_project: Handle<UiNode>,
|
||||
exclude_project: Handle<Button>,
|
||||
clean_project: Handle<Button>,
|
||||
project_size_receiver: Receiver<ProjectSize>,
|
||||
project_size_sender: Sender<ProjectSize>,
|
||||
pub focused: bool,
|
||||
|
||||
@@ -23,6 +23,7 @@ use crate::{
|
||||
settings::{Project, Settings},
|
||||
utils,
|
||||
};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::file_browser::PathFilter;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use fyrox::{
|
||||
@@ -102,8 +103,8 @@ impl Vcs {
|
||||
|
||||
pub struct ProjectWizard {
|
||||
pub window: Handle<UiNode>,
|
||||
create: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
create: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
path_field: Handle<UiNode>,
|
||||
name_field: Handle<UiNode>,
|
||||
style_field: Handle<UiNode>,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::{settings::Project, utils, utils::make_button};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::gui::window::WindowAlignment;
|
||||
use fyrox::{
|
||||
core::{log::Log, pool::Handle},
|
||||
@@ -65,8 +66,8 @@ impl Version {
|
||||
pub struct UpgradeTool {
|
||||
window: Handle<UiNode>,
|
||||
version_type_selector: Handle<UiNode>,
|
||||
upgrade: Handle<UiNode>,
|
||||
cancel: Handle<UiNode>,
|
||||
upgrade: Handle<Button>,
|
||||
cancel: Handle<Button>,
|
||||
selected_version: Version,
|
||||
version_input_field: Handle<UiNode>,
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
// SOFTWARE.
|
||||
|
||||
use cargo_metadata::{semver::VersionReq, Dependency, Metadata};
|
||||
use fyrox::gui::button::Button;
|
||||
use fyrox::{
|
||||
core::pool::Handle,
|
||||
gui::{
|
||||
button::ButtonBuilder, text::TextBuilder, utils::make_simple_tooltip,
|
||||
widget::WidgetBuilder, BuildContext, HorizontalAlignment, Thickness, UiNode,
|
||||
VerticalAlignment,
|
||||
widget::WidgetBuilder, BuildContext, HorizontalAlignment, Thickness, VerticalAlignment,
|
||||
},
|
||||
};
|
||||
use std::{
|
||||
@@ -55,7 +55,7 @@ pub fn make_button(
|
||||
column: usize,
|
||||
tooltip: Option<&str>,
|
||||
ctx: &mut BuildContext,
|
||||
) -> Handle<UiNode> {
|
||||
) -> Handle<Button> {
|
||||
let mut widget_builder = WidgetBuilder::new()
|
||||
.on_row(row)
|
||||
.on_column(column)
|
||||
|
||||
Reference in New Issue
Block a user