Skip to content

Commit

Permalink
Change drag events in the map editor into pointer down events (#118)
Browse files Browse the repository at this point in the history
* fix: change map painting from on drag to on pointer down

* fix: change tilepicker selection from on drag to on pointer down

* chore: stop using deprecated `image::GenericImageView::bounds`
  • Loading branch information
white-axe authored Mar 25, 2024
1 parent 55ea5ef commit d51aa4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion crates/components/src/tilepicker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ impl Tilepicker {
};
let pos = ((pos - canvas_rect.min) / 32.).to_pos2();

if response.dragged_by(egui::PointerButton::Primary) {
if response.is_pointer_button_down_on()
&& ui.input(|i| i.pointer.button_down(egui::PointerButton::Primary))
{
let drag_origin = if let Some(drag_origin) = self.drag_origin {
drag_origin
} else {
Expand Down
3 changes: 2 additions & 1 deletion crates/graphics/src/tiles/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ fn write_texture_region<P>(
P: image::Pixel,
P::Subpixel: bytemuck::Pod,
{
let (x, y, width, height) = image.bounds();
let (x, y) = image.offsets();
let (width, height) = image.dimensions();
let bytes = bytemuck::cast_slice(image.inner().as_raw());

let inner_width = image.inner().width();
Expand Down
7 changes: 5 additions & 2 deletions crates/ui/src/tabs/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,11 @@ impl luminol_core::Tab for Tab {
}

// Tile drawing
if response.dragged_by(egui::PointerButton::Primary)
&& !ui.input(|i| i.modifiers.command)
if response.is_pointer_button_down_on()
&& ui.input(|i| {
i.pointer.button_down(egui::PointerButton::Primary)
&& !i.modifiers.command
})
{
self.handle_brush(
map_x as usize,
Expand Down

0 comments on commit d51aa4a

Please sign in to comment.