From 27ac3d9dc125747036eb7ee1cc7ec91ba645e294 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Thu, 28 Jul 2022 18:57:23 +1000 Subject: [PATCH] fix image modal center --- services/gam/src/bitmap.rs | 4 ++++ services/gam/src/modal/image.rs | 2 +- services/modals/src/lib.rs | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/services/gam/src/bitmap.rs b/services/gam/src/bitmap.rs index aa10284ad..933861984 100644 --- a/services/gam/src/bitmap.rs +++ b/services/gam/src/bitmap.rs @@ -278,6 +278,10 @@ impl Bitmap { for tile in self.mosaic.as_mut_slice() { tile.translate(offset); } + self.bound.tl.x += offset.x; + self.bound.tl.y += offset.y; + self.bound.br.x += offset.x; + self.bound.br.y += offset.y; } pub fn rotate90(&mut self) -> Self { diff --git a/services/gam/src/modal/image.rs b/services/gam/src/modal/image.rs index 5d528193f..ecebe6393 100644 --- a/services/gam/src/modal/image.rs +++ b/services/gam/src/modal/image.rs @@ -1,6 +1,6 @@ use crate::*; -pub const IMG_MODAL_HEIGHT: u32 = 300; +pub const IMG_MODAL_HEIGHT: u32 = 374; pub const IMG_MODAL_WIDTH: u32 = 296; #[derive(Debug)] pub struct Image { diff --git a/services/modals/src/lib.rs b/services/modals/src/lib.rs index a64db38e4..eb7ae33e5 100644 --- a/services/modals/src/lib.rs +++ b/services/modals/src/lib.rs @@ -10,7 +10,7 @@ use gam::*; use num_traits::*; #[cfg(feature = "ditherpunk")] use std::convert::TryInto; -use std::cmp::min; +use std::cmp::max; use xous::{send_message, Message, CID}; use xous_ipc::Buffer; @@ -203,10 +203,10 @@ impl Modals { // center image in modal const BORDER: u32 = 3; let margin = Point::new( - (BORDER + min(0,(gam::IMG_MODAL_WIDTH - 2 * BORDER - bm_width) / 2)) + (BORDER + max(0, (gam::IMG_MODAL_WIDTH - 2 * BORDER - bm_width) / 2)) .try_into() .unwrap(), - (BORDER + min(0, (gam::IMG_MODAL_HEIGHT - 2 * BORDER - bm_height) / 2)) + (BORDER + max(0, (gam::IMG_MODAL_HEIGHT - 2 * BORDER - bm_height) / 2)) .try_into() .unwrap(), );