From 6c47bd6e80500c66273a5c14993343d70efe6c39 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 9 Jun 2024 13:04:01 +0300 Subject: Rename apply_scale to to_physical_precise_round Consistency with Smithay. --- src/ui/config_error_notification.rs | 6 +++--- src/ui/exit_confirm_dialog.rs | 6 +++--- src/ui/hotkey_overlay.rs | 8 ++++---- src/ui/screenshot_ui.rs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/ui') diff --git a/src/ui/config_error_notification.rs b/src/ui/config_error_notification.rs index 566941c5..2def4b20 100644 --- a/src/ui/config_error_notification.rs +++ b/src/ui/config_error_notification.rs @@ -18,7 +18,7 @@ use crate::animation::Animation; use crate::render_helpers::primary_gpu_texture::PrimaryGpuTextureRenderElement; use crate::render_helpers::renderer::NiriRenderer; use crate::render_helpers::texture::{TextureBuffer, TextureRenderElement}; -use crate::utils::{apply_scale, output_size}; +use crate::utils::{output_size, to_physical_precise_round}; const TEXT: &str = "Failed to parse the config file. \ Please run niri validate \ @@ -173,7 +173,7 @@ fn render( ) -> anyhow::Result> { let _span = tracy_client::span!("config_error_notification::render"); - let padding = apply_scale(scale, PADDING); + let padding: i32 = to_physical_precise_round(scale, PADDING); let mut text = String::from(TEXT); let mut border_color = (1., 0.3, 0.3); @@ -187,7 +187,7 @@ fn render( }; let mut font = FontDescription::from_string(FONT); - font.set_absolute_size(apply_scale(scale, font.size()).into()); + font.set_absolute_size(to_physical_precise_round(scale, font.size())); let surface = ImageSurface::create(cairo::Format::ARgb32, 0, 0)?; let cr = cairo::Context::new(&surface)?; diff --git a/src/ui/exit_confirm_dialog.rs b/src/ui/exit_confirm_dialog.rs index 6007eeda..9ffae3a7 100644 --- a/src/ui/exit_confirm_dialog.rs +++ b/src/ui/exit_confirm_dialog.rs @@ -13,7 +13,7 @@ use crate::render_helpers::memory::MemoryBuffer; use crate::render_helpers::primary_gpu_texture::PrimaryGpuTextureRenderElement; use crate::render_helpers::renderer::NiriRenderer; use crate::render_helpers::texture::{TextureBuffer, TextureRenderElement}; -use crate::utils::{apply_scale, output_size}; +use crate::utils::{output_size, to_physical_precise_round}; const TEXT: &str = "Are you sure you want to exit niri?\n\n\ Press Enter to confirm."; @@ -101,10 +101,10 @@ impl ExitConfirmDialog { fn render(scale: f64) -> anyhow::Result { let _span = tracy_client::span!("exit_confirm_dialog::render"); - let padding = apply_scale(scale, PADDING); + let padding: i32 = to_physical_precise_round(scale, PADDING); let mut font = FontDescription::from_string(FONT); - font.set_absolute_size(apply_scale(scale, font.size()).into()); + font.set_absolute_size(to_physical_precise_round(scale, font.size())); let surface = ImageSurface::create(cairo::Format::ARgb32, 0, 0)?; let cr = cairo::Context::new(&surface)?; diff --git a/src/ui/hotkey_overlay.rs b/src/ui/hotkey_overlay.rs index e93dcb30..5fef2821 100644 --- a/src/ui/hotkey_overlay.rs +++ b/src/ui/hotkey_overlay.rs @@ -18,7 +18,7 @@ use crate::input::CompositorMod; use crate::render_helpers::primary_gpu_texture::PrimaryGpuTextureRenderElement; use crate::render_helpers::renderer::NiriRenderer; use crate::render_helpers::texture::{TextureBuffer, TextureRenderElement}; -use crate::utils::{apply_scale, output_size}; +use crate::utils::{output_size, to_physical_precise_round}; const PADDING: i32 = 8; // const MARGIN: i32 = PADDING * 2; @@ -134,8 +134,8 @@ fn render( let _span = tracy_client::span!("hotkey_overlay::render"); // let margin = MARGIN * scale; - let padding = apply_scale(scale, PADDING); - let line_interval = apply_scale(scale, LINE_INTERVAL); + let padding: i32 = to_physical_precise_round(scale, PADDING); + let line_interval: i32 = to_physical_precise_round(scale, LINE_INTERVAL); // FIXME: if it doesn't fit, try splitting in two columns or something. // let mut target_size = output_size; @@ -245,7 +245,7 @@ fn render( .collect::>(); let mut font = FontDescription::from_string(FONT); - font.set_absolute_size(apply_scale(scale, font.size()).into()); + font.set_absolute_size(to_physical_precise_round(scale, font.size())); let surface = ImageSurface::create(cairo::Format::ARgb32, 0, 0)?; let cr = cairo::Context::new(&surface)?; diff --git a/src/ui/screenshot_ui.rs b/src/ui/screenshot_ui.rs index 807d8ab4..facb9692 100644 --- a/src/ui/screenshot_ui.rs +++ b/src/ui/screenshot_ui.rs @@ -20,7 +20,7 @@ use crate::render_helpers::primary_gpu_texture::PrimaryGpuTextureRenderElement; use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement}; use crate::render_helpers::texture::{TextureBuffer, TextureRenderElement}; use crate::render_helpers::RenderTarget; -use crate::utils::apply_scale; +use crate::utils::to_physical_precise_round; const BORDER: i32 = 2; @@ -212,7 +212,7 @@ impl ScreenshotUi { *b = rect.loc + rect.size - Size::from((1, 1)); } - let border = apply_scale(scale, BORDER); + let border = to_physical_precise_round(scale, BORDER); let resize = move |buffer: &mut SolidColorBuffer, w: i32, h: i32| { let size = Size::<_, Physical>::from((w, h)); -- cgit