Skip to content

Commit c423c4f

Browse files
committed
Don't reserve space for pixel shifting when it is disabled
1 parent b179508 commit c423c4f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ impl FunctionLayer {
116116
let c = Context::new(&surface).unwrap();
117117
c.translate(DFR_HEIGHT as f64, 0.0);
118118
c.rotate((90.0f64).to_radians());
119-
let button_width = ((DFR_WIDTH - PIXEL_SHIFT_WIDTH_PX as i32) - (BUTTON_SPACING_PX * (self.buttons.len() - 1) as i32)) as f64 / self.buttons.len() as f64;
119+
let pixel_shift_width = if config.enable_pixel_shift { PIXEL_SHIFT_WIDTH_PX } else { 0 };
120+
let button_width = ((DFR_WIDTH - pixel_shift_width as i32) - (BUTTON_SPACING_PX * (self.buttons.len() - 1) as i32)) as f64 / self.buttons.len() as f64;
120121
let radius = 8.0f64;
121122
let bot = (DFR_HEIGHT as f64) * 0.2;
122123
let top = (DFR_HEIGHT as f64) * 0.85;
@@ -127,7 +128,7 @@ impl FunctionLayer {
127128
c.select_font_face("sans-serif", FontSlant::Normal, FontWeight::Bold);
128129
c.set_font_size(32.0);
129130
for (i, button) in self.buttons.iter().enumerate() {
130-
let left_edge = (i as f64 * (button_width + BUTTON_SPACING_PX as f64)).floor() + pixel_shift_x + (PIXEL_SHIFT_WIDTH_PX / 2) as f64;
131+
let left_edge = (i as f64 * (button_width + BUTTON_SPACING_PX as f64)).floor() + pixel_shift_x + (pixel_shift_width / 2) as f64;
131132
let color = if active_buttons[i] {
132133
BUTTON_COLOR_ACTIVE
133134
} else if config.show_button_outlines {

0 commit comments

Comments
 (0)