mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-16 03:56:12 +08:00
Check that a widget is being dragged before checking the event in graphview.
A bug in gtk4-rs makes the library print errors when accessing an event, this change reduces the amount of errors, as they are only printed when the mouse is over a node now.
This commit is contained in:
@@ -44,24 +44,26 @@ mod imp {
|
|||||||
fn constructed(&self, obj: &Self::Type) {
|
fn constructed(&self, obj: &Self::Type) {
|
||||||
self.parent_constructed(obj);
|
self.parent_constructed(obj);
|
||||||
|
|
||||||
|
// Move the Node that is currently being dragged to the cursor position as long as Mouse Button 1 is held.
|
||||||
let motion_controller = gtk::EventControllerMotion::new();
|
let motion_controller = gtk::EventControllerMotion::new();
|
||||||
motion_controller.connect_motion(|controller, x, y| {
|
motion_controller.connect_motion(|controller, x, y| {
|
||||||
if controller
|
let instance = controller
|
||||||
.get_current_event()
|
.get_widget()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get_modifier_state()
|
.dynamic_cast::<Self::Type>()
|
||||||
.contains(gdk::ModifierType::BUTTON1_MASK)
|
.unwrap();
|
||||||
{
|
let this = imp::GraphView::from_instance(&instance);
|
||||||
let instance = controller
|
|
||||||
.get_widget()
|
if let Some(ref widget) = *this.dragged.borrow() {
|
||||||
|
if controller
|
||||||
|
.get_current_event()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.dynamic_cast::<Self::Type>()
|
.get_modifier_state()
|
||||||
.unwrap();
|
.contains(gdk::ModifierType::BUTTON1_MASK)
|
||||||
let this = imp::GraphView::from_instance(&instance);
|
{
|
||||||
if let Some(ref widget) = *this.dragged.borrow() {
|
instance.move_node(&widget, x as f32, y as f32);
|
||||||
this.move_node(&widget, x as f32, y as f32);
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
});
|
});
|
||||||
obj.add_controller(&motion_controller);
|
obj.add_controller(&motion_controller);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user