Typo: 'hilight' -> 'highlight'.
[synfig.git] / synfig-studio / trunk / src / gtkmm / workarea.cpp
index dce50cd..313646f 100644 (file)
@@ -7,6 +7,7 @@
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **     Copyright 2006 Yue Shi Lai
+**     Copyright (c) 2007 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -634,7 +635,9 @@ WorkArea::WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interfac
        dragging(DRAG_NONE),
        show_grid(false),
        tile_w(128),
-       tile_h(128)
+       tile_h(128),
+       timecode_width(0),
+       timecode_height(0)
 {
        show_guides=true;
        curr_input_device=0;
@@ -804,11 +807,20 @@ WorkArea::~WorkArea()
        // don't leave the render function queued if we are about to vanish;
        // that causes crashes
        if(render_idle_func_id)
-       {
-               synfig::info("g_source_remove() returns %d", g_source_remove(render_idle_func_id));
                render_idle_func_id=0;
-       } else
-               synfig::info("no render_idle_func_id to clear\n");
+}
+
+bool
+WorkArea::get_updating()const
+{
+       return App::single_threaded && async_renderer && async_renderer->updating;
+}
+
+void
+WorkArea::stop_updating(bool cancel)
+{
+       async_renderer->stop();
+       if (cancel) canceled_=true;
 }
 
 void
@@ -1049,7 +1061,7 @@ void
 WorkArea::set_focus_point(const synfig::Point &point)
 {
        // These next three lines try to ensure that we place the
-       // focus on a pixel boundry
+       // focus on a pixel boundary
        /*Point adjusted(point[0]/abs(get_pw()),point[1]/abs(get_ph()));
        adjusted[0]=(abs(adjusted[0]-floor(adjusted[0]))<0.5)?floor(adjusted[0])*abs(get_pw()):ceil(adjusted[0])*abs(get_ph());
        adjusted[1]=(abs(adjusted[1]-floor(adjusted[1]))<0.5)?floor(adjusted[1])*abs(get_ph()):ceil(adjusted[1])*abs(get_ph());
@@ -1190,7 +1202,7 @@ WorkArea::on_drawing_area_event(GdkEvent *event)
                        modifier=Gdk::ModifierType(event->button.state);
                }
 
-               // Make sure we recognise the device
+               // Make sure we recognize the device
                if(curr_input_device)
                {
                        if(curr_input_device!=device)
@@ -1256,7 +1268,7 @@ WorkArea::on_drawing_area_event(GdkEvent *event)
        // GDK mouse scrolling events
        else if(event->any.type==GDK_SCROLL)
        {
-               // GDK information needed to properly interprete mouse
+               // GDK information needed to properly interpret mouse
                // scrolling events are: scroll.state, scroll.x/scroll.y, and
                // scroll.direction. The value of scroll.direction will be
                // obtained later.
@@ -1483,7 +1495,7 @@ WorkArea::on_drawing_area_event(GdkEvent *event)
 
                signal_cursor_moved_();
 
-               // Guide/Duck hilights on hover
+               // Guide/Duck highlights on hover
                if(dragging==DRAG_NONE)
                {
                        GuideList::iterator iter;
@@ -2175,6 +2187,13 @@ public:
 bool
 studio::WorkArea::async_update_preview()
 {
+       if (get_updating())
+       {
+               stop_updating();
+               queue_render_preview();
+               return false;
+       }
+
        async_renderer=0;
 
        queued=false;
@@ -2462,13 +2481,41 @@ WorkArea::queue_scroll()
 
        drawing_area->get_window()->scroll(-dx,-dy);
 
-       /*drawing_area->queue_draw_area(
-               0,
-               0,
-               128,
-               64
-       );
-       */
+       if (timecode_width && timecode_height)
+       {
+               drawing_area->queue_draw_area(4,       4,    4+timecode_width,    4+timecode_height);
+               drawing_area->queue_draw_area(4-dx, 4-dy, 4-dx+timecode_width, 4-dy+timecode_height);
+       }
+
+#ifndef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+       if(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
+       {
+               int maxx = drawing_area->get_width()-1;
+               int maxy = drawing_area->get_height()-1;
+
+               if (dx > 0)
+               {
+                       drawing_area->queue_draw_area(      0, 0,       1, maxy);
+                       drawing_area->queue_draw_area(maxx-dx, 0, maxx-dx, maxy);
+               }
+               else if (dx < 0) 
+               {
+                       drawing_area->queue_draw_area(   maxx, 0,    maxx, maxy);
+                       drawing_area->queue_draw_area(    -dx, 0,     -dx, maxy);
+               }
+               if (dy > 0)
+               {
+                       drawing_area->queue_draw_area(0,       0, maxx,       1);
+                       drawing_area->queue_draw_area(0, maxy-dy, maxx, maxy-dy);
+               }
+               else if (dy < 0) 
+               {
+                       drawing_area->queue_draw_area(0,    maxy, maxx,    maxy);
+                       drawing_area->queue_draw_area(0,     -dy, maxx,     -dy);
+               }
+       }
+#endif // USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+
        last_focus_point=focus_point;
 }
 
@@ -2598,12 +2645,12 @@ studio::WorkArea::set_cursor(Gdk::CursorType x)
        drawing_area->get_window()->set_cursor(Gdk::Cursor(x));
 }
 
-#include "iconcontroler.h"
+#include "iconcontroller.h"
 
 void
 studio::WorkArea::refresh_cursor()
 {
-//     set_cursor(IconControler::get_tool_cursor(canvas_view->get_smach().get_state_name(),drawing_area->get_window()));
+//     set_cursor(IconController::get_tool_cursor(canvas_view->get_smach().get_state_name(),drawing_area->get_window()));
 }
 
 void