mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-10 15:12:52 +02:00
correct spacing on komorebi and network widgets (WIP)
This commit is contained in:
@@ -147,7 +147,7 @@ impl BarWidget for Battery {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
config.apply_on_widget(true, true, ui, |ui| {
|
||||||
ui.add(
|
ui.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
.selectable(false)
|
.selectable(false)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ impl BarWidget for Cpu {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
config.apply_on_widget(true, true, ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ impl BarWidget for Date {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
config.apply_on_widget(true, true, ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(WidgetText::LayoutJob(layout_job.clone()))
|
Label::new(WidgetText::LayoutJob(layout_job.clone()))
|
||||||
|
|||||||
+155
-157
@@ -124,12 +124,30 @@ pub struct Komorebi {
|
|||||||
impl BarWidget for Komorebi {
|
impl BarWidget for Komorebi {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
let mut komorebi_notification_state = self.komorebi_notification_state.borrow_mut();
|
let mut komorebi_notification_state = self.komorebi_notification_state.borrow_mut();
|
||||||
|
let mut enable_widget: [bool; 4] = [self.workspaces.enable, false, false, false];
|
||||||
|
|
||||||
if self.workspaces.enable {
|
if let Some(layout) = self.layout {
|
||||||
|
enable_widget[1] = layout.enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(configuration_switcher) = &self.configuration_switcher {
|
||||||
|
enable_widget[2] = configuration_switcher.enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(focused_window) = self.focused_window {
|
||||||
|
if focused_window.enable {
|
||||||
|
let titles = &komorebi_notification_state.focused_container_information.0;
|
||||||
|
enable_widget[3] = !titles.is_empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let last_enabled_widget_index = enable_widget.iter().rposition(|&x| x);
|
||||||
|
|
||||||
|
if enable_widget[0] {
|
||||||
let mut update = None;
|
let mut update = None;
|
||||||
|
|
||||||
// NOTE: There should always be at least one workspace.
|
// NOTE: There should always be at least one workspace.
|
||||||
config.apply_on_widget(false, ui, |ui| {
|
config.apply_on_widget(false, last_enabled_widget_index == Some(0), ui, |ui| {
|
||||||
for (i, (ws, should_show)) in
|
for (i, (ws, should_show)) in
|
||||||
komorebi_notification_state.workspaces.iter().enumerate()
|
komorebi_notification_state.workspaces.iter().enumerate()
|
||||||
{
|
{
|
||||||
@@ -194,60 +212,49 @@ impl BarWidget for Komorebi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(layout) = self.layout {
|
if enable_widget[1] {
|
||||||
if layout.enable {
|
config.apply_on_widget(true, last_enabled_widget_index == Some(1), ui, |ui| {
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
if ui
|
||||||
if ui
|
.add(
|
||||||
.add(
|
Label::new(komorebi_notification_state.layout.to_string())
|
||||||
Label::new(komorebi_notification_state.layout.to_string())
|
.selectable(false)
|
||||||
.selectable(false)
|
.sense(Sense::click()),
|
||||||
.sense(Sense::click()),
|
)
|
||||||
)
|
.clicked()
|
||||||
.clicked()
|
{
|
||||||
{
|
match komorebi_notification_state.layout {
|
||||||
match komorebi_notification_state.layout {
|
KomorebiLayout::Default(_) => {
|
||||||
KomorebiLayout::Default(_) => {
|
if komorebi_client::send_message(&SocketMessage::CycleLayout(
|
||||||
if komorebi_client::send_message(&SocketMessage::CycleLayout(
|
CycleDirection::Next,
|
||||||
CycleDirection::Next,
|
))
|
||||||
))
|
.is_err()
|
||||||
.is_err()
|
{
|
||||||
{
|
tracing::error!("could not send message to komorebi: CycleLayout");
|
||||||
tracing::error!(
|
|
||||||
"could not send message to komorebi: CycleLayout"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
KomorebiLayout::Floating => {
|
|
||||||
if komorebi_client::send_message(&SocketMessage::ToggleTiling)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
tracing::error!(
|
|
||||||
"could not send message to komorebi: ToggleTiling"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
KomorebiLayout::Paused => {
|
|
||||||
if komorebi_client::send_message(&SocketMessage::TogglePause)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
tracing::error!(
|
|
||||||
"could not send message to komorebi: TogglePause"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
KomorebiLayout::Custom => {}
|
|
||||||
}
|
}
|
||||||
|
KomorebiLayout::Floating => {
|
||||||
|
if komorebi_client::send_message(&SocketMessage::ToggleTiling).is_err()
|
||||||
|
{
|
||||||
|
tracing::error!("could not send message to komorebi: ToggleTiling");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KomorebiLayout::Paused => {
|
||||||
|
if komorebi_client::send_message(&SocketMessage::TogglePause).is_err() {
|
||||||
|
tracing::error!("could not send message to komorebi: TogglePause");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KomorebiLayout::Custom => {}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(configuration_switcher) = &self.configuration_switcher {
|
if enable_widget[2] {
|
||||||
if configuration_switcher.enable {
|
let configuration_switcher = self.configuration_switcher.as_ref().unwrap();
|
||||||
for (name, location) in configuration_switcher.configurations.iter() {
|
for (name, location) in configuration_switcher.configurations.iter() {
|
||||||
let path = PathBuf::from(location);
|
let path = PathBuf::from(location);
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
config.apply_on_widget(true, ui,|ui|{
|
config.apply_on_widget(true, last_enabled_widget_index == Some(2), ui,|ui|{
|
||||||
if ui
|
if ui
|
||||||
.add(Label::new(name).selectable(false).sense(Sense::click()))
|
.add(Label::new(name).selectable(false).sense(Sense::click()))
|
||||||
.clicked()
|
.clicked()
|
||||||
@@ -295,126 +302,117 @@ impl BarWidget for Komorebi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(focused_window) = self.focused_window {
|
if enable_widget[3] {
|
||||||
if focused_window.enable {
|
let focused_window = self.focused_window.unwrap();
|
||||||
let titles = &komorebi_notification_state.focused_container_information.0;
|
let titles = &komorebi_notification_state.focused_container_information.0;
|
||||||
|
config.apply_on_widget(true, last_enabled_widget_index == Some(4), ui, |ui| {
|
||||||
|
let icons = &komorebi_notification_state.focused_container_information.1;
|
||||||
|
let focused_window_idx =
|
||||||
|
komorebi_notification_state.focused_container_information.2;
|
||||||
|
|
||||||
if !titles.is_empty() {
|
let iter = titles.iter().zip(icons.iter());
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
|
||||||
let icons = &komorebi_notification_state.focused_container_information.1;
|
|
||||||
let focused_window_idx =
|
|
||||||
komorebi_notification_state.focused_container_information.2;
|
|
||||||
|
|
||||||
let iter = titles.iter().zip(icons.iter());
|
for (i, (title, icon)) in iter.enumerate() {
|
||||||
|
if focused_window.show_icon {
|
||||||
|
if let Some(img) = icon {
|
||||||
|
ui.add(
|
||||||
|
Image::from(&img_to_texture(ctx, img))
|
||||||
|
.maintain_aspect_ratio(true)
|
||||||
|
.max_height(15.0),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i, (title, icon)) in iter.enumerate() {
|
if i == focused_window_idx {
|
||||||
if focused_window.show_icon {
|
let font_id = ctx
|
||||||
if let Some(img) = icon {
|
.style()
|
||||||
ui.add(
|
.text_styles
|
||||||
Image::from(&img_to_texture(ctx, img))
|
.get(&TextStyle::Body)
|
||||||
.maintain_aspect_ratio(true)
|
.cloned()
|
||||||
.max_height(15.0),
|
.unwrap_or_else(FontId::default);
|
||||||
);
|
|
||||||
}
|
let layout_job = LayoutJob::simple(
|
||||||
|
title.to_string(),
|
||||||
|
font_id.clone(),
|
||||||
|
komorebi_notification_state
|
||||||
|
.stack_accent
|
||||||
|
.unwrap_or(ctx.style().visuals.selection.stroke.color),
|
||||||
|
100.0,
|
||||||
|
);
|
||||||
|
|
||||||
|
if titles.len() > 1 {
|
||||||
|
let available_height = ui.available_height();
|
||||||
|
let mut custom_ui = CustomUi(ui);
|
||||||
|
custom_ui.add_sized_left_to_right(
|
||||||
|
Vec2::new(
|
||||||
|
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
||||||
|
available_height,
|
||||||
|
),
|
||||||
|
Label::new(layout_job).selectable(false).truncate(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let available_height = ui.available_height();
|
||||||
|
let mut custom_ui = CustomUi(ui);
|
||||||
|
custom_ui.add_sized_left_to_right(
|
||||||
|
Vec2::new(
|
||||||
|
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
||||||
|
available_height,
|
||||||
|
),
|
||||||
|
Label::new(title).selectable(false).truncate(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let available_height = ui.available_height();
|
||||||
|
let mut custom_ui = CustomUi(ui);
|
||||||
|
|
||||||
|
if custom_ui
|
||||||
|
.add_sized_left_to_right(
|
||||||
|
Vec2::new(
|
||||||
|
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
||||||
|
available_height,
|
||||||
|
),
|
||||||
|
Label::new(title)
|
||||||
|
.selectable(false)
|
||||||
|
.sense(Sense::click())
|
||||||
|
.truncate(),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
if komorebi_client::send_message(&SocketMessage::MouseFollowsFocus(
|
||||||
|
false,
|
||||||
|
))
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: MouseFollowsFocus"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if i == focused_window_idx {
|
if komorebi_client::send_message(&SocketMessage::FocusStackWindow(i))
|
||||||
let font_id = ctx
|
.is_err()
|
||||||
.style()
|
{
|
||||||
.text_styles
|
tracing::error!(
|
||||||
.get(&TextStyle::Body)
|
"could not send message to komorebi: FocusStackWindow"
|
||||||
.cloned()
|
|
||||||
.unwrap_or_else(FontId::default);
|
|
||||||
|
|
||||||
let layout_job = LayoutJob::simple(
|
|
||||||
title.to_string(),
|
|
||||||
font_id.clone(),
|
|
||||||
komorebi_notification_state
|
|
||||||
.stack_accent
|
|
||||||
.unwrap_or(ctx.style().visuals.selection.stroke.color),
|
|
||||||
100.0,
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if titles.len() > 1 {
|
if komorebi_client::send_message(&SocketMessage::MouseFollowsFocus(
|
||||||
let available_height = ui.available_height();
|
komorebi_notification_state.mouse_follows_focus,
|
||||||
let mut custom_ui = CustomUi(ui);
|
))
|
||||||
custom_ui.add_sized_left_to_right(
|
.is_err()
|
||||||
Vec2::new(
|
{
|
||||||
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
tracing::error!(
|
||||||
available_height,
|
"could not send message to komorebi: MouseFollowsFocus"
|
||||||
),
|
);
|
||||||
Label::new(layout_job).selectable(false).truncate(),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
let available_height = ui.available_height();
|
|
||||||
let mut custom_ui = CustomUi(ui);
|
|
||||||
custom_ui.add_sized_left_to_right(
|
|
||||||
Vec2::new(
|
|
||||||
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
|
||||||
available_height,
|
|
||||||
),
|
|
||||||
Label::new(title).selectable(false).truncate(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let available_height = ui.available_height();
|
|
||||||
let mut custom_ui = CustomUi(ui);
|
|
||||||
|
|
||||||
if custom_ui
|
|
||||||
.add_sized_left_to_right(
|
|
||||||
Vec2::new(
|
|
||||||
MAX_LABEL_WIDTH.load(Ordering::SeqCst) as f32,
|
|
||||||
available_height,
|
|
||||||
),
|
|
||||||
Label::new(title)
|
|
||||||
.selectable(false)
|
|
||||||
.sense(Sense::click())
|
|
||||||
.truncate(),
|
|
||||||
)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
if komorebi_client::send_message(
|
|
||||||
&SocketMessage::MouseFollowsFocus(false),
|
|
||||||
)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
tracing::error!(
|
|
||||||
"could not send message to komorebi: MouseFollowsFocus"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if komorebi_client::send_message(
|
|
||||||
&SocketMessage::FocusStackWindow(i),
|
|
||||||
)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
tracing::error!(
|
|
||||||
"could not send message to komorebi: FocusStackWindow"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if komorebi_client::send_message(
|
|
||||||
&SocketMessage::MouseFollowsFocus(
|
|
||||||
komorebi_notification_state.mouse_follows_focus,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
tracing::error!(
|
|
||||||
"could not send message to komorebi: MouseFollowsFocus"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ impl BarWidget for Media {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
config.apply_on_widget(true, true, ui, |ui| {
|
||||||
let available_height = ui.available_height();
|
let available_height = ui.available_height();
|
||||||
let mut custom_ui = CustomUi(ui);
|
let mut custom_ui = CustomUi(ui);
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ impl BarWidget for Memory {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
config.apply_on_widget(true, true, ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
|
|||||||
+67
-55
@@ -318,71 +318,83 @@ impl Network {
|
|||||||
|
|
||||||
impl BarWidget for Network {
|
impl BarWidget for Network {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.show_total_data_transmitted {
|
let mut enable_widget: [bool; 3] = [
|
||||||
for output in self.total_data_transmitted() {
|
self.show_total_data_transmitted,
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
self.show_network_activity,
|
||||||
ui.add(Label::new(output).selectable(false));
|
false,
|
||||||
});
|
];
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.show_network_activity {
|
|
||||||
for output in self.network_activity() {
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
|
||||||
ui.add(Label::new(output).selectable(false));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.enable {
|
if self.enable {
|
||||||
self.default_interface();
|
self.default_interface();
|
||||||
|
|
||||||
if !self.default_interface.is_empty() {
|
if !self.default_interface.is_empty() {
|
||||||
let font_id = ctx
|
enable_widget[2] = true;
|
||||||
.style()
|
}
|
||||||
.text_styles
|
}
|
||||||
.get(&TextStyle::Body)
|
|
||||||
.cloned()
|
|
||||||
.unwrap_or_else(FontId::default);
|
|
||||||
|
|
||||||
let mut layout_job = LayoutJob::simple(
|
let last_enabled_widget_index = enable_widget.iter().rposition(|&x| x);
|
||||||
match self.label_prefix {
|
|
||||||
LabelPrefix::Icon | LabelPrefix::IconAndText => {
|
|
||||||
egui_phosphor::regular::WIFI_HIGH.to_string()
|
|
||||||
}
|
|
||||||
LabelPrefix::None | LabelPrefix::Text => String::new(),
|
|
||||||
},
|
|
||||||
font_id.clone(),
|
|
||||||
ctx.style().visuals.selection.stroke.color,
|
|
||||||
100.0,
|
|
||||||
);
|
|
||||||
|
|
||||||
if let LabelPrefix::Text | LabelPrefix::IconAndText = self.label_prefix {
|
if enable_widget[0] {
|
||||||
self.default_interface.insert_str(0, "NET: ");
|
for output in self.total_data_transmitted() {
|
||||||
}
|
config.apply_on_widget(true, last_enabled_widget_index == Some(0), ui, |ui| {
|
||||||
|
ui.add(Label::new(output).selectable(false));
|
||||||
layout_job.append(
|
|
||||||
&self.default_interface,
|
|
||||||
10.0,
|
|
||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
|
||||||
);
|
|
||||||
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
|
||||||
if ui
|
|
||||||
.add(
|
|
||||||
Label::new(layout_job)
|
|
||||||
.selectable(false)
|
|
||||||
.sense(Sense::click()),
|
|
||||||
)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
if let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn() {
|
|
||||||
eprintln!("{}", error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if enable_widget[1] {
|
||||||
|
for output in self.network_activity() {
|
||||||
|
config.apply_on_widget(true, last_enabled_widget_index == Some(1), ui, |ui| {
|
||||||
|
ui.add(Label::new(output).selectable(false));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if enable_widget[2] {
|
||||||
|
let font_id = ctx
|
||||||
|
.style()
|
||||||
|
.text_styles
|
||||||
|
.get(&TextStyle::Body)
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or_else(FontId::default);
|
||||||
|
|
||||||
|
let mut layout_job = LayoutJob::simple(
|
||||||
|
match self.label_prefix {
|
||||||
|
LabelPrefix::Icon | LabelPrefix::IconAndText => {
|
||||||
|
egui_phosphor::regular::WIFI_HIGH.to_string()
|
||||||
|
}
|
||||||
|
LabelPrefix::None | LabelPrefix::Text => String::new(),
|
||||||
|
},
|
||||||
|
font_id.clone(),
|
||||||
|
ctx.style().visuals.selection.stroke.color,
|
||||||
|
100.0,
|
||||||
|
);
|
||||||
|
|
||||||
|
if let LabelPrefix::Text | LabelPrefix::IconAndText = self.label_prefix {
|
||||||
|
self.default_interface.insert_str(0, "NET: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
layout_job.append(
|
||||||
|
&self.default_interface,
|
||||||
|
10.0,
|
||||||
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
|
);
|
||||||
|
|
||||||
|
config.apply_on_widget(true, last_enabled_widget_index == Some(2), ui, |ui| {
|
||||||
|
if ui
|
||||||
|
.add(
|
||||||
|
Label::new(layout_job)
|
||||||
|
.selectable(false)
|
||||||
|
.sense(Sense::click()),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
if let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn() {
|
||||||
|
eprintln!("{}", error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-11
@@ -86,19 +86,20 @@ impl RenderConfig {
|
|||||||
|
|
||||||
pub fn apply_on_widget<R>(
|
pub fn apply_on_widget<R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
use_spacing: bool,
|
more_inner_margin: bool,
|
||||||
// TODO: this should remove the margin on the last widget on the left side and the first widget on the right side
|
is_last_widget: bool,
|
||||||
// This is complex, since the last/first widget can have multiple "sections", like komorebi, network, ...
|
|
||||||
// This and the same setting on RenderConfig needs to be combined.
|
|
||||||
//no_spacing: Option<bool>,
|
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
add_contents: impl FnOnce(&mut Ui) -> R,
|
add_contents: impl FnOnce(&mut Ui) -> R,
|
||||||
) -> InnerResponse<R> {
|
) -> InnerResponse<R> {
|
||||||
|
// since a widget can call this multiple times, it is necessary to know the last time
|
||||||
|
// in order to add widget spacing correctly
|
||||||
|
self.no_spacing = self.no_spacing && is_last_widget;
|
||||||
|
|
||||||
if let Grouping::Widget(config) = self.grouping {
|
if let Grouping::Widget(config) = self.grouping {
|
||||||
return self.define_group(use_spacing, config, ui, add_contents);
|
return self.define_group(more_inner_margin, config, ui, add_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.fallback_widget_group(use_spacing, ui, add_contents)
|
self.fallback_widget_group(more_inner_margin, ui, add_contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fallback_group<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
fn fallback_group<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
||||||
@@ -110,13 +111,13 @@ impl RenderConfig {
|
|||||||
|
|
||||||
fn fallback_widget_group<R>(
|
fn fallback_widget_group<R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
use_spacing: bool,
|
more_inner_margin: bool,
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
add_contents: impl FnOnce(&mut Ui) -> R,
|
add_contents: impl FnOnce(&mut Ui) -> R,
|
||||||
) -> InnerResponse<R> {
|
) -> InnerResponse<R> {
|
||||||
Frame::none()
|
Frame::none()
|
||||||
.outer_margin(self.widget_outer_margin())
|
.outer_margin(self.widget_outer_margin())
|
||||||
.inner_margin(match use_spacing {
|
.inner_margin(match more_inner_margin {
|
||||||
true => Margin::symmetric(5.0, 0.0),
|
true => Margin::symmetric(5.0, 0.0),
|
||||||
false => Margin::same(0.0),
|
false => Margin::same(0.0),
|
||||||
})
|
})
|
||||||
@@ -125,14 +126,14 @@ impl RenderConfig {
|
|||||||
|
|
||||||
fn define_group<R>(
|
fn define_group<R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
use_spacing: bool,
|
more_inner_margin: bool,
|
||||||
config: GroupingConfig,
|
config: GroupingConfig,
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
add_contents: impl FnOnce(&mut Ui) -> R,
|
add_contents: impl FnOnce(&mut Ui) -> R,
|
||||||
) -> InnerResponse<R> {
|
) -> InnerResponse<R> {
|
||||||
Frame::none()
|
Frame::none()
|
||||||
.outer_margin(self.widget_outer_margin())
|
.outer_margin(self.widget_outer_margin())
|
||||||
.inner_margin(match use_spacing {
|
.inner_margin(match more_inner_margin {
|
||||||
true => Margin::symmetric(8.0, 3.0),
|
true => Margin::symmetric(8.0, 3.0),
|
||||||
false => Margin::symmetric(3.0, 3.0),
|
false => Margin::symmetric(3.0, 3.0),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ impl BarWidget for Storage {
|
|||||||
TextFormat::simple(font_id.clone(), ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id.clone(), ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
// TODO: WIP
|
||||||
|
config.apply_on_widget(true, false, ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ impl BarWidget for Time {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
config.apply_on_widget(true, ui, |ui| {
|
config.apply_on_widget(true, true, ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
|
|||||||
Reference in New Issue
Block a user