-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: How to center a grid? #27
Comments
This is actually not a simple question. Gtk allocates space evenly between
widgets configured with expand set to true, so adding a tray on one side
will skew the center (since the two labels get expanded to equal size).
The only certain way to achieve this that is to implement left, center and
right grids and pack widgets into these.
It should be easy to implement, but I need to think of how to do this
right in terms of configuration.
I'm currently thinking of allowing multiple layout sections, I.e.:
Layout("left") {...}
Layout("center") {...}
Layout("right") {...}
If the default Layout is "left", we should get the current behaviour.
…On Tue, 26 Apr 2022, 17:06 aMir733, ***@***.***> wrote:
In a way that it shows up at the center of the screen?
I have this layout: taskbar - label (for spacing) - grid (I want this
centered) - label (spacing again) - tray. But it's not exactly centered.
—
Reply to this email directly, view it on GitHub
<#27>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASHPFFGWEZURRQPDGYVSN4TVHAH7ZANCNFSM5UMLFP6Q>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Another way to do it in my opinion is to have an "align" variable inside the widget, like:
and if it's not defined in the user's configuration then set it to left as in default. This way when you release the update people don't have to update their configuration file. |
The problem with using a widget property is that gtk only allows aligning
widgets in respect to space they are allocated, so setting center
alignment to the grid will center it in respect to the space available
apart from the tray (I.e. it will be skewed from the center of the window).
The only way to center a widget in respect to the window is to use a gtk
box. This means we either need to introduce a new widget type (which will
be used only once) or to create a box by default and allow users to pack
widgets into 3 grids in the box.
We could use a single layout and use a widget property to sort widgets into
the 3 grids, but then we have a problem with hierarchy. I.e. if we
specify center alignment, where in the central grid will the widget go?
…On Wed, 27 Apr 2022, 11:35 aMir733, ***@***.***> wrote:
Another way to do it in my opinion is to have an "align" variable inside
the widget, like:
grid {
align = "center"
...
}
and if it's not defined in the user's configuration then set it to left as
in default. This way when you release the update people don't have to
update their configuration file.
—
Reply to this email directly, view it on GitHub
<#27 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASHPFFDREUPOZJB4N2TXIVDVHEJ5JANCNFSM5UMLFP6Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I pushed the initial implementation of the 3 grids into the main git
branch. You can pack widgets into "start", "center" and "end" grids. If you
omit grids name, it will be assumed to be the start grid, this should
preserve compatibility with the existing configs. You may need to have a
start grid in the current version even if it's empty. I'll fix this
limitation on the next update.
Can you check if this works for your use case please?
…On Wed, 27 Apr 2022, 19:09 Lev Babiev, ***@***.***> wrote:
The problem with using a widget property is that gtk only allows aligning
widgets in respect to space they are allocated, so setting center
alignment to the grid will center it in respect to the space available
apart from the tray (I.e. it will be skewed from the center of the window).
The only way to center a widget in respect to the window is to use a gtk
box. This means we either need to introduce a new widget type (which will
be used only once) or to create a box by default and allow users to pack
widgets into 3 grids in the box.
We could use a single layout and use a widget property to sort widgets
into the 3 grids, but then we have a problem with hierarchy. I.e. if we
specify center alignment, where in the central grid will the widget go?
On Wed, 27 Apr 2022, 11:35 aMir733, ***@***.***> wrote:
> Another way to do it in my opinion is to have an "align" variable inside
> the widget, like:
>
> grid {
> align = "center"
> ...
> }
>
> and if it's not defined in the user's configuration then set it to left
> as in default. This way when you release the update people don't have to
> update their configuration file.
>
> —
> Reply to this email directly, view it on GitHub
> <#27 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ASHPFFDREUPOZJB4N2TXIVDVHEJ5JANCNFSM5UMLFP6Q>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
It works perfectly! I will open a new issue if I encounter any problems. |
I may introduce a slight breaking change for start/ center/ end layouts.
The names will need to have a leading ':', I.e. change "center" to ":
center". The intention is to allow running multiple bars in the same
process, so layouts can be named to contain both a bar id and a grid I'd,
I.e. "bar1:center". Bar id will be optional if you just want a single bar,
so for a single bar you'll just need to add a leading ':'.
I think it's better to make the naming change now, before grid id feature
makes it into a release.
I'll let you know when I push this change into git.
…On Sat, 30 Apr 2022, 18:14 aMir733, ***@***.***> wrote:
It works perfectly! I will open a new issue if I encounter any problems.
Thanks for all your hard work!
—
Reply to this email directly, view it on GitHub
<#27 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASHPFFBXYGKB27KPB7ISHJDVHVS77ANCNFSM5UMLFP6Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
The new names should now work in current git.
…On Wed, 27 Apr 2022, 08:16 Lev Babiev, ***@***.***> wrote:
This is actually not a simple question. Gtk allocates space evenly
between widgets configured with expand set to true, so adding a tray on
one side will skew the center (since the two labels get expanded to equal
size).
The only certain way to achieve this that is to implement left, center and
right grids and pack widgets into these.
It should be easy to implement, but I need to think of how to do this
right in terms of configuration.
I'm currently thinking of allowing multiple layout sections, I.e.:
Layout("left") {...}
Layout("center") {...}
Layout("right") {...}
If the default Layout is "left", we should get the current behaviour.
On Tue, 26 Apr 2022, 17:06 aMir733, ***@***.***> wrote:
> In a way that it shows up at the center of the screen?
> I have this layout: taskbar - label (for spacing) - grid (I want this
> centered) - label (spacing again) - tray. But it's not exactly centered.
>
> —
> Reply to this email directly, view it on GitHub
> <#27>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ASHPFFGWEZURRQPDGYVSN4TVHAH7ZANCNFSM5UMLFP6Q>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>
|
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In a way that it shows up at the center of the screen?
I have this layout: taskbar - label (for spacing) - grid (I want this centered) - label (spacing again) - tray. But it's not exactly centered.
The text was updated successfully, but these errors were encountered: