Skip to content

Commit

Permalink
fix(bar): use layout on Area to prevent shaking
Browse files Browse the repository at this point in the history
There were some cases were the bar was showing some shaking, turns out
that using `ui.with_layout` instead of `ui.horizontal_centered` removes
this shaking, so this commit makes that change and uses the
`right_to_left` layout on the right widgets again, meaning that we need
to reverse them again.
  • Loading branch information
alex-ds13 authored and LGUG2Z committed Dec 20, 2024
1 parent eb8a988 commit ad08585
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions komorebi-bar/src/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::MONITOR_LEFT;
use crate::MONITOR_RIGHT;
use crate::MONITOR_TOP;
use crossbeam_channel::Receiver;
use eframe::egui::Align;
use eframe::egui::Align2;
use eframe::egui::Area;
use eframe::egui::CentralPanel;
Expand All @@ -28,6 +29,7 @@ use eframe::egui::FontFamily;
use eframe::egui::FontId;
use eframe::egui::Frame;
use eframe::egui::Id;
use eframe::egui::Layout;
use eframe::egui::Margin;
use eframe::egui::Rgba;
use eframe::egui::Style;
Expand Down Expand Up @@ -397,6 +399,8 @@ impl Komobar {
});
}

right_widgets.reverse();

self.left_widgets = left_widgets;
self.center_widgets = center_widgets;
self.right_widgets = right_widgets;
Expand Down Expand Up @@ -582,7 +586,7 @@ impl eframe::App for Komobar {
left_area_frame.inner_margin.left = frame.inner_margin.x;
}
left_area_frame.show(ui, |ui| {
ui.horizontal_centered(|ui| {
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
let mut render_conf = render_config.clone();
render_conf.alignment = Some(Alignment::Left);

Expand All @@ -606,7 +610,7 @@ impl eframe::App for Komobar {
right_area_frame.inner_margin.right = frame.inner_margin.x;
}
right_area_frame.show(ui, |ui| {
ui.horizontal_centered(|ui| {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
let mut render_conf = render_config.clone();
render_conf.alignment = Some(Alignment::Right);

Expand All @@ -627,7 +631,7 @@ impl eframe::App for Komobar {
.show(ctx, |ui| {
let center_area_frame = area_frame;
center_area_frame.show(ui, |ui| {
ui.horizontal_centered(|ui| {
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
let mut render_conf = render_config.clone();
render_conf.alignment = Some(Alignment::Center);

Expand Down

0 comments on commit ad08585

Please sign in to comment.