mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-25 04:32:10 +00:00
Add a "Location" config.
Partially implements https://github.com/scorpion-26/gBar/issues/20
This commit is contained in:
parent
9ee1fde653
commit
a95debf3c2
6 changed files with 146 additions and 69 deletions
|
@ -13,7 +13,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.right {
|
.right {
|
||||||
margin-right: 10px;
|
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@
|
||||||
|
|
||||||
.reboot-button {
|
.reboot-button {
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
margin-right: 6px;
|
|
||||||
color: #6272a4;
|
color: #6272a4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,10 +40,6 @@
|
||||||
color: #ff5555;
|
color: #ff5555;
|
||||||
}
|
}
|
||||||
|
|
||||||
.power-box-expand {
|
|
||||||
margin-right: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.system-confirm {
|
.system-confirm {
|
||||||
color: #50fa7b;
|
color: #50fa7b;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +49,6 @@ trough {
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-style: none;
|
border-style: none;
|
||||||
background-color: #44475a;
|
background-color: #44475a;
|
||||||
margin-top: 2px;
|
|
||||||
min-width: 4px;
|
min-width: 4px;
|
||||||
min-height: 4px;
|
min-height: 4px;
|
||||||
}
|
}
|
||||||
|
@ -74,13 +67,13 @@ highlight {
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-style: none;
|
border-style: none;
|
||||||
|
min-width: 6px;
|
||||||
min-height: 6px;
|
min-height: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.audio-icon {
|
.audio-icon {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
color: #ffb86c;
|
color: #ffb86c;
|
||||||
margin-right: 12px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.audio-volume trough {
|
.audio-volume trough {
|
||||||
|
@ -96,7 +89,6 @@ highlight {
|
||||||
.mic-icon {
|
.mic-icon {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
color: #bd93f9;
|
color: #bd93f9;
|
||||||
margin-right: 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mic-volume trough {
|
.mic-volume trough {
|
||||||
|
@ -110,34 +102,29 @@ highlight {
|
||||||
}
|
}
|
||||||
|
|
||||||
.package-outofdate {
|
.package-outofdate {
|
||||||
|
margin: -5px -5px -5px -5px;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
margin-right: -5px;
|
|
||||||
margin-left: -5px;
|
|
||||||
color: #ff5555;
|
color: #ff5555;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bt-num {
|
.bt-num {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #1793D1;
|
color: #1793D1;
|
||||||
margin-left: -6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bt-label-on {
|
.bt-label-on {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
color: #1793D1;
|
color: #1793D1;
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bt-label-off {
|
.bt-label-off {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
color: #1793D1;
|
color: #1793D1;
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bt-label-connected {
|
.bt-label-connected {
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
color: #1793D1;
|
color: #1793D1;
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.disk-util-progress {
|
.disk-util-progress {
|
||||||
|
@ -148,7 +135,6 @@ highlight {
|
||||||
|
|
||||||
.disk-data-text {
|
.disk-data-text {
|
||||||
color: #bd93f9;
|
color: #bd93f9;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +145,6 @@ highlight {
|
||||||
|
|
||||||
.vram-data-text {
|
.vram-data-text {
|
||||||
color: #ffb86c;
|
color: #ffb86c;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +155,6 @@ highlight {
|
||||||
|
|
||||||
.ram-data-text {
|
.ram-data-text {
|
||||||
color: #f1fa8c;
|
color: #f1fa8c;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +165,6 @@ highlight {
|
||||||
|
|
||||||
.gpu-data-text {
|
.gpu-data-text {
|
||||||
color: #8be9fd;
|
color: #8be9fd;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +176,6 @@ highlight {
|
||||||
|
|
||||||
.cpu-data-text {
|
.cpu-data-text {
|
||||||
color: #50fa7b;
|
color: #50fa7b;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,13 +187,11 @@ highlight {
|
||||||
|
|
||||||
.battery-data-text {
|
.battery-data-text {
|
||||||
color: #ff79c6;
|
color: #ff79c6;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.network-data-text {
|
.network-data-text {
|
||||||
color: #50fa7b;
|
color: #50fa7b;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ $textsize: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right {
|
.right {
|
||||||
margin-right: 10px;
|
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,27 +47,22 @@ $textsize: 16px;
|
||||||
|
|
||||||
.reboot-button {
|
.reboot-button {
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
//margin: -6px 6px -6px 0px;
|
|
||||||
margin-right: 6px;
|
|
||||||
|
|
||||||
color: $darkblue;
|
color: $darkblue;
|
||||||
}
|
}
|
||||||
.sleep-button {
|
.sleep-button {
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
//margin: -6px 0px -6px 0px;
|
|
||||||
|
|
||||||
color: $darkblue;
|
color: $darkblue;
|
||||||
}
|
}
|
||||||
.exit-button {
|
.exit-button {
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
//margin: -6px 0px -6px 0px;
|
|
||||||
|
|
||||||
color: $darkblue;
|
color: $darkblue;
|
||||||
}
|
}
|
||||||
|
|
||||||
.power-button {
|
.power-button {
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
//margin: -16px -24px -16px 0px;
|
|
||||||
|
|
||||||
color: $red;
|
color: $red;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +71,6 @@ $textsize: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.power-box-expand {
|
.power-box-expand {
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.system-confirm {
|
.system-confirm {
|
||||||
|
@ -90,7 +83,7 @@ trough {
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-style: none;
|
border-style: none;
|
||||||
background-color: $inactive;
|
background-color: $inactive;
|
||||||
margin-top: 2px;
|
// margin-top: 2px;
|
||||||
min-width: 4px;
|
min-width: 4px;
|
||||||
min-height: 4px;
|
min-height: 4px;
|
||||||
}
|
}
|
||||||
|
@ -110,13 +103,15 @@ highlight {
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-style: none;
|
border-style: none;
|
||||||
|
// For vertical we need width, for horizontal we need height
|
||||||
|
// Both can coexist though
|
||||||
|
min-width: 6px;
|
||||||
min-height: 6px;
|
min-height: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.audio-icon {
|
.audio-icon {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
color: $orange;
|
color: $orange;
|
||||||
margin-right: 12px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.audio-volume {
|
.audio-volume {
|
||||||
|
@ -136,7 +131,7 @@ highlight {
|
||||||
.mic-icon {
|
.mic-icon {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
color: $purple;
|
color: $purple;
|
||||||
margin-right: 0px;
|
// margin-right: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mic-volume {
|
.mic-volume {
|
||||||
|
@ -154,31 +149,26 @@ highlight {
|
||||||
}
|
}
|
||||||
|
|
||||||
.package-outofdate {
|
.package-outofdate {
|
||||||
|
margin: -5px -5px -5px -5px;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
margin-right: -5px;
|
|
||||||
margin-left: -5px;
|
|
||||||
color: $red;
|
color: $red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bt-num {
|
.bt-num {
|
||||||
font-size: $textsize;
|
font-size: $textsize;
|
||||||
color: $btblue;
|
color: $btblue;
|
||||||
margin-left: -6px;
|
|
||||||
}
|
}
|
||||||
.bt-label-on {
|
.bt-label-on {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
color: $btblue;
|
color: $btblue;
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
.bt-label-off {
|
.bt-label-off {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
color: $btblue;
|
color: $btblue;
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
.bt-label-connected {
|
.bt-label-connected {
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
color: $btblue;
|
color: $btblue;
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.disk-util-progress {
|
.disk-util-progress {
|
||||||
|
@ -188,7 +178,6 @@ highlight {
|
||||||
}
|
}
|
||||||
.disk-data-text {
|
.disk-data-text {
|
||||||
color: $purple;
|
color: $purple;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: $textsize;
|
font-size: $textsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +187,6 @@ highlight {
|
||||||
}
|
}
|
||||||
.vram-data-text {
|
.vram-data-text {
|
||||||
color: $orange;
|
color: $orange;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: $textsize;
|
font-size: $textsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +196,6 @@ highlight {
|
||||||
}
|
}
|
||||||
.ram-data-text {
|
.ram-data-text {
|
||||||
color: $yellow;
|
color: $yellow;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: $textsize;
|
font-size: $textsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +205,6 @@ highlight {
|
||||||
}
|
}
|
||||||
.gpu-data-text {
|
.gpu-data-text {
|
||||||
color: $cyan;
|
color: $cyan;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: $textsize;
|
font-size: $textsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +215,6 @@ highlight {
|
||||||
}
|
}
|
||||||
.cpu-data-text {
|
.cpu-data-text {
|
||||||
color: $green;
|
color: $green;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: $textsize;
|
font-size: $textsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,13 +225,11 @@ highlight {
|
||||||
}
|
}
|
||||||
.battery-data-text {
|
.battery-data-text {
|
||||||
color: $pink;
|
color: $pink;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: $textsize;
|
font-size: $textsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
.network-data-text {
|
.network-data-text {
|
||||||
color: $green;
|
color: $green;
|
||||||
margin-right: 6px;
|
|
||||||
font-size: $textsize;
|
font-size: $textsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,11 @@ WorkspaceScrollInvert: false
|
||||||
# since the protocol is not as feature complete as Hyprland IPC.
|
# since the protocol is not as feature complete as Hyprland IPC.
|
||||||
UseHyprlandIPC: false
|
UseHyprlandIPC: false
|
||||||
|
|
||||||
|
# The location of the bar
|
||||||
|
# Needs to be capitalized!!
|
||||||
|
# Values are: L (Left), R (Right), T (Top), B (bottom)
|
||||||
|
Location: T
|
||||||
|
|
||||||
# Forces the time to be centered.
|
# Forces the time to be centered.
|
||||||
# This can cause the right issue to clip outside, if there is not enough space on screen (e.g. when opening the text)
|
# This can cause the right issue to clip outside, if there is not enough space on screen (e.g. when opening the text)
|
||||||
# Setting this to false will definitely fix this issue, but it won't look very good, since it will be off-center.
|
# Setting this to false will definitely fix this issue, but it won't look very good, since it will be off-center.
|
||||||
|
|
153
src/Bar.cpp
153
src/Bar.cpp
|
@ -4,6 +4,7 @@
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "SNI.h"
|
#include "SNI.h"
|
||||||
|
#include <cmath>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
namespace Bar
|
namespace Bar
|
||||||
|
@ -268,16 +269,74 @@ namespace Bar
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void SetTransform(Widget& widget, const Transform& primary, const Transform& secondary = {})
|
||||||
|
{
|
||||||
|
if (Config::Get().location == 'T' || Config::Get().location == 'B')
|
||||||
|
{
|
||||||
|
widget.SetHorizontalTransform(primary);
|
||||||
|
widget.SetVerticalTransform(secondary);
|
||||||
|
}
|
||||||
|
else if (Config::Get().location == 'R' || Config::Get().location == 'L')
|
||||||
|
{
|
||||||
|
widget.SetVerticalTransform(primary);
|
||||||
|
widget.SetHorizontalTransform(secondary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline TransitionType GetTransitionType()
|
||||||
|
{
|
||||||
|
switch (Config::Get().location)
|
||||||
|
{
|
||||||
|
case 'T':
|
||||||
|
case 'B': return TransitionType::SlideLeft;
|
||||||
|
case 'L':
|
||||||
|
case 'R': return TransitionType::SlideUp;
|
||||||
|
default: LOG("Invalid location char \"" << Config::Get().location << "\"!") return TransitionType::SlideLeft;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Orientation GetOrientation()
|
||||||
|
{
|
||||||
|
switch (Config::Get().location)
|
||||||
|
{
|
||||||
|
case 'T':
|
||||||
|
case 'B': return Orientation::Horizontal;
|
||||||
|
case 'L':
|
||||||
|
case 'R': return Orientation::Vertical;
|
||||||
|
default: LOG("Invalid location char \"" << Config::Get().location << "\"!") return Orientation::Horizontal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double GetAngle()
|
||||||
|
{
|
||||||
|
if (Config::Get().location == 'T' || Config::Get().location == 'B')
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (Config::Get().location == 'L')
|
||||||
|
{
|
||||||
|
return 270; // 90 is buggy (Clipped text)
|
||||||
|
}
|
||||||
|
else if (Config::Get().location == 'R')
|
||||||
|
{
|
||||||
|
return 270;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG("Invalid location char \"" << Config::Get().location << "\"!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void WidgetSensor(Widget& parent, TimerCallback<Sensor>&& callback, const std::string& sensorClass, const std::string& textClass, Text*& textPtr)
|
void WidgetSensor(Widget& parent, TimerCallback<Sensor>&& callback, const std::string& sensorClass, const std::string& textClass, Text*& textPtr)
|
||||||
{
|
{
|
||||||
auto eventBox = Widget::Create<EventBox>();
|
auto eventBox = Widget::Create<EventBox>();
|
||||||
{
|
{
|
||||||
auto box = Widget::Create<Box>();
|
auto box = Widget::Create<Box>();
|
||||||
box->SetSpacing({0, false});
|
box->SetSpacing({0, false});
|
||||||
box->SetHorizontalTransform({-1, true, Alignment::Right});
|
SetTransform(*box, {-1, true, Alignment::Right});
|
||||||
|
box->SetOrientation(GetOrientation());
|
||||||
{
|
{
|
||||||
auto revealer = Widget::Create<Revealer>();
|
auto revealer = Widget::Create<Revealer>();
|
||||||
revealer->SetTransition({TransitionType::SlideLeft, 500});
|
revealer->SetTransition({GetTransitionType(), 500});
|
||||||
// Add event to eventbox for the revealer to open
|
// Add event to eventbox for the revealer to open
|
||||||
eventBox->SetHoverFn(
|
eventBox->SetHoverFn(
|
||||||
[textRevealer = revealer.get()](EventBox&, bool hovered)
|
[textRevealer = revealer.get()](EventBox&, bool hovered)
|
||||||
|
@ -287,14 +346,25 @@ namespace Bar
|
||||||
{
|
{
|
||||||
auto text = Widget::Create<Text>();
|
auto text = Widget::Create<Text>();
|
||||||
text->SetClass(textClass);
|
text->SetClass(textClass);
|
||||||
|
text->SetAngle(GetAngle());
|
||||||
|
SetTransform(*text, {-1, true, Alignment::Fill, 0, 6});
|
||||||
textPtr = text.get();
|
textPtr = text.get();
|
||||||
revealer->AddChild(std::move(text));
|
revealer->AddChild(std::move(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sensor = Widget::Create<Sensor>();
|
auto sensor = Widget::Create<Sensor>();
|
||||||
sensor->SetClass(sensorClass);
|
sensor->SetClass(sensorClass);
|
||||||
|
double angle = -90;
|
||||||
|
switch (Config::Get().location)
|
||||||
|
{
|
||||||
|
case 'T':
|
||||||
|
case 'B': angle = -90; break;
|
||||||
|
case 'L':
|
||||||
|
case 'R': angle = 0; break;
|
||||||
|
}
|
||||||
|
sensor->SetStyle({angle});
|
||||||
sensor->AddTimer<Sensor>(std::move(callback), DynCtx::updateTime);
|
sensor->AddTimer<Sensor>(std::move(callback), DynCtx::updateTime);
|
||||||
sensor->SetHorizontalTransform({24, true, Alignment::Fill});
|
SetTransform(*sensor, {24, true, Alignment::Fill});
|
||||||
|
|
||||||
box->AddChild(std::move(revealer));
|
box->AddChild(std::move(revealer));
|
||||||
box->AddChild(std::move(sensor));
|
box->AddChild(std::move(sensor));
|
||||||
|
@ -316,8 +386,8 @@ namespace Bar
|
||||||
auto widgetAudioSlider = [](Widget& parent, AudioType type)
|
auto widgetAudioSlider = [](Widget& parent, AudioType type)
|
||||||
{
|
{
|
||||||
auto slider = Widget::Create<Slider>();
|
auto slider = Widget::Create<Slider>();
|
||||||
slider->SetOrientation(Orientation::Horizontal);
|
slider->SetOrientation(GetOrientation());
|
||||||
slider->SetHorizontalTransform({100, true, Alignment::Fill});
|
SetTransform(*slider, {100, true, Alignment::Fill});
|
||||||
slider->SetInverted(true);
|
slider->SetInverted(true);
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
@ -342,9 +412,11 @@ namespace Bar
|
||||||
{
|
{
|
||||||
auto box = Widget::Create<Box>();
|
auto box = Widget::Create<Box>();
|
||||||
box->SetSpacing({8, false});
|
box->SetSpacing({8, false});
|
||||||
box->SetHorizontalTransform({-1, true, Alignment::Right});
|
SetTransform(*box, {-1, true, Alignment::Right});
|
||||||
|
box->SetOrientation(GetOrientation());
|
||||||
{
|
{
|
||||||
auto icon = Widget::Create<Text>();
|
auto icon = Widget::Create<Text>();
|
||||||
|
icon->SetAngle(GetAngle());
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case AudioType::Input:
|
case AudioType::Input:
|
||||||
|
@ -355,6 +427,7 @@ namespace Bar
|
||||||
case AudioType::Output:
|
case AudioType::Output:
|
||||||
icon->SetClass("audio-icon");
|
icon->SetClass("audio-icon");
|
||||||
icon->SetText(" ");
|
icon->SetText(" ");
|
||||||
|
SetTransform(*icon, {-1, true, Alignment::Fill, 0, 6});
|
||||||
DynCtx::audioIcon = icon.get();
|
DynCtx::audioIcon = icon.get();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +436,7 @@ namespace Bar
|
||||||
{
|
{
|
||||||
EventBox& eventBox = (EventBox&)parent;
|
EventBox& eventBox = (EventBox&)parent;
|
||||||
auto revealer = Widget::Create<Revealer>();
|
auto revealer = Widget::Create<Revealer>();
|
||||||
revealer->SetTransition({TransitionType::SlideLeft, 500});
|
revealer->SetTransition({GetTransitionType(), 500});
|
||||||
// Add event to eventbox for the revealer to open
|
// Add event to eventbox for the revealer to open
|
||||||
eventBox.SetHoverFn(
|
eventBox.SetHoverFn(
|
||||||
[slideRevealer = revealer.get()](EventBox&, bool hovered)
|
[slideRevealer = revealer.get()](EventBox&, bool hovered)
|
||||||
|
@ -419,6 +492,7 @@ namespace Bar
|
||||||
text->SetText("");
|
text->SetText("");
|
||||||
text->SetVisible(false);
|
text->SetVisible(false);
|
||||||
text->SetClass("package-empty");
|
text->SetClass("package-empty");
|
||||||
|
text->SetAngle(GetAngle());
|
||||||
text->AddTimer<Text>(DynCtx::UpdatePackages, 1000 * Config::Get().checkUpdateInterval, TimerDispatchBehaviour::ImmediateDispatch);
|
text->AddTimer<Text>(DynCtx::UpdatePackages, 1000 * Config::Get().checkUpdateInterval, TimerDispatchBehaviour::ImmediateDispatch);
|
||||||
parent.AddChild(std::move(text));
|
parent.AddChild(std::move(text));
|
||||||
}
|
}
|
||||||
|
@ -428,13 +502,17 @@ namespace Bar
|
||||||
{
|
{
|
||||||
auto box = Widget::Create<Box>();
|
auto box = Widget::Create<Box>();
|
||||||
box->SetSpacing({0, false});
|
box->SetSpacing({0, false});
|
||||||
|
box->SetOrientation(GetOrientation());
|
||||||
{
|
{
|
||||||
auto devText = Widget::Create<Text>();
|
auto devText = Widget::Create<Text>();
|
||||||
|
devText->SetAngle(GetAngle());
|
||||||
DynCtx::btDevText = devText.get();
|
DynCtx::btDevText = devText.get();
|
||||||
devText->SetClass("bt-num");
|
devText->SetClass("bt-num");
|
||||||
|
|
||||||
auto iconText = Widget::Create<Button>();
|
auto iconText = Widget::Create<Button>();
|
||||||
iconText->OnClick(DynCtx::OnBTClick);
|
iconText->OnClick(DynCtx::OnBTClick);
|
||||||
|
iconText->SetAngle(GetAngle());
|
||||||
|
SetTransform(*iconText, {-1, true, Alignment::Fill, 0, 6});
|
||||||
DynCtx::btIconText = iconText.get();
|
DynCtx::btIconText = iconText.get();
|
||||||
|
|
||||||
box->AddChild(std::move(devText));
|
box->AddChild(std::move(devText));
|
||||||
|
@ -452,10 +530,11 @@ namespace Bar
|
||||||
{
|
{
|
||||||
auto box = Widget::Create<Box>();
|
auto box = Widget::Create<Box>();
|
||||||
box->SetSpacing({0, false});
|
box->SetSpacing({0, false});
|
||||||
box->SetHorizontalTransform({-1, true, Alignment::Right});
|
SetTransform(*box, {-1, true, Alignment::Right});
|
||||||
|
box->SetOrientation(GetOrientation());
|
||||||
{
|
{
|
||||||
auto revealer = Widget::Create<Revealer>();
|
auto revealer = Widget::Create<Revealer>();
|
||||||
revealer->SetTransition({TransitionType::SlideLeft, 500});
|
revealer->SetTransition({GetTransitionType(), 500});
|
||||||
// Add event to eventbox for the revealer to open
|
// Add event to eventbox for the revealer to open
|
||||||
eventBox->SetHoverFn(
|
eventBox->SetHoverFn(
|
||||||
[textRevealer = revealer.get()](EventBox&, bool hovered)
|
[textRevealer = revealer.get()](EventBox&, bool hovered)
|
||||||
|
@ -465,6 +544,8 @@ namespace Bar
|
||||||
{
|
{
|
||||||
auto text = Widget::Create<Text>();
|
auto text = Widget::Create<Text>();
|
||||||
text->SetClass("network-data-text");
|
text->SetClass("network-data-text");
|
||||||
|
text->SetAngle(GetAngle());
|
||||||
|
SetTransform(*text, {-1, true, Alignment::Fill, 0, 6});
|
||||||
DynCtx::networkText = text.get();
|
DynCtx::networkText = text.get();
|
||||||
revealer->AddChild(std::move(text));
|
revealer->AddChild(std::move(text));
|
||||||
}
|
}
|
||||||
|
@ -472,8 +553,9 @@ namespace Bar
|
||||||
auto sensor = Widget::Create<NetworkSensor>();
|
auto sensor = Widget::Create<NetworkSensor>();
|
||||||
sensor->SetLimitUp({(double)Config::Get().minUploadBytes, (double)Config::Get().maxUploadBytes});
|
sensor->SetLimitUp({(double)Config::Get().minUploadBytes, (double)Config::Get().maxUploadBytes});
|
||||||
sensor->SetLimitDown({(double)Config::Get().minDownloadBytes, (double)Config::Get().maxDownloadBytes});
|
sensor->SetLimitDown({(double)Config::Get().minDownloadBytes, (double)Config::Get().maxDownloadBytes});
|
||||||
|
sensor->SetAngle(GetAngle());
|
||||||
sensor->AddTimer<NetworkSensor>(DynCtx::UpdateNetwork, DynCtx::updateTime);
|
sensor->AddTimer<NetworkSensor>(DynCtx::UpdateNetwork, DynCtx::updateTime);
|
||||||
sensor->SetHorizontalTransform({24, true, Alignment::Fill});
|
SetTransform(*sensor, {24, true, Alignment::Fill});
|
||||||
|
|
||||||
box->AddChild(std::move(revealer));
|
box->AddChild(std::move(revealer));
|
||||||
box->AddChild(std::move(sensor));
|
box->AddChild(std::move(sensor));
|
||||||
|
@ -538,20 +620,24 @@ namespace Bar
|
||||||
{
|
{
|
||||||
auto powerBox = Widget::Create<Box>();
|
auto powerBox = Widget::Create<Box>();
|
||||||
powerBox->SetClass("power-box");
|
powerBox->SetClass("power-box");
|
||||||
powerBox->SetHorizontalTransform({-1, false, Alignment::Right});
|
SetTransform(*powerBox, {-1, false, Alignment::Right});
|
||||||
powerBox->SetSpacing({0, false});
|
powerBox->SetSpacing({0, false});
|
||||||
|
powerBox->SetOrientation(GetOrientation());
|
||||||
{
|
{
|
||||||
auto revealer = Widget::Create<Revealer>();
|
auto revealer = Widget::Create<Revealer>();
|
||||||
DynCtx::powerBoxRevealer = revealer.get();
|
DynCtx::powerBoxRevealer = revealer.get();
|
||||||
revealer->SetTransition({TransitionType::SlideLeft, 500});
|
revealer->SetTransition({GetTransitionType(), 500});
|
||||||
{
|
{
|
||||||
auto powerBoxExpand = Widget::Create<Box>();
|
auto powerBoxExpand = Widget::Create<Box>();
|
||||||
powerBoxExpand->SetClass("power-box-expand");
|
powerBoxExpand->SetClass("power-box-expand");
|
||||||
powerBoxExpand->SetSpacing({8, true});
|
powerBoxExpand->SetSpacing({8, true});
|
||||||
|
powerBoxExpand->SetOrientation(GetOrientation());
|
||||||
|
SetTransform(*powerBoxExpand, {-1, true, Alignment::Fill, 0, 6});
|
||||||
{
|
{
|
||||||
auto exitButton = Widget::Create<Button>();
|
auto exitButton = Widget::Create<Button>();
|
||||||
exitButton->SetClass("exit-button");
|
exitButton->SetClass("exit-button");
|
||||||
exitButton->SetText("");
|
exitButton->SetText("");
|
||||||
|
exitButton->SetAngle(GetAngle());
|
||||||
exitButton->OnClick(
|
exitButton->OnClick(
|
||||||
[setActivate](Button& but)
|
[setActivate](Button& but)
|
||||||
{
|
{
|
||||||
|
@ -569,6 +655,7 @@ namespace Bar
|
||||||
auto lockButton = Widget::Create<Button>();
|
auto lockButton = Widget::Create<Button>();
|
||||||
lockButton->SetClass("sleep-button");
|
lockButton->SetClass("sleep-button");
|
||||||
lockButton->SetText("");
|
lockButton->SetText("");
|
||||||
|
lockButton->SetAngle(GetAngle());
|
||||||
lockButton->OnClick(
|
lockButton->OnClick(
|
||||||
[setActivate](Button& but)
|
[setActivate](Button& but)
|
||||||
{
|
{
|
||||||
|
@ -586,6 +673,7 @@ namespace Bar
|
||||||
auto sleepButton = Widget::Create<Button>();
|
auto sleepButton = Widget::Create<Button>();
|
||||||
sleepButton->SetClass("sleep-button");
|
sleepButton->SetClass("sleep-button");
|
||||||
sleepButton->SetText("");
|
sleepButton->SetText("");
|
||||||
|
sleepButton->SetAngle(GetAngle());
|
||||||
sleepButton->OnClick(
|
sleepButton->OnClick(
|
||||||
[setActivate](Button& but)
|
[setActivate](Button& but)
|
||||||
{
|
{
|
||||||
|
@ -603,6 +691,8 @@ namespace Bar
|
||||||
auto rebootButton = Widget::Create<Button>();
|
auto rebootButton = Widget::Create<Button>();
|
||||||
rebootButton->SetClass("reboot-button");
|
rebootButton->SetClass("reboot-button");
|
||||||
rebootButton->SetText("");
|
rebootButton->SetText("");
|
||||||
|
rebootButton->SetAngle(GetAngle());
|
||||||
|
SetTransform(*rebootButton, {-1, true, Alignment::Fill, 0, 6});
|
||||||
rebootButton->OnClick(
|
rebootButton->OnClick(
|
||||||
[setActivate](Button& but)
|
[setActivate](Button& but)
|
||||||
{
|
{
|
||||||
|
@ -629,7 +719,8 @@ namespace Bar
|
||||||
auto powerButton = Widget::Create<Button>();
|
auto powerButton = Widget::Create<Button>();
|
||||||
powerButton->SetClass("power-button");
|
powerButton->SetClass("power-button");
|
||||||
powerButton->SetText(" ");
|
powerButton->SetText(" ");
|
||||||
powerButton->SetHorizontalTransform({24, true, Alignment::Fill});
|
powerButton->SetAngle(GetAngle());
|
||||||
|
SetTransform(*powerButton, {24, true, Alignment::Fill});
|
||||||
powerButton->OnClick(
|
powerButton->OnClick(
|
||||||
[setActivate](Button& but)
|
[setActivate](Button& but)
|
||||||
{
|
{
|
||||||
|
@ -656,20 +747,18 @@ namespace Bar
|
||||||
#ifdef WITH_WORKSPACES
|
#ifdef WITH_WORKSPACES
|
||||||
void WidgetWorkspaces(Widget& parent)
|
void WidgetWorkspaces(Widget& parent)
|
||||||
{
|
{
|
||||||
auto margin = Widget::Create<Box>();
|
|
||||||
margin->SetHorizontalTransform({12, false, Alignment::Left});
|
|
||||||
parent.AddChild(std::move(margin));
|
|
||||||
auto eventBox = Widget::Create<EventBox>();
|
auto eventBox = Widget::Create<EventBox>();
|
||||||
eventBox->SetScrollFn(DynCtx::ScrollWorkspaces);
|
eventBox->SetScrollFn(DynCtx::ScrollWorkspaces);
|
||||||
{
|
{
|
||||||
auto box = Widget::Create<Box>();
|
auto box = Widget::Create<Box>();
|
||||||
box->SetSpacing({8, true});
|
box->SetSpacing({8, true});
|
||||||
box->SetHorizontalTransform({-1, true, Alignment::Left});
|
box->SetOrientation(GetOrientation());
|
||||||
|
SetTransform(*box, {-1, true, Alignment::Left, 12, 0});
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < DynCtx::workspaces.size(); i++)
|
for (size_t i = 0; i < DynCtx::workspaces.size(); i++)
|
||||||
{
|
{
|
||||||
auto workspace = Widget::Create<Button>();
|
auto workspace = Widget::Create<Button>();
|
||||||
workspace->SetHorizontalTransform({8, false, Alignment::Fill});
|
SetTransform(*workspace, {8, false, Alignment::Fill});
|
||||||
workspace->OnClick(
|
workspace->OnClick(
|
||||||
[i](Button&)
|
[i](Button&)
|
||||||
{
|
{
|
||||||
|
@ -691,13 +780,15 @@ namespace Bar
|
||||||
monitorID = monitor;
|
monitorID = monitor;
|
||||||
|
|
||||||
auto mainWidget = Widget::Create<Box>();
|
auto mainWidget = Widget::Create<Box>();
|
||||||
|
mainWidget->SetOrientation(GetOrientation());
|
||||||
mainWidget->SetSpacing({0, false});
|
mainWidget->SetSpacing({0, false});
|
||||||
mainWidget->SetClass("bar");
|
mainWidget->SetClass("bar");
|
||||||
{
|
{
|
||||||
// Calculate how much space we need have for the left widget.
|
// Calculate how much space we need have for the left widget.
|
||||||
// The center widget will come directly after that.
|
// The center widget will come directly after that.
|
||||||
// This ensures that the center widget is centered.
|
// This ensures that the center widget is centered.
|
||||||
int windowCenter = window.GetWidth() / 2;
|
bool topToBottom = Config::Get().location == 'L' || Config::Get().location == 'R';
|
||||||
|
int windowCenter = (topToBottom ? window.GetHeight() : window.GetWidth()) / 2;
|
||||||
int endLeftWidgets = windowCenter - Config::Get().timeSpace / 2;
|
int endLeftWidgets = windowCenter - Config::Get().timeSpace / 2;
|
||||||
|
|
||||||
if (!Config::Get().centerTime)
|
if (!Config::Get().centerTime)
|
||||||
|
@ -708,9 +799,10 @@ namespace Bar
|
||||||
|
|
||||||
auto left = Widget::Create<Box>();
|
auto left = Widget::Create<Box>();
|
||||||
left->SetSpacing({0, false});
|
left->SetSpacing({0, false});
|
||||||
|
left->SetOrientation(GetOrientation());
|
||||||
// For centerTime the width of the left widget handles the centering.
|
// For centerTime the width of the left widget handles the centering.
|
||||||
// For not centerTime we want to set it as much right as possible. So let this expand as much as possible.
|
// For not centerTime we want to set it as much right as possible. So let this expand as much as possible.
|
||||||
left->SetHorizontalTransform({endLeftWidgets, !Config::Get().centerTime, Alignment::Left});
|
SetTransform(*left, {endLeftWidgets, !Config::Get().centerTime, Alignment::Left});
|
||||||
#ifdef WITH_WORKSPACES
|
#ifdef WITH_WORKSPACES
|
||||||
if (RuntimeConfig::Get().hasWorkspaces)
|
if (RuntimeConfig::Get().hasWorkspaces)
|
||||||
{
|
{
|
||||||
|
@ -719,10 +811,12 @@ namespace Bar
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto center = Widget::Create<Box>();
|
auto center = Widget::Create<Box>();
|
||||||
center->SetHorizontalTransform({(int)Config::Get().timeSpace, false, Alignment::Left});
|
center->SetOrientation(GetOrientation());
|
||||||
|
SetTransform(*center, {(int)Config::Get().timeSpace, false, Alignment::Left});
|
||||||
{
|
{
|
||||||
auto time = Widget::Create<Text>();
|
auto time = Widget::Create<Text>();
|
||||||
time->SetHorizontalTransform({-1, true, Alignment::Center});
|
SetTransform(*time, {-1, true, Alignment::Center});
|
||||||
|
time->SetAngle(GetAngle());
|
||||||
time->SetClass("time-text");
|
time->SetClass("time-text");
|
||||||
time->SetText("Uninitialized");
|
time->SetText("Uninitialized");
|
||||||
time->AddTimer<Text>(DynCtx::UpdateTime, 1000);
|
time->AddTimer<Text>(DynCtx::UpdateTime, 1000);
|
||||||
|
@ -732,7 +826,8 @@ namespace Bar
|
||||||
auto right = Widget::Create<Box>();
|
auto right = Widget::Create<Box>();
|
||||||
right->SetClass("right");
|
right->SetClass("right");
|
||||||
right->SetSpacing({8, false});
|
right->SetSpacing({8, false});
|
||||||
right->SetHorizontalTransform({-1, true, Alignment::Right});
|
right->SetOrientation(GetOrientation());
|
||||||
|
SetTransform(*right, {-1, true, Alignment::Right, 0, 10});
|
||||||
{
|
{
|
||||||
#ifdef WITH_SNI
|
#ifdef WITH_SNI
|
||||||
SNI::WidgetSNI(*right);
|
SNI::WidgetSNI(*right);
|
||||||
|
@ -758,7 +853,17 @@ namespace Bar
|
||||||
mainWidget->AddChild(std::move(center));
|
mainWidget->AddChild(std::move(center));
|
||||||
mainWidget->AddChild(std::move(right));
|
mainWidget->AddChild(std::move(right));
|
||||||
}
|
}
|
||||||
window.SetAnchor(Anchor::Left | Anchor::Right | Anchor::Top);
|
|
||||||
|
Anchor anchor;
|
||||||
|
switch (Config::Get().location)
|
||||||
|
{
|
||||||
|
case 'T': anchor = Anchor::Top | Anchor::Left | Anchor::Right; break;
|
||||||
|
case 'B': anchor = Anchor::Bottom | Anchor::Left | Anchor::Right; break;
|
||||||
|
case 'L': anchor = Anchor::Left | Anchor::Top | Anchor::Bottom; break;
|
||||||
|
case 'R': anchor = Anchor::Right | Anchor::Top | Anchor::Bottom; break;
|
||||||
|
default: LOG("Invalid location char \"" << Config::Get().location << "\"!"); anchor = Anchor::Top | Anchor::Left | Anchor::Right;
|
||||||
|
}
|
||||||
|
window.SetAnchor(anchor);
|
||||||
window.SetMainWidget(std::move(mainWidget));
|
window.SetMainWidget(std::move(mainWidget));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,8 @@ void Config::Load()
|
||||||
AddConfigVar("AudioMinVolume", config.audioMinVolume, lineView, foundProperty);
|
AddConfigVar("AudioMinVolume", config.audioMinVolume, lineView, foundProperty);
|
||||||
AddConfigVar("AudioMaxVolume", config.audioMaxVolume, lineView, foundProperty);
|
AddConfigVar("AudioMaxVolume", config.audioMaxVolume, lineView, foundProperty);
|
||||||
|
|
||||||
|
AddConfigVar("Location", config.location, lineView, foundProperty);
|
||||||
|
|
||||||
std::pair<std::string, uint32_t> buf;
|
std::pair<std::string, uint32_t> buf;
|
||||||
bool hasntFoundProperty = !foundProperty;
|
bool hasntFoundProperty = !foundProperty;
|
||||||
AddConfigVar("SNIIconSize", buf, lineView, foundProperty);
|
AddConfigVar("SNIIconSize", buf, lineView, foundProperty);
|
||||||
|
|
|
@ -42,6 +42,8 @@ public:
|
||||||
|
|
||||||
uint32_t timeSpace = 300; // How much time should be reserved for the time widget.
|
uint32_t timeSpace = 300; // How much time should be reserved for the time widget.
|
||||||
|
|
||||||
|
char location = 'T'; // The Location of the bar. Can be L,R,T,B
|
||||||
|
|
||||||
// SNIIconSize: ["Title String"], ["Size"]
|
// SNIIconSize: ["Title String"], ["Size"]
|
||||||
std::unordered_map<std::string, uint32_t> sniIconSizes;
|
std::unordered_map<std::string, uint32_t> sniIconSizes;
|
||||||
std::unordered_map<std::string, int32_t> sniPaddingTop;
|
std::unordered_map<std::string, int32_t> sniPaddingTop;
|
||||||
|
|
Loading…
Reference in a new issue