forge
Explore
Log in

Don't you dare go Hollow

layout: Handle padding in ColumnWidth::resolve()

Browse files at this commit

8491ba593ebba31c55a75c80e5ee646189175b76Ivan MolodetskikhParent: 6fcdb41
src/layout.rsmodified+8 -16
@@ -357,10 +357,11 @@ impl FocusRing {
357 impl ColumnWidth {357 impl ColumnWidth {
358 fn resolve(self, options: &Options, view_width: i32) -> i32 {358 fn resolve(self, options: &Options, view_width: i32) -> i32 {
359 match self {359 match self {
360- ColumnWidth::Proportion(proportion) => (view_width as f64 * proportion).floor() as i32,360+ ColumnWidth::Proportion(proportion) => {
361+ ((view_width - PADDING) as f64 * proportion).floor() as i32 - PADDING
362+ }
361 ColumnWidth::Preset(idx) => options.preset_widths[idx].resolve(options, view_width),363 ColumnWidth::Preset(idx) => options.preset_widths[idx].resolve(options, view_width),
362- // FIXME: remove this PADDING from here after redesigning how padding works.364+ ColumnWidth::Fixed(width) => width,
363- ColumnWidth::Fixed(width) => width + PADDING,
364 }365 }
365 }366 }
366 }367 }
@@ -1596,9 +1597,7 @@ impl<W: LayoutElement> Workspace<W> {
1596 }1597 }
1597 1598
1598 pub fn configure_new_window(&self, window: &Window) {1599 pub fn configure_new_window(&self, window: &Window) {
1599- let width = ColumnWidth::default()1600+ let width = ColumnWidth::default().resolve(&self.options, self.working_area.size.w);
1600- .resolve(&self.options, self.working_area.size.w - PADDING)
1601- - PADDING;
1602 let height = self.working_area.size.h - PADDING * 2;1601 let height = self.working_area.size.h - PADDING * 2;
1603 let size = Size::from((max(width, 1), max(height, 1)));1602 let size = Size::from((max(width, 1), max(height, 1)));
1604 1603
@@ -2284,10 +2283,7 @@ impl<W: LayoutElement> Column<W> {
2284 .unwrap_or(i32::MAX);2283 .unwrap_or(i32::MAX);
2285 let max_width = max(max_width, min_width);2284 let max_width = max(max_width, min_width);
2286 2285
2287- let width = self2286+ let width = self.width.resolve(&self.options, self.working_area.size.w);
2288- .width
2289- .resolve(&self.options, self.working_area.size.w - PADDING)
2290- - PADDING;
2291 let height = (self.working_area.size.h - PADDING) / self.window_count() as i32 - PADDING;2287 let height = (self.working_area.size.h - PADDING) / self.window_count() as i32 - PADDING;
2292 let size = Size::from((max(min(width, max_width), min_width), max(height, 1)));2288 let size = Size::from((max(min(width, max_width), min_width), max(height, 1)));
2293 2289
@@ -2356,8 +2352,7 @@ impl<W: LayoutElement> Column<W> {
2356 .preset_widths2352 .preset_widths
2357 .iter()2353 .iter()
2358 .position(|prop| {2354 .position(|prop| {
2359- prop.resolve(&self.options, self.working_area.size.w - PADDING) - PADDING2355+ prop.resolve(&self.options, self.working_area.size.w) > current
2360- > current
2361 })2356 })
2362 .unwrap_or(0)2357 .unwrap_or(0)
2363 }2358 }
@@ -2378,10 +2373,7 @@ impl<W: LayoutElement> Column<W> {
2378 }2373 }
2379 2374
2380 fn set_column_width(&mut self, change: SizeChange) {2375 fn set_column_width(&mut self, change: SizeChange) {
2381- let current_px = self2376+ let current_px = self.width.resolve(&self.options, self.working_area.size.w);
2382- .width
2383- .resolve(&self.options, self.working_area.size.w - PADDING)
2384- - PADDING;
2385 2377
2386 let current = match self.width {2378 let current = match self.width {
2387 ColumnWidth::Preset(idx) => self.options.preset_widths[idx],2379 ColumnWidth::Preset(idx) => self.options.preset_widths[idx],