elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.1k stars 376 forks source link

[BUG] Sliding animations don't work with revealer #196

Open ahmedkhalf opened 3 years ago

ahmedkhalf commented 3 years ago

Describe the bug

All slide animations just don't work with the reveler widget, however, the fade animation works.

Reproducing the issue

  1. Use this config
<eww>
    <windows>
        <window name="bar_window" stacking="fg" focusable="false">
            <geometry anchor="top left" x="0px" y="0px" width="100%" height="48px"/>
            <reserve side="left" distance="50px"/>
            <widget>
                <revealer transition="slideright" duration="1s" reveal="{{show}}">
                    <box hexpand="false">
                        <label text="lolololololol"/>
                    </box>
                </revealer>
            </widget>
        </window>
    </windows>
</eww>
  1. eww daemon
  2. eww open bar_window
  3. eww update show=true As you can see the label shows instantly and without animation
  4. eww update show=false As you can see the label hides abruptly after 1 second and without animation

Expected behaviour

I expect the sliding animations to work.

snakedye commented 3 years ago

The dimension of the widget in the direction you want the animation need to be null.

ahmedkhalf commented 3 years ago

I don't understand, can you let me know what modifocations to the xml will I need to do for it to work? @snakedye

snakedye commented 3 years ago

Make the width or height of the window 0

ahmedkhalf commented 3 years ago

It works when showing but not when hiding...

https://user-images.githubusercontent.com/36672196/123415487-66362f00-d5c6-11eb-84a8-83e2126f6b0b.mp4

code:

<eww>
    <windows>
        <window name="bar_window" stacking="fg" focusable="false">
            <geometry anchor="top left" x="0px" y="0px" width="100%" height="0"/>
            <reserve side="top" distance="40px"/>
            <widget>
                <revealer transition="slidedown" duration="1s" reveal="{{show}}">
                    <box class="main_box_bar_window" orientation="h">
                        jeff
                    </box>
                </revealer>
            </widget>
        </window>
    </windows>
</eww>
snakedye commented 3 years ago

Try this https://github.com/snakedye/eww/tree/revealer-patch

Animeshz commented 2 years ago

Is this already fixed somewhere? I guess so, it does work in my case since when I started using eww (probably the last month).

https://user-images.githubusercontent.com/26714676/132976860-044e527c-d83c-4388-9be5-388531c36a78.mp4

elkowar commented 2 years ago

Well the main issue here seems to be that the window size doesn't get reset to 0 when hiding the contents. This means that it works within a window, but it breaks if you try to hide/show the entire window using revealer

Animeshz commented 2 years ago

Wait window can be embedded into widgets? 👀

elkowar commented 2 years ago

no, but you can make the revealer be at the root of your window. In that case, the revealer being hidden pretty much means that the window is hidden

Animeshz commented 2 years ago

Tried testing in different scenarios, there seem to be two condition for the animation to happen:

  1. Ancestor at least must be a window containing widget like expander or eventbox.
  2. Parent widget's orientation must be parallel to the animation (EventBox behave like horizontal | Expander behave like vertical | Box can have configurable orientation etc.)

A sample widget that works with slideup/slidedown using expander:

(defvar winrev false)

(defwindow topbar
  :monitor 0 :stacking "fg" :wm-ignore false :windowtype "dock"
  :reserve (struts :side "top" :distance "30px")
  :geometry (geometry :x "0" :y "0" :width "100%" :height "30px" :anchor "top center")
  (expander :expanded true
;    (box                ; still works
      (revealer :transition "slidedown" :reveal winrev :duration "1s"
        "Hello World!")))

with eww update winrev=true

EDIT: A very much related upstream issue https://gitlab.gnome.org/GNOME/gtk/-/issues/1020. Seems like this undocumented behavior is somewhat just an upstream issue to me.

viandoxdev commented 2 years ago

is there any other conditions ? i can't get a slideleft / slideright animation to work, i have this right now:

(defvar rev false)

(defwindow sidebar
  :monitor 0
  :geometry (geometry :x "0%"
              :y "0%"
              :width "25%"
              :height "100%"
              :anchor "top left")
  :stacking "fg"
  :wm-ignore "true"
  :windowtype "normal"
  (eventbox
    (revealer :transition "slideright"
      :reveal rev
      :duration "1s"
      "things")))

which should follow the conditions, but just doesn't work. Setting the width of the window to 0 gives the same behaviour as a @ahmedkhalf above, animation on enter, but not on leave (window width doesn't go back to zero as well, but content goes away).

Also, @Animeshz did you have to do anything notable to make your horizontal sliding animations work ? because yours does and i couldn't find any real difference.

druskus20 commented 2 years ago

@viandoxdev You might want to check a couple of my examples here https://github.com/druskus20/eugh, I've been messing around with revealer for a bit today. I dont see anything particularly wrong with your code at first glance though. You are trying to do stuff a bit weird, because from what I can tell, you expect the whole window to hide? (or am I completely wrong here)

Animeshz commented 2 years ago

Yeah exactly, I guess title should be more clear, window hide/show does not work as expected using the revealer.

druskus20 commented 2 years ago

Im not sure you can hide/reveal the entire window because of gtk reserves space. Though you might be able to have a window with a transparent background and then an animation for a children box.

Animeshz commented 2 years ago

Then probably this issue isn't an issue? 👀

druskus20 commented 2 years ago

Probably not an eww issue, but rather just gtk intended or unintended behaviour

misterupkeep commented 2 years ago

As this SO answer would suggest, all operations that could have possibly caused a dynamic content resize need to issue a resize request to the smallest window possible, from where GTK will constrain check it into its smallest.

This would mean resizing on each expander and revealer state change (those are the only two places I think this happens). Performance-wise, this window size recalc would happen inside GTK (if GTK did it for you) anyways, so it's practically unavoidable.

On a side-note, this link might be useful to let clicks and (probably) other events pass through to other windows below.

Kibouo commented 2 years ago

Encountered this issue during my setup. Both for hiding the window (this issue) and dynamic sizing (#254). A work-around for hiding the window is hideIt.sh. However, a proper fix would be great as it allows for more dynamic widgets overall.