Page MenuHomePhabricator

efl_ui_item: add API that restricts a item from beeing unselected
Needs ReviewPublic

Authored by bu5hm4n on Oct 8 2019, 7:40 AM.

Details

Summary

There are usecases where items should not be unselectable by the user.
For example in the tab_bar. With this commit, a tab bar user cannot
unselect a item by hand anymore.

Depends on D10305

Diff Detail

Repository
rEFL core/efl
Branch
1
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 14222
bu5hm4n created this revision.Oct 8 2019, 7:40 AM
bu5hm4n requested review of this revision.Oct 8 2019, 7:40 AM

I had not noticed that tab_bars could be left with no page selected. But I thought we would be fixing this at the Single_Selectable level, by having a mechanism to force one element to be always selected. Maybe a new Efl.Ui.Select_Mode?

zmike requested changes to this revision.Oct 8 2019, 8:03 AM

I agree, this needs discussion.

This revision now requires changes to proceed.Oct 8 2019, 8:03 AM

This is not solvable alone at the single_selection layer, as we would need something in the theme to ignore the clickable event of this beeing unpressed. We cannot just quickly change the selection state of the item again, as this would at least render one frame wrong.

We can add something ontop of single_selection that uses this property...

bu5hm4n updated this revision to Diff 26427.Mon, Oct 28, 12:28 AM
bu5hm4n edited the summary of this revision. (Show Details)

add API in a higher level.

segfaultxavi added inline comments.Mon, Oct 28, 3:23 AM
src/lib/elementary/efl_ui_tab_bar.c
133

So by default tabs can be deselected by the user?
I am confused, I thought the whole point of this new flag was to prevent this.

Yeah, there is now a inverted meaning, since we swapped the naming of the name...

bu5hm4n updated this revision to Diff 26439.Mon, Oct 28, 8:46 AM

flip boolean flag

So now, when you add items to a tab bar, you have to manually set allow_manual_deselection to false for every tab? Can't this be automated?

segfaultxavi accepted this revision.Tue, Nov 5, 8:51 AM

Builds, passes tests and fixes the issue as advertised. Code looks good to me.

src/lib/elementary/efl_ui_single_selectable.eo
34
Controls whether items can be deselected by the user by clicking over the currently selected item. Keep in mind that this leads to containers with no item selected, which is not always desirable (for example, for tabs).
36

$true if clicking on a selected item results in the item being deselected.

so is this some alternative way after removing select_always?
as I see the usage looks quite similar..

I made the same mistake, but, no, they are different things :)

select_always allows you to select again and again the same object (even if it is already selected), so the application would receive the selected events multiple times.
This patch is about not allowing empty selections. Related, but not the same thing.

BTW, we already had this confusion in T8057#140379, in point number 5.