cropper

changeset 3:6aaba3a61563

added ratio control code
author meillo@marmaro.de
date Wed, 05 Dec 2007 00:08:39 +0100
parents e359bea4c8ac
children 2f11ab3e6047
files Makefile callbacks.c callbacks.h
diffstat 3 files changed, 48 insertions(+), 34 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Tue Dec 04 23:20:51 2007 +0100
     1.2 +++ b/Makefile	Wed Dec 05 00:08:39 2007 +0100
     1.3 @@ -19,7 +19,7 @@
     1.4  
     1.5  
     1.6  clean:
     1.7 -	rm ${OBJS}
     1.8 +	rm *.o
     1.9  	rm ${PACKAGE}
    1.10  
    1.11  
     2.1 --- a/callbacks.c	Tue Dec 04 23:20:51 2007 +0100
     2.2 +++ b/callbacks.c	Wed Dec 05 00:08:39 2007 +0100
     2.3 @@ -6,61 +6,75 @@
     2.4  #include "support.h"
     2.5  
     2.6  
     2.7 +void update_spin_button_ratio(GtkWidget* spinbutton) {
     2.8 +	g_print("ratio change: %f\n", ratio);
     2.9 +	/*gtk_spin_button_set_value((spinbutton), gtk_spin_button_get_value(spinbutton));*/
    2.10 +	/*gtk_spin_button_update(spinbutton);*/
    2.11 +	on_ratio_w_spinbutton_value_changed(spinbutton, NULL);
    2.12 +}
    2.13  
    2.14  void on_ratio_none_activate (GtkMenuItem* menuitem, gpointer user_data) {
    2.15 -	ratio = 0;
    2.16 +	ratio = (double) 1;
    2.17 +	update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton"));
    2.18  }
    2.19  
    2.20  
    2.21  void on_ratio_square_activate (GtkMenuItem* menuitem, gpointer user_data) {
    2.22 -	ratio = 1;
    2.23 +	ratio = (double) 1;
    2.24 +	update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton"));
    2.25  }
    2.26  
    2.27  
    2.28  void on_ratio_4x3_activate (GtkMenuItem* menuitem, gpointer user_data) {
    2.29 -	ratio = 4/3;
    2.30 +	ratio = (double) 4/3;
    2.31 +	update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton"));
    2.32  }
    2.33  
    2.34  
    2.35  void on_ratio_3x2_activate (GtkMenuItem* menuitem, gpointer user_data) {
    2.36 -	ratio = 3/2;
    2.37 +	ratio = (double) 3/2;
    2.38 +	update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton"));
    2.39  }
    2.40  
    2.41  
    2.42  void on_ratio_custom_activate (GtkMenuItem* menuitem, gpointer user_data) {
    2.43 +	ratio = (double) gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_w_spinbutton")) / gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_h_spinbutton"));
    2.44 +	update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton"));
    2.45 +}
    2.46 +
    2.47 +
    2.48 +
    2.49 +
    2.50 +
    2.51 +void on_ratio_w_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) {
    2.52 +	/*gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), gtk_spin_button_get_value(spinbutton) / ratio);*/
    2.53 +	g_print("spinbutton W - ratio: %f\n", ratio);
    2.54 +	gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), gtk_spin_button_get_value(spinbutton) / ratio);
    2.55 +}
    2.56 +
    2.57 +
    2.58 +void on_ratio_w_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) {
    2.59 +}
    2.60 +
    2.61 +
    2.62 +void on_ratio_h_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) {
    2.63 +}
    2.64 +
    2.65 +
    2.66 +void on_ratio_h_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) {
    2.67 +	/*gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(spinbutton) * ratio);*/
    2.68 +	g_print("spinbutton H - ratio: %f\n", ratio);
    2.69 +	gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(spinbutton) * ratio);
    2.70  
    2.71  }
    2.72  
    2.73  
    2.74 +void on_ratio_swap_button_clicked (GtkButton* button, gpointer user_data) {
    2.75 +	
    2.76 +	ratio = 1.0 / ratio;
    2.77 +	gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_h_spinbutton")));
    2.78 +	gtk_spin_button_update(lookup_widget(cropper_window, "ratio_w_spinbutton"));
    2.79  
    2.80 -
    2.81 -
    2.82 -void on_ratio_w_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) {
    2.83 -
    2.84 -}
    2.85 -
    2.86 -
    2.87 -void on_ratio_w_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) {
    2.88 -
    2.89 -}
    2.90 -
    2.91 -
    2.92 -void on_ratio_h_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) {
    2.93 -
    2.94 -}
    2.95 -
    2.96 -
    2.97 -void on_ratio_h_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) {
    2.98 -
    2.99 -}
   2.100 -
   2.101 -
   2.102 -void on_ratio_swap_button_clicked (GtkButton* button, gpointer user_data) {
   2.103 -	gint h;
   2.104 -	
   2.105 -	h = gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_w_spinbutton"));
   2.106 -	gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_h_spinbutton")));
   2.107 -	gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), h);
   2.108  }
   2.109  
   2.110  
     3.1 --- a/callbacks.h	Tue Dec 04 23:20:51 2007 +0100
     3.2 +++ b/callbacks.h	Wed Dec 05 00:08:39 2007 +0100
     3.3 @@ -1,6 +1,6 @@
     3.4  #include <gtk/gtk.h>
     3.5  
     3.6 -gdouble ratio;
     3.7 +double ratio;
     3.8  
     3.9  void on_ratio_none_activate(GtkMenuItem* menuitem, gpointer user_data);
    3.10  void on_ratio_square_activate(GtkMenuItem* menuitem, gpointer user_data);