eww icon indicating copy to clipboard operation
eww copied to clipboard

Add support for "round-digits" property for scale widget

Open gavynriebau opened this issue 2 years ago • 1 comments

Description

This property enables controlling to how many digits the value of a scale gets rounded to when the value changes.

Usage

This property can be used on the scale control like the following:

(scale :min 0
           :max 101
           :marks true
           :hexpand true
           :value volume
           :draw-value true
           :round-digits "0"
           :onchange "scripts/setvol {}")

Demo

The following shows the behavior of a scale control before and after this change was introduced. In the "before" video we can see that the value of the "volume" (shown on right) would not consistently update because as the slider is dragged with the mouse the values include decimal values. When a decimal value is included the "setvol" function was not successful. In the "after" video setting the value is successful because the values are rounded to zero decimal places.

The "volume" variable was setup as follows:

(deflisten volume :initial "0"
  "scripts/pollvol")

Before https://user-images.githubusercontent.com/11895736/182007096-32a4c08c-9593-40c3-a7d4-152a590a0733.mp4

After https://user-images.githubusercontent.com/11895736/182007111-150d3461-1b75-40f7-bfd9-a152240b8412.mp4

Checklist

Please make sure you can check all the boxes that apply to this PR.

  • [X] All widgets I've added are correctly documented.
  • [x] I added my changes to CHANGELOG.md, if appropriate.
  • [ ] The documentation in the docs/content/main directory has been adjusted to reflect my changes. (property docs automatically generated??)
  • [X] I used cargo fmt to automatically format all code before committing

gavynriebau avatar Jul 31 '22 02:07 gavynriebau

I haven't (yet) updated the docs in docs/content/main because I think the gen-docs.ts script automatically does this. Please let me know if I need to manually run the script and I will do so

gavynriebau avatar Jul 31 '22 02:07 gavynriebau