Page MenuHomePhabricator

eoapi: Clean up orientation vs. ui direction
Closed, ResolvedPublic

Description

Efl.Orient (enum) and Efl.Orientation (interface) are used in both UI and image types of elements, with mixed results:
Orientation takes the values 0,90,180,270 and its default value is "UP". This doesn't make sense for UI elements, which are by default oriented either down- or right-wards.
I propose to introduce a new enum Efl.Ui.Dir and the associated interface:

enum Efl.Ui.Dir
{
   [[Direction for UI objects and layouts.

     Not to be confused with $Efl.Orient which is for images and canvases. This
     enum is used to define how widgets should expand and orient themselves,
     not to rotate images.

     See also @Efl.Ui.Direction.
   ]]
   default = 0,[[Default direction. Each widget may have a different default.]]
   horizontal, [[Horizontal direction, along the X axis. Usually left-to-right,
                 but may be inverted to right-to-left if mirroring is on.]]
   vertical,   [[Vertical direction, along the Y axis. Usually downwards.]]
   ltr,        [[Horizontal, left-to-right direction.]]
   rtl,        [[Horizontal, right-to-left direction.]]
   down,       [[Vertical, top-to-bottom direction.]]
   up,         [[Vertical, bottom-to-top direction.]]
   right = Efl.Ui.Dir.ltr, [[Right is an alias for LTR.]]
   left = Efl.Ui.Dir.rtl, [[Left is an alias for RTL.]]
}

Vertical/up/down are not a problem I think.
My only worry is basically how to handle RTL. I believe that:

  • LTR always means LTR (== right)
  • RTL always means RTL (== left)
  • HORIZONTAL means LTR in ltr locales and RTL in rtl locales, depending on how the mirroring is set. If mirroring is true then it'll mean rtl. By default it means ltr.
  • DEFAULT follows whatever the widget decides, which means HORIZONTAL in many cases (eg. progressbar, slider, ...).

I'm just not 100% sure about mirroring.

jpeg reassigned this task from jpeg to singh.amitesh.Aug 9 2017, 11:03 PM

Amitesh, it's your job now to finish the last conversion: Efl.Ui.Panes :)
After that we still need to do two things:

  1. Remove HORIZONTAL/VERTICAL from the orientation
  2. Verify that all widgets respect HORIZONTAL and LTR/RTL properly with mirrored mode, i.e. LTR/RTL are fixed but HORIZONTAL can switch from LTR to RTL.

The naming here is rather confusing - is dir really obvious? - https://en.m.wikipedia.org/wiki/Dir

How about flow instead?

I am also confused that right is an alias of left to right - that means that the default text alignment for efl.ui.dir.right orientation is left and vice-versa - potentially confusing.

jpeg added a comment.Aug 10 2017, 3:46 PM

The naming here is rather confusing - is dir really obvious? - https://en.m.wikipedia.org/wiki/Dir

I agree.

How about flow instead?

Direction is not confusing, though? I just need an enum name that matches Efl.Ui.Direction. Flow doesn't match here. Flow makes sense in other contexts (box flow).
Maybe we just need something like Direction_Type? (and same, Orientation_Type instead of Orient?)

I am also confused that right is an alias of left to right - that means that the default text alignment for efl.ui.dir.right orientation is left and vice-versa - potentially confusing.

This is not really meant for text but for layouts. Though this is a good point as well.

jpeg added a comment.EditedAug 10 2017, 8:33 PM
In T5870#94409, @jpeg wrote:

I am also confused that right is an alias of left to right - that means that the default text alignment for efl.ui.dir.right orientation is left and vice-versa - potentially confusing.

This is not really meant for text but for layouts. Though this is a good point as well.

To expand on this, I think text needs (according to @herdsman comment to me):

  • LTR
  • RTL
  • AnyRTL
  • INHERIT (parent's value)
  • LOCALE (optional)

There is no Up/Down/Vertical

jpeg added a comment.Aug 30 2017, 7:56 PM

Dir is used mostly for Direction things in EFL, a little bit for Directory but the separation of concepts is very clear in the namespaces. Honestly I can't find a much better name than Efl.Ui.Dir for this purpose.
As for left/right and all of that I discussed with some people here and I think we can use the odd but precise words of Leftward, Rightward, Upward, Downward. Any objection as a native speaker? Not sure about 's' or no 's' (like LeftwardS).

Diffusion added a commit: Restricted Diffusion Commit.Aug 20 2018, 1:00 PM
Diffusion added a commit: Restricted Diffusion Commit.Aug 20 2018, 1:00 PM