[libhandy/wip/haecker-felix/flap-widget] Generalize transition allocations
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/wip/haecker-felix/flap-widget] Generalize transition allocations
- Date: Thu, 19 Nov 2020 10:41:36 +0000 (UTC)
commit 60e50598fd48268f40d93890144536a4bd6d9b9d
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Nov 19 02:22:34 2020 +0500
Generalize transition allocations
src/hdy-flap.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index 038761bd..1f579306 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2020 Felix Häcker <haeckerfelix gnome org>
+ * Copyright (C) 2020 Purism SPC
*
* SPDX-License-Identifier: LGPL-2.1+
*/
@@ -33,6 +34,8 @@
*/
#define HDY_SWIPE_BORDER 16
+#define FLAP_MOTION_FACTOR 1.0
+#define CONTENT_MOTION_FACTOR 0.0
struct _HdyFlap
{
@@ -469,6 +472,8 @@ compute_allocation (HdyFlap *self,
GtkAllocation *flap_alloc,
GtkAllocation *content_alloc)
{
+ gint content_offset, flap_offset;
+
if (!self->flap && !self->content)
return;
@@ -489,18 +494,26 @@ compute_allocation (HdyFlap *self,
return;
if (self->orientation == GTK_ORIENTATION_HORIZONTAL) {
+ content_offset = (gint) round (MIN (self->fold_progress, self->reveal_progress) * CONTENT_MOTION_FACTOR
* flap_alloc->width);
+ flap_offset = (gint) round ((self->reveal_progress - 1) * FLAP_MOTION_FACTOR * flap_alloc->width);
+
if (self->flap_position == get_start_or_end (self)) {
- content_alloc->x = alloc->width - content_alloc->width;
- flap_alloc->x = (self->reveal_progress - 1) * flap_alloc->width;
+ content_alloc->x = alloc->width - content_alloc->width + content_offset;
+ flap_alloc->x = flap_offset;
} else {
- flap_alloc->x = alloc->width - self->reveal_progress * flap_alloc->width;
+ content_alloc->x = -content_offset;
+ flap_alloc->x = alloc->width - flap_alloc->width - flap_offset;
}
} else {
+ content_offset = (gint) round (MIN (self->fold_progress, self->reveal_progress) * CONTENT_MOTION_FACTOR
* flap_alloc->height);
+ flap_offset = (gint) round ((self->reveal_progress - 1) * FLAP_MOTION_FACTOR * flap_alloc->height);
+
if (self->flap_position == GTK_PACK_START) {
- content_alloc->y = alloc->height - content_alloc->height;
- flap_alloc->y = (self->reveal_progress - 1) * flap_alloc->height;
+ content_alloc->y = alloc->height - content_alloc->height + content_offset;
+ flap_alloc->y = flap_offset;
} else {
- flap_alloc->y = alloc->height - self->reveal_progress * flap_alloc->height;
+ content_alloc->y = -content_offset;
+ flap_alloc->y = alloc->height - flap_alloc->height - flap_offset;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]