Page MenuHomePhabricator

Efl.Ui.Slider step property is weird
Closed, ResolvedPublic

Description

The step property is very strange in elm Slider , it is clamped in the range 0.0-1.0
seems it is threated as a percentage and not like a normal values like it should be.

For example is not possible to setup a slider as:

min=0 max=100 step=5

in fact in the elm test there is a nasty function _step_size_calculate() that try to avoid the issue.

Also the step property is not taken in account when you drag the slider with the mouse, it only work with keyboard (as the doc say).

IMO this property should be fixed to behave "normally" and work also when dragging.

DaveMDS created this task.Nov 6 2016, 5:37 AM
zmike edited projects, added Restricted Project; removed efl.Jun 11 2018, 6:54 AM
q66 edited projects, added efl: widgets; removed Restricted Project.Jun 11 2018, 7:33 AM
zmike added subscribers: cedric, bu5hm4n, segfaultxavi, zmike.

Yeah it looks like step is currently expected to be 1 / step_size which seems pretty hostile to developers.

Agreed. The API for Efl.Ui.Slider allows setting any value for min and max but then restricts step to the [0, 1] range, which is weird (in src/lib/elementary/efl_ui_slider.c).
Dragging with the mouse seems to take step into account in the calculations, but it just does not work. efl_ui_drag_step_move() is used but efl_ui_drag_step_set() is never called...

I am changing the ticket name, since we cannot change the legacy API of Elm.Slider, right?

segfaultxavi renamed this task from elm.Slider step property is weird to Efl.Ui.Slider step property is weird.Jan 16 2019, 1:52 AM
zmike added a comment.Jan 16 2019, 5:28 AM

Correct; this could only be changed for the interface api.

segfaultxavi moved this task from Backlog to Evaluating on the efl: api board.Feb 5 2019, 3:34 AM

I think the API is OK, except for the docs in efl_ui_range_display.eo, which state that range_min_max can be anything, but range_value must be in the [0, 1] interval. I see no reason for this arbitrary restriction.

As @DaveMDS posted initially, there are implementation issues regarding the range_step in efl_ui_range_interactive.eo, but the API seems fine.

zmike moved this task from Evaluating to "easy" on the efl: api board.Feb 6 2019, 5:37 AM
zmike moved this task from "easy" to Backlog on the efl: api board.Feb 7 2019, 8:34 AM

@segfaultxavi

Was there any result of this discussion ?
If we make "value_set" and "step_set" to use not percentage but direct value (between min and max),
what would be expected problems ?

If there is no reason to support these values with percentage, I hope to change them.

Looks like the result is that the API is fine, but there are implementation issues.

I see no problem to stop using percentages. if you submit a patch to do it, I can take care of the docs then.

I think i accidentally fixed that in the past when i removed that error?

Yeah, you removed the check for 0 < step < 1 in the slider.

However, elm_test continues to work as before, which means that the implementation still expects step to be from 0 to 1.
This still needs to be fixed, along with mouse drags not using the step value.

The docs will need to be updated, which means that this is a change in the API.

the mouse drags never used the step variable, slider can get values that are outside the n*step and i think that is normal ?
Like scaling something, you might want to have a step of 0.1 but still want to reach 0.95.

What makes more sense to me is something like a mode, which can put this widget into something like:

  • discrete value mode: you can only select values which are n*step
  • normal mode: you can select everything, and step is used as something like a hint for user interaction.

(Right now spinner, spin, spin_button etc. are just running in normal mode)