Kaydet (Commit) 2dd5ba7e authored tarafından Khaled Hosny's avatar Khaled Hosny Kaydeden (comit) Andras Timar

Fix GTK3 right-to-left rendering

* Reverse the direction of arrows e.g. in menus
* Reverse the position of combobox button

They are lumped together because fixing one breaks the other

Change-Id: I65afb08785e67db72a72ad39f1de56db037b640a
Reviewed-on: https://gerrit.libreoffice.org/17788Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/17845Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst db6a9f71
...@@ -77,6 +77,11 @@ static void NWConvertVCLStateToGTKState( ControlState nVCLState, ...@@ -77,6 +77,11 @@ static void NWConvertVCLStateToGTKState( ControlState nVCLState,
if ( nVCLState & ControlState::FOCUSED ) if ( nVCLState & ControlState::FOCUSED )
*nGTKState = (GtkStateFlags) (*nGTKState | GTK_STATE_FLAG_FOCUSED); *nGTKState = (GtkStateFlags) (*nGTKState | GTK_STATE_FLAG_FOCUSED);
if (AllSettings::GetLayoutRTL())
{
*nGTKState = (GtkStateFlags) (*nGTKState | GTK_STATE_FLAG_DIR_RTL);
}
} }
enum { enum {
...@@ -661,9 +666,11 @@ Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlType nType, ...@@ -661,9 +666,11 @@ Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlType nType,
nButtonWidth = nArrowWidth + padding.left + padding.right; nButtonWidth = nArrowWidth + padding.left + padding.right;
if( nPart == PART_BUTTON_DOWN ) if( nPart == PART_BUTTON_DOWN )
{ {
Point aPos = Point(aAreaRect.Left() + aAreaRect.GetWidth() - nButtonWidth, aAreaRect.Top());
if (AllSettings::GetLayoutRTL())
aPos.X() = aAreaRect.Left();
aButtonRect.SetSize( Size( nButtonWidth, aAreaRect.GetHeight() ) ); aButtonRect.SetSize( Size( nButtonWidth, aAreaRect.GetHeight() ) );
aButtonRect.SetPos( Point( aAreaRect.Left() + aAreaRect.GetWidth() - nButtonWidth, aButtonRect.SetPos(aPos);
aAreaRect.Top() ) );
} }
else if( nPart == PART_SUB_EDIT ) else if( nPart == PART_SUB_EDIT )
{ {
...@@ -675,7 +682,10 @@ Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlType nType, ...@@ -675,7 +682,10 @@ Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlType nType,
aButtonRect.SetSize( Size( aAreaRect.GetWidth() - nButtonWidth - (adjust_left + adjust_right), aButtonRect.SetSize( Size( aAreaRect.GetWidth() - nButtonWidth - (adjust_left + adjust_right),
aAreaRect.GetHeight() - (adjust_top + adjust_bottom)) ); aAreaRect.GetHeight() - (adjust_top + adjust_bottom)) );
Point aEditPos = aAreaRect.TopLeft(); Point aEditPos = aAreaRect.TopLeft();
aEditPos.X() += adjust_left; if (AllSettings::GetLayoutRTL())
aEditPos.X() += nButtonWidth;
else
aEditPos.X() += adjust_left;
aEditPos.Y() += adjust_top; aEditPos.Y() += adjust_top;
aButtonRect.SetPos( aEditPos ); aButtonRect.SetPos( aEditPos );
} }
...@@ -703,6 +713,8 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, ...@@ -703,6 +713,8 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr,
Rectangle aEditBoxRect( areaRect ); Rectangle aEditBoxRect( areaRect );
aEditBoxRect.SetSize( Size( areaRect.GetWidth() - buttonRect.GetWidth(), aEditBoxRect.GetHeight() ) ); aEditBoxRect.SetSize( Size( areaRect.GetWidth() - buttonRect.GetWidth(), aEditBoxRect.GetHeight() ) );
if (AllSettings::GetLayoutRTL())
aEditBoxRect.SetPos( Point( areaRect.Left() + buttonRect.GetWidth(), areaRect.Top() ) );
arrowRect.SetSize( Size( (gint)(ARROW_SIZE), arrowRect.SetSize( Size( (gint)(ARROW_SIZE),
(gint)(ARROW_SIZE) ) ); (gint)(ARROW_SIZE) ) );
...@@ -719,7 +731,10 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, ...@@ -719,7 +731,10 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr,
{ {
gtk_style_context_save(mpEntryStyle); gtk_style_context_save(mpEntryStyle);
gtk_style_context_set_state(mpEntryStyle, flags); gtk_style_context_set_state(mpEntryStyle, flags);
gtk_style_context_set_junction_sides(mpEntryStyle, GTK_JUNCTION_RIGHT); if (AllSettings::GetLayoutRTL())
gtk_style_context_set_junction_sides(mpEntryStyle, GTK_JUNCTION_LEFT);
else
gtk_style_context_set_junction_sides(mpEntryStyle, GTK_JUNCTION_RIGHT);
gtk_render_background(mpComboboxStyle, cr, gtk_render_background(mpComboboxStyle, cr,
0, 0, 0, 0,
...@@ -727,12 +742,13 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, ...@@ -727,12 +742,13 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr,
gtk_render_frame(mpComboboxStyle, cr, gtk_render_frame(mpComboboxStyle, cr,
0, 0, 0, 0,
areaRect.GetWidth(), areaRect.GetHeight()); areaRect.GetWidth(), areaRect.GetHeight());
gtk_render_background(mpEntryStyle, cr, gtk_render_background(mpEntryStyle, cr,
0, 0, (aEditBoxRect.Left() - areaRect.Left()),
(aEditBoxRect.Top() - areaRect.Top()),
aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() ); aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
gtk_render_frame(mpEntryStyle, cr, gtk_render_frame(mpEntryStyle, cr,
0, 0, (aEditBoxRect.Left() - areaRect.Left()),
(aEditBoxRect.Top() - areaRect.Top()),
aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() ); aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
gtk_style_context_restore(mpEntryStyle); gtk_style_context_restore(mpEntryStyle);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment