Keep correct size on the animate button after pressed.
[synfig.git] / synfig-studio / trunk / src / gtkmm / canvasview.cpp
index d877e6d..a3c42cc 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>
@@ -952,7 +951,6 @@ CanvasView::create_time_bar()
        //Gtk::HScrollbar *time_scroll = manage(new class Gtk::HScrollbar(time_adjustment()));
        //TIME BAR TEMPORARY POSITION
        //Widget_Timeslider *time_scroll = manage(new Widget_Timeslider);
-       timeslider->show();
        timeslider->set_time_adjustment(&time_adjustment());
        timeslider->set_bounds_adjustment(&time_window_adjustment());
        //layout_table->attach(*timeslider, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL);
@@ -961,7 +959,7 @@ CanvasView::create_time_bar()
        tooltips.set_tip(*timeslider,_("Changes the current time"));
        time_window_scroll->show();
        timeslider->show();
-       time_window_scroll->set_flags(Gtk::CAN_FOCUS);
+       //time_window_scroll->set_flags(Gtk::CAN_FOCUS); // Uncomment this produce bad render of the HScroll
        timeslider->set_flags(Gtk::CAN_FOCUS);
 
        //time_scroll->signal_value_changed().connect(sigc::mem_fun(*work_area, &studio::WorkArea::render_preview_hook));
@@ -992,15 +990,21 @@ CanvasView::create_time_bar()
        current_time_widget->signal_value_changed().connect(
                sigc::mem_fun(*this,&CanvasView::on_current_time_widget_changed)
        );
+       current_time_widget->set_size_request(0,-1); // request horizontal shrink
+       tooltips.set_tip(*current_time_widget,_("Current time"));
+       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)
        );
@@ -1017,17 +1021,17 @@ CanvasView::create_time_bar()
        keyframedial->show();
        keyframebutton=keyframedial->get_lock_button();
 
-       Gtk::Table *table = manage(new class Gtk::Table(4, 4, false));
+       Gtk::Table *table = manage(new class Gtk::Table(5, 3, false));
        timebar = table;
 
        //Attach widgets to the time bar table
-       table->attach(*manage(disp_audio), 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
+       table->attach(*manage(disp_audio), 1, 5, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
        table->attach(*framedial, 0, 1, 2, 3,Gtk::SHRINK, Gtk::SHRINK);
        table->attach(*current_time_widget, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       table->attach(*timeslider, 1, 4, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
-       table->attach(*time_window_scroll, 1, 4, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
-       table->attach(*keyframedial, 0, 1, 3, 4, Gtk::SHRINK, Gtk::SHRINK);
-       table->attach(*animatebutton, 2, 3, 3, 4, Gtk::SHRINK, Gtk::SHRINK);
+       table->attach(*timeslider, 1, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
+       table->attach(*time_window_scroll, 1, 3, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
+       table->attach(*keyframedial, 3, 4, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
+       table->attach(*animatebutton, 4, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
        //table->attach(*keyframebutton, 1, 2, 3, 4, Gtk::SHRINK, Gtk::SHRINK);
 
 
@@ -2576,10 +2580,11 @@ void
 CanvasView::on_mode_changed(synfigapp::CanvasInterface::Mode mode)
 {
        // If the animate flag was set in mode...
+       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
        if(mode&synfigapp::MODE_ANIMATE)
        {
                Gtk::Image *icon;
-               icon=manage(new Gtk::Image(Gtk::StockID("gtk-no"),Gtk::ICON_SIZE_BUTTON));
+               icon=manage(new Gtk::Image(Gtk::StockID("gtk-no"),iconsize));
                animatebutton->remove();
                animatebutton->add(*icon);
                tooltips.set_tip(*animatebutton,_("In Animate Editing Mode"));
@@ -2589,7 +2594,7 @@ CanvasView::on_mode_changed(synfigapp::CanvasInterface::Mode mode)
        else
        {
                Gtk::Image *icon;
-               icon=manage(new Gtk::Image(Gtk::StockID("gtk-yes"),Gtk::ICON_SIZE_BUTTON));
+               icon=manage(new Gtk::Image(Gtk::StockID("gtk-yes"),iconsize));
                animatebutton->remove();
                animatebutton->add(*icon);
                tooltips.set_tip(*animatebutton,_("Not in Animate Editing Mode"));
@@ -3151,8 +3156,8 @@ CanvasView::play()
                        return;
                }
        }
+       on_play_stop_pressed();
        is_playing_=false;
-
        time_adjustment().set_value(endtime);
        time_adjustment().value_changed();
 }
@@ -3209,7 +3214,7 @@ void
 CanvasView::show_timebar()
 {
        timebar->show();
-       current_time_widget->show();
+       //current_time_widget->show(); // not needed now that belongs to the timebar
 
        //keyframe_tab_child->show();
        if(layer_tree)
@@ -3916,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();
+}