rename LayerId to AreaLayerId
This commit is contained in:
parent
6ae4bc486b
commit
1e770ae3bd
14 changed files with 77 additions and 64 deletions
|
@ -77,8 +77,8 @@ impl Area {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn layer(&self) -> LayerId {
|
||||
LayerId::new(self.order, self.id)
|
||||
pub fn layer(&self) -> AreaLayerId {
|
||||
AreaLayerId::new(self.order, self.id)
|
||||
}
|
||||
|
||||
/// If false, no content responds to click
|
||||
|
@ -187,7 +187,7 @@ impl Area {
|
|||
}
|
||||
|
||||
pub(crate) struct Prepared {
|
||||
layer_id: LayerId,
|
||||
layer_id: AreaLayerId,
|
||||
state: State,
|
||||
move_response: Response,
|
||||
enabled: bool,
|
||||
|
@ -229,7 +229,7 @@ impl Area {
|
|||
constrain,
|
||||
} = self;
|
||||
|
||||
let layer_id = LayerId::new(order, id);
|
||||
let layer_id = AreaLayerId::new(order, id);
|
||||
|
||||
let state = ctx.memory().areas.get(id).copied();
|
||||
let is_new = state.is_none();
|
||||
|
@ -328,7 +328,7 @@ impl Area {
|
|||
return;
|
||||
}
|
||||
|
||||
let layer_id = LayerId::new(self.order, self.id);
|
||||
let layer_id = AreaLayerId::new(self.order, self.id);
|
||||
let area_rect = ctx.memory().areas.get(self.id).map(|area| area.rect());
|
||||
if let Some(area_rect) = area_rect {
|
||||
let clip_rect = ctx.available_rect();
|
||||
|
@ -416,7 +416,7 @@ impl Prepared {
|
|||
}
|
||||
}
|
||||
|
||||
fn pointer_pressed_on_area(ctx: &Context, layer_id: LayerId) -> bool {
|
||||
fn pointer_pressed_on_area(ctx: &Context, layer_id: AreaLayerId) -> bool {
|
||||
if let Some(pointer_pos) = ctx.pointer_interact_pos() {
|
||||
let any_pressed = ctx.input().pointer.any_pressed();
|
||||
any_pressed && ctx.layer_id_at(pointer_pos) == Some(layer_id)
|
||||
|
|
|
@ -331,7 +331,7 @@ impl SidePanel {
|
|||
ctx: &Context,
|
||||
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
|
||||
) -> InnerResponse<R> {
|
||||
let layer_id = LayerId::background();
|
||||
let layer_id = AreaLayerId::background();
|
||||
let side = self.side;
|
||||
let available_rect = ctx.available_rect();
|
||||
let clip_rect = ctx.input().screen_rect();
|
||||
|
@ -783,7 +783,7 @@ impl TopBottomPanel {
|
|||
ctx: &Context,
|
||||
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
|
||||
) -> InnerResponse<R> {
|
||||
let layer_id = LayerId::background();
|
||||
let layer_id = AreaLayerId::background();
|
||||
let available_rect = ctx.available_rect();
|
||||
let side = self.side;
|
||||
|
||||
|
@ -1039,7 +1039,7 @@ impl CentralPanel {
|
|||
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
|
||||
) -> InnerResponse<R> {
|
||||
let available_rect = ctx.available_rect();
|
||||
let layer_id = LayerId::background();
|
||||
let layer_id = AreaLayerId::background();
|
||||
let id = Id::new("central_panel");
|
||||
|
||||
let clip_rect = ctx.input().screen_rect();
|
||||
|
|
|
@ -282,7 +282,7 @@ pub fn was_tooltip_open_last_frame(ctx: &Context, tooltip_id: Id) -> bool {
|
|||
for (count, (individual_id, _size)) in &state.individual_ids_and_sizes {
|
||||
if *individual_id == tooltip_id {
|
||||
let area_id = common_id.with(count);
|
||||
let layer_id = LayerId::new(Order::Tooltip, area_id);
|
||||
let layer_id = AreaLayerId::new(Order::Tooltip, area_id);
|
||||
if ctx.memory().areas.visible_last_frame(&layer_id) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -488,7 +488,7 @@ impl PossibleInteractions {
|
|||
/// Either a move or resize
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(crate) struct WindowInteraction {
|
||||
pub(crate) area_layer_id: LayerId,
|
||||
pub(crate) area_layer_id: AreaLayerId,
|
||||
pub(crate) start_rect: Rect,
|
||||
pub(crate) left: bool,
|
||||
pub(crate) right: bool,
|
||||
|
@ -518,7 +518,7 @@ fn interact(
|
|||
window_interaction: WindowInteraction,
|
||||
ctx: &Context,
|
||||
margins: Vec2,
|
||||
area_layer_id: LayerId,
|
||||
area_layer_id: AreaLayerId,
|
||||
area: &mut area::Prepared,
|
||||
resize_id: Id,
|
||||
) -> Option<WindowInteraction> {
|
||||
|
@ -585,7 +585,7 @@ fn move_and_resize_window(ctx: &Context, window_interaction: &WindowInteraction)
|
|||
fn window_interaction(
|
||||
ctx: &Context,
|
||||
possible: PossibleInteractions,
|
||||
area_layer_id: LayerId,
|
||||
area_layer_id: AreaLayerId,
|
||||
id: Id,
|
||||
rect: Rect,
|
||||
) -> Option<WindowInteraction> {
|
||||
|
@ -626,7 +626,7 @@ fn window_interaction(
|
|||
fn resize_hover(
|
||||
ctx: &Context,
|
||||
possible: PossibleInteractions,
|
||||
area_layer_id: LayerId,
|
||||
area_layer_id: AreaLayerId,
|
||||
rect: Rect,
|
||||
) -> Option<WindowInteraction> {
|
||||
let pointer = ctx.input().pointer.interact_pos()?;
|
||||
|
|
|
@ -64,9 +64,9 @@ struct ContextImpl {
|
|||
requested_repaint_last_frame: bool,
|
||||
|
||||
/// Written to during the frame.
|
||||
layer_rects_this_frame: ahash::HashMap<LayerId, Vec<(Id, Rect)>>,
|
||||
layer_rects_this_frame: ahash::HashMap<AreaLayerId, Vec<(Id, Rect)>>,
|
||||
/// Read
|
||||
layer_rects_prev_frame: ahash::HashMap<LayerId, Vec<(Id, Rect)>>,
|
||||
layer_rects_prev_frame: ahash::HashMap<AreaLayerId, Vec<(Id, Rect)>>,
|
||||
|
||||
#[cfg(feature = "accesskit")]
|
||||
is_accesskit_enabled: bool,
|
||||
|
@ -101,7 +101,7 @@ impl ContextImpl {
|
|||
// Ensure we register the background area so panels and background ui can catch clicks:
|
||||
let screen_rect = self.input.screen_rect();
|
||||
self.memory.areas.set_state(
|
||||
LayerId::background(),
|
||||
AreaLayerId::background(),
|
||||
containers::area::State {
|
||||
pos: screen_rect.min,
|
||||
size: screen_rect.size(),
|
||||
|
@ -377,7 +377,7 @@ impl Context {
|
|||
&self,
|
||||
clip_rect: Rect,
|
||||
item_spacing: Vec2,
|
||||
layer_id: LayerId,
|
||||
layer_id: AreaLayerId,
|
||||
id: Id,
|
||||
rect: Rect,
|
||||
sense: Sense,
|
||||
|
@ -400,7 +400,7 @@ impl Context {
|
|||
// Whichever widget is added LAST (=on top) gets the input:
|
||||
if interact_rect.is_positive() && sense.interactive() {
|
||||
if self.style().debug.show_interactive_widgets {
|
||||
Self::layer_painter(self, LayerId::debug()).rect(
|
||||
Self::layer_painter(self, AreaLayerId::debug()).rect(
|
||||
interact_rect,
|
||||
0.0,
|
||||
Color32::YELLOW.additive().linear_multiply(0.005),
|
||||
|
@ -429,12 +429,12 @@ impl Context {
|
|||
|
||||
if slf.memory.options.style.debug.show_blocking_widget {
|
||||
drop(slf);
|
||||
Self::layer_painter(self, LayerId::debug()).debug_rect(
|
||||
Self::layer_painter(self, AreaLayerId::debug()).debug_rect(
|
||||
interact_rect,
|
||||
Color32::GREEN,
|
||||
"Covered",
|
||||
);
|
||||
Self::layer_painter(self, LayerId::debug()).debug_rect(
|
||||
Self::layer_painter(self, AreaLayerId::debug()).debug_rect(
|
||||
prev_rect,
|
||||
Color32::LIGHT_BLUE,
|
||||
"On top",
|
||||
|
@ -456,7 +456,7 @@ impl Context {
|
|||
/// You specify if a thing is hovered, and the function gives a [`Response`].
|
||||
pub(crate) fn interact_with_hovered(
|
||||
&self,
|
||||
layer_id: LayerId,
|
||||
layer_id: AreaLayerId,
|
||||
id: Id,
|
||||
rect: Rect,
|
||||
sense: Sense,
|
||||
|
@ -604,14 +604,14 @@ impl Context {
|
|||
}
|
||||
|
||||
/// Get a full-screen painter for a new or existing layer
|
||||
pub fn layer_painter(&self, layer_id: LayerId) -> Painter {
|
||||
pub fn layer_painter(&self, layer_id: AreaLayerId) -> Painter {
|
||||
let screen_rect = self.input().screen_rect();
|
||||
Painter::new(self.clone(), layer_id, screen_rect)
|
||||
}
|
||||
|
||||
/// Paint on top of everything else
|
||||
pub fn debug_painter(&self) -> Painter {
|
||||
Self::layer_painter(self, LayerId::debug())
|
||||
Self::layer_painter(self, AreaLayerId::debug())
|
||||
}
|
||||
|
||||
/// How much space is still available after panels has been added.
|
||||
|
@ -1232,25 +1232,25 @@ impl Context {
|
|||
impl Context {
|
||||
/// Move all the graphics at the given layer.
|
||||
/// Can be used to implement drag-and-drop (see relevant demo).
|
||||
pub fn translate_layer(&self, layer_id: LayerId, delta: Vec2) {
|
||||
pub fn translate_layer(&self, layer_id: AreaLayerId, delta: Vec2) {
|
||||
if delta != Vec2::ZERO {
|
||||
self.graphics().list(layer_id).translate(delta);
|
||||
}
|
||||
}
|
||||
|
||||
/// Top-most layer at the given position.
|
||||
pub fn layer_id_at(&self, pos: Pos2) -> Option<LayerId> {
|
||||
pub fn layer_id_at(&self, pos: Pos2) -> Option<AreaLayerId> {
|
||||
let resize_grab_radius_side = self.style().interaction.resize_grab_radius_side;
|
||||
self.memory().layer_id_at(pos, resize_grab_radius_side)
|
||||
}
|
||||
|
||||
/// Moves the given area to the top in its [`Order`].
|
||||
/// [`Area`]:s and [`Window`]:s also do this automatically when being clicked on or interacted with.
|
||||
pub fn move_to_top(&self, layer_id: LayerId) {
|
||||
pub fn move_to_top(&self, layer_id: AreaLayerId) {
|
||||
self.memory().areas.move_to_top(layer_id);
|
||||
}
|
||||
|
||||
pub(crate) fn rect_contains_pointer(&self, layer_id: LayerId, rect: Rect) -> bool {
|
||||
pub(crate) fn rect_contains_pointer(&self, layer_id: AreaLayerId, rect: Rect) -> bool {
|
||||
rect.is_positive() && {
|
||||
let pointer_pos = self.input().pointer.interact_pos();
|
||||
if let Some(pointer_pos) = pointer_pos {
|
||||
|
@ -1517,7 +1517,7 @@ impl Context {
|
|||
ui.indent("areas", |ui| {
|
||||
ui.label("Visible areas, ordered back to front.");
|
||||
ui.label("Hover to highlight");
|
||||
let layers_ids: Vec<LayerId> = self.memory().areas.order().to_vec();
|
||||
let layers_ids: Vec<AreaLayerId> = self.memory().areas.order().to_vec();
|
||||
for layer_id in layers_ids {
|
||||
let area = self.memory().areas.get(layer_id.id).copied();
|
||||
if let Some(area) = area {
|
||||
|
|
|
@ -69,12 +69,12 @@ impl Order {
|
|||
/// Also acts as an identifier for [`Area`]:s.
|
||||
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct LayerId {
|
||||
pub struct AreaLayerId {
|
||||
pub order: Order,
|
||||
pub id: Id,
|
||||
}
|
||||
|
||||
impl LayerId {
|
||||
impl AreaLayerId {
|
||||
pub fn new(order: Order, id: Id) -> Self {
|
||||
Self { order, id }
|
||||
}
|
||||
|
@ -163,13 +163,16 @@ impl PaintList {
|
|||
pub(crate) struct GraphicLayers([IdMap<PaintList>; Order::COUNT]);
|
||||
|
||||
impl GraphicLayers {
|
||||
pub fn list(&mut self, layer_id: LayerId) -> &mut PaintList {
|
||||
pub fn list(&mut self, layer_id: AreaLayerId) -> &mut PaintList {
|
||||
self.0[layer_id.order as usize]
|
||||
.entry(layer_id.id)
|
||||
.or_default()
|
||||
}
|
||||
|
||||
pub fn drain(&mut self, area_order: &[LayerId]) -> impl ExactSizeIterator<Item = ClippedShape> {
|
||||
pub fn drain(
|
||||
&mut self,
|
||||
area_order: &[AreaLayerId],
|
||||
) -> impl ExactSizeIterator<Item = ClippedShape> {
|
||||
let mut all_shapes: Vec<_> = Default::default();
|
||||
|
||||
for &order in &Order::ALL {
|
||||
|
|
|
@ -361,7 +361,7 @@ pub use {
|
|||
grid::Grid,
|
||||
id::{Id, IdMap},
|
||||
input_state::{InputState, MultiTouchInfo, PointerState},
|
||||
layers::{LayerId, Order},
|
||||
layers::{AreaLayerId, Order},
|
||||
layout::*,
|
||||
memory::Memory,
|
||||
painter::Painter,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{area, window, Id, IdMap, InputState, LayerId, Pos2, Rect, Style};
|
||||
use crate::{area, window, AreaLayerId, Id, IdMap, InputState, Pos2, Rect, Style};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -357,12 +357,12 @@ impl Memory {
|
|||
}
|
||||
|
||||
/// Top-most layer at the given position.
|
||||
pub fn layer_id_at(&self, pos: Pos2, resize_interact_radius_side: f32) -> Option<LayerId> {
|
||||
pub fn layer_id_at(&self, pos: Pos2, resize_interact_radius_side: f32) -> Option<AreaLayerId> {
|
||||
self.areas.layer_id_at(pos, resize_interact_radius_side)
|
||||
}
|
||||
|
||||
/// An iterator over all layers. Back-to-front. Top is last.
|
||||
pub fn layer_ids(&self) -> impl ExactSizeIterator<Item = LayerId> + '_ {
|
||||
pub fn layer_ids(&self) -> impl ExactSizeIterator<Item = AreaLayerId> + '_ {
|
||||
self.areas.order().iter().copied()
|
||||
}
|
||||
|
||||
|
@ -525,16 +525,16 @@ impl Memory {
|
|||
pub struct Areas {
|
||||
areas: IdMap<area::State>,
|
||||
/// Back-to-front. Top is last.
|
||||
order: Vec<LayerId>,
|
||||
visible_last_frame: ahash::HashSet<LayerId>,
|
||||
visible_current_frame: ahash::HashSet<LayerId>,
|
||||
order: Vec<AreaLayerId>,
|
||||
visible_last_frame: ahash::HashSet<AreaLayerId>,
|
||||
visible_current_frame: ahash::HashSet<AreaLayerId>,
|
||||
|
||||
/// When an area want to be on top, it is put in here.
|
||||
/// At the end of the frame, this is used to reorder the layers.
|
||||
/// This means if several layers want to be on top, they will keep their relative order.
|
||||
/// So if you close three windows and then reopen them all in one frame,
|
||||
/// they will all be sent to the top, but keep their previous internal order.
|
||||
wants_to_be_on_top: ahash::HashSet<LayerId>,
|
||||
wants_to_be_on_top: ahash::HashSet<AreaLayerId>,
|
||||
}
|
||||
|
||||
impl Areas {
|
||||
|
@ -547,11 +547,11 @@ impl Areas {
|
|||
}
|
||||
|
||||
/// Back-to-front. Top is last.
|
||||
pub(crate) fn order(&self) -> &[LayerId] {
|
||||
pub(crate) fn order(&self) -> &[AreaLayerId] {
|
||||
&self.order
|
||||
}
|
||||
|
||||
pub(crate) fn set_state(&mut self, layer_id: LayerId, state: area::State) {
|
||||
pub(crate) fn set_state(&mut self, layer_id: AreaLayerId, state: area::State) {
|
||||
self.visible_current_frame.insert(layer_id);
|
||||
self.areas.insert(layer_id.id, state);
|
||||
if !self.order.iter().any(|x| *x == layer_id) {
|
||||
|
@ -560,7 +560,7 @@ impl Areas {
|
|||
}
|
||||
|
||||
/// Top-most layer at the given position.
|
||||
pub fn layer_id_at(&self, pos: Pos2, resize_interact_radius_side: f32) -> Option<LayerId> {
|
||||
pub fn layer_id_at(&self, pos: Pos2, resize_interact_radius_side: f32) -> Option<AreaLayerId> {
|
||||
for layer in self.order.iter().rev() {
|
||||
if self.is_visible(layer) {
|
||||
if let Some(state) = self.areas.get(&layer.id) {
|
||||
|
@ -578,15 +578,15 @@ impl Areas {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn visible_last_frame(&self, layer_id: &LayerId) -> bool {
|
||||
pub fn visible_last_frame(&self, layer_id: &AreaLayerId) -> bool {
|
||||
self.visible_last_frame.contains(layer_id)
|
||||
}
|
||||
|
||||
pub fn is_visible(&self, layer_id: &LayerId) -> bool {
|
||||
pub fn is_visible(&self, layer_id: &AreaLayerId) -> bool {
|
||||
self.visible_last_frame.contains(layer_id) || self.visible_current_frame.contains(layer_id)
|
||||
}
|
||||
|
||||
pub fn visible_layer_ids(&self) -> ahash::HashSet<LayerId> {
|
||||
pub fn visible_layer_ids(&self) -> ahash::HashSet<AreaLayerId> {
|
||||
self.visible_last_frame
|
||||
.iter()
|
||||
.copied()
|
||||
|
@ -602,7 +602,7 @@ impl Areas {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn move_to_top(&mut self, layer_id: LayerId) {
|
||||
pub fn move_to_top(&mut self, layer_id: AreaLayerId) {
|
||||
self.visible_current_frame.insert(layer_id);
|
||||
self.wants_to_be_on_top.insert(layer_id);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
|
||||
use crate::{
|
||||
emath::{Align2, Pos2, Rect, Vec2},
|
||||
layers::{LayerId, PaintList, ShapeIdx},
|
||||
layers::{AreaLayerId, PaintList, ShapeIdx},
|
||||
Color32, Context, FontId,
|
||||
};
|
||||
use epaint::{
|
||||
|
@ -21,7 +21,7 @@ pub struct Painter {
|
|||
ctx: Context,
|
||||
|
||||
/// Where we paint
|
||||
layer_id: LayerId,
|
||||
layer_id: AreaLayerId,
|
||||
|
||||
/// Everything painted in this [`Painter`] will be clipped against this.
|
||||
/// This means nothing outside of this rectangle will be visible on screen.
|
||||
|
@ -34,7 +34,7 @@ pub struct Painter {
|
|||
|
||||
impl Painter {
|
||||
/// Create a painter to a specific layer within a certain clip rectangle.
|
||||
pub fn new(ctx: Context, layer_id: LayerId, clip_rect: Rect) -> Self {
|
||||
pub fn new(ctx: Context, layer_id: AreaLayerId, clip_rect: Rect) -> Self {
|
||||
Self {
|
||||
ctx,
|
||||
layer_id,
|
||||
|
@ -45,7 +45,7 @@ impl Painter {
|
|||
|
||||
/// Redirect where you are painting.
|
||||
#[must_use]
|
||||
pub fn with_layer_id(self, layer_id: LayerId) -> Self {
|
||||
pub fn with_layer_id(self, layer_id: AreaLayerId) -> Self {
|
||||
Self {
|
||||
ctx: self.ctx,
|
||||
layer_id,
|
||||
|
@ -68,7 +68,7 @@ impl Painter {
|
|||
}
|
||||
|
||||
/// Redirect where you are painting.
|
||||
pub fn set_layer_id(&mut self, layer_id: LayerId) {
|
||||
pub fn set_layer_id(&mut self, layer_id: AreaLayerId) {
|
||||
self.layer_id = layer_id;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ impl Painter {
|
|||
|
||||
/// Where we paint
|
||||
#[inline(always)]
|
||||
pub fn layer_id(&self) -> LayerId {
|
||||
pub fn layer_id(&self) -> AreaLayerId {
|
||||
self.layer_id
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
emath::{Align, Pos2, Rect, Vec2},
|
||||
menu, Context, CursorIcon, Id, LayerId, PointerButton, Sense, Ui, WidgetText,
|
||||
menu, AreaLayerId, Context, CursorIcon, Id, PointerButton, Sense, Ui, WidgetText,
|
||||
NUM_POINTER_BUTTONS,
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub struct Response {
|
|||
|
||||
// IN:
|
||||
/// Which layer the widget is part of.
|
||||
pub layer_id: LayerId,
|
||||
pub layer_id: AreaLayerId,
|
||||
|
||||
/// The [`Id`] of the widget/area this response pertains.
|
||||
pub id: Id,
|
||||
|
|
|
@ -71,7 +71,13 @@ impl Ui {
|
|||
///
|
||||
/// Normally you would not use this directly, but instead use
|
||||
/// [`SidePanel`], [`TopBottomPanel`], [`CentralPanel`], [`Window`] or [`Area`].
|
||||
pub fn new(ctx: Context, layer_id: LayerId, id: Id, max_rect: Rect, clip_rect: Rect) -> Self {
|
||||
pub fn new(
|
||||
ctx: Context,
|
||||
layer_id: AreaLayerId,
|
||||
id: Id,
|
||||
max_rect: Rect,
|
||||
clip_rect: Rect,
|
||||
) -> Self {
|
||||
let style = ctx.style();
|
||||
Ui {
|
||||
id,
|
||||
|
@ -310,7 +316,7 @@ impl Ui {
|
|||
|
||||
/// Use this to paint stuff within this [`Ui`].
|
||||
#[inline]
|
||||
pub fn layer_id(&self) -> LayerId {
|
||||
pub fn layer_id(&self) -> AreaLayerId {
|
||||
self.painter().layer_id()
|
||||
}
|
||||
|
||||
|
@ -1728,7 +1734,7 @@ impl Ui {
|
|||
/// Redirect shapes to another paint layer.
|
||||
pub fn with_layer_id<R>(
|
||||
&mut self,
|
||||
layer_id: LayerId,
|
||||
layer_id: AreaLayerId,
|
||||
add_contents: impl FnOnce(&mut Self) -> R,
|
||||
) -> InnerResponse<R> {
|
||||
self.scope(|ui| {
|
||||
|
|
|
@ -354,8 +354,10 @@ impl WrapApp {
|
|||
}
|
||||
}
|
||||
|
||||
let painter =
|
||||
ctx.layer_painter(LayerId::new(Order::Foreground, Id::new("file_drop_target")));
|
||||
let painter = ctx.layer_painter(AreaLayerId::new(
|
||||
Order::Foreground,
|
||||
Id::new("file_drop_target"),
|
||||
));
|
||||
|
||||
let screen_rect = ctx.input().screen_rect();
|
||||
painter.rect_filled(screen_rect, 0.0, Color32::from_black_alpha(192));
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn drag_source(ui: &mut Ui, id: Id, body: impl FnOnce(&mut Ui)) {
|
|||
ui.output().cursor_icon = CursorIcon::Grabbing;
|
||||
|
||||
// Paint the body to a new layer:
|
||||
let layer_id = LayerId::new(Order::Tooltip, id);
|
||||
let layer_id = AreaLayerId::new(Order::Tooltip, id);
|
||||
let response = ui.with_layer_id(layer_id, body).response;
|
||||
|
||||
// Now we move the visuals of the body to where the mouse is.
|
||||
|
|
|
@ -88,8 +88,10 @@ fn preview_files_being_dropped(ctx: &egui::Context) {
|
|||
}
|
||||
}
|
||||
|
||||
let painter =
|
||||
ctx.layer_painter(LayerId::new(Order::Foreground, Id::new("file_drop_target")));
|
||||
let painter = ctx.layer_painter(AreaLayerId::new(
|
||||
Order::Foreground,
|
||||
Id::new("file_drop_target"),
|
||||
));
|
||||
|
||||
let screen_rect = ctx.input().screen_rect();
|
||||
painter.rect_filled(screen_rect, 0.0, Color32::from_black_alpha(192));
|
||||
|
|
Loading…
Reference in a new issue