mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-13 08:32:44 +02:00
added widget grouping and group module
This commit is contained in:
+13
-3
@@ -1,8 +1,10 @@
|
|||||||
use crate::config::Grouping;
|
|
||||||
use crate::config::KomobarConfig;
|
use crate::config::KomobarConfig;
|
||||||
use crate::config::KomobarTheme;
|
use crate::config::KomobarTheme;
|
||||||
use crate::config::Position;
|
use crate::config::Position;
|
||||||
use crate::config::PositionConfig;
|
use crate::config::PositionConfig;
|
||||||
|
use crate::group::BorderRadius;
|
||||||
|
use crate::group::Grouping;
|
||||||
|
use crate::group::GroupingConfig;
|
||||||
use crate::komorebi::Komorebi;
|
use crate::komorebi::Komorebi;
|
||||||
use crate::komorebi::KomorebiNotificationState;
|
use crate::komorebi::KomorebiNotificationState;
|
||||||
use crate::process_hwnd;
|
use crate::process_hwnd;
|
||||||
@@ -319,8 +321,16 @@ impl Komobar {
|
|||||||
let mut komobar = Self {
|
let mut komobar = Self {
|
||||||
config: config.clone(),
|
config: config.clone(),
|
||||||
render_config: RenderConfig {
|
render_config: RenderConfig {
|
||||||
_grouping: match config.grouping {
|
grouping: match config.grouping {
|
||||||
None => Grouping::None,
|
// TESTING
|
||||||
|
None => Grouping::Widget(GroupingConfig {
|
||||||
|
rounding: Some(BorderRadius {
|
||||||
|
nw: 15.0,
|
||||||
|
ne: 15.0,
|
||||||
|
sw: 15.0,
|
||||||
|
se: 15.0,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
Some(grouping) => grouping,
|
Some(grouping) => grouping,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ impl Battery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Battery {
|
impl BarWidget for Battery {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.enable {
|
if self.enable {
|
||||||
let output = self.output();
|
let output = self.output();
|
||||||
if !output.is_empty() {
|
if !output.is_empty() {
|
||||||
@@ -148,11 +148,13 @@ impl BarWidget for Battery {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
ui.add(
|
ui.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
.selectable(false)
|
.selectable(false)
|
||||||
.sense(Sense::click()),
|
.sense(Sense::click()),
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
use crate::group::Grouping;
|
||||||
use crate::widget::WidgetConfig;
|
use crate::widget::WidgetConfig;
|
||||||
use eframe::egui::Pos2;
|
use eframe::egui::Pos2;
|
||||||
use eframe::egui::Rounding;
|
|
||||||
use eframe::egui::TextBuffer;
|
use eframe::egui::TextBuffer;
|
||||||
use eframe::egui::Vec2;
|
use eframe::egui::Vec2;
|
||||||
use komorebi_client::KomorebiTheme;
|
use komorebi_client::KomorebiTheme;
|
||||||
@@ -181,41 +181,3 @@ pub enum LabelPrefix {
|
|||||||
/// Show an icon and text
|
/// Show an icon and text
|
||||||
IconAndText,
|
IconAndText,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
|
||||||
pub enum Grouping {
|
|
||||||
/// No grouping is applied
|
|
||||||
None,
|
|
||||||
/// Widgets are grouped individually
|
|
||||||
Widget(GroupingConfig),
|
|
||||||
/// Widgets are grouped on each side
|
|
||||||
Side(GroupingConfig),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
|
||||||
pub struct GroupingConfig {
|
|
||||||
pub rounding: Option<BorderRadius>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
|
||||||
pub struct BorderRadius {
|
|
||||||
/// Radius of the rounding of the North-West (left top) corner.
|
|
||||||
pub nw: f32,
|
|
||||||
/// Radius of the rounding of the North-East (right top) corner.
|
|
||||||
pub ne: f32,
|
|
||||||
/// Radius of the rounding of the South-West (left bottom) corner.
|
|
||||||
pub sw: f32,
|
|
||||||
/// Radius of the rounding of the South-East (right bottom) corner.
|
|
||||||
pub se: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<BorderRadius> for Rounding {
|
|
||||||
fn from(value: BorderRadius) -> Self {
|
|
||||||
Self {
|
|
||||||
nw: value.nw,
|
|
||||||
ne: value.ne,
|
|
||||||
sw: value.sw,
|
|
||||||
se: value.se,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ impl Cpu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Cpu {
|
impl BarWidget for Cpu {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.enable {
|
if self.enable {
|
||||||
let output = self.output();
|
let output = self.output();
|
||||||
if !output.is_empty() {
|
if !output.is_empty() {
|
||||||
@@ -100,6 +100,7 @@ impl BarWidget for Cpu {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
@@ -108,11 +109,13 @@ impl BarWidget for Cpu {
|
|||||||
)
|
)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
if let Err(error) = Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
if let Err(error) =
|
||||||
|
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{}", error)
|
eprintln!("{}", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ impl Date {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Date {
|
impl BarWidget for Date {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.enable {
|
if self.enable {
|
||||||
let mut output = self.output();
|
let mut output = self.output();
|
||||||
if !output.is_empty() {
|
if !output.is_empty() {
|
||||||
@@ -120,6 +120,7 @@ impl BarWidget for Date {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(WidgetText::LayoutJob(layout_job.clone()))
|
Label::new(WidgetText::LayoutJob(layout_job.clone()))
|
||||||
@@ -130,6 +131,7 @@ impl BarWidget for Date {
|
|||||||
{
|
{
|
||||||
self.format.next()
|
self.format.next()
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
use eframe::egui::Frame;
|
||||||
|
use eframe::egui::InnerResponse;
|
||||||
|
use eframe::egui::Margin;
|
||||||
|
use eframe::egui::Rounding;
|
||||||
|
use eframe::egui::Ui;
|
||||||
|
use schemars::JsonSchema;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
pub enum Grouping {
|
||||||
|
/// No grouping is applied
|
||||||
|
None,
|
||||||
|
/// Widgets are grouped individually
|
||||||
|
Widget(GroupingConfig),
|
||||||
|
/// Widgets are grouped on each side
|
||||||
|
Side(GroupingConfig),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Grouping {
|
||||||
|
pub fn apply_on_widget<R>(
|
||||||
|
&mut self,
|
||||||
|
ui: &mut Ui,
|
||||||
|
add_contents: impl FnOnce(&mut Ui) -> R,
|
||||||
|
) -> InnerResponse<R> {
|
||||||
|
match self {
|
||||||
|
Self::None => InnerResponse {
|
||||||
|
inner: add_contents(ui),
|
||||||
|
response: ui.response().clone(),
|
||||||
|
},
|
||||||
|
Self::Widget(_config) => {
|
||||||
|
Frame::none()
|
||||||
|
//.fill(Color32::from_black_alpha(255u8))
|
||||||
|
.outer_margin(Margin::symmetric(0.0, 0.0))
|
||||||
|
.inner_margin(Margin::symmetric(7.0, 2.0))
|
||||||
|
.rounding(Rounding::same(15.0))
|
||||||
|
.stroke(ui.style().visuals.widgets.noninteractive.bg_stroke)
|
||||||
|
.show(ui, add_contents)
|
||||||
|
}
|
||||||
|
Self::Side(_config) => InnerResponse {
|
||||||
|
inner: add_contents(ui),
|
||||||
|
response: ui.response().clone(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
pub struct GroupingConfig {
|
||||||
|
pub rounding: Option<BorderRadius>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
pub struct BorderRadius {
|
||||||
|
/// Radius of the rounding of the North-West (left top) corner.
|
||||||
|
pub nw: f32,
|
||||||
|
/// Radius of the rounding of the North-East (right top) corner.
|
||||||
|
pub ne: f32,
|
||||||
|
/// Radius of the rounding of the South-West (left bottom) corner.
|
||||||
|
pub sw: f32,
|
||||||
|
/// Radius of the rounding of the South-East (right bottom) corner.
|
||||||
|
pub se: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<BorderRadius> for Rounding {
|
||||||
|
fn from(value: BorderRadius) -> Self {
|
||||||
|
Self {
|
||||||
|
nw: value.nw,
|
||||||
|
ne: value.ne,
|
||||||
|
sw: value.sw,
|
||||||
|
se: value.se,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,13 +123,15 @@ pub struct Komorebi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Komorebi {
|
impl BarWidget for Komorebi {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _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();
|
||||||
|
|
||||||
if self.workspaces.enable {
|
if self.workspaces.enable {
|
||||||
let mut update = None;
|
let mut update = None;
|
||||||
|
|
||||||
for (i, (ws, should_show)) in komorebi_notification_state.workspaces.iter().enumerate()
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
|
for (i, (ws, should_show)) in
|
||||||
|
komorebi_notification_state.workspaces.iter().enumerate()
|
||||||
{
|
{
|
||||||
if *should_show
|
if *should_show
|
||||||
&& ui
|
&& ui
|
||||||
@@ -145,15 +147,21 @@ impl BarWidget for Komorebi {
|
|||||||
if komorebi_client::send_message(&SocketMessage::MouseFollowsFocus(false))
|
if komorebi_client::send_message(&SocketMessage::MouseFollowsFocus(false))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!("could not send message to komorebi: MouseFollowsFocus");
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: MouseFollowsFocus"
|
||||||
|
);
|
||||||
proceed = false;
|
proceed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if proceed
|
if proceed
|
||||||
&& komorebi_client::send_message(&SocketMessage::FocusWorkspaceNumber(i))
|
&& komorebi_client::send_message(&SocketMessage::FocusWorkspaceNumber(
|
||||||
|
i,
|
||||||
|
))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!("could not send message to komorebi: FocusWorkspaceNumber");
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: FocusWorkspaceNumber"
|
||||||
|
);
|
||||||
proceed = false;
|
proceed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,18 +171,23 @@ impl BarWidget for Komorebi {
|
|||||||
))
|
))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!("could not send message to komorebi: MouseFollowsFocus");
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: MouseFollowsFocus"
|
||||||
|
);
|
||||||
proceed = false;
|
proceed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if proceed
|
if proceed
|
||||||
&& komorebi_client::send_message(&SocketMessage::RetileWithResizeDimensions)
|
&& komorebi_client::send_message(
|
||||||
|
&SocketMessage::RetileWithResizeDimensions,
|
||||||
|
)
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!("could not send message to komorebi: Retile");
|
tracing::error!("could not send message to komorebi: Retile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if let Some(update) = update {
|
if let Some(update) = update {
|
||||||
komorebi_notification_state.selected_workspace = update;
|
komorebi_notification_state.selected_workspace = update;
|
||||||
@@ -185,6 +198,7 @@ impl BarWidget for Komorebi {
|
|||||||
|
|
||||||
if let Some(layout) = self.layout {
|
if let Some(layout) = self.layout {
|
||||||
if layout.enable {
|
if layout.enable {
|
||||||
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(komorebi_notification_state.layout.to_string())
|
Label::new(komorebi_notification_state.layout.to_string())
|
||||||
@@ -200,23 +214,33 @@ impl BarWidget for Komorebi {
|
|||||||
))
|
))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!("could not send message to komorebi: CycleLayout");
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: CycleLayout"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KomorebiLayout::Floating => {
|
KomorebiLayout::Floating => {
|
||||||
if komorebi_client::send_message(&SocketMessage::ToggleTiling).is_err()
|
if komorebi_client::send_message(&SocketMessage::ToggleTiling)
|
||||||
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!("could not send message to komorebi: ToggleTiling");
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: ToggleTiling"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KomorebiLayout::Paused => {
|
KomorebiLayout::Paused => {
|
||||||
if komorebi_client::send_message(&SocketMessage::TogglePause).is_err() {
|
if komorebi_client::send_message(&SocketMessage::TogglePause)
|
||||||
tracing::error!("could not send message to komorebi: TogglePause");
|
.is_err()
|
||||||
|
{
|
||||||
|
tracing::error!(
|
||||||
|
"could not send message to komorebi: TogglePause"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KomorebiLayout::Custom => {}
|
KomorebiLayout::Custom => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
}
|
}
|
||||||
@@ -226,8 +250,9 @@ impl BarWidget for Komorebi {
|
|||||||
if configuration_switcher.enable {
|
if configuration_switcher.enable {
|
||||||
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() {
|
||||||
&& ui
|
config.grouping.apply_on_widget(ui,|ui|{
|
||||||
|
if ui
|
||||||
.add(Label::new(name).selectable(false).sense(Sense::click()))
|
.add(Label::new(name).selectable(false).sense(Sense::click()))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
@@ -273,6 +298,7 @@ impl BarWidget for Komorebi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,6 +308,7 @@ impl BarWidget for Komorebi {
|
|||||||
|
|
||||||
if let Some(focused_window) = self.focused_window {
|
if let Some(focused_window) = self.focused_window {
|
||||||
if focused_window.enable {
|
if focused_window.enable {
|
||||||
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
let titles = &komorebi_notification_state.focused_container_information.0;
|
let titles = &komorebi_notification_state.focused_container_information.0;
|
||||||
let icons = &komorebi_notification_state.focused_container_information.1;
|
let icons = &komorebi_notification_state.focused_container_information.1;
|
||||||
let focused_window_idx =
|
let focused_window_idx =
|
||||||
@@ -365,7 +392,9 @@ impl BarWidget for Komorebi {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if komorebi_client::send_message(&SocketMessage::FocusStackWindow(i))
|
if komorebi_client::send_message(&SocketMessage::FocusStackWindow(
|
||||||
|
i,
|
||||||
|
))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
@@ -387,6 +416,7 @@ impl BarWidget for Komorebi {
|
|||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ mod battery;
|
|||||||
mod config;
|
mod config;
|
||||||
mod cpu;
|
mod cpu;
|
||||||
mod date;
|
mod date;
|
||||||
|
mod group;
|
||||||
mod komorebi;
|
mod komorebi;
|
||||||
mod media;
|
mod media;
|
||||||
mod memory;
|
mod memory;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ impl Media {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Media {
|
impl BarWidget for Media {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.enable {
|
if self.enable {
|
||||||
let output = self.output();
|
let output = self.output();
|
||||||
if !output.is_empty() {
|
if !output.is_empty() {
|
||||||
@@ -103,6 +103,7 @@ impl BarWidget for Media {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
config.grouping.apply_on_widget(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);
|
||||||
|
|
||||||
@@ -121,6 +122,7 @@ impl BarWidget for Media {
|
|||||||
{
|
{
|
||||||
self.toggle();
|
self.toggle();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ impl Memory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Memory {
|
impl BarWidget for Memory {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.enable {
|
if self.enable {
|
||||||
let output = self.output();
|
let output = self.output();
|
||||||
if !output.is_empty() {
|
if !output.is_empty() {
|
||||||
@@ -103,6 +103,7 @@ impl BarWidget for Memory {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
@@ -111,11 +112,13 @@ impl BarWidget for Memory {
|
|||||||
)
|
)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
if let Err(error) = Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
if let Err(error) =
|
||||||
|
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{}", error)
|
eprintln!("{}", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ use crate::WIDGET_SPACING;
|
|||||||
use eframe::egui::text::LayoutJob;
|
use eframe::egui::text::LayoutJob;
|
||||||
use eframe::egui::Context;
|
use eframe::egui::Context;
|
||||||
use eframe::egui::FontId;
|
use eframe::egui::FontId;
|
||||||
use eframe::egui::Frame;
|
|
||||||
use eframe::egui::Label;
|
use eframe::egui::Label;
|
||||||
use eframe::egui::Margin;
|
|
||||||
use eframe::egui::Rounding;
|
|
||||||
use eframe::egui::Sense;
|
use eframe::egui::Sense;
|
||||||
use eframe::egui::TextFormat;
|
use eframe::egui::TextFormat;
|
||||||
use eframe::egui::TextStyle;
|
use eframe::egui::TextStyle;
|
||||||
@@ -321,16 +318,10 @@ impl Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Network {
|
impl BarWidget for Network {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.show_total_data_transmitted {
|
if self.show_total_data_transmitted {
|
||||||
for output in self.total_data_transmitted() {
|
for output in self.total_data_transmitted() {
|
||||||
Frame::none()
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
//.fill(Color32::from_black_alpha(255u8))
|
|
||||||
.outer_margin(Margin::symmetric(0.0, 0.0))
|
|
||||||
.inner_margin(Margin::symmetric(7.0, 2.0))
|
|
||||||
.rounding(Rounding::same(15.0))
|
|
||||||
.stroke(ui.style().visuals.widgets.noninteractive.bg_stroke)
|
|
||||||
.show(ui, |ui| {
|
|
||||||
ui.add(Label::new(output).selectable(false));
|
ui.add(Label::new(output).selectable(false));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -340,13 +331,7 @@ impl BarWidget for Network {
|
|||||||
|
|
||||||
if self.show_network_activity {
|
if self.show_network_activity {
|
||||||
for output in self.network_activity() {
|
for output in self.network_activity() {
|
||||||
Frame::none()
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
//.fill(Color32::from_black_alpha(255u8))
|
|
||||||
.outer_margin(Margin::symmetric(0.0, 0.0))
|
|
||||||
.inner_margin(Margin::symmetric(7.0, 2.0))
|
|
||||||
.rounding(Rounding::same(15.0))
|
|
||||||
.stroke(ui.style().visuals.widgets.noninteractive.bg_stroke)
|
|
||||||
.show(ui, |ui| {
|
|
||||||
ui.add(Label::new(output).selectable(false));
|
ui.add(Label::new(output).selectable(false));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -387,13 +372,7 @@ impl BarWidget for Network {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
Frame::none()
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
//.fill(Color32::from_black_alpha(255u8))
|
|
||||||
.outer_margin(Margin::symmetric(0.0, 0.0))
|
|
||||||
.inner_margin(Margin::symmetric(7.0, 2.0))
|
|
||||||
.rounding(Rounding::same(15.0))
|
|
||||||
.stroke(ui.style().visuals.widgets.noninteractive.bg_stroke)
|
|
||||||
.show(ui, |ui| {
|
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
@@ -402,8 +381,7 @@ impl BarWidget for Network {
|
|||||||
)
|
)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
if let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn()
|
if let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn() {
|
||||||
{
|
|
||||||
eprintln!("{}", error)
|
eprintln!("{}", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ impl Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Storage {
|
impl BarWidget for Storage {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.enable {
|
if self.enable {
|
||||||
let font_id = ctx
|
let font_id = ctx
|
||||||
.style()
|
.style()
|
||||||
@@ -108,6 +108,7 @@ 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.grouping.apply_on_widget(ui, |ui| {
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
@@ -127,6 +128,7 @@ impl BarWidget for Storage {
|
|||||||
eprintln!("{}", error)
|
eprintln!("{}", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ui.add_space(WIDGET_SPACING);
|
ui.add_space(WIDGET_SPACING);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ use crate::WIDGET_SPACING;
|
|||||||
use eframe::egui::text::LayoutJob;
|
use eframe::egui::text::LayoutJob;
|
||||||
use eframe::egui::Context;
|
use eframe::egui::Context;
|
||||||
use eframe::egui::FontId;
|
use eframe::egui::FontId;
|
||||||
use eframe::egui::Frame;
|
|
||||||
use eframe::egui::Label;
|
use eframe::egui::Label;
|
||||||
use eframe::egui::Margin;
|
|
||||||
use eframe::egui::Rounding;
|
|
||||||
use eframe::egui::Sense;
|
use eframe::egui::Sense;
|
||||||
use eframe::egui::TextFormat;
|
use eframe::egui::TextFormat;
|
||||||
use eframe::egui::TextStyle;
|
use eframe::egui::TextStyle;
|
||||||
@@ -81,7 +78,7 @@ impl Time {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BarWidget for Time {
|
impl BarWidget for Time {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, _config: RenderConfig) {
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, mut config: RenderConfig) {
|
||||||
if self.enable {
|
if self.enable {
|
||||||
let mut output = self.output();
|
let mut output = self.output();
|
||||||
if !output.is_empty() {
|
if !output.is_empty() {
|
||||||
@@ -114,13 +111,7 @@ impl BarWidget for Time {
|
|||||||
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
TextFormat::simple(font_id, ctx.style().visuals.text_color()),
|
||||||
);
|
);
|
||||||
|
|
||||||
Frame::none()
|
config.grouping.apply_on_widget(ui, |ui| {
|
||||||
//.fill(Color32::from_black_alpha(255u8))
|
|
||||||
.outer_margin(Margin::symmetric(0.0, 0.0))
|
|
||||||
.inner_margin(Margin::symmetric(7.0, 2.0))
|
|
||||||
.rounding(Rounding::same(15.0))
|
|
||||||
.stroke(ui.style().visuals.widgets.noninteractive.bg_stroke)
|
|
||||||
.show(ui, |ui| {
|
|
||||||
if ui
|
if ui
|
||||||
.add(
|
.add(
|
||||||
Label::new(layout_job)
|
Label::new(layout_job)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use crate::battery::Battery;
|
use crate::battery::Battery;
|
||||||
use crate::battery::BatteryConfig;
|
use crate::battery::BatteryConfig;
|
||||||
use crate::config::Grouping;
|
|
||||||
use crate::cpu::Cpu;
|
use crate::cpu::Cpu;
|
||||||
use crate::cpu::CpuConfig;
|
use crate::cpu::CpuConfig;
|
||||||
use crate::date::Date;
|
use crate::date::Date;
|
||||||
use crate::date::DateConfig;
|
use crate::date::DateConfig;
|
||||||
|
use crate::group::Grouping;
|
||||||
use crate::komorebi::Komorebi;
|
use crate::komorebi::Komorebi;
|
||||||
use crate::komorebi::KomorebiConfig;
|
use crate::komorebi::KomorebiConfig;
|
||||||
use crate::media::Media;
|
use crate::media::Media;
|
||||||
@@ -30,7 +30,7 @@ pub trait BarWidget {
|
|||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct RenderConfig {
|
pub struct RenderConfig {
|
||||||
/// Sets how widgets are grouped
|
/// Sets how widgets are grouped
|
||||||
pub _grouping: Grouping,
|
pub grouping: Grouping,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
|||||||
Reference in New Issue
Block a user