clutter: Remove deprecated ClutterTableLayout

https://gitlab.gnome.org/GNOME/mutter/merge_requests/921
This commit is contained in:
Adam Jackson 2019-11-06 12:26:04 -05:00 committed by Georges Basile Stavracas Neto
parent 289e24f1f7
commit 7adaaab2d6
11 changed files with 15 additions and 2538 deletions

View File

@ -48,7 +48,7 @@
* Constraints provide a way to build user interfaces by using
* relations between #ClutterActors, without explicit fixed
* positioning and sizing, similarly to how fluid layout managers like
* #ClutterBoxLayout and #ClutterTableLayout lay out their children.
* #ClutterBoxLayout lay out their children.
*
* Constraints are attached to a #ClutterActor, and are available
* for inspection using clutter_actor_get_constraints().

View File

@ -12,7 +12,6 @@
#include "deprecated/clutter-rectangle.h"
#include "deprecated/clutter-stage.h"
#include "deprecated/clutter-state.h"
#include "deprecated/clutter-table-layout.h"
#include "deprecated/clutter-timeline.h"
#undef __CLUTTER_DEPRECATED_H_INSIDE__

View File

@ -1183,29 +1183,6 @@ typedef enum /*< prefix=CLUTTER_PAN >*/
CLUTTER_PAN_AXIS_AUTO
} ClutterPanAxis;
/**
* ClutterTableAlignment:
* @CLUTTER_TABLE_ALIGNMENT_START: Align the child to the top or to the
* left of a cell in the table, depending on the axis
* @CLUTTER_TABLE_ALIGNMENT_CENTER: Align the child to the center of
* a cell in the table
* @CLUTTER_TABLE_ALIGNMENT_END: Align the child to the bottom or to the
* right of a cell in the table, depending on the axis
*
* The alignment policies available on each axis of the #ClutterTableLayout
*
* Since: 1.4
*
* Deprecated: 1.22: Use the alignment properties of #ClutterActor
*/
typedef enum
{
CLUTTER_TABLE_ALIGNMENT_START,
CLUTTER_TABLE_ALIGNMENT_CENTER,
CLUTTER_TABLE_ALIGNMENT_END
} ClutterTableAlignment;
/**
* ClutterTextureFlags:
* @CLUTTER_TEXTURE_NONE: No flags

View File

@ -44,12 +44,12 @@
* SECTION:clutter-grid-layout
* @Short_description: A layout manager for a grid of actors
* @Title: ClutterGridLayout
* @See_also: #ClutterTableLayout, #ClutterBoxLayout
* @See_also: #ClutterBoxLayout
*
* #ClutterGridLayout is a layout manager which arranges its child widgets in
* rows and columns. It is a very similar to #ClutterTableLayout and
* #ClutterBoxLayout, but it consistently uses #ClutterActor's
* alignment and expansion flags instead of custom child properties.
* rows and columns. It is a very similar to #ClutterBoxLayout, but it
* consistently uses #ClutterActor's alignment and expansion flags instead of
* custom child properties.
*
* Children are added using clutter_grid_layout_attach(). They can span
* multiple rows or columns. It is also possible to add a child next to an

View File

@ -98,7 +98,7 @@
* |[
* {
* "type" : "ClutterBox",
* "layout-manager" : { "type" : "ClutterTableLayout" },
* "layout-manager" : { "type" : "ClutterGridLayout" },
* "children" : [
* {
* "type" : "ClutterText",

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author:
* Jose Dapena Paz <jdapena@igalia.com>
*
* Based on the MX MxTable actor by:
* Thomas Wood <thomas.wood@intel.com>
*/
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#ifndef __CLUTTER_TABLE_LAYOUT_H__
#define __CLUTTER_TABLE_LAYOUT_H__
#include <clutter/clutter-layout-manager.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_TABLE_LAYOUT (clutter_table_layout_get_type ())
#define CLUTTER_TABLE_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_TABLE_LAYOUT, ClutterTableLayout))
#define CLUTTER_IS_TABLE_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_TABLE_LAYOUT))
#define CLUTTER_TABLE_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_TABLE_LAYOUT, ClutterTableLayoutClass))
#define CLUTTER_IS_TABLE_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_TABLE_LAYOUT))
#define CLUTTER_TABLE_LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_TABLE_LAYOUT, ClutterTableLayoutClass))
typedef struct _ClutterTableLayout ClutterTableLayout;
typedef struct _ClutterTableLayoutPrivate ClutterTableLayoutPrivate;
typedef struct _ClutterTableLayoutClass ClutterTableLayoutClass;
/**
* ClutterTableLayout:
*
* The #ClutterTableLayout structure contains only private data
* and should be accessed using the provided API
*
* Since: 1.4
*
* Deprecated: 1.18: Use #ClutterGridLayout instead
*/
struct _ClutterTableLayout
{
/*< private >*/
ClutterLayoutManager parent_instance;
ClutterTableLayoutPrivate *priv;
};
/**
* ClutterTableLayoutClass:
*
* The #ClutterTableLayoutClass structure contains only private
* data and should be accessed using the provided API
*
* Since: 1.4
*
* Deprecated: 1.18: Use #ClutterGridLayout instead
*/
struct _ClutterTableLayoutClass
{
/*< private >*/
ClutterLayoutManagerClass parent_class;
};
CLUTTER_DEPRECATED_FOR (clutter_grid_layout_get_type)
GType clutter_table_layout_get_type (void) G_GNUC_CONST;
CLUTTER_DEPRECATED_FOR (clutter_grid_layout_new)
ClutterLayoutManager *clutter_table_layout_new (void);
CLUTTER_DEPRECATED_FOR (clutter_grid_layout_attach)
void clutter_table_layout_pack (ClutterTableLayout *layout,
ClutterActor *actor,
gint column,
gint row);
CLUTTER_DEPRECATED_FOR (clutter_grid_layout_set_column_spacing)
void clutter_table_layout_set_column_spacing (ClutterTableLayout *layout,
guint spacing);
CLUTTER_DEPRECATED_FOR (clutter_grid_layout_set_row_spacing)
void clutter_table_layout_set_row_spacing (ClutterTableLayout *layout,
guint spacing);
CLUTTER_DEPRECATED
void clutter_table_layout_set_span (ClutterTableLayout *layout,
ClutterActor *actor,
gint column_span,
gint row_span);
CLUTTER_DEPRECATED
gint clutter_table_layout_get_row_count (ClutterTableLayout *layout);
CLUTTER_DEPRECATED
gint clutter_table_layout_get_column_count (ClutterTableLayout *layout);
CLUTTER_DEPRECATED
void clutter_table_layout_set_use_animations (ClutterTableLayout *layout,
gboolean animate);
CLUTTER_DEPRECATED
void clutter_table_layout_set_easing_mode (ClutterTableLayout *layout,
gulong mode);
CLUTTER_DEPRECATED
void clutter_table_layout_set_easing_duration (ClutterTableLayout *layout,
guint msecs);
G_END_DECLS
#endif /* __CLUTTER_TABLE_LAYOUT_H__ */

