[libadwaita/wip/cdavis/fold-threshold-policy: 4/6] Add AdwFoldThresholdPolicy




commit 0c2417842f61275774845440e79e37f2968544f8
Author: Christopher Davis <christopherdavis gnome org>
Date:   Wed Jun 23 15:10:28 2021 -0700

    Add AdwFoldThresholdPolicy
    
    Currently we have hardcoded behaviour for flap and leaflet,
    where leaflet uses the sum of natural widths and flap uses
    the sum of minimum widths to determine what size to fold
    at.
    
    Some applications, like Fractal, need to be able to adjust
    this behaviour. For that purpose, we need AdwFoldThresholdPolicy.

 src/adw-enums.c.in              |  1 +
 src/adw-fold-threshold-policy.c | 18 ++++++++++++++++++
 src/adw-fold-threshold-policy.h | 23 +++++++++++++++++++++++
 src/adwaita.h                   |  1 +
 src/meson.build                 |  3 +++
 5 files changed, 46 insertions(+)
---
diff --git a/src/adw-enums.c.in b/src/adw-enums.c.in
index 4025237c..238a7283 100644
--- a/src/adw-enums.c.in
+++ b/src/adw-enums.c.in
@@ -3,6 +3,7 @@
 #include "config.h"
 #include "adw-enums.h"
 #include "adw-flap.h"
+#include "adw-fold-threshold-policy.h"
 #include "adw-header-bar.h"
 #include "adw-leaflet.h"
 #include "adw-navigation-direction.h"
diff --git a/src/adw-fold-threshold-policy.c b/src/adw-fold-threshold-policy.c
new file mode 100644
index 00000000..6c50aa21
--- /dev/null
+++ b/src/adw-fold-threshold-policy.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2021 Christopher Davis <christopherdavis gnome org>
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+
+#include "config.h"
+#include "adw-fold-threshold-policy.h"
+
+/**
+ * AdwFoldThresholdPolicy:
+ * @ADW_FOLD_THRESHOLD_POLICY_MINIMUM: Folding is based on the minimum size
+ * @ADW_FOLD_THRESHOLD_POLICY_NATURAL: Folding is based on the natural size
+ *
+ * Determines when [class Adw Flap] and [class@Adw.Leaflet] will fold.
+ *
+ * Since: 1.0
+ */
diff --git a/src/adw-fold-threshold-policy.h b/src/adw-fold-threshold-policy.h
new file mode 100644
index 00000000..c6703099
--- /dev/null
+++ b/src/adw-fold-threshold-policy.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2021 Christopher Davis <christopherdavis gnome org>
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+
+#pragma once
+
+#if !defined(_ADWAITA_INSIDE) && !defined(ADWAITA_COMPILATION)
+#error "Only <adwaita.h> can be included directly."
+#endif
+
+#include <glib-object.h>
+#include "adw-enums.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+  ADW_FOLD_THRESHOLD_POLICY_MINIMUM,
+  ADW_FOLD_THRESHOLD_POLICY_NATURAL,
+} AdwFoldThresholdPolicy;
+
+G_END_DECLS
diff --git a/src/adwaita.h b/src/adwaita.h
index 642094ca..ba9bf074 100644
--- a/src/adwaita.h
+++ b/src/adwaita.h
@@ -38,6 +38,7 @@ G_BEGIN_DECLS
 #include "adw-enum-value-object.h"
 #include "adw-expander-row.h"
 #include "adw-flap.h"
+#include "adw-fold-threshold-policy.h"
 #include "adw-header-bar.h"
 #include "adw-leaflet.h"
 #include "adw-main.h"
diff --git a/src/meson.build b/src/meson.build
index 5f7f6c53..95ee4d63 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -11,6 +11,7 @@ libadwaita_resources = gnome.compile_resources(
 
 adw_public_enum_headers = [
   'adw-flap.h',
+  'adw-fold-threshold-policy.h',
   'adw-header-bar.h',
   'adw-leaflet.h',
   'adw-navigation-direction.h',
@@ -82,6 +83,7 @@ src_headers = [
   'adw-enum-value-object.h',
   'adw-expander-row.h',
   'adw-flap.h',
+  'adw-fold-threshold-policy.h',
   'adw-header-bar.h',
   'adw-leaflet.h',
   'adw-main.h',
@@ -135,6 +137,7 @@ src_sources = [
   'adw-fading-label.c',
   'adw-flap.c',
   'adw-focus.c',
+  'adw-fold-threshold-policy.c',
   'adw-gizmo.c',
   'adw-header-bar.c',
   'adw-indicator-bin.c',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]