** \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
#include <synfig/target_scanline.h>
#include <synfig/target_tile.h>
#include <synfig/surface.h>
+#include <synfig/valuenode_composite.h>
#include <synfigapp/canvasinterface.h>
#include "event_mouse.h"
#include "event_layerclick.h"
}
- virtual bool start_frame(synfig::ProgressCallback *cb)
+ virtual bool start_frame(synfig::ProgressCallback */*cb*/)
{
synfig::Mutex::Lock lock(mutex);
}
- virtual bool start_frame(synfig::ProgressCallback *cb)
+ virtual bool start_frame(synfig::ProgressCallback */*cb*/)
{
return true;
}
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;
if(!data.empty())
{
if(!load_sketch(data))
- load_sketch(dirname(canvas->get_file_name())+ETL_DIRECTORY_SEPERATOR+basename(data));
+ load_sketch(dirname(canvas->get_file_name())+ETL_DIRECTORY_SEPARATOR+basename(data));
}
}
WorkArea::~WorkArea()
{
// delete [] buffer;
+
+ // don't leave the render function queued if we are about to vanish;
+ // that causes crashes
+ if(render_idle_func_id)
+ render_idle_func_id=0;
}
void
if(duck)
{
- clicked_duck=0;
+ // make a note of whether the duck we click on was selected or not
if(duck_is_selected(duck))
- {
clicked_duck=duck;
- }
else
{
- if(modifier&GDK_SHIFT_MASK)
- {
- select_duck(duck);
- }
- else if(modifier&GDK_CONTROL_MASK)
- {
- select_duck(duck);
- }
- else
- {
+ clicked_duck=0;
+ // if CTRL isn't pressed, clicking an unselected duck will unselect all other ducks
+ if(!(modifier&GDK_CONTROL_MASK))
clear_selected_ducks();
- select_duck(duck);
- }
+ select_duck(duck);
}
}
}
{
//get_selected_duck()->signal_user_click(0)();
//if(clicked_duck)clicked_duck->signal_user_click(0)();
+
+ // if the user is holding shift while clicking on a tangent duck, consider splitting the tangent
+ if (event->motion.state&GDK_SHIFT_MASK && duck->get_type() == Duck::TYPE_TANGENT)
+ {
+ synfigapp::ValueDesc value_desc = duck->get_value_desc();
+
+ // we have the tangent, but need the vertex - that's the parent
+ if (value_desc.parent_is_value_node()) {
+ ValueNode_Composite::Handle parent_value_node = value_desc.get_parent_value_node();
+
+ // if the tangent isn't split, then split it
+ if (!((*(parent_value_node->get_link("split")))(get_time()).get(bool())))
+ {
+ get_canvas_view()->canvas_interface()->
+ change_value(synfigapp::ValueDesc(parent_value_node,
+ parent_value_node->get_link_index_from_name("split")),
+ true);
+ // rebuild the ducks from scratch, so the tangents ducks aren't connected
+ get_canvas_view()->rebuild_ducks();
+
+ // reprocess the mouse click
+ return on_drawing_area_event(event);
+ }
+ } else {
+ // I don't know how to access the vertex from the tangent duck when originally drawing the bline in the bline tool
+
+ // synfig::ValueNode::Handle vn = value_desc.get_value_node();
+ synfig::info("parent isn't value node? shift-drag-tangent doesn't work in bline tool yet...");
+ }
+ }
+
dragging=DRAG_DUCK;
drag_point=mouse_pos;
//drawing_area->queue_draw();
get_canvas_view()->duck_refresh_flag=true;
if(!drag_did_anything)
{
- //etl::handle<Duck> duck=find_duck(mouse_pos,radius);
-
- if(modifier&GDK_SHIFT_MASK)
- {
- //synfig::info("DUCK_DRAG_RELEASE: SHIFT-MASK ON!");
- if(clicked_duck)
- {
- //synfig::info("DUCK_DRAG_RELEASE: CLICKED DUCK!");
- unselect_duck(clicked_duck);
- }
- }
- else if(modifier&GDK_CONTROL_MASK)
+ // if we originally clicked on a selected duck ...
+ if(clicked_duck)
{
- //synfig::info("DUCK_DRAG_RELEASE: CONTROL-MASK ON!");
- if(clicked_duck)
- {
- //synfig::info("DUCK_DRAG_RELEASE: CLICKED DUCK!");
+ // ... and CTRL is pressed, then just toggle the clicked duck
+ // otherwise make the clicked duck the only selected duck
+ if(modifier&GDK_CONTROL_MASK)
unselect_duck(clicked_duck);
- }
- }
- else
- {
- //synfig::info("DUCK_DRAG_RELEASE: NO MASK!");
- if(clicked_duck)
+ else
{
- //synfig::info("DUCK_DRAG_RELEASE: CLICKED DUCK!");
clear_selected_ducks();
select_duck(clicked_duck);
}
+ clicked_duck->signal_user_click(0)();
}
- if(clicked_duck)clicked_duck->signal_user_click(0)();
}
else
{
if(canvas_view->get_smach().process_event(EventBox(drag_point,mouse_pos,MouseButton(event->button.button),modifier))==Smach::RESULT_ACCEPT)
return true;
- if(!(modifier&GDK_CONTROL_MASK) && !(modifier&GDK_SHIFT_MASK))
+ // when dragging a box around some ducks:
+ // SHIFT selects; CTRL toggles; SHIFT+CTRL unselects; <none> clears all then selects
+ if(modifier&GDK_SHIFT_MASK)
+ select_ducks_in_box(drag_point,mouse_pos);
+
+ if(modifier&GDK_CONTROL_MASK)
+ toggle_select_ducks_in_box(drag_point,mouse_pos);
+ else if(!(modifier&GDK_SHIFT_MASK))
+ {
clear_selected_ducks();
- select_ducks_in_box(drag_point,mouse_pos);
+ select_ducks_in_box(drag_point,mouse_pos);
+ }
ret=true;
}
else
}
bool
-WorkArea::on_hruler_event(GdkEvent *event)
+WorkArea::on_hruler_event(GdkEvent */*event*/)
{
/*
switch(event->type)
}
bool
-WorkArea::on_vruler_event(GdkEvent *event)
+WorkArea::on_vruler_event(GdkEvent */*event*/)
{
/*
switch(event->type)
}
synfig::Point
-WorkArea::comp_to_screen_coords(synfig::Point pos)const
+WorkArea::comp_to_screen_coords(synfig::Point /*pos*/)const
{
synfig::warning("WorkArea::comp_to_screen_coords: Not yet implemented");
return synfig::Point();
}
}
-
// Calculate the window coordinates of the top-left
// corner of the canvas.
//const synfig::Vector::value_type
Glib::RefPtr<Gdk::GC> gc=Gdk::GC::create(drawing_area->get_window());
-
-
// If we are in animate mode, draw a red border around the screen
if(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
{
- /*gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
+// #define USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+#ifdef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+ // This method of drawing the red border doesn't work on any
+ // Gtk theme which uses the crux-engine, hcengine, industrial,
+ // mist, or ubuntulooks engine, such as the default ubuntu
+ // 'Human' theme.
+ drawing_frame->modify_bg(Gtk::STATE_NORMAL,Gdk::Color("#FF0000"));
+#else
+ // So let's do it in a more primitive fashion.
+ gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
drawing_area->get_window()->draw_rectangle(
gc,
false, // Fill?
0,0, // x,y
- drawing_area->get_width()-1,drawing_area->get_height()-1 //w,h
- );
- */
- drawing_frame->modify_bg(Gtk::STATE_NORMAL,Gdk::Color("#FF0000"));
- //get_window()->set_background(Gdk::Color("#FF0000"));
+ drawing_area->get_width()-1,drawing_area->get_height()-1); // w,h
+#endif
}
+#ifdef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
else
drawing_frame->unset_bg(Gtk::STATE_NORMAL);
-
-
+#endif
previous_focus=get_focus_point();
}
+namespace studio
+{
class WorkAreaProgress : public synfig::ProgressCallback
{
WorkArea *work_area;
return cb->amount_complete(current,total);
}
};
+}
bool
studio::WorkArea::async_update_preview()
{
+ if (single_threaded() && async_renderer && async_renderer->updating == true)
+ {
+ async_renderer->stop();
+ return false;
+ }
+
async_renderer=0;
queued=false;
if(!async_renderer)
return;
- // If we completed successfuly, then
+ // If we completed successfully, then
// we aren't dirty anymore
if(async_renderer->has_success())
{
dirty=false;
get_canvas_view()->reset_cancel_status();
- bool ret=false;
RendDesc desc=get_canvas()->rend_desc();
//newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
if(cb)
cb->task(strprintf("Rendering canvas %s...",get_canvas()->get_name().c_str()));
- target->render(cb);
+ bool ret = target->render(cb);
if(!ret && !get_canvas_view()->get_cancel_status() && dirty)
{
// it is being displayed correctly
drawing_area->queue_draw();
- // If we completed successfuly, then
+ // If we completed successfully, then
// we aren't dirty anymore
if(ret)
{
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;
}
gboolean
studio::WorkArea::__render_preview(gpointer data)
{
-
WorkArea *work_area(static_cast<WorkArea*>(data));
+ // there's no point anyone trying to cancel the timer now - it's gone off already
+ work_area->render_idle_func_id = 0;
+
work_area->queued=false;
work_area->async_render_preview(work_area->get_canvas_view()->get_time());
{
//synfig::info("queue_render_preview(): (re)queuing...");
//render_idle_func_id=g_idle_add_full(G_PRIORITY_DEFAULT,__render_preview,this,NULL);
- render_idle_func_id=g_timeout_add_full(G_PRIORITY_DEFAULT,queue_time,__render_preview,this,NULL);
+ render_idle_func_id=g_timeout_add_full(
+ G_PRIORITY_DEFAULT, // priority -
+ queue_time, // interval - the time between calls to the function, in milliseconds (1/1000ths of a second)
+ __render_preview, // function - function to call
+ this, // data - data to pass to function
+ NULL); // notify - function to call when the idle is removed, or NULL
queued=true;
}
/* else if(rendering)