Vadoola / Tomotroid

Simple Pomodoro Timer made with Rust + Slint. Design shamelessly ripped from Pomotroid
MIT License
35 stars 7 forks source link

Add in a filter map on the Config Settings model to hide settings. #75

Closed Vadoola closed 3 months ago

Vadoola commented 6 months ago

This is needed to hide the "Deactivate Always On Top on Breaks" when "Always on Top" is false. In order to match what Pomotroid does.

I also was initially thinking about disabling the settings for features that don't work on Wayland such as the Always on Top and Global Hot Keys (and even have some started some work that hasn't been committed going down this route), but now I'm wondering if I should just use the filter map as well to hide them? However if I hide them I can't use my other idea, which is maybe a tooltip on the disabled components stating they are not yet supported on Wayland.

Vadoola commented 4 months ago

Ideally the settings ConfigBar would slide in and out when the setting is available or not, similar to how it does in Pomotroid. This would require some sort of Enter / Leave Animation support, which is not currently supported in Slint. My attempts so far to do it using some other method such as the init function have not been successful.

Relevant Issues and Discussions:

Vadoola commented 3 months ago

I've been playing around with ideas on how I could get the config items to slide in and out similar to how it does on Pomotroid. The report for these test can be found here.

So far I have the slide out working great by putting the filter_model.reset() behind a timer longer than the animation, but I can't get the slide in to work. They always just show up without any form of animation.

Vadoola commented 3 months ago

Ok So I managed to get a slide in working as well. It's pretty hacky, and a bit more cumbersome than the slide out. It might work fine for Tomotroid as it's use is limited, but I imagine it would be difficult to scale. The update with the slide in can be found in the repo linked above.

Vadoola commented 3 months ago

So in commit 5a12351 I added in the logic for the filter model, but the animation isn't working, and it has now occurred to me why. With the way I created my test program it was required to call filt_model.reset() for it to update properly. Per the docs for reset() "Manually reapply the filter. You need to run this e.g. if the filtering function depends on mutable state and it has changed.".

I'm not certain of the inner workings here, but the code added in commit 5a12351 didn't require me to call filter_model.reset(), it would update as soon as I changed the model. I added the the model update to the timer callback, but if the model hasn't updated of course the animation won't start. Since the change to the model is getting applied right away I can't rely on the timer delay to reset the filter and do the animation.

I'm wondering if I need to add an "animateOut" property to the model or something. Update the model to animate out, then on the timer callback update the model with the correct value to hide the config bar?

Vadoola commented 3 months ago

This was closed with commit 5d492d4, the filter is working, the slide in/out animation is working.