예제 #1
0
bool Application::save_project(std::string &file_name)
{
    namespace ss = statesaving;

    char buff[256]; // buff for node names and int properties
    xmlDocPtr doc = xmlNewDoc(XMLSTR "1.0");
    // "project" node with its "name" attribute
    xmlNodePtr root_node = xmlNewNode(NULL, XMLSTR ss::ROOT_NODE);
    xmlDocSetRootElement(doc, root_node);
    xmlNewProp(root_node, XMLSTR ss::PROJECT_NAME_ATTR, XMLSTR ss::DEFAULT_PROJECT_NAME);
    xmlNewProp(root_node, XMLSTR ss::PROJECT_VERSION_ATTR, XMLSTR PACKAGE_VERSION);
    sprintf(buff, "%d", get_current_clip_number());
    xmlNewProp(root_node, XMLSTR ss::CURRENT_CLIP_ATTR, XMLSTR buff);
    // "clips" node
    xmlNodePtr clips_node = xmlNewChild(root_node, NULL, XMLSTR ss::CLIPS_NODE, NULL); // No text contents

    for (ClipIterator iter = clips_.begin(); iter != clips_.end(); ++iter)
    {
        Clip *clip = iter->second.get();
        if (clip->size() > 0) // do not save empty clips
        {
            xmlNodePtr clip_node = xmlNewChild(clips_node, NULL, XMLSTR ss::CLIP_NODE, NULL);
            // clip ID:
            sprintf(buff, "%d", clip->get_id());
            xmlNewProp(clip_node, XMLSTR ss::CLIP_ID_PROPERTY, XMLSTR buff);
            // clip FPS:
            sprintf(buff, "%d", clip->get_playhead_fps());
            xmlNewProp(clip_node, XMLSTR ss::CLIP_FPS_PROPERTY, XMLSTR buff);
            // clip direction:
            xmlNewProp(clip_node, XMLSTR ss::CLIP_DIRECTION_PROPERTY, XMLSTR clip->get_direction().c_str());
            // images:
            xmlNodePtr images_node = xmlNewChild(clip_node, NULL, XMLSTR ss::IMAGES_NODE, NULL);
            for (unsigned int image_num = 0; image_num < clip->size(); image_num++)
            {
                Image *image = clip->get_image(image_num);
                xmlNodePtr image_node = xmlNewChild(images_node, NULL, XMLSTR ss::IMAGE_NODE, NULL);
                xmlNewProp(image_node, XMLSTR ss::IMAGE_NAME_ATTR, XMLSTR image->get_name().c_str());
            }
        }
    }

    // Save document to file
    xmlSaveFormatFileEnc(file_name.c_str(), doc, "UTF-8", 1);
    if (config_->get_verbose())
        std::cout << "Saved the project to " << file_name << std::endl;
    // Free the document + global variables that may have been allocated by the parser.
    xmlFreeDoc(doc);
    xmlCleanupParser();
    return true;
}
예제 #2
0
void InfoWindow::update_thumbnail_for_clip(unsigned int clip_number)
{
    if (clip_number >= clips_.size())
    {
        g_critical("%s: Clip number bigger than size of known clips.", __FUNCTION__);
        return;
    }
    Clip *clip = app_->get_clip(clip_number);
    ClipInfoBox *clip_info = clips_.at(clip_number).get();
    unsigned int frames = clip->size();
    if (frames == 0)
        clutter_actor_hide(clip_info->image_);
    else
    {
        clutter_actor_show(clip_info->image_);
        Image *image = clip->get_image(0);
        if (image == 0)
            std::cout << __FUNCTION__ << ": Could not get a handle to any image!" << std::endl;
        else
        {
            std::string file_name = clip->get_image_full_path(image);
            load_thumbnail_from_file(CLUTTER_TEXTURE(clip_info->image_), file_name, 80, 60);
        }
    }
}
예제 #3
0
void InfoWindow::update_num_frames(unsigned int clip_number)
{
    if (clip_number >= clips_.size())
    {
        g_critical("%s: Clip number bigger than size of known clips.", __FUNCTION__);
        return;
    }
    Clip *clip = app_->get_clip(clip_number);
    ClipInfoBox *clip_info = clips_.at(clip_number).get();
    unsigned int frames = clip->size();
    std::ostringstream os;
    os << "  # <b>" << clip_number << "</b>" << std::endl;
    os << "images: " << frames;
    clutter_text_set_markup(CLUTTER_TEXT(clip_info->label_), os.str().c_str());
}
예제 #4
0
/** 
 * Called on every frame. 
 *
 * (Clutter Timeline handler)
 * Times the playback frames and display it if it's time to do so.
 *
 * Prints the rendering FPS information. 
 * Calls Controller::update_playback_image
 * We could draw some stuff using OpenGL in this callback.
 */
void Gui::on_render_frame(ClutterTimeline * /*timeline*/, gint /*msecs*/, gpointer user_data)
{
    // Prints rendering FPS information

    Gui *context = static_cast<Gui*>(user_data);

    context->owner_->check_for_messages();
    bool verbose = context->owner_->get_configuration()->get_verbose();
    Clip *thisclip = context->owner_->get_current_clip();

    // calculate rendering FPS
    context->fps_calculation_timer_.tick();
    ++context->number_of_frames_in_last_second_;
    if (context->fps_calculation_timer_.get_elapsed() >= 1.0f)
    {
        if (verbose)
            std::cout << "Rendering FPS: " << context->number_of_frames_in_last_second_ << std::endl;
        context->rendering_fps_ = context->number_of_frames_in_last_second_;
        context->number_of_frames_in_last_second_ = 0;
        context->fps_calculation_timer_.reset();
    }
    // Display info:
    if (context->enable_info_)
        context->update_info_text();
    context->info_window_.update_info_window();

    context->owner_->get_controller()->update_playback_image();

    //TODO:2010-08-26:aalex:connect to Controller's on_no_image_to_play
    if(thisclip->size() > 0) 
    {     
        if (context->current_layout_ != LAYOUT_LIVEFEED_ONLY)
            clutter_actor_show_all(CLUTTER_ACTOR(context->playback_group_));
        else
            clutter_actor_hide_all(CLUTTER_ACTOR(context->playback_group_));
    } else {
        clutter_actor_hide_all(CLUTTER_ACTOR(context->playback_group_));
    }
    // // This is just a test
    // static float rot = 0.0f;
    // rot += 1.0f;
    // clutter_actor_set_rotation(CLUTTER_ACTOR(context->live_input_texture_), CLUTTER_Z_AXIS, rot, 160.0f, 120.0f, 0.0f);
}