Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-welcome
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-welcome
Commits
de28ab3a
Commit
de28ab3a
authored
Oct 05, 2020
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'update_position' into 'master'
Refactor `update_position` See merge request GNOME/gnome-tour!26
parents
c1ae5c1a
0eafe2c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
paginator.rs
src/widgets/paginator.rs
+14
-8
No files found.
src/widgets/paginator.rs
View file @
de28ab3a
...
...
@@ -64,17 +64,23 @@ impl PaginatorWidget {
}
fn
update_position
(
&
self
)
{
let
n_pages
=
self
.carousel
.get_n_pages
()
as
f64
;
let
position
=
self
.carousel
.get_position
();
let
page_nr
=
position
.round
()
as
u32
;
let
opacity_close
=
(
position
-
n_pages
+
2
_f64
)
.max
(
0
_f64
);
let
opacity_previous
=
if
position
<=
1
_f64
{
position
}
else
{
1
_f64
};
let
opacity_next
=
if
position
<=
1
_f64
&&
position
<=
n_pages
{
position
%
n_pages
}
else
{
1
_f64
};
let
n_pages
=
self
.carousel
.get_n_pages
()
as
f64
;
let
forelast_page
=
n_pages
-
2.0
;
let
last_page
=
n_pages
-
1.0
;
let
(
opacity_close
,
opacity_previous
,
opacity_next
)
=
if
(
0.0
<=
position
)
&&
(
position
<
1.0
)
{
(
0.0
,
position
,
position
)
}
else
if
(
1.0
<=
position
)
&&
(
position
<=
forelast_page
)
{
(
0.0
,
1.0
,
1.0
)
}
else
if
(
forelast_page
<
position
)
&&
(
position
<=
last_page
)
{
(
position
-
forelast_page
,
1.0
,
1.0
)
}
else
{
panic!
(
"Position of the carousel is outside the allowed range"
);
};
self
.close_btn
.set_opacity
(
opacity_close
);
self
.close_btn
.set_visible
(
opacity_close
>
0
_f64
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment