mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Improve drag-code
This commit is contained in:
@@ -3,8 +3,7 @@ use std::collections::HashMap;
|
||||
use egui::{vec2, Rect};
|
||||
|
||||
use crate::dock::{
|
||||
is_being_dragged, is_possible_drag, Behavior, DropContext, InsertionPoint, LayoutInsertion,
|
||||
NodeId, Nodes,
|
||||
is_being_dragged, Behavior, DropContext, InsertionPoint, LayoutInsertion, NodeId, Nodes,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
||||
@@ -58,8 +57,7 @@ impl Tabs {
|
||||
let next_active = self.tab_bar_ui(behavior, ui, rect, nodes, drop_context, node_id);
|
||||
|
||||
// When dragged, don't show it (it is "being held")
|
||||
let is_active_being_dragged =
|
||||
ui.memory(|mem| mem.is_being_dragged(self.active.id())) && is_possible_drag(ui.ctx());
|
||||
let is_active_being_dragged = is_being_dragged(ui.ctx(), self.active);
|
||||
if !is_active_being_dragged {
|
||||
nodes.node_ui(behavior, drop_context, ui, self.active);
|
||||
}
|
||||
|
||||
@@ -165,11 +165,7 @@ enum SimplifyAction {
|
||||
}
|
||||
|
||||
fn is_possible_drag(ctx: &egui::Context) -> bool {
|
||||
ctx.input(|input| {
|
||||
!input.pointer.any_pressed()
|
||||
&& !input.pointer.could_any_button_be_click()
|
||||
&& !input.pointer.any_click()
|
||||
})
|
||||
ctx.input(|input| input.pointer.is_decidedly_dragging())
|
||||
}
|
||||
|
||||
fn is_being_dragged(ctx: &egui::Context, node_id: NodeId) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user