-/* === S I N F G =========================================================== */
+/* === S Y N F I G ========================================================= */
/*! \file preview.cpp
** \brief Preview implementation file
**
** $Id: preview.cpp,v 1.2 2005/01/10 08:13:44 darco Exp $
**
** \legal
-** Copyright (c) 2002 Robert B. Quattlebaum Jr.
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
**
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
** \endlegal
*/
/* ========================================================================= */
#include <gtkmm/stock.h>
#include <gtkmm/separator.h>
-#include <sinfg/target_scanline.h>
-#include <sinfg/surface.h>
+#include <synfig/target_scanline.h>
+#include <synfig/surface.h>
#include <algorithm>
#include "asyncrenderer.h"
using namespace std;
using namespace etl;
-using namespace sinfg;
+using namespace synfig;
using namespace studio;
/* === M A C R O S ========================================================= */
{
if(Target_Scanline::set_rend_desc(r))
{
- /*sinfg::warning("Succeeded in setting the desc to new one: %d x %d, %.2f fps [%.2f,%.2f]",
+ /*synfig::warning("Succeeded in setting the desc to new one: %d x %d, %.2f fps [%.2f,%.2f]",
desc.get_w(),desc.get_h(),desc.get_frame_rate(),
(float)desc.get_time_start(),(float)desc.get_time_end());*/
//ok... notify our subscribers...
signal_frame_done_(this);
curframe += 1;
- //sinfg::warning("Finished the frame stuff, and changed time to %.3f",t);
+ //synfig::warning("Finished the frame stuff, and changed time to %.3f",t);
}
virtual Color * start_scanline(int scanline)
etl::handle<Preview_Target> target = new Preview_Target;
//connect our information to his...
- //sinfg::warning("Connecting to the end frame function...");
+ //synfig::warning("Connecting to the end frame function...");
target->signal_frame_done().connect(sigc::mem_fun(*this,&Preview::frame_finish));
//set the options
- //sinfg::warning("Setting Canvas");
+ //synfig::warning("Setting Canvas");
target->set_canvas(get_canvas());
target->set_quality(quality);
newh = (int)floor(desc.get_h()*zoom+0.5);
float newfps = fps;
- /*sinfg::warning("Setting the render description: %d x %d, %f fps, [%f,%f]",
+ /*synfig::warning("Setting the render description: %d x %d, %f fps, [%f,%f]",
neww,newh,newfps, overbegin?begintime:(float)desc.get_time_start(),
overend?endtime:(float)desc.get_time_end());*/
if(overbegin)
{
desc.set_time_start(std::max(begintime,(float)desc.get_time_start()));
- //sinfg::warning("Set start time to %.2f...",(float)desc.get_time_start());
+ //synfig::warning("Set start time to %.2f...",(float)desc.get_time_start());
}
if(overend)
{
desc.set_time_end(std::min(endtime,(float)desc.get_time_end()));
- //sinfg::warning("Set end time to %.2f...",(float)desc.get_time_end());
+ //synfig::warning("Set end time to %.2f...",(float)desc.get_time_end());
}
//setting the description
frames.resize(0);
//now tell it to go... with inherited prog. reporting...
- //sinfg::info("Rendering Asynchronously...");
+ //synfig::info("Rendering Asynchronously...");
if(renderer) renderer->stop();
renderer = new AsyncRenderer(target);
renderer->start();
const Surface &surf = targ->get_surface();
const RendDesc& r = targ->get_rend_desc();
- //sinfg::warning("Finished a frame at %f s",time);
+ //synfig::warning("Finished a frame at %f s",time);
//copy EVERYTHING!
PixelFormat pf(PF_RGB);
- const int total_bytes(r.get_w()*r.get_h()*sinfg::channels(pf));
+ const int total_bytes(r.get_w()*r.get_h()*synfig::channels(pf));
- //sinfg::warning("Creating a buffer");
+ //synfig::warning("Creating a buffer");
unsigned char *buffer((unsigned char*)malloc(total_bytes));
if(!buffer)
return;
//convert all the pixles to the pixbuf... buffer... thing...
- //sinfg::warning("Converting...");
+ //synfig::warning("Converting...");
convert_color_format(buffer, surf[0], surf.get_w()*surf.get_h(), pf, App::gamma);
//load time
fe.t = time;
//uses and manages the memory for the buffer...
- //sinfg::warning("Create a pixmap...");
+ //synfig::warning("Create a pixmap...");
fe.buf =
Gdk::Pixbuf::create_from_data(
buffer, // pointer to the data
8, // bits per sample
surf.get_w(), // width
surf.get_h(), // height
- surf.get_w()*sinfg::channels(pf), // stride (pitch)
+ surf.get_w()*synfig::channels(pf), // stride (pitch)
sigc::ptr_fun(free_guint8)
);
//add the flipbook element to the list (assume time is correct)
- //sinfg::info("Prev: Adding %f s to the list", time);
+ //synfig::info("Prev: Adding %f s to the list", time);
frames.push_back(fe);
signal_changed()();
adj_time_scrub(0,0,1000,1,10,0),
scr_time_scrub(adj_time_scrub),
b_loop(/*_("Loop")*/),
+currentindex(0),
+audiotime(0),
adj_sound(0,0,4),
l_lasttime("0s"),
playing(false)
//find the frame and display it...
if(preview)
{
- //sinfg::warning("Updating at %.3f s",time);
+ //synfig::warning("Updating at %.3f s",time);
//use time to find closest frame...
studio::Preview::FlipBook::const_iterator beg = preview->begin(),end = preview->end();
{
//don't bother with binary search it will just be slower...
- //sinfg::info("Search for time %f",time);
+ //synfig::info("Search for time %f",time);
//incrementally go in either direction
//(bias downward towards beg, because that's what we want)
for(;i != end;++i)
{
- //sinfg::info("Look at %f",i->t);
+ //synfig::info("Look at %f",i->t);
if(i->t > time) break;
- //sinfg::info("Go past...");
+ //synfig::info("Go past...");
}
//if(i!=beg)--i;
for(;i != beg;)
{
--i;
- //sinfg::info("Look at %f",i->t);
+ //synfig::info("Look at %f",i->t);
if(i->t <= time) break;
- //sinfg::info("Go past...");
+ //synfig::info("Go past...");
}
/*i = preview->begin(); end = preview->end();
//don't get the closest, round down... (if we can)
if(i == end)
{
- sinfg::error("i == end....");
+ synfig::error("i == end....");
//assert(0);
currentbuf.clear();
currentindex = 0;
if(timedisp != i->t)
{
timedisp = i->t;
- //sinfg::warning("Update at: %f seconds (%f s)",time,timedisp);
+ //synfig::warning("Update at: %f seconds (%f s)",time,timedisp);
preview_draw();
- //sinfg::warning("success!");
+ //synfig::warning("success!");
}
}
}
sx = draw_area.get_width() / (float)px->get_width();
sy = draw_area.get_height() / (float)px->get_height();
- //sinfg::info("widget_preview redraw: now to scale the bitmap: %.3f x %.3f",sx,sy);
+ //synfig::info("widget_preview redraw: now to scale the bitmap: %.3f x %.3f",sx,sy);
//round to smallest scale (fit entire thing in window without distortion)
if(sx > sy) sx = sy;
pxnew = px->scale_simple(nw,nh,Gdk::INTERP_NEAREST);
- //sinfg::info("Now to draw to the window...");
+ //synfig::info("Now to draw to the window...");
//copy to window
Glib::RefPtr<Gdk::Window> wind = draw_area.get_window();
Glib::RefPtr<Gdk::Drawable> surf = Glib::RefPtr<Gdk::Drawable>::cast_static(wind);
draw_area.get_window()->begin_paint_rect(r);
}
- if(!wind) sinfg::warning("The destination window is broken...");
- if(!surf) sinfg::warning("The destination is not drawable...");
+ if(!wind) synfig::warning("The destination window is broken...");
+ if(!surf) synfig::warning("The destination is not drawable...");
if(surf)
{
Glib::ustring timecode(Time((double)timedisp).round(preview->get_global_fps())
.get_string(preview->get_global_fps(),
App::get_time_format()));
- //sinfg::info("Time for preview draw is: %s for time %g", timecode.c_str(), adj_time_scrub.get_value());
+ //synfig::info("Time for preview draw is: %s for time %g", timecode.c_str(), adj_time_scrub.get_value());
gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
layout->set_text(timecode);
draw_area.get_window()->end_paint();
- //sinfg::warning("Refresh the draw area");
+ //synfig::warning("Refresh the draw area");
//make sure the widget refreshes
return false;
bool studio::Widget_Preview::play_update()
{
float diff = timer.pop_time();
- //sinfg::info("Play update: diff = %.2f",diff);
+ //synfig::info("Play update: diff = %.2f",diff);
if(playing)
{
if(newtime != audiotime)
{
- //sinfg::info("Adjusted time from %.3lf to %.3lf", time,newtime);
+ //synfig::info("Adjusted time from %.3lf to %.3lf", time,newtime);
time = audiotime = newtime;
}
}
play_stop();
update();
- //sinfg::info("Play Stopped: time set to %f",adj_time_scrub.get_value());
+ //synfig::info("Play Stopped: time set to %f",adj_time_scrub.get_value());
return false;
}
}
//update the window to the correct image we might want to do this later...
//update();
- //sinfg::warning("Did update pu");
+ //synfig::warning("Did update pu");
}
return true;
}
//if(!playing)
{
update();
- //sinfg::warning("Did update sm");
+ //synfig::warning("Did update sm");
}
}
}
}
- //sinfg::info("Scrubbing to %.3f, setting adj to %.3f",oldt,t);
+ //synfig::info("Scrubbing to %.3f, setting adj to %.3f",oldt,t);
if(adj_time_scrub.get_value() != t)
{
{
preview = prev;
- sinfg::info("Setting preview");
+ synfig::info("Setting preview");
//stop playing the mini animation...
stop();
{
//set the internal values
float rate = preview->get_fps();
- sinfg::info(" FPS = %f",rate);
+ synfig::info(" FPS = %f",rate);
if(rate)
{
float start = preview->get_begintime();
prevchanged = prev->signal_changed().connect(sigc::mem_fun(*this,&Widget_Preview::whenupdated));
prev->signal_destroyed().connect(sigc::mem_fun(*this,&Widget_Preview::disconnect_preview));
update();
- //sinfg::warning("Did update sp");
+ //synfig::warning("Did update sp");
queue_draw();
}
}
{
if(preview && !playing)
{
- //sinfg::info("Playing at %lf",adj_time_scrub.get_value());
+ //synfig::info("Playing at %lf",adj_time_scrub.get_value());
//audiotime = adj_time_scrub.get_value();
playing = true;
//adj_time_scrub.set_value(adj_time_scrub.get_lower());
update(); //we don't want to call play update because that will try to advance the timer
- //sinfg::warning("Did update p");
+ //synfig::warning("Did update p");
//approximate length of time in seconds, right?
double rate = /*std::min(*/adj_time_scrub.get_step_increment()/*,1/30.0)*/;
int timeout = (int)floor(1000*rate);
- //sinfg::info(" rate = %.3lfs = %d ms",rate,timeout);
+ //synfig::info(" rate = %.3lfs = %d ms",rate,timeout);
signal_play_(adj_time_scrub.get_value());
playing = false;
signal_stop()();
if(audio) audio->stop(); //!< stop the audio
- //sinfg::info("Stopping...");
+ //synfig::info("Stopping...");
}
void studio::Widget_Preview::stop()
{
- //sinfg::warning("stopping");
+ //synfig::warning("stopping");
play_stop();
timecon.disconnect();
}