Project

General

Profile

Actions

Improvements #14727

open
RM

Add alias to Side enum for RTL

Improvements #14727: Add alias to Side enum for RTL

Added by Romain Mardulyn 30 days ago. Updated 16 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
08/10/2026
Due date:
% Done:

0%

Estimated time:

Description

In RTL mode, Wt replaces the right by the left and vice-versa. This means that in RTL mode, the Side::Left value is actually means Side::Right . This is great because it allows to use the same code for RTL and LTR mode. This can, however, be quite confusing when developing an application primarily in RTL.

To help developing primarily in RTL, I think it would be helpful to have an alias with the RTL specific name. For instance, we would have RtlSide::Left that could be used to signify the left side when in RTL, but the right side in LTR.

AA Updated by Ali Ali 17 days ago Actions #1

Romain Mardulyn wrote:

In RTL mode, Wt replaces the right by the left and vice-versa. This means that in RTL mode, the Side::Left value is actually means Side::Right . This is great because it allows to use the same code for RTL and LTR mode. This can, however, be quite confusing when developing an application primarily in RTL.

To help developing primarily in RTL, I think it would be helpful to have equivalent enums but with the RTL specific name. For instance, we would have an RtlSide enum class, for which RtlSide::Left is used to signify the left side when in RTL, but the right side in LTR.

I agree that the current behavior can be confusing when developing primarily in RTL, but I’m not sure that introducing a separate RtlSide enum is the best solution.

I think the underlying issue is that Side::Left and Side::Right are currently being used to represent two different concepts: physical sides and logical sides.

Instead of introducing an RTL-specific enum, it may be cleaner to add logical values such as LineStart and LineEnd to the existing Side enum.

For example:

  • Side::Left / Side::Right would always refer to the physical left/right side.
  • Side::LineStart / Side::LineEnd would refer to the logical start/end of the line, and would automatically map to left/right depending on the document direction.

This would be particularly useful for applications that support both LTR and RTL languages. With a separate RtlSide enum, the developer would have to choose between two different enum types depending on the context, which could make bilingual applications more complicated and error-prone.

With logical sides, the intent is explicit and independent of the document direction. For example, if an element should always be placed at the beginning of the text direction, the code could simply use:

Side::LineStart

and the same code would work correctly in both LTR and RTL modes.

So rather than adding an RTL-specific abstraction, I think adding LineStart and LineEnd to the existing API would provide a more general solution. It would also follow the distinction between physical and logical directions that is commonly used in modern layout systems.

RM Updated by Romain Mardulyn 16 days ago · Edited Actions #2

  • Subject changed from Add different enum for RTL to Add alias to Side enum for RTL
  • Description updated (diff)

Hi Ali Ali,

I do completely agree with you, what you proposed would be ideal. The issue is that we cannot simply change the fact that Side::Left and Side::Right are swapped in RTL. This would break retro-compatibility. Therefor we are stuck with this until a Wt version 5.0.0 (for which there is no plan yet) is released.

It would be possible to add an option to control whether the swap happens or not, but that would make it harder for us to maintain than what I propose.

It was not clear in what I wrote, but the idea would be that RtlSide would automatically be translated to the correct Side equivalent. It would be an alias, not really a different enum. I changed the description of the ticket to make it clearer.

Actions

Also available in: PDF Atom