mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-18 07:34:54 +00:00
slider: Reverse handle direction in RTL
Rework slider handle to reverse directions when the slider is
Right-to-Left.
Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5107
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2943>
(cherry picked from commit 405b549a05)
This commit is contained in:
parent
d430f4dc65
commit
9be6db83a3
1 changed files with 12 additions and 4 deletions
|
|
@ -36,6 +36,7 @@ var Slider = GObject.registerClass({
|
|||
let cr = this.get_context();
|
||||
let themeNode = this.get_theme_node();
|
||||
let [width, height] = this.get_surface_size();
|
||||
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
|
||||
|
||||
let handleRadius = themeNode.get_length('-slider-handle-radius');
|
||||
|
||||
|
|
@ -44,10 +45,13 @@ var Slider = GObject.registerClass({
|
|||
themeNode.lookup_color('-slider-handle-border-color', false);
|
||||
|
||||
const ceiledHandleRadius = Math.ceil(handleRadius + handleBorderWidth);
|
||||
const handleX = ceiledHandleRadius +
|
||||
(width - 2 * ceiledHandleRadius) * this._value / this._maxValue;
|
||||
const handleY = height / 2;
|
||||
|
||||
let handleX = ceiledHandleRadius +
|
||||
(width - 2 * ceiledHandleRadius) * this._value / this._maxValue;
|
||||
if (rtl)
|
||||
handleX = width - handleX;
|
||||
|
||||
let color = themeNode.get_foreground_color();
|
||||
Clutter.cairo_set_source_color(cr, color);
|
||||
cr.arc(handleX, handleY, handleRadius, 0, 2 * Math.PI);
|
||||
|
|
@ -189,9 +193,13 @@ var Slider = GObject.registerClass({
|
|||
_moveHandle(absX, _absY) {
|
||||
let relX, sliderX;
|
||||
[sliderX] = this.get_transformed_position();
|
||||
relX = absX - sliderX;
|
||||
|
||||
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
|
||||
let width = this._barLevelWidth;
|
||||
|
||||
relX = absX - sliderX;
|
||||
if (rtl)
|
||||
relX = width - relX;
|
||||
|
||||
let handleRadius = this.get_theme_node().get_length('-slider-handle-radius');
|
||||
|
||||
let newvalue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue