[gtk+/wip/baedert/children] label: Remove angle property
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/children] label: Remove angle property
- Date: Thu, 1 Dec 2016 10:02:20 +0000 (UTC)
commit eb53c179cdb9a3da25019c8341d5c1dd379a3646
Author: Timm Bäder <mail baedert org>
Date: Thu Dec 1 09:21:46 2016 +0100
label: Remove angle property
docs/reference/gtk/gtk4-sections.txt | 2 -
gtk/gtklabel.c | 290 ++--------------------------------
gtk/gtklabel.h | 5 -
gtk/gtktoolbutton.c | 5 -
gtk/gtktoolitemgroup.c | 7 -
5 files changed, 11 insertions(+), 298 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index b1de118..3a66888 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -1656,12 +1656,10 @@ gtk_label_get_selection_bounds
gtk_label_get_use_markup
gtk_label_get_use_underline
gtk_label_get_single_line_mode
-gtk_label_get_angle
gtk_label_set_label
gtk_label_set_use_markup
gtk_label_set_use_underline
gtk_label_set_single_line_mode
-gtk_label_set_angle
gtk_label_get_current_uri
gtk_label_set_track_visited_links
gtk_label_get_track_visited_links
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 42dac23..3ef4629 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -261,7 +261,6 @@ struct _GtkLabelPrivate
gchar *label;
gchar *text;
- gdouble angle;
gfloat xalign;
gfloat yalign;
@@ -272,7 +271,6 @@ struct _GtkLabelPrivate
guint use_markup : 1;
guint ellipsize : 3;
guint single_line_mode : 1;
- guint have_transform : 1;
guint in_click : 1;
guint wrap_mode : 3;
guint pattern_set : 1;
@@ -375,7 +373,6 @@ enum {
PROP_ELLIPSIZE,
PROP_WIDTH_CHARS,
PROP_SINGLE_LINE_MODE,
- PROP_ANGLE,
PROP_MAX_WIDTH_CHARS,
PROP_TRACK_VISITED_LINKS,
PROP_LINES,
@@ -386,11 +383,6 @@ enum {
static GParamSpec *label_props[NUM_PROPERTIES] = { NULL, };
-/* When rotating ellipsizable text we want the natural size to request
- * more to ensure the label wont ever ellipsize in an allocation of full natural size.
- * */
-#define ROTATION_ELLIPSIZE_PADDING 2
-
static guint signals[LAST_SIGNAL] = { 0 };
static GQuark quark_shortcuts_connected;
@@ -982,24 +974,6 @@ gtk_label_class_init (GtkLabelClass *class)
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
- * GtkLabel:angle:
- *
- * The angle that the baseline of the label makes with the horizontal,
- * in degrees, measured counterclockwise. An angle of 90 reads from
- * from bottom to top, an angle of 270, from top to bottom. Ignored
- * if the label is selectable.
- *
- * Since: 2.6
- **/
- label_props[PROP_ANGLE] =
- g_param_spec_double ("angle",
- P_("Angle"),
- P_("Angle at which the label is rotated"),
- 0.0, 360.0,
- 0.0,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
-
- /**
* GtkLabel:max-width-chars:
*
* The desired maximum width of the label, in characters. If this property
@@ -1230,9 +1204,6 @@ gtk_label_set_property (GObject *object,
case PROP_SINGLE_LINE_MODE:
gtk_label_set_single_line_mode (label, g_value_get_boolean (value));
break;
- case PROP_ANGLE:
- gtk_label_set_angle (label, g_value_get_double (value));
- break;
case PROP_MAX_WIDTH_CHARS:
gtk_label_set_max_width_chars (label, g_value_get_int (value));
break;
@@ -1310,9 +1281,6 @@ gtk_label_get_property (GObject *object,
case PROP_SINGLE_LINE_MODE:
g_value_set_boolean (value, gtk_label_get_single_line_mode (label));
break;
- case PROP_ANGLE:
- g_value_set_double (value, gtk_label_get_angle (label));
- break;
case PROP_MAX_WIDTH_CHARS:
g_value_set_int (value, gtk_label_get_max_width_chars (label));
break;
@@ -3357,83 +3325,19 @@ static void
gtk_label_update_layout_width (GtkLabel *label)
{
GtkLabelPrivate *priv = label->priv;
- GtkWidget *widget = GTK_WIDGET (label);
g_assert (priv->layout);
if (priv->ellipsize || priv->wrap)
{
GtkAllocation allocation;
- PangoRectangle logical;
- gint width, height;
+ gint width;
gtk_css_gadget_get_content_allocation (priv->gadget, &allocation, NULL);
width = allocation.width;
- height = allocation.height;
-
- if (priv->have_transform)
- {
- PangoContext *context = gtk_widget_get_pango_context (widget);
- const PangoMatrix *matrix = pango_context_get_matrix (context);
- const gdouble dx = matrix->xx; /* cos (M_PI * angle / 180) */
- const gdouble dy = matrix->xy; /* sin (M_PI * angle / 180) */
-
- pango_layout_set_width (priv->layout, -1);
- pango_layout_get_pixel_extents (priv->layout, NULL, &logical);
-
- if (fabs (dy) < 0.01)
- {
- if (logical.width > width)
- pango_layout_set_width (priv->layout, width * PANGO_SCALE);
- }
- else if (fabs (dx) < 0.01)
- {
- if (logical.width > height)
- pango_layout_set_width (priv->layout, height * PANGO_SCALE);
- }
- else
- {
- gdouble x0, y0, x1, y1, length;
- gboolean vertical;
- gint cy;
-
- x0 = width / 2;
- y0 = dx ? x0 * dy / dx : G_MAXDOUBLE;
- vertical = fabs (y0) > height / 2;
-
- if (vertical)
- {
- y0 = height/2;
- x0 = dy ? y0 * dx / dy : G_MAXDOUBLE;
- }
-
- length = 2 * sqrt (x0 * x0 + y0 * y0);
- pango_layout_set_width (priv->layout, rint (length * PANGO_SCALE));
- pango_layout_get_pixel_size (priv->layout, NULL, &cy);
-
- x1 = +dy * cy/2;
- y1 = -dx * cy/2;
- if (vertical)
- {
- y0 = height/2 + y1 - y0;
- x0 = -y0 * dx/dy;
- }
- else
- {
- x0 = width/2 + x1 - x0;
- y0 = -x0 * dy/dx;
- }
-
- length = length - sqrt (x0 * x0 + y0 * y0) * 2;
- pango_layout_set_width (priv->layout, rint (length * PANGO_SCALE));
- }
- }
- else
- {
- pango_layout_set_width (priv->layout, width * PANGO_SCALE);
- }
+ pango_layout_set_width (priv->layout, width * PANGO_SCALE);
}
else
{
@@ -3517,29 +3421,6 @@ gtk_label_ensure_layout (GtkLabel *label)
if (!priv->layout)
{
PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */
- gdouble angle = gtk_label_get_angle (label);
-
- if (angle != 0.0 && !priv->select_info)
- {
- PangoMatrix matrix = PANGO_MATRIX_INIT;
-
- /* We rotate the standard singleton PangoContext for the widget,
- * depending on the fact that it's meant pretty much exclusively
- * for our use.
- */
- pango_matrix_rotate (&matrix, angle);
-
- pango_context_set_matrix (gtk_widget_get_pango_context (widget), &matrix);
-
- priv->have_transform = TRUE;
- }
- else
- {
- if (priv->have_transform)
- pango_context_set_matrix (gtk_widget_get_pango_context (widget), NULL);
-
- priv->have_transform = FALSE;
- }
priv->layout = gtk_widget_create_pango_layout (widget, priv->text);
@@ -3579,14 +3460,9 @@ static GtkSizeRequestMode
gtk_label_get_request_mode (GtkWidget *widget)
{
GtkLabel *label = GTK_LABEL (widget);
- gdouble angle;
-
- angle = gtk_label_get_angle (label);
if (label->priv->wrap)
- return (angle == 90 || angle == 270)
- ? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
- : GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
+ return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
}
@@ -3721,42 +3597,11 @@ gtk_label_get_preferred_size (GtkWidget *widget,
gint *natural_baseline)
{
GtkLabel *label = GTK_LABEL (widget);
- GtkLabelPrivate *priv = label->priv;
PangoRectangle widest_rect;
PangoRectangle smallest_rect;
gtk_label_get_preferred_layout_size (label, &smallest_rect, &widest_rect);
- /* Now that we have minimum and natural sizes in pango extents, apply a possible transform */
- if (priv->have_transform)
- {
- PangoContext *context;
- const PangoMatrix *matrix;
-
- context = pango_layout_get_context (priv->layout);
- matrix = pango_context_get_matrix (context);
-
- pango_matrix_transform_rectangle (matrix, &widest_rect);
- pango_matrix_transform_rectangle (matrix, &smallest_rect);
-
- /* Bump the size in case of ellipsize to ensure pango has
- * enough space in the angles (note, we could alternatively set the
- * layout to not ellipsize when we know we have been allocated our
- * full size, or it may be that pango needs a fix here).
- */
- if (priv->ellipsize && priv->angle != 0 && priv->angle != 90 &&
- priv->angle != 180 && priv->angle != 270 && priv->angle != 360)
- {
- /* For some reason we only need this at about 110 degrees, and only
- * when gaining in height
- */
- widest_rect.height += ROTATION_ELLIPSIZE_PADDING * 2 * PANGO_SCALE;
- widest_rect.width += ROTATION_ELLIPSIZE_PADDING * 2 * PANGO_SCALE;
- smallest_rect.height += ROTATION_ELLIPSIZE_PADDING * 2 * PANGO_SCALE;
- smallest_rect.width += ROTATION_ELLIPSIZE_PADDING * 2 * PANGO_SCALE;
- }
- }
-
widest_rect.width = PANGO_PIXELS_CEIL (widest_rect.width);
widest_rect.height = PANGO_PIXELS_CEIL (widest_rect.height);
@@ -3765,27 +3610,9 @@ gtk_label_get_preferred_size (GtkWidget *widget,
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- /* Note, we cant use get_size_for_allocation() when rotating
- * ellipsized labels.
- */
- if (!(priv->ellipsize && priv->have_transform) &&
- (priv->angle == 90 || priv->angle == 270))
- {
- /* Doing a h4w request on a rotated label here, return the
- * required width for the minimum height.
- */
- get_size_for_allocation (label,
- smallest_rect.height,
- minimum_size, natural_size,
- NULL, NULL);
-
- }
- else
- {
- /* Normal desired width */
- *minimum_size = smallest_rect.width;
- *natural_size = widest_rect.width;
- }
+ /* Normal desired width */
+ *minimum_size = smallest_rect.width;
+ *natural_size = widest_rect.width;
if (minimum_baseline)
*minimum_baseline = -1;
@@ -3795,36 +3622,8 @@ gtk_label_get_preferred_size (GtkWidget *widget,
}
else /* GTK_ORIENTATION_VERTICAL */
{
- /* Note, we cant use get_size_for_allocation() when rotating
- * ellipsized labels.
- */
- if (!(priv->ellipsize && priv->have_transform) &&
- (priv->angle == 0 || priv->angle == 180 || priv->angle == 360))
- {
- /* Doing a w4h request on a label here, return the required
- * height for the minimum width.
- */
- get_size_for_allocation (label,
- widest_rect.width,
- minimum_size, natural_size,
- minimum_baseline, natural_baseline);
-
- if (priv->angle == 180)
- {
- if (minimum_baseline)
- *minimum_baseline = *minimum_size - *minimum_baseline;
- if (natural_baseline)
- *natural_baseline = *natural_size - *natural_baseline;
- }
- }
- else
- {
- /* A vertically rotated label does w4h, so return the base
- * desired height (text length)
- */
- *minimum_size = MIN (smallest_rect.height, widest_rect.height);
- *natural_size = MAX (smallest_rect.height, widest_rect.height);
- }
+ *minimum_size = MIN (smallest_rect.height, widest_rect.height);
+ *natural_size = MAX (smallest_rect.height, widest_rect.height);
}
}
@@ -3846,8 +3645,8 @@ gtk_label_measure (GtkCssGadget *gadget,
label = GTK_LABEL (widget);
priv = label->priv;
- if ((orientation == GTK_ORIENTATION_VERTICAL && for_size != -1 && priv->wrap && (priv->angle == 0 ||
priv->angle == 180 || priv->angle == 360)) ||
- (orientation == GTK_ORIENTATION_HORIZONTAL && priv->wrap && (priv->angle == 90 || priv->angle == 270)))
+ if ((orientation == GTK_ORIENTATION_VERTICAL && for_size != -1 && priv->wrap) ||
+ (orientation == GTK_ORIENTATION_HORIZONTAL && priv->wrap))
{
if (priv->wrap)
gtk_label_clear_layout (label);
@@ -3899,13 +3698,6 @@ get_layout_location (GtkLabel *label,
pango_layout_get_extents (priv->layout, NULL, &logical);
- if (priv->have_transform)
- {
- PangoContext *context = gtk_widget_get_pango_context (widget);
- const PangoMatrix *matrix = pango_context_get_matrix (context);
- pango_matrix_transform_rectangle (matrix, &logical);
- }
-
pango_extents_to_pixels (&logical, NULL);
req_width = logical.width;
@@ -3918,7 +3710,7 @@ get_layout_location (GtkLabel *label,
x = floor (allocation.x + xalign * (allocation.width - req_width) - logical.x);
baseline_offset = 0;
- if (baseline != -1 && !priv->have_transform)
+ if (baseline != -1)
{
layout_baseline = pango_layout_get_baseline (priv->layout) / PANGO_SCALE;
baseline_offset = baseline - layout_baseline;
@@ -5461,66 +5253,6 @@ gtk_label_get_selectable (GtkLabel *label)
return priv->select_info && priv->select_info->selectable;
}
-/**
- * gtk_label_set_angle:
- * @label: a #GtkLabel
- * @angle: the angle that the baseline of the label makes with
- * the horizontal, in degrees, measured counterclockwise
- *
- * Sets the angle of rotation for the label. An angle of 90 reads from
- * from bottom to top, an angle of 270, from top to bottom. The angle
- * setting for the label is ignored if the label is selectable,
- * wrapped, or ellipsized.
- *
- * Since: 2.6
- **/
-void
-gtk_label_set_angle (GtkLabel *label,
- gdouble angle)
-{
- GtkLabelPrivate *priv;
-
- g_return_if_fail (GTK_IS_LABEL (label));
-
- priv = label->priv;
-
- /* Canonicalize to [0,360]. We don't canonicalize 360 to 0, because
- * double property ranges are inclusive, and changing 360 to 0 would
- * make a property editor behave strangely.
- */
- if (angle < 0 || angle > 360.0)
- angle = angle - 360. * floor (angle / 360.);
-
- if (priv->angle != angle)
- {
- priv->angle = angle;
-
- gtk_label_clear_layout (label);
- gtk_widget_queue_resize (GTK_WIDGET (label));
-
- g_object_notify_by_pspec (G_OBJECT (label), label_props[PROP_ANGLE]);
- }
-}
-
-/**
- * gtk_label_get_angle:
- * @label: a #GtkLabel
- *
- * Gets the angle of rotation for the label. See
- * gtk_label_set_angle().
- *
- * Returns: the angle of rotation for the label
- *
- * Since: 2.6
- **/
-gdouble
-gtk_label_get_angle (GtkLabel *label)
-{
- g_return_val_if_fail (GTK_IS_LABEL (label), 0.0);
-
- return label->priv->angle;
-}
-
static void
gtk_label_set_selection_text (GtkLabel *label,
GtkSelectionData *selection_data)
diff --git a/gtk/gtklabel.h b/gtk/gtklabel.h
index 928bc50..ea33db9 100644
--- a/gtk/gtklabel.h
+++ b/gtk/gtklabel.h
@@ -177,11 +177,6 @@ void gtk_label_set_selectable (GtkLabel *label,
GDK_AVAILABLE_IN_ALL
gboolean gtk_label_get_selectable (GtkLabel *label);
GDK_AVAILABLE_IN_ALL
-void gtk_label_set_angle (GtkLabel *label,
- gdouble angle);
-GDK_AVAILABLE_IN_ALL
-gdouble gtk_label_get_angle (GtkLabel *label);
-GDK_AVAILABLE_IN_ALL
void gtk_label_select_region (GtkLabel *label,
gint start_offset,
gint end_offset);
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c
index 594d6af..8d4f2d9 100644
--- a/gtk/gtktoolbutton.c
+++ b/gtk/gtktoolbutton.c
@@ -425,7 +425,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
{
gfloat align;
- gtk_label_set_angle (GTK_LABEL (label), 0);
align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
if (align < 0.4)
gtk_widget_set_halign (label, GTK_ALIGN_START);
@@ -439,10 +438,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gfloat align;
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_NONE);
- if (gtk_widget_get_direction (GTK_WIDGET (tool_item)) == GTK_TEXT_DIR_RTL)
- gtk_label_set_angle (GTK_LABEL (label), -90);
- else
- gtk_label_set_angle (GTK_LABEL (label), 90);
align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
if (align < 0.4)
gtk_widget_set_valign (label, GTK_ALIGN_END);
diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c
index ffdcd9a..2461aa3 100644
--- a/gtk/gtktoolitemgroup.c
+++ b/gtk/gtktoolitemgroup.c
@@ -335,10 +335,8 @@ gtk_tool_item_group_header_adjust_style (GtkToolItemGroup *group)
{
GtkWidget *frame = gtk_bin_get_child (GTK_BIN (group->priv->header));
GtkWidget *label_widget = gtk_bin_get_child (GTK_BIN (frame));
- GtkWidget *widget = GTK_WIDGET (group);
GtkToolItemGroupPrivate* priv = group->priv;
gint dx = 0, dy = 0;
- GtkTextDirection direction = gtk_widget_get_direction (widget);
switch (gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)))
{
@@ -348,10 +346,6 @@ gtk_tool_item_group_header_adjust_style (GtkToolItemGroup *group)
if (GTK_IS_LABEL (label_widget))
{
gtk_label_set_ellipsize (GTK_LABEL (label_widget), PANGO_ELLIPSIZE_NONE);
- if (GTK_TEXT_DIR_RTL == direction)
- gtk_label_set_angle (GTK_LABEL (label_widget), -90);
- else
- gtk_label_set_angle (GTK_LABEL (label_widget), 90);
}
break;
@@ -361,7 +355,6 @@ gtk_tool_item_group_header_adjust_style (GtkToolItemGroup *group)
if (GTK_IS_LABEL (label_widget))
{
gtk_label_set_ellipsize (GTK_LABEL (label_widget), priv->ellipsize);
- gtk_label_set_angle (GTK_LABEL (label_widget), 0);
}
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]