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