fix image modal center

This commit is contained in:
nworbnhoj 2022-07-28 18:57:23 +10:00
parent 7af94e674d
commit 27ac3d9dc1
3 changed files with 8 additions and 4 deletions

View file

@ -278,6 +278,10 @@ impl Bitmap {
for tile in self.mosaic.as_mut_slice() { for tile in self.mosaic.as_mut_slice() {
tile.translate(offset); 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 { pub fn rotate90(&mut self) -> Self {

View file

@ -1,6 +1,6 @@
use crate::*; use crate::*;
pub const IMG_MODAL_HEIGHT: u32 = 300; pub const IMG_MODAL_HEIGHT: u32 = 374;
pub const IMG_MODAL_WIDTH: u32 = 296; pub const IMG_MODAL_WIDTH: u32 = 296;
#[derive(Debug)] #[derive(Debug)]
pub struct Image { pub struct Image {

View file

@ -10,7 +10,7 @@ use gam::*;
use num_traits::*; use num_traits::*;
#[cfg(feature = "ditherpunk")] #[cfg(feature = "ditherpunk")]
use std::convert::TryInto; use std::convert::TryInto;
use std::cmp::min; use std::cmp::max;
use xous::{send_message, Message, CID}; use xous::{send_message, Message, CID};
use xous_ipc::Buffer; use xous_ipc::Buffer;
@ -203,10 +203,10 @@ impl Modals {
// center image in modal // center image in modal
const BORDER: u32 = 3; const BORDER: u32 = 3;
let margin = Point::new( 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() .try_into()
.unwrap(), .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() .try_into()
.unwrap(), .unwrap(),
); );