Skip to content

Commit 58231df

Browse files
committed
improve reveal handling for props
needs to change value immediately, not at the end of animate
1 parent 4d74a47 commit 58231df

File tree

5 files changed

+32
-30
lines changed

5 files changed

+32
-30
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,13 @@ then check the build status here:
237237

238238
## TODO
239239

240-
- save and restore properties setting and properties position
241-
242-
seems a bit buggy right now
243-
244240
- prop position should be distance from right edge, not left edge
245241

242+
and improve the default position ... should be the width of the
243+
properties widget
244+
245+
- on props hide, force kb focus to iamgedisplay
246+
246247
- use eg. alt-left, alt-right to flip between images in "vipsdisp a.jpg b.jpg"
247248
or maybe shift-<, shift->?
248249

src/animatedpane.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ struct _Animatedpane
2121

2222
GtkWidget *paned;
2323

24+
// the state we expose via properties
2425
gboolean revealed;
25-
26-
/* Saved position of the GtkPaned separator.
27-
*/
2826
int position;
2927

30-
/* Animation state.
31-
*/
28+
// animation state.
3229
double elapsed;
3330
double last_frame_time;
3431
gboolean is_animating;
@@ -124,13 +121,23 @@ animatedpaned_set_child_position( Animatedpane *animatedpane, int position )
124121
gtk_paned_set_position( GTK_PANED( animatedpane->paned ), position );
125122
}
126123

124+
/* From clutter-easing.c, based on Robert Penner's infamous easing equations,
125+
* MIT license.
126+
*/
127+
static double
128+
ease_out_cubic( double t )
129+
{
130+
double p = t - 1;
131+
132+
return( p * p * p + 1 );
133+
}
134+
127135
static gboolean
128136
animatedpane_animate_tick( GtkWidget *widget, GdkFrameClock *frame_clock,
129137
gpointer client_data )
130138
{
131139
Animatedpane *animatedpane = ANIMATEDPANE( widget );
132140
gint64 frame_time = gdk_frame_clock_get_frame_time( frame_clock );
133-
gboolean revealed = GPOINTER_TO_INT( client_data );
134141

135142
double t;
136143

@@ -151,8 +158,8 @@ animatedpane_animate_tick( GtkWidget *widget, GdkFrameClock *frame_clock,
151158
if( t >= 0.99 ) {
152159
// all done
153160
animatedpaned_set_child_position( animatedpane, animatedpane->stop );
154-
animatedpaned_set_child_visibility( animatedpane, revealed );
155-
animatedpane->revealed = revealed;
161+
if( !animatedpane->revealed )
162+
animatedpaned_set_child_visibility( animatedpane, FALSE );
156163
animatedpane->is_animating = FALSE;
157164

158165
return( G_SOURCE_REMOVE );
@@ -175,6 +182,8 @@ animatedpaned_set_revealed( Animatedpane *animatedpane, gboolean revealed )
175182
#endif /* DEBUG */
176183

177184
if( animatedpane->revealed != revealed ) {
185+
animatedpane->revealed = revealed;
186+
178187
if( animatedpaned_enable_animations( animatedpane ) ) {
179188
animatedpane->last_frame_time = -1;
180189
animatedpane->elapsed = 0.0;
@@ -198,12 +207,10 @@ animatedpaned_set_revealed( Animatedpane *animatedpane, gboolean revealed )
198207
animatedpaned_set_child_visibility( animatedpane, TRUE );
199208

200209
gtk_widget_add_tick_callback( GTK_WIDGET( animatedpane ),
201-
animatedpane_animate_tick, GINT_TO_POINTER( revealed ),
202-
NULL );
210+
animatedpane_animate_tick, NULL, NULL );
203211
}
204212
else {
205213
animatedpaned_set_child_visibility( animatedpane, revealed );
206-
animatedpane->revealed = revealed;
207214
}
208215
}
209216
}

src/gtk/imagewindow.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
</child>
201201

202202
<child>
203-
<object class="Animatedpane" id="paned">
203+
<object class="Animatedpane" id="properties_pane">
204204
<property name="wide-handle">true</property>
205205
<property name="resize-start-child">false</property>
206206
<property name="shrink-start-child">true</property>

src/imagewindow.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
/*
22
#define DEBUG
3-
*/
4-
5-
/*
6-
#define EXPERIMENTAL_PROPERTIES_EDIT
7-
*/
3+
*/
84

95
#include "vipsdisp.h"
106

@@ -61,7 +57,7 @@ struct _ImageWindow
6157
GtkWidget *imagedisplay;
6258
GtkWidget *display_bar;
6359
GtkWidget *info_bar;
64-
GtkWidget *paned;
60+
GtkWidget *properties_pane;
6561
GtkWidget *properties;
6662

6763
/* Throttle progress bar updates to a few per second with this.
@@ -786,10 +782,10 @@ image_window_close_action( GSimpleAction *action,
786782
gtk_window_destroy( GTK_WINDOW( win ) );
787783
}
788784

789-
/* From clutter-easing.c, based on Robert Penner's
790-
* infamous easing equations, MIT license.
785+
/* From clutter-easing.c, based on Robert Penner's infamous easing equations,
786+
* MIT license.
791787
*/
792-
double
788+
static double
793789
ease_out_cubic( double t )
794790
{
795791
double p = t - 1;
@@ -1456,7 +1452,7 @@ image_window_properties( GSimpleAction *action,
14561452
puts("image_window_properties");
14571453
#endif /* DEBUG */
14581454

1459-
g_object_set( win->paned,
1455+
g_object_set( win->properties_pane,
14601456
"revealed", g_variant_get_boolean( state ),
14611457
NULL );
14621458

@@ -1585,7 +1581,7 @@ image_window_init( ImageWindow *win )
15851581
G_SETTINGS_BIND_DEFAULT );
15861582

15871583
g_settings_bind( win->settings, "properties",
1588-
G_OBJECT( win->paned ),
1584+
G_OBJECT( win->properties_pane ),
15891585
"revealed",
15901586
G_SETTINGS_BIND_DEFAULT );
15911587

@@ -1636,7 +1632,7 @@ image_window_class_init( ImageWindowClass *class )
16361632
BIND( imagedisplay );
16371633
BIND( display_bar );
16381634
BIND( info_bar );
1639-
BIND( paned );
1635+
BIND( properties_pane );
16401636
BIND( properties );
16411637

16421638
gtk_widget_class_bind_template_callback( GTK_WIDGET_CLASS( class ),

src/imagewindow.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,5 @@ void image_window_get_mouse_position( ImageWindow *win,
1616
GtkWidget *image_window_get_main_box( ImageWindow *win );
1717
GSettings *image_window_get_settings( ImageWindow *win );
1818

19-
double ease_out_cubic( double t );
20-
2119
#endif /* __IMAGE_WINDOW_H */
2220

0 commit comments

Comments
 (0)