[gnome-games] aisleriot: Make card step a style property
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games] aisleriot: Make card step a style property
- Date: Mon, 4 Jan 2010 12:59:45 +0000 (UTC)
commit 23f9d3dc3e1f48d75204ec75f1c948090a934694
Author: Christian Persch <chpe gnome org>
Date: Mon Jan 4 13:53:50 2010 +0100
aisleriot: Make card step a style property
Make the in-stack card displacement offset a style property.
aisleriot/ar-style-private.h | 2 +
aisleriot/ar-style.c | 68 ++++++++++++++++++++++++++++++++---------
aisleriot/ar-style.h | 2 +
aisleriot/board.c | 14 ++++++--
4 files changed, 67 insertions(+), 19 deletions(-)
---
diff --git a/aisleriot/ar-style-private.h b/aisleriot/ar-style-private.h
index 7f27db4..c38fb59 100644
--- a/aisleriot/ar-style-private.h
+++ b/aisleriot/ar-style-private.h
@@ -32,6 +32,7 @@ static const GdkColor default_selection_color = { 0, 0 /* red */, 0 /* green */,
#endif /* !DEFAULT_CARD_SLOT_RATIO */
#define DEFAULT_CARD_OVERHANG (0.0)
+#define DEFAULT_CARD_STEP (0.2)
struct _ArStylePrivate
{
@@ -41,6 +42,7 @@ struct _ArStylePrivate
double card_slot_ratio;
double card_overhang;
+ double card_step;
int dnd_drag_threshold;
int double_click_time;
diff --git a/aisleriot/ar-style.c b/aisleriot/ar-style.c
index cfaa11b..e885205 100644
--- a/aisleriot/ar-style.c
+++ b/aisleriot/ar-style.c
@@ -23,7 +23,9 @@
enum
{
PROP_0,
+ PROP_CARD_OVERHANG,
PROP_CARD_SLOT_RATIO,
+ PROP_CARD_STEP,
PROP_CARD_THEME,
PROP_CLICK_TO_MOVE,
PROP_DND_DRAG_THRESHOLD,
@@ -33,7 +35,6 @@ enum
PROP_FOCUS_LINE_WIDTH,
PROP_FOCUS_PADDING,
PROP_INTERIOR_FOCUS,
- PROP_CARD_OVERHANG,
PROP_RTL,
PROP_SELECTION_COLOR,
PROP_TOUCHSCREEN_MODE,
@@ -55,6 +56,7 @@ ar_style_init (ArStyle *style)
_ar_clutter_color_from_gdk_color (&priv->selection_color, &default_selection_color);
priv->card_slot_ratio = DEFAULT_CARD_SLOT_RATIO;
priv->card_overhang = DEFAULT_CARD_OVERHANG;
+ priv->card_step = DEFAULT_CARD_STEP;
priv->dnd_drag_threshold = 8;
priv->double_click_time = 250;
priv->focus_line_width = 1;
@@ -100,6 +102,10 @@ ar_style_get_property (GObject *object,
g_value_set_double (value, ar_style_get_card_slot_ratio (style));
break;
+ case PROP_CARD_STEP:
+ g_value_set_double (value, ar_style_get_card_step (style));
+ break;
+
case PROP_CARD_THEME:
g_value_set_object (value, ar_style_get_card_theme (style));
break;
@@ -171,6 +177,10 @@ ar_style_set_property (GObject *object,
priv->card_slot_ratio = g_value_get_double (value);
break;
+ case PROP_CARD_STEP:
+ priv->card_step = g_value_get_double (value);
+ break;
+
case PROP_CARD_THEME:
ar_style_set_card_theme (style, g_value_get_object (value));
break;
@@ -251,6 +261,34 @@ ar_style_class_init (ArStyleClass *klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
+ /**
+ * ArStyle:card-overhang:
+ *
+ * This controls how much of a card is allowed to hang off of the bottom
+ * of the screen. If set to %0.0, the last card is always fully visible.
+ */
+ g_object_class_install_property
+ (object_class,
+ PROP_CARD_OVERHANG,
+ g_param_spec_double (AR_STYLE_PROP_CARD_OVERHANG, NULL, NULL,
+ 0.0, 1.0, DEFAULT_CARD_OVERHANG,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * ArStyle:card-step:
+ *
+ * This controls how much one card is offset the previous one in card stacks.
+ */
+ g_object_class_install_property
+ (object_class,
+ PROP_CARD_STEP,
+ g_param_spec_double (AR_STYLE_PROP_CARD_STEP, NULL, NULL,
+ /* FIXMEchpe: allow values > 1.0 here? */
+ 0.0, 1.0, DEFAULT_CARD_STEP,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property
(object_class,
PROP_CARD_THEME,
@@ -323,20 +361,6 @@ ar_style_class_init (ArStyleClass *klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
- /**
- * ArStyle:card-overhang:
- *
- * This controls how much of a card is allowed to hang off of the bottom
- * of the screen. If set to %0.0, the last card is always fully visible.
- */
- g_object_class_install_property
- (object_class,
- PROP_CARD_OVERHANG,
- g_param_spec_double (AR_STYLE_PROP_CARD_OVERHANG, NULL, NULL,
- 0.0, 1.0, DEFAULT_CARD_OVERHANG,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
g_object_class_install_property
(object_class,
PROP_RTL,
@@ -648,6 +672,20 @@ ar_style_get_card_overhang (ArStyle *style)
}
/**
+ * ar_style_get_card_step:
+ * @style: an #ArStyle
+ *
+ * Returns:
+ */
+double
+ar_style_get_card_step (ArStyle *style)
+{
+ ArStylePrivate *priv = style->priv;
+
+ return priv->card_step;
+}
+
+/**
* ar_style_get_selection_color:
* @style: an #ArStyle
* @color: location to store the color
diff --git a/aisleriot/ar-style.h b/aisleriot/ar-style.h
index db52c48..17d38cb 100644
--- a/aisleriot/ar-style.h
+++ b/aisleriot/ar-style.h
@@ -57,6 +57,7 @@ ArStyle* ar_style_new (void);
#define AR_STYLE_PROP_CARD_SLOT_RATIO "card-slot-prop"
#define AR_STYLE_PROP_CARD_THEME "card-theme"
#define AR_STYLE_PROP_CARD_OVERHANG "card-overhang"
+#define AR_STYLE_PROP_CARD_STEP "card-step"
#define AR_STYLE_PROP_CLICK_TO_MOVE "click-to-move"
#define AR_STYLE_PROP_DND_DRAG_THRESHOLD "dnd-drag-threshold"
#define AR_STYLE_PROP_DOUBLE_CLICK_TIME "double-click-time"
@@ -96,6 +97,7 @@ int ar_style_get_focus_padding (ArStyle *style);
double ar_style_get_card_slot_ratio (ArStyle *style);
double ar_style_get_card_overhang (ArStyle *style);
+double ar_style_get_card_step (ArStyle *style);
void ar_style_get_selection_color (ArStyle *style,
ClutterColor * const color);
diff --git a/aisleriot/board.c b/aisleriot/board.c
index 190db3e..263df2a 100644
--- a/aisleriot/board.c
+++ b/aisleriot/board.c
@@ -54,7 +54,6 @@
* how much is allowed to slip off the bottom or right.
*/
#define MIN_DELTA (0.05)
-#define MAX_DELTA (0.2)
/* The minimum size for the playing area. Almost completely arbitrary. */
#define BOARD_MIN_WIDTH 300
@@ -582,6 +581,7 @@ slot_update_geometry (AisleriotBoard *board,
GdkRectangle old_rect;
GByteArray *cards;
int delta, xofs, yofs, pixeldx;
+ double card_step;
if (!priv->geometry_set)
return;
@@ -589,6 +589,8 @@ slot_update_geometry (AisleriotBoard *board,
cards = slot->cards;
old_rect = slot->rect;
+ card_step = ar_style_get_card_step (priv->style);
+
xofs = priv->xoffset;
yofs = priv->yoffset;
@@ -616,7 +618,7 @@ slot_update_geometry (AisleriotBoard *board,
double n_cards = cards->len - 1; /* FIXMEchpe: slot->exposed - 1 ? */
if (slot->expanded_down) {
- double y_from_bottom, max_dy = MAX_DELTA;
+ double y_from_bottom, max_dy = card_step;
float allocation_height = priv->allocation.y2 - priv->allocation.y1;
if (slot->dy_set)
@@ -632,7 +634,7 @@ slot_update_geometry (AisleriotBoard *board,
dy = CLAMP (dy, MIN_DELTA, max_dy);
} else if (slot->expanded_right) {
if (priv->is_rtl) {
- double x_from_left, max_dx = MAX_DELTA;
+ double x_from_left, max_dx = card_step;
if (slot->dx_set)
max_dx = slot->expansion.dx;
@@ -644,7 +646,7 @@ slot_update_geometry (AisleriotBoard *board,
slot->pixeldx = DOUBLE_TO_INT_CEIL (- dx * priv->card_size.width);
pixeldx = -slot->pixeldx;
} else {
- double x_from_right, max_dx = MAX_DELTA;
+ double x_from_right, max_dx = card_step;
float allocation_width = priv->allocation.x2 - priv->allocation.x1;
if (slot->dx_set)
@@ -2163,6 +2165,10 @@ aisleriot_board_sync_style (ArStyle *style,
update_geometry |= TRUE;
}
+ if (pspec_name == NULL || pspec_name == I_(AR_STYLE_PROP_CARD_STEP)) {
+ update_geometry |= TRUE;
+ }
+
if (pspec_name == NULL || pspec_name == I_(AR_STYLE_PROP_INTERIOR_FOCUS)) {
gboolean interior_focus;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]