[drag-and-drop] Disable interactions with Tooltip layer
This commit is contained in:
parent
63c0379082
commit
c9c12f2d79
|
|
@ -53,10 +53,7 @@ impl Area {
|
|||
}
|
||||
|
||||
pub fn layer(&self) -> LayerId {
|
||||
LayerId {
|
||||
order: self.order,
|
||||
id: self.id,
|
||||
}
|
||||
LayerId::new(self.order, self.id)
|
||||
}
|
||||
|
||||
/// moveable by dragging the area?
|
||||
|
|
|
|||
|
|
@ -458,8 +458,8 @@ impl Context {
|
|||
.map(|id| self.memory().has_kb_focus(id))
|
||||
.unwrap_or(false);
|
||||
|
||||
if interaction_id.is_none() || sense == Sense::nothing() {
|
||||
// Not interested in input:
|
||||
if interaction_id.is_none() || sense == Sense::nothing() || !layer_id.allow_interaction() {
|
||||
// Not interested or allowed input:
|
||||
return Response {
|
||||
ctx: self.clone(),
|
||||
sense,
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ pub enum Order {
|
|||
/// Normal moveable windows that you reorder by click
|
||||
Middle,
|
||||
/// Popups, menus etc that should always be painted on top of windows
|
||||
Foreground,
|
||||
/// Foreground objects can also have tooltips
|
||||
Foreground,
|
||||
/// Things floating on top of everything else, like tooltips.
|
||||
/// You cannot interact with these.
|
||||
Tooltip,
|
||||
/// Debug layer, always painted last / on top
|
||||
Debug,
|
||||
|
|
@ -26,6 +28,13 @@ impl Order {
|
|||
Self::Tooltip,
|
||||
Self::Debug,
|
||||
];
|
||||
|
||||
pub fn allow_interaction(&self) -> bool {
|
||||
match self {
|
||||
Self::Background | Self::Middle | Self::Foreground | Self::Debug => true,
|
||||
Self::Tooltip => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An identifier for a paint layer.
|
||||
|
|
@ -38,6 +47,10 @@ pub struct LayerId {
|
|||
}
|
||||
|
||||
impl LayerId {
|
||||
pub fn new(order: Order, id: Id) -> Self {
|
||||
Self { order, id }
|
||||
}
|
||||
|
||||
pub fn debug() -> Self {
|
||||
Self {
|
||||
order: Order::Debug,
|
||||
|
|
@ -51,6 +64,10 @@ impl LayerId {
|
|||
id: Id::background(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn allow_interaction(&self) -> bool {
|
||||
self.order.allow_interaction()
|
||||
}
|
||||
}
|
||||
|
||||
/// A unique identifier of a specific `PaintCmd` in a `PaintList`.
|
||||
|
|
|
|||
|
|
@ -109,10 +109,7 @@ impl Ui {
|
|||
let mut ctx = Context::new();
|
||||
ctx.begin_frame(Default::default());
|
||||
let id = Id::new("__test");
|
||||
let layer_id = LayerId {
|
||||
order: Order::Middle,
|
||||
id,
|
||||
};
|
||||
let layer_id = LayerId::new(Order::Middle, id);
|
||||
let rect = Rect::from_min_size(Pos2::new(0.0, 0.0), vec2(1000.0, 1000.0));
|
||||
Self::new(ctx, layer_id, id, rect, rect)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue