Page MenuHomePhabricator

efl_ui_item: add API that restricts a item from beeing unselected
ClosedPublic

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
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.Oct 28 2019, 12:28 AM
bu5hm4n edited the summary of this revision. (Show Details)

add API in a higher level.

segfaultxavi added inline comments.Oct 28 2019, 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.Oct 28 2019, 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.Nov 5 2019, 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.

zmike added a comment.Mon, Dec 23, 6:49 AM

Alright, well it's been a while and we haven't come up with better ideas, so I don't want to block it anymore. I'm okay with this if nobody else has objections.

cedric accepted this revision.Wed, Jan 1, 2:20 PM

Some time there is no perfect solution and good is good enough.

cedric added a comment.Wed, Jan 1, 2:21 PM

@zmike I will let you approve it and land.

zmike accepted this revision.Thu, Jan 2, 6:06 AM
This revision is now accepted and ready to land.Thu, Jan 2, 6:06 AM
Closed by commit rEFL92c01d9e6301: efl_ui_item: add API that restricts a item from beeing unselected (authored by Marcel Hollerbach <mail@marcel-hollerbach.de>, committed by zmike). · Explain WhyThu, Jan 2, 6:12 AM
This revision was automatically updated to reflect the committed changes.