Skip to content

Commit

Permalink
feat: resize handle hover signifier
Browse files Browse the repository at this point in the history
  • Loading branch information
technobaboo committed Jul 7, 2024
1 parent 732973e commit 5ad1bf9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/resize_handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ impl ResizeHandle {
&ResourceID::new_namespaced("flatland", "resize_handle"),
)?;
let sphere = model.part("sphere")?;
sphere.set_material_parameter(
"color",
MaterialParameter::Color(rgba_linear!(0.75, 0.75, 0.75, 1.0)),
)?;

let field = Field::create(&model, Transform::identity(), Shape::Sphere(0.005))?;
let input = InputHandler::create(root, Transform::identity(), &field)?.queue()?;
Expand Down Expand Up @@ -222,6 +226,26 @@ impl ResizeHandle {
},
);

// if something just got close
if self.grab_action.hovering().added().len() > 0
&& self.grab_action.hovering().added().len()
== self.grab_action.hovering().current().len()
{
let _ = self.sphere.set_material_parameter(
"color",
MaterialParameter::Color(rgba_linear!(1.0, 1.0, 1.0, 1.0)),
);
}

if self.grab_action.hovering().current().len() == 0
&& self.grab_action.hovering().removed().len() > 0
{
let _ = self.sphere.set_material_parameter(
"color",
MaterialParameter::Color(rgba_linear!(0.5, 0.5, 0.5, 1.0)),
);
}

if self.grab_action.actor_started() {
let _ = self.sphere.set_material_parameter(
"color",
Expand All @@ -234,7 +258,7 @@ impl ResizeHandle {
if self.grab_action.actor_stopped() {
let _ = self.sphere.set_material_parameter(
"color",
MaterialParameter::Color(rgba_linear!(1.0, 1.0, 1.0, 1.0)),
MaterialParameter::Color(rgba_linear!(0.5, 0.5, 0.5, 1.0)),
);
}
}
Expand Down

0 comments on commit 5ad1bf9

Please sign in to comment.