View File

@ -226,7 +226,6 @@ clutter_deprecated_headers = [
'deprecated/clutter-rectangle.h',
'deprecated/clutter-stage.h',
'deprecated/clutter-state.h',
'deprecated/clutter-table-layout.h',
'deprecated/clutter-timeline.h',
]
@ -237,7 +236,6 @@ clutter_deprecated_sources = [
'deprecated/clutter-group.c',
'deprecated/clutter-rectangle.c',
'deprecated/clutter-state.c',
'deprecated/clutter-table-layout.c',
]
clutter_backend_sources = []

View File

@ -41,7 +41,6 @@ clutter_tests_interactive_test_sources = [
'test-scrolling.c',
'test-swipe-action.c',
'test-cogl-point-sprites.c',
'test-table-layout.c',
'test-path-constraint.c',
'test-state-script.c',
'test-devices.c',

View File

@ -1,290 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <gmodule.h>
#include <clutter/clutter.h>
#include <cogl/cogl.h>
#include <cogl-pango/cogl-pango.h>
#include "test-utils.h"
#define FONT "Sans 12"
int
test_table_layout_main (int argc, char *argv[]);
const char *
test_table_layout_describe (void);
static void
set_text (ClutterActor *actor, const gchar *text)
{
GList *children, *l;
children = clutter_container_get_children (CLUTTER_CONTAINER (actor));
for (l = children; l; l = g_list_next (l)) {
if (CLUTTER_IS_TEXT (l->data)) {
clutter_text_set_text (CLUTTER_TEXT (l->data), text);
break;
}
}
g_list_free (children);
}
static void
toggle_expand (ClutterActor *actor, ClutterEvent *event, ClutterBox *box)
{
gboolean x_expand;
gchar *label;
ClutterLayoutManager *layout = clutter_box_get_layout_manager (box);
clutter_layout_manager_child_get (layout, CLUTTER_CONTAINER (box), actor,
"x-expand", &x_expand,
NULL);
x_expand = !x_expand;
clutter_layout_manager_child_set (layout, CLUTTER_CONTAINER (box), actor,
"x-expand", x_expand,
"y-expand", x_expand,
NULL);
label = g_strdup_printf ("Expand = %d", x_expand);
set_text (actor, label);
g_free (label);
}
static const gchar *
get_alignment_name (ClutterTableAlignment alignment)
{
switch (alignment)
{
case CLUTTER_TABLE_ALIGNMENT_START:
return "start";
case CLUTTER_TABLE_ALIGNMENT_CENTER:
return "center";
case CLUTTER_TABLE_ALIGNMENT_END:
return "end";
}
return "undefined";
}
static void
randomise_align (ClutterActor *actor, ClutterEvent *event, ClutterBox *box)
{
ClutterTableAlignment x_align, y_align;
gchar *label;
ClutterLayoutManager *layout;
layout = clutter_box_get_layout_manager (box);
x_align = (ClutterTableAlignment) g_random_int_range (0, 3);
y_align = (ClutterTableAlignment) g_random_int_range (0, 3);
clutter_layout_manager_child_set (layout, CLUTTER_CONTAINER (box), actor,
"x-align", x_align,
"y-align", y_align,
NULL);
label = g_strdup_printf ("Align (%s, %s)",
get_alignment_name (x_align),
get_alignment_name (y_align));
set_text (actor, label);
g_free (label);
}
static void
toggle_visible (ClutterActor *actor, ClutterEvent *event, gpointer userdata)
{
clutter_actor_hide (actor);
}
gboolean drag = FALSE;
static ClutterActor *
create_cell (ClutterActor *actor, const gchar *color_str)
{
ClutterActor *result;
ClutterActor *rectangle;
ClutterColor color;
result =
clutter_box_new (clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL,
CLUTTER_BIN_ALIGNMENT_FILL));
rectangle = clutter_rectangle_new ();
clutter_color_from_string (&color, color_str);
clutter_rectangle_set_color (CLUTTER_RECTANGLE (rectangle), (const ClutterColor *) &color);
clutter_color_from_string (&color, "#000f");
clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (rectangle), (const ClutterColor *) &color);
clutter_rectangle_set_border_width (CLUTTER_RECTANGLE (rectangle), 2);
clutter_actor_show (rectangle);
clutter_actor_set_reactive (result, TRUE);
clutter_container_add_actor (CLUTTER_CONTAINER (result), rectangle);
clutter_box_pack (CLUTTER_BOX (result), actor,
"x-align", CLUTTER_BIN_ALIGNMENT_CENTER,
"y-align", CLUTTER_BIN_ALIGNMENT_CENTER,
NULL);
return result;
}
static ClutterActor *
create_text (const gchar *label, const gchar *color)
{
ClutterActor *text;
ClutterActor *result;
text = clutter_text_new_with_text (FONT, label);
clutter_actor_show (text);
result = create_cell (text, color);
clutter_actor_show (result);
return result;
}
static ClutterActor *
create_image (const gchar *file, const gchar *color)
{
ClutterActor *texture;
ClutterActor *result;
texture = clutter_test_utils_create_texture_from_file (file, NULL);
g_object_set (G_OBJECT (texture), "keep-aspect-ratio", TRUE, NULL);
clutter_actor_show (texture);
result = create_cell (texture, color);
clutter_actor_show (result);
return result;
}
G_MODULE_EXPORT int
test_table_layout_main (int argc, char *argv[])
{
ClutterActor *stage;
ClutterLayoutManager *layout;
ClutterActor *actor1, *actor2, *actor3, *actor4, *actor5, *actor6, *actor7, *actor8, *actor9, *actor10;
ClutterActor *box;
gchar *file;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Table Layout");
clutter_actor_set_size (stage, 640, 480);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
layout = clutter_table_layout_new ();
clutter_table_layout_set_column_spacing (CLUTTER_TABLE_LAYOUT (layout), 10);
clutter_table_layout_set_row_spacing (CLUTTER_TABLE_LAYOUT (layout), 10);
clutter_table_layout_set_use_animations (CLUTTER_TABLE_LAYOUT (layout), TRUE);
box = clutter_box_new (layout);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_WIDTH, -10.0));
clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_HEIGHT, -10.0));
actor1 = create_text ("label 1", "#f66f");
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
actor2 = create_image (file, "#bbcf");
g_free (file);
actor3 = create_text ("label 3", "#6f6f");
actor4 = create_text ("Expand = 1", "#66ff");
actor5 = create_text ("label 5", "#f6ff");
actor6 = create_text ("label 6", "#6fff");
actor7 = create_text ("Align (center, center)", "#66ff");
actor8 = create_text ("label 8", "#ffff");
actor9 = create_text ("label 9", "#666f");
actor10 = create_text ("label 10", "#aaaf");
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor1, 0, 0);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor2, 1, 0);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor3, 1, 1);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor4, 0, 2);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor5, 0, 3);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor6, 1, 3);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor7, 1, 4);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor8, 0, 4);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor9, 0, 5);
clutter_table_layout_pack (CLUTTER_TABLE_LAYOUT (layout), actor10, 0, -1);
clutter_table_layout_set_span (CLUTTER_TABLE_LAYOUT (layout), actor1, 1, 2);
clutter_table_layout_set_span (CLUTTER_TABLE_LAYOUT (layout), actor7, 1, 2);
clutter_table_layout_set_span (CLUTTER_TABLE_LAYOUT (layout), actor4, 2, 1);
clutter_actor_set_size (actor1, 100, 100);
clutter_actor_set_width (actor4, 250);
clutter_layout_manager_child_set (CLUTTER_LAYOUT_MANAGER (layout),
CLUTTER_CONTAINER (box),
actor1,
"x-expand", FALSE, "y-expand", FALSE,
NULL);
clutter_layout_manager_child_set (CLUTTER_LAYOUT_MANAGER (layout),
CLUTTER_CONTAINER (box),
actor4,
"x-expand", TRUE, "y-expand", TRUE,
"x-fill", TRUE, "y-fill", TRUE,
NULL);
clutter_layout_manager_child_set (CLUTTER_LAYOUT_MANAGER (layout),
CLUTTER_CONTAINER (box),
actor7,
"x-expand", TRUE, "y-expand", TRUE,
"x-fill", FALSE, "y-fill", FALSE,
NULL);
clutter_layout_manager_child_set (CLUTTER_LAYOUT_MANAGER (layout),
CLUTTER_CONTAINER (box),
actor8,
"x-expand", FALSE, "y-expand", FALSE,
NULL);
clutter_layout_manager_child_set (CLUTTER_LAYOUT_MANAGER (layout),
CLUTTER_CONTAINER (box),
actor9,
"x-expand", FALSE, "y-expand", FALSE,
NULL);
clutter_layout_manager_child_set (CLUTTER_LAYOUT_MANAGER (layout),
CLUTTER_CONTAINER (box),
actor2,
"y-fill", FALSE,
"x-fill", FALSE,
NULL);
clutter_actor_set_position (box, 5, 5);
g_signal_connect (actor4, "button-release-event", G_CALLBACK (toggle_expand), box);
g_signal_connect (actor7, "button-release-event", G_CALLBACK (randomise_align), box);
g_signal_connect (actor10, "button-release-event", G_CALLBACK (toggle_visible), NULL);
/* g_signal_connect (stage, "button-press-event", G_CALLBACK (button_press), */
/* box); */
/* g_signal_connect (stage, "motion-event", G_CALLBACK (motion_event), */
/* box); */
/* g_signal_connect (stage, "button-release-event", G_CALLBACK (button_release), */
/* box); */
clutter_actor_show (stage);
g_debug ("table row count = %d",
clutter_table_layout_get_row_count (CLUTTER_TABLE_LAYOUT (layout)));
g_debug ("table column count = %d",
clutter_table_layout_get_column_count (CLUTTER_TABLE_LAYOUT (layout)));
clutter_main ();
return EXIT_SUCCESS;
}
G_MODULE_EXPORT const char *
test_table_layout_describe (void)
{
return "TableLayout layout manager example.";
}

View File

@ -254,7 +254,7 @@ test_text_field_main (gint argc,
{
ClutterActor *stage;
ClutterActor *box, *label, *entry;
ClutterLayoutManager *table;
ClutterLayoutManager *grid;
PangoAttrList *entry_attrs;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
@ -265,12 +265,12 @@ test_text_field_main (gint argc,
clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
table = clutter_table_layout_new ();
clutter_table_layout_set_column_spacing (CLUTTER_TABLE_LAYOUT (table), 6);
clutter_table_layout_set_row_spacing (CLUTTER_TABLE_LAYOUT (table), 6);
grid = clutter_grid_layout_new ();
clutter_grid_layout_set_column_spacing (CLUTTER_GRID_LAYOUT (grid), 6);
clutter_grid_layout_set_row_spacing (CLUTTER_GRID_LAYOUT (grid), 6);
box = clutter_actor_new ();
clutter_actor_set_layout_manager (box, table);
clutter_actor_set_layout_manager (box, grid);
clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_WIDTH, -24.0));
clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_HEIGHT, -24.0));
clutter_actor_set_position (box, 12, 12);
@ -279,7 +279,7 @@ test_text_field_main (gint argc,
label = create_label (CLUTTER_COLOR_White, "<b>Input field:</b>");
g_object_set (label, "min-width", 150.0, NULL);
clutter_actor_add_child (box, label);
clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), label,
clutter_layout_manager_child_set (grid, CLUTTER_CONTAINER (box), label,
"row", 0,
"column", 0,
"x-expand", FALSE,
@ -291,7 +291,7 @@ test_text_field_main (gint argc,
pango_attr_list_insert (entry_attrs, pango_attr_underline_color_new (65535, 0, 0));
entry = create_entry (CLUTTER_COLOR_Black, "somme misspeeled textt", entry_attrs, 0, 0);
clutter_actor_add_child (box, entry);
clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), entry,
clutter_layout_manager_child_set (grid, CLUTTER_CONTAINER (box), entry,
"row", 0,
"column", 1,
"x-expand", TRUE,
@ -302,7 +302,7 @@ test_text_field_main (gint argc,
label = create_label (CLUTTER_COLOR_White, "<b>A very long password field:</b>");
clutter_actor_add_child (box, label);
clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), label,
clutter_layout_manager_child_set (grid, CLUTTER_CONTAINER (box), label,
"row", 1,
"column", 0,
"x-expand", FALSE,
@ -311,7 +311,7 @@ test_text_field_main (gint argc,
entry = create_entry (CLUTTER_COLOR_Black, "password", NULL, '*', 8);
clutter_actor_add_child (box, entry);
clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), entry,
clutter_layout_manager_child_set (grid, CLUTTER_CONTAINER (box), entry,
"row", 1,
"column", 1,
"x-expand", TRUE,