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
8915a19c
Commit
8915a19c
authored
Jan 26, 2022
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
paginator: Fix focus when switching pages
parent
e5dacb49
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
paginator.rs
src/widgets/paginator.rs
+24
-8
No files found.
src/widgets/paginator.rs
View file @
8915a19c
...
...
@@ -22,6 +22,7 @@ mod imp {
pub
(
super
)
start_btn
:
TemplateChild
<
gtk
::
Button
>
,
#[template_child]
pub
(
super
)
previous_btn
:
TemplateChild
<
gtk
::
Button
>
,
pub
(
super
)
going_backward
:
Cell
<
bool
>
,
}
impl
Default
for
PaginatorWidget
{
...
...
@@ -33,6 +34,7 @@ mod imp {
previous_btn
:
TemplateChild
::
default
(),
pages
:
RefCell
::
new
(
Vec
::
new
()),
current_page
:
Cell
::
new
(
0
),
going_backward
:
Cell
::
new
(
false
),
}
}
}
...
...
@@ -138,14 +140,8 @@ impl PaginatorWidget {
let
last_page
=
n_pages
-
1.0
;
let
(
opacity_previous
,
opacity_start
,
opacity_next
)
=
if
(
0.0
..
1.0
)
.contains
(
&
position
)
{
if
position
==
0.0
{
(
position
,
1.0
-
position
,
position
)
}
else
{
(
position
,
1.0
-
position
,
position
)
}
}
else
if
(
0.0
<=
position
)
&&
(
position
<=
forelast_page
)
{
(
1.0
,
0.0
,
1.0
)
}
else
if
forelast_page
>=
position
{
(
position
,
1.0
-
position
,
position
)
}
else
if
position
<=
forelast_page
{
(
1.0
,
0.0
,
1.0
)
}
else
if
position
>
forelast_page
{
(
1.0
,
0.0
,
last_page
-
position
)
...
...
@@ -158,6 +154,8 @@ impl PaginatorWidget {
let
can_target_start
=
opacity_next
<
f64
::
EPSILON
;
let
can_target_next
=
opacity_next
>
0
_f64
&&
position
<=
forelast_page
;
log
::
debug!
(
"page number {}/{}"
,
page_nr
,
last_page
);
imp
.start_btn
.set_opacity
(
opacity_start
);
imp
.start_btn
.set_visible
(
opacity_start
>
0
_f64
);
imp
.start_btn
.set_can_target
(
can_target_start
);
...
...
@@ -174,6 +172,24 @@ impl PaginatorWidget {
pub
fn
set_page
(
&
self
,
page_nr
:
u32
)
{
let
imp
=
self
.imp
();
let
total_pages
=
imp
.carousel
.n_pages
();
if
page_nr
==
total_pages
-
1
{
imp
.going_backward
.set
(
true
);
}
else
if
page_nr
==
0
{
imp
.going_backward
.set
(
false
);
}
if
!
imp
.going_backward
.get
()
{
if
page_nr
==
0
{
imp
.start_btn
.grab_focus
();
}
else
{
imp
.next_btn
.grab_focus
();
}
}
else
{
imp
.previous_btn
.grab_focus
();
}
if
page_nr
<
imp
.carousel
.n_pages
()
{
let
pages
=
&
imp
.pages
.borrow
();
let
page
=
pages
.get
(
page_nr
as
usize
)
.unwrap
();
...
...
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