Add Play/Stop button to the Frame Dial.
authorCarlos Lopez <carlos@pcnuevo.(none)>
Mon, 22 Jun 2009 18:08:36 +0000 (20:08 +0200)
committerCarlos Lopez <carlos@pcnuevo.(none)>
Mon, 22 Jun 2009 18:08:36 +0000 (20:08 +0200)
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/gtkmm/canvasview.h
synfig-studio/trunk/src/gtkmm/framedial.cpp
synfig-studio/trunk/src/gtkmm/framedial.h

index 32530cd..7c3aa0a 100644 (file)
@@ -99,7 +99,6 @@
 #include "preview.h"
 #include "audiocontainer.h"
 #include "widget_timeslider.h"
-#include "framedial.h"
 #include "keyframedial.h"
 
 #include <synfigapp/main.h>
@@ -997,13 +996,16 @@ CanvasView::create_time_bar()
        current_time_widget->show();
 
        //Setup the FrameDial widget
-       FrameDial *framedial = manage(new class FrameDial());
+       framedial = manage(new class FrameDial());
        framedial->signal_seek_begin().connect(
                        sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time), Time::begin())
        );
        framedial->signal_seek_prev_frame().connect(
                        sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame), -1)
        );
+       framedial->signal_play_stop().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::on_play_stop_pressed)
+       );
        framedial->signal_seek_next_frame().connect(
                        sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame), 1)
        );
@@ -3154,8 +3156,8 @@ CanvasView::play()
                        return;
                }
        }
+       on_play_stop_pressed();
        is_playing_=false;
-
        time_adjustment().set_value(endtime);
        time_adjustment().value_changed();
 }
@@ -3919,3 +3921,30 @@ CanvasView::on_delete_event(GdkEventAny* event __attribute__ ((unused)))
 
        return true;
 }
+
+//! Modify the play stop button apearence and play stop the animation
+void
+CanvasView::on_play_stop_pressed()
+{
+       Gtk::Image *icon;
+       Gtk::Button *stop_button;
+       stop_button=framedial->get_play_button();
+       bool play_flag;
+       if(!is_playing())
+       {
+               icon = manage(new Gtk::Image(Gtk::Stock::MEDIA_STOP, Gtk::IconSize::from_name("synfig-small_icon")));
+               stop_button->set_relief(Gtk::RELIEF_NORMAL);
+               play_flag=true;
+       }
+       else
+       {
+               icon = manage(new Gtk::Image(Gtk::Stock::MEDIA_PLAY, Gtk::IconSize::from_name("synfig-small_icon")));
+               stop_button->set_relief(Gtk::RELIEF_NONE);
+               play_flag=false;
+       }
+       stop_button->remove();
+       stop_button->add(*icon);
+       icon->set_padding(0, 0);
+       icon->show();
+       if(play_flag) play(); else stop();
+}
index 6f1f87e..844a57f 100644 (file)
@@ -65,6 +65,7 @@
 
 #include "dialog_waypoint.h"
 #include "dialog_keyframe.h"
+#include "framedial.h"
 
 #include "duckmatic.h"
 #include <gtkmm/scale.h>
@@ -263,6 +264,7 @@ private:
        Gtk::Widget *timebar;
        Gtk::Button *animatebutton;
        Gtk::Button *keyframebutton;
+       FrameDial *framedial;
 
 
        //! Shows current time and allows edition
@@ -679,6 +681,8 @@ private:
        //void on_audio_play();
        bool on_audio_scrub();
 
+       void on_play_stop_pressed();
+
 protected:
        bool close_instance_when_safe();
        bool on_delete_event(GdkEventAny* event);
index a361bd3..0392f4b 100644 (file)
@@ -49,7 +49,7 @@ using namespace studio;
 
 /* === M E T H O D S ======================================================= */
 
-FrameDial::FrameDial(): Gtk::Table(3, 1, false)
+FrameDial::FrameDial(): Gtk::Table(5, 1, false)
 {
        Gtk::IconSize iconsize = Gtk::IconSize::from_name("synfig-small_icon");
 
@@ -57,6 +57,8 @@ FrameDial::FrameDial(): Gtk::Table(3, 1, false)
                                        _("Seek to Begin"));
        seek_prev_frame = create_icon(iconsize, Gtk::Stock::MEDIA_REWIND,
                                        _("Previous Frame"));
+       play_stop = create_icon(iconsize, Gtk::Stock::MEDIA_PLAY,
+                                       _("Play"));
        seek_next_frame = create_icon(iconsize, Gtk::Stock::MEDIA_FORWARD,
                                        _("Next Frame"));
        seek_end = create_icon(iconsize, Gtk::Stock::MEDIA_NEXT,
@@ -64,8 +66,9 @@ FrameDial::FrameDial(): Gtk::Table(3, 1, false)
 
        attach(*seek_begin, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
        attach(*seek_prev_frame, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*seek_next_frame, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*seek_end, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*play_stop, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*seek_next_frame, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*seek_end, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
 }
 
 Gtk::Button *
index 01f2be0..89dfac3 100644 (file)
@@ -50,6 +50,7 @@ class FrameDial : public Gtk::Table
 
        Gtk::Button *seek_begin;
        Gtk::Button *seek_prev_frame;
+       Gtk::Button *play_stop;
        Gtk::Button *seek_next_frame;
        Gtk::Button *seek_end;
 
@@ -59,10 +60,13 @@ class FrameDial : public Gtk::Table
 public:
        FrameDial();
 
-       Glib::SignalProxy0<void> signal_seek_begin()       { return seek_begin->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_seek_prev_frame()  { return seek_prev_frame->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_seek_next_frame()  { return seek_next_frame->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_seek_end()         { return seek_end->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_seek_begin()            { return seek_begin->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_seek_prev_frame()       { return seek_prev_frame->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_play_stop()                     { return play_stop->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_seek_next_frame()       { return seek_next_frame->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_seek_end()                      { return seek_end->signal_clicked(); }
+
+       Gtk::Button *get_play_button() { return play_stop; }
 
 }; // END of class FrameDial