@@ -95,7 +95,7 @@ impl FunctionLayer {
9595 c. translate ( DFR_HEIGHT as f64 , 0.0 ) ;
9696 c. rotate ( ( 90.0f64 ) . to_radians ( ) ) ;
9797 let button_width = DFR_WIDTH as f64 / ( self . buttons . len ( ) + 1 ) as f64 ;
98- let spacing_width = ( DFR_WIDTH as f64 - self . buttons . len ( ) as f64 * button_width) / ( self . buttons . len ( ) + 1 ) as f64 ;
98+ let spacing_width = ( DFR_WIDTH as f64 - self . buttons . len ( ) as f64 * button_width) / ( self . buttons . len ( ) - 1 ) as f64 ;
9999 let radius = 8.0f64 ;
100100 let bot = 0.09 * DFR_HEIGHT as f64 + radius;
101101 let top = bot + 0.82 * DFR_HEIGHT as f64 - 2.0 * radius;
@@ -104,7 +104,7 @@ impl FunctionLayer {
104104 c. select_font_face ( "sans-serif" , FontSlant :: Normal , FontWeight :: Bold ) ;
105105 c. set_font_size ( 32.0 ) ;
106106 for ( i, button) in self . buttons . iter ( ) . enumerate ( ) {
107- let left_edge = i as f64 * ( button_width + spacing_width) + spacing_width ;
107+ let left_edge = i as f64 * ( button_width + spacing_width) ;
108108 let color = if active_buttons[ i] { BUTTON_COLOR_ACTIVE } else { BUTTON_COLOR_INACTIVE } ;
109109 c. set_source_rgb ( color, color, color) ;
110110 // draw box with rounded corners
@@ -170,8 +170,8 @@ impl LibinputInterface for Interface {
170170
171171fn button_hit ( num : u32 , idx : u32 , x : f64 , y : f64 ) -> bool {
172172 let button_width = DFR_WIDTH as f64 / ( num + 1 ) as f64 ;
173- let spacing_width = ( DFR_WIDTH as f64 - num as f64 * button_width) / ( num + 1 ) as f64 ;
174- let left_edge = idx as f64 * ( button_width + spacing_width) + spacing_width ;
173+ let spacing_width = ( DFR_WIDTH as f64 - num as f64 * button_width) / ( num - 1 ) as f64 ;
174+ let left_edge = idx as f64 * ( button_width + spacing_width) ;
175175 if x < left_edge || x > ( left_edge + button_width) {
176176 return false
177177 }
0 commit comments