Merge commit 'HEAD'; branch 'timelinework' into gui

This commit is contained in:
Joel Holdsworth 2008-06-05 21:00:42 +01:00
commit 9598b92d7e
15 changed files with 1028 additions and 1568 deletions

View file

@ -33,47 +33,55 @@ AM_CFLAGS =\
bin_PROGRAMS += lumigui
lumigui_SOURCES = \
$(lumigui_srcdir)/gtk-lumiera.cpp \
$(lumigui_srcdir)/gtk-lumiera.hpp \
$(lumigui_srcdir)/window-manager.cpp \
$(lumigui_srcdir)/window-manager.hpp \
$(lumigui_srcdir)/workspace/actions.cpp \
$(lumigui_srcdir)/workspace/actions.hpp \
$(lumigui_srcdir)/workspace/workspace-window.cpp \
$(lumigui_srcdir)/workspace/workspace-window.hpp \
$(lumigui_srcdir)/dialogs/render.cpp \
$(lumigui_srcdir)/dialogs/render.hpp \
$(lumigui_srcdir)/dialogs/preferences-dialog.cpp \
$(lumigui_srcdir)/dialogs/preferences-dialog.hpp \
$(lumigui_srcdir)/panels/panel.cpp \
$(lumigui_srcdir)/panels/panel.hpp \
$(lumigui_srcdir)/panels/timeline-panel.cpp \
$(lumigui_srcdir)/panels/timeline-panel.hpp \
$(lumigui_srcdir)/panels/viewer-panel.cpp \
$(lumigui_srcdir)/panels/viewer-panel.hpp \
$(lumigui_srcdir)/panels/assets-panel.cpp \
$(lumigui_srcdir)/panels/asset-panels.hpp \
$(lumigui_srcdir)/widgets/video-display-widget.cpp \
$(lumigui_srcdir)/widgets/video-display-widget.hpp \
$(lumigui_srcdir)/widgets/timeline-widget.cpp \
$(lumigui_srcdir)/widgets/timeline-widget.hpp \
$(lumigui_srcdir)/model/project.cpp \
$(lumigui_srcdir)/model/project.hpp \
$(lumigui_srcdir)/output/displayer.cpp \
$(lumigui_srcdir)/output/displayer.hpp \
$(lumigui_srcdir)/output/gdkdisplayer.cpp \
$(lumigui_srcdir)/output/gdkdisplayer.hpp \
$(lumigui_srcdir)/output/xvdisplayer.cpp \
lumigui_SOURCES = \
$(lumigui_srcdir)/gtk-lumiera.cpp \
$(lumigui_srcdir)/gtk-lumiera.hpp \
$(lumigui_srcdir)/window-manager.cpp \
$(lumigui_srcdir)/window-manager.hpp \
$(lumigui_srcdir)/workspace/actions.cpp \
$(lumigui_srcdir)/workspace/actions.hpp \
$(lumigui_srcdir)/workspace/workspace-window.cpp \
$(lumigui_srcdir)/workspace/workspace-window.hpp \
$(lumigui_srcdir)/dialogs/render.cpp \
$(lumigui_srcdir)/dialogs/render.hpp \
$(lumigui_srcdir)/dialogs/preferences-dialog.cpp \
$(lumigui_srcdir)/dialogs/preferences-dialog.hpp \
$(lumigui_srcdir)/panels/panel.cpp \
$(lumigui_srcdir)/panels/panel.hpp \
$(lumigui_srcdir)/panels/timeline-panel.cpp \
$(lumigui_srcdir)/panels/timeline-panel.hpp \
$(lumigui_srcdir)/panels/viewer-panel.cpp \
$(lumigui_srcdir)/panels/viewer-panel.hpp \
$(lumigui_srcdir)/panels/assets-panel.cpp \
$(lumigui_srcdir)/panels/asset-panels.hpp \
$(lumigui_srcdir)/widgets/video-display-widget.cpp \
$(lumigui_srcdir)/widgets/video-display-widget.hpp \
$(lumigui_srcdir)/widgets/timeline-widget.cpp \
$(lumigui_srcdir)/widgets/timeline-widget.hpp \
$(lumigui_srcdir)/widgets/timeline/header-container.cpp \
$(lumigui_srcdir)/widgets/timeline/header-container.hpp \
$(lumigui_srcdir)/widgets/timeline/track.cpp \
$(lumigui_srcdir)/widgets/timeline/track.hpp \
$(lumigui_srcdir)/widgets/timeline/video-track.cpp \
$(lumigui_srcdir)/widgets/timeline/video-track.hpp \
$(lumigui_srcdir)/widgets/timeline/timeline-body.cpp \
$(lumigui_srcdir)/widgets/timeline/timeline-body.hpp \
$(lumigui_srcdir)/model/project.cpp \
$(lumigui_srcdir)/model/project.hpp \
$(lumigui_srcdir)/output/displayer.cpp \
$(lumigui_srcdir)/output/displayer.hpp \
$(lumigui_srcdir)/output/gdkdisplayer.cpp \
$(lumigui_srcdir)/output/gdkdisplayer.hpp \
$(lumigui_srcdir)/output/xvdisplayer.cpp \
$(lumigui_srcdir)/output/xvdisplayer.hpp
lumigui_LDFLAGS =
lumigui_LDADD = $(GTK_LUMIERA_LIBS)
lumigui_DEPENDENCIES = \
$(top_builddir)/lumiera_ui.rc \
$(top_builddir)/assets-panel.png \
$(top_builddir)/timeline-panel.png \
lumigui_DEPENDENCIES = \
$(top_builddir)/lumiera_ui.rc \
$(top_builddir)/assets-panel.png \
$(top_builddir)/timeline-panel.png \
$(top_builddir)/viewer-panel.png
$(top_builddir)/lumiera_ui.rc:

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,8 @@
#include "../gtk-lumiera.hpp"
#include "timeline-panel.hpp"
using namespace Gtk;
namespace lumiera {
namespace gui {
namespace panels {
@ -30,7 +32,7 @@ namespace panels {
TimelinePanel::TimelinePanel() :
Panel("timeline", _("Timeline"), "timeline_panel")
{
pack_start(timeline_widget);
pack_start(timeline_widget, PACK_EXPAND_WIDGET);
}
} // namespace panels

View file

@ -1,5 +1,5 @@
/*
timeline.cpp - Implementation of the timeline widget
timeline-widget.cpp - Implementation of the timeline widget
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
@ -20,54 +20,117 @@
* *****************************************************/
#include <gdkmm/drawable.h>
#include <gdkmm/general.h>
#include <cairomm-1.0/cairomm/cairomm.h>
#include "timeline-widget.hpp"
using namespace Gtk;
using namespace std;
using namespace lumiera::gui::widgets::timeline;
namespace lumiera {
namespace gui {
namespace widgets {
TimelineWidget::TimelineWidget()
const int TimelineWidget::TrackPadding = 1;
const int TimelineWidget::HeaderWidth = 100;
TimelineWidget::TimelineWidget() :
Table(2, 2),
totalHeight(0),
horizontalAdjustment(0, 0, 0),
verticalAdjustment(0, 0, 0),
horizontalScroll(horizontalAdjustment),
verticalScroll(verticalAdjustment),
ruler("ruler")
{
set_flags(Gtk::NO_WINDOW);
body = new TimelineBody(this);
g_assert(body != NULL);
headerContainer = new HeaderContainer(this);
g_assert(headerContainer != NULL);
verticalAdjustment.signal_value_changed().connect(
sigc::mem_fun(this, &TimelineWidget::on_scroll) );
attach(*body, 1, 2, 1, 2, FILL|EXPAND, FILL|EXPAND);
attach(ruler, 1, 2, 0, 1, FILL|EXPAND, SHRINK);
attach(*headerContainer, 0, 1, 1, 2, SHRINK, FILL|EXPAND);
attach(horizontalScroll, 1, 2, 2, 3, FILL|EXPAND, SHRINK);
attach(verticalScroll, 2, 3, 1, 2, SHRINK, FILL|EXPAND);
tracks.push_back(&video1);
tracks.push_back(&video2);
update_tracks();
}
TimelineWidget::~TimelineWidget()
{
g_assert(body != NULL);
delete body;
g_assert(headerContainer != NULL);
delete headerContainer;
}
void
TimelineWidget::on_realize()
TimelineWidget::on_scroll()
{
//Call base class:
Gtk::Widget::on_realize();
}
bool
TimelineWidget::on_expose_event(GdkEventExpose* event)
void
TimelineWidget::on_size_allocate(Allocation& allocation)
{
// This is where we draw on the window
Glib::RefPtr<Gdk::Window> window = get_window();
if(window)
{
/*Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
if(event)
Widget::on_size_allocate(allocation);
update_scroll();
}
void
TimelineWidget::update_tracks()
{
g_assert(headerContainer != NULL);
headerContainer->update_headers();
// Recalculate the total height of the timeline scrolled area
totalHeight = 0;
vector<timeline::Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
// clip to the area that needs to be re-exposed so we don't draw any
// more than we need to.
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
}
// Paint the background
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->paint();*/
}
return true;
timeline::Track *track = *i;
g_assert(track != NULL);
totalHeight += track->get_height() + TrackPadding;
}
}
void
TimelineWidget::update_scroll()
{
g_assert(body != NULL);
const Allocation body_allocation = body->get_allocation();
// Calculate the length that can be scrolled:
// the total height of all the tracks minus one screenful
int y_scroll_length = totalHeight - body_allocation.get_height();
if(y_scroll_length < 0) y_scroll_length = 0;
// If by resizing we're now over-scrolled, scroll back to
// maximum distance
if((int)verticalAdjustment.get_value() > y_scroll_length)
verticalAdjustment.set_value(y_scroll_length);
verticalAdjustment.set_upper(y_scroll_length);
// Hide the scrollbar if no scrolling is possible
if(y_scroll_length == 0 && verticalScroll.is_visible())
verticalScroll.hide();
else if(y_scroll_length != 0 && !verticalScroll.is_visible())
verticalScroll.show();
}
int
TimelineWidget::get_y_scroll_offset() const
{
return (int)verticalAdjustment.get_value();
}
} // namespace widgets
} // namespace gui

View file

@ -1,5 +1,5 @@
/*
timeline.hpp - Declaration of the timeline widget
timeline-widget.hpp - Declaration of the timeline widget
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
@ -19,32 +19,74 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file timeline.hpp
/** @file timeline-widget.hpp
** This file contains the definition of timeline widget
*/
#ifndef TIMELINE_WIDGET_HPP
#define TIMELINE_WIDGET_HPP
#include "timeline/header-container.hpp"
#include "timeline/timeline-body.hpp"
#include "timeline/track.hpp"
#include "timeline/video-track.hpp"
#include <gtkmm.h>
#include <vector>
namespace lumiera {
namespace gui {
namespace widgets {
class TimelineWidget : public Gtk::Widget
{
public:
TimelineWidget();
class TimelineWidget : public Gtk::Table
{
public:
TimelineWidget();
/* ===== Overrides ===== */
protected:
virtual void on_realize();
virtual bool on_expose_event(GdkEventExpose* event);
};
~TimelineWidget();
/* ===== Events ===== */
protected:
void on_scroll();
void on_size_allocate(Gtk::Allocation& allocation);
/* ===== Internals ===== */
protected:
void update_tracks();
void update_scroll();
int get_y_scroll_offset() const;
protected:
int totalHeight;
timeline::VideoTrack video1;
timeline::VideoTrack video2;
std::vector<timeline::Track*> tracks;
timeline::TimelineBody *body;
timeline::HeaderContainer *headerContainer;
Gtk::Label ruler;
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
Gtk::HScrollbar horizontalScroll;
Gtk::VScrollbar verticalScroll;
/* ===== Constants ===== */
protected:
static const int TrackPadding;
static const int HeaderWidth;
friend class timeline::TimelineBody;
friend class timeline::HeaderContainer;
};
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // TIMELINE_WIDGET_HPP

View file

@ -0,0 +1,193 @@
/*
header-container.cpp - Implementation of the header container widget
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
#include "header-container.hpp"
#include "track.hpp"
#include "../timeline-widget.hpp"
using namespace Gtk;
using namespace std;
namespace lumiera {
namespace gui {
namespace widgets {
namespace timeline {
HeaderContainer::HeaderContainer(lumiera::gui::widgets::TimelineWidget *timeline_widget) :
timelineWidget(timeline_widget)
{
set_flags(Gtk::NO_WINDOW);
set_redraw_on_allocate(false);
timelineWidget->verticalAdjustment.signal_value_changed().connect(
sigc::mem_fun(this, &HeaderContainer::on_scroll) );
}
void
HeaderContainer::update_headers()
{
g_assert(timelineWidget != NULL);
vector<timeline::Track*> &tracks = timelineWidget->tracks;
vector<timeline::Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
Widget &header = track->get_header_widget();
header.set_parent(*this);
header.show();
}
layout_headers();
}
void
HeaderContainer::on_realize()
{
set_flags(Gtk::NO_WINDOW);
ensure_style();
// Call base class:
Gtk::Widget::on_realize();
// Create the GdkWindow:
GdkWindowAttr attributes;
memset(&attributes, 0, sizeof(attributes));
Allocation allocation = get_allocation();
// Set initial position and size of the Gdk::Window:
attributes.x = allocation.get_x();
attributes.y = allocation.get_y();
attributes.width = allocation.get_width();
attributes.height = allocation.get_height();
attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
gdkWindow = Gdk::Window::create(get_window() /* parent */, &attributes,
GDK_WA_X | GDK_WA_Y);
unset_flags(Gtk::NO_WINDOW);
set_window(gdkWindow);
// Unset the background so as to make the colour match the parent window
unset_bg(STATE_NORMAL);
// Make the widget receive expose events
gdkWindow->set_user_data(gobj());
}
void
HeaderContainer::on_unrealize()
{
gdkWindow.clear();
//Call base class:
Gtk::Widget::on_unrealize();
}
void
HeaderContainer::on_size_request (Requisition* requisition)
{
//Initialize the output parameter:
*requisition = Gtk::Requisition();
requisition->width = TimelineWidget::HeaderWidth;
requisition->height = 0;
}
void
HeaderContainer::on_size_allocate (Allocation& allocation)
{
// Use the offered allocation for this container:
set_allocation(allocation);
// Resize the widget's window
if(gdkWindow)
gdkWindow->resize(allocation.get_width(), allocation.get_height());
// Relayout the child widgets of the headers
layout_headers();
}
void
HeaderContainer::forall_vfunc(gboolean /* include_internals */,
GtkCallback callback, gpointer callback_data)
{
g_assert(timelineWidget != NULL);
vector<timeline::Track*> &tracks = timelineWidget->tracks;
vector<timeline::Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
callback(track->get_header_widget().gobj(),
callback_data);
}
}
void
HeaderContainer::on_scroll()
{
layout_headers();
}
void
HeaderContainer::layout_headers()
{
g_assert(timelineWidget != NULL);
int offset = 0;
const int y_scroll_offset = timelineWidget->get_y_scroll_offset();
const Allocation container_allocation = get_allocation();
vector<timeline::Track*> &tracks = timelineWidget->tracks;
vector<timeline::Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
Widget &header = track->get_header_widget();
const int height = 100;//header->get_track_height();
Gtk::Allocation header_allocation;
header_allocation.set_x (0);
header_allocation.set_y (offset - y_scroll_offset);
header_allocation.set_width (container_allocation.get_width ());
header_allocation.set_height (height);
header.size_allocate(header_allocation);
offset += height + TimelineWidget::TrackPadding;
}
}
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera

View file

@ -0,0 +1,76 @@
/*
header-container.hpp - Declaration of the header container widget
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file header-container.hpp
** This file contains the definition of the header container
** widget
*/
#ifndef HEADER_CONTAINER_HPP
#define HEADER_CONTAINER_HPP
#include <gtkmm.h>
#include <vector>
namespace lumiera {
namespace gui {
namespace widgets {
class TimelineWidget;
namespace timeline {
class HeaderContainer : public Gtk::Container
{
public:
HeaderContainer(lumiera::gui::widgets::TimelineWidget *timeline_widget);
void update_headers();
private:
void on_realize();
void on_unrealize();
void on_size_allocate (Gtk::Allocation& allocation);
void on_size_request (Gtk::Requisition* requisition);
void forall_vfunc(gboolean include_internals, GtkCallback callback,
gpointer callback_data);
void on_scroll();
/* ===== Internals ===== */
private:
void layout_headers();
private:
lumiera::gui::widgets::TimelineWidget *timelineWidget;
Glib::RefPtr<Gdk::Window> gdkWindow;
};
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // HEADER_CONTAINER_HPP

View file

@ -0,0 +1,137 @@
/*
timeline.cpp - Implementation of the timeline widget
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
#include <cairomm-1.0/cairomm/cairomm.h>
#include "timeline-body.hpp"
#include "../timeline-widget.hpp"
using namespace Gtk;
using namespace std;
using namespace lumiera::gui::widgets;
using namespace lumiera::gui::widgets::timeline;
namespace lumiera {
namespace gui {
namespace widgets {
namespace timeline {
TimelineBody::TimelineBody(lumiera::gui::widgets::TimelineWidget *timeline_widget) :
Glib::ObjectBase("TimelineBody"),
timelineWidget(timeline_widget)
{
g_assert(timelineWidget != NULL);
// Connect up some events
timelineWidget->horizontalAdjustment.signal_value_changed().connect(
sigc::mem_fun(this, &TimelineBody::on_scroll) );
timelineWidget->verticalAdjustment.signal_value_changed().connect(
sigc::mem_fun(this, &TimelineBody::on_scroll) );
// Install style properties
gtk_widget_class_install_style_property(
GTK_WIDGET_CLASS(G_OBJECT_GET_CLASS(gobj())),
g_param_spec_boxed("track_background",
"Track Background",
"The background colour of timeline tracks",
GDK_TYPE_COLOR, G_PARAM_READABLE));
}
void
TimelineBody::on_scroll()
{
queue_draw();
}
bool
TimelineBody::on_expose_event(GdkEventExpose* event)
{
// This is where we draw on the window
Glib::RefPtr<Gdk::Window> window = get_window();
if(!window)
return false;
// Makes sure the widget styles have been loaded
read_styles();
// Prepare to render via cairo
Gtk::Allocation allocation = get_allocation();
Cairo::RefPtr<Cairo::Context> cairo = window->create_cairo_context();
// Translate the view by the scroll distance
cairo->translate(
-(int)timelineWidget->horizontalAdjustment.get_value(),
-(int)timelineWidget->verticalAdjustment.get_value());
// Interate drawing each track
vector<timeline::Track*>::iterator i;
for(i = timelineWidget->tracks.begin();
i != timelineWidget->tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
const int track_height = track->get_height();
// Draw the track background
cairo->rectangle(0, 0, allocation.get_width(), track_height);
gdk_cairo_set_source_color(cairo->cobj(), &track_background);
cairo->fill();
// Render the track
cairo->save();
track->draw_track(cairo);
cairo->restore();
// Shift for the next track
cairo->translate(0, track_height + TimelineWidget::TrackPadding);
}
return true;
}
void
TimelineBody::read_styles()
{
GdkColor *colour;
gtk_widget_style_get(Widget::gobj(), "track_background", &colour, NULL);
// Did the color load successfully?
if(colour != NULL)
track_background = *colour;
else
{
g_warning("track_background style value failed to load");
track_background.red = 0x0000;
track_background.green = 0x0000;
track_background.blue = 0x0000;
track_background.pixel = 0x00000000;
}
}
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera

View file

@ -0,0 +1,65 @@
/*
timeline-body.hpp - Declaration of the timeline body widget
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file timeline-body.hpp
** This file contains the definition of timeline body widget
*/
#ifndef TIMELINE_BODY_HPP
#define TIMELINE_BODY_HPP
#include <gtkmm.h>
namespace lumiera {
namespace gui {
namespace widgets {
class TimelineWidget;
namespace timeline {
class TimelineBody : public Gtk::DrawingArea
{
public:
TimelineBody(lumiera::gui::widgets::TimelineWidget *timeline_widget);
/* ===== Events ===== */
protected:
void on_scroll();
virtual bool on_expose_event(GdkEventExpose* event);
/* ===== Internals ===== */
private:
void read_styles();
private:
GdkColor track_background;
lumiera::gui::widgets::TimelineWidget *timelineWidget;
};
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // TIMELINE_BODY_HPP

View file

@ -0,0 +1,57 @@
/*
track.cpp - Implementation of the timeline track object
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
#include "track.hpp"
namespace lumiera {
namespace gui {
namespace widgets {
namespace timeline {
Track::Track()
{
}
Glib::ustring
Track::get_title()
{
return "Hello";
}
int
Track::get_height()
{
return get_header_widget().get_allocation().get_height();
}
void
Track::draw_track(Cairo::RefPtr<Cairo::Context> cairo)
{
}
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera

View file

@ -0,0 +1,58 @@
/*
track.hpp - Declaration of the timeline track object
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file track.hpp
** This file contains the definition of timeline track object
*/
#ifndef TRACK_HPP
#define TRACK_HPP
#include <gtkmm.h>
namespace lumiera {
namespace gui {
namespace widgets {
namespace timeline {
class Track
{
public:
Track();
Glib::ustring get_title();
virtual Gtk::Widget& get_header_widget() = 0;
virtual int get_height();
virtual void draw_track(Cairo::RefPtr<Cairo::Context> cairo);
protected:
};
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // TRACK_HPP

View file

@ -0,0 +1,62 @@
/*
video-track.cpp - Implementation of the timeline video track object
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
#include "video-track.hpp"
using namespace Gtk;
namespace lumiera {
namespace gui {
namespace widgets {
namespace timeline {
VideoTrack::VideoTrack() :
headerWidget("HeaderTest")
{
headerFrame.add(headerWidget);
headerFrame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
headerFrame.set_name ("TimelineHeaderBaseUnselected");
}
Gtk::Widget&
VideoTrack::get_header_widget()
{
return headerFrame;
}
/*int
VideoTrack::get_height()
{
return 100;
}*/
void
VideoTrack::draw_track(Cairo::RefPtr<Cairo::Context> cairo)
{
}
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera

View file

@ -0,0 +1,58 @@
/*
video-track.hpp - Declaration of the timeline video track object
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
This program 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.
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file video-track.hpp
** This file contains the definition of video track object
*/
#ifndef VIDEO_TRACK_HPP
#define VIDEO_TRACK_HPP
#include "track.hpp"
namespace lumiera {
namespace gui {
namespace widgets {
namespace timeline {
class VideoTrack : public Track
{
public:
VideoTrack();
virtual Gtk::Widget& get_header_widget();
//virtual int get_height();
virtual void draw_track(Cairo::RefPtr<Cairo::Context> cairo);
protected:
Gtk::Label headerWidget;
Gtk::Frame headerFrame;
};
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // VIDEO_TRACK_HPP

View file

@ -36,123 +36,123 @@ namespace widgets {
VideoDisplayWidget::VideoDisplayWidget() :
gdkWindow(NULL),
displayer(NULL)
{
set_flags(Gtk::NO_WINDOW);
}
{
set_flags(Gtk::NO_WINDOW);
}
VideoDisplayWidget::~VideoDisplayWidget()
{
if(displayer != NULL)
delete displayer;
}
{
if(displayer != NULL)
delete displayer;
}
void
VideoDisplayWidget::on_realize()
{
set_flags(Gtk::NO_WINDOW);
{
set_flags(Gtk::NO_WINDOW);
//Call base class:
Gtk::Widget::on_realize();
// Call base class:
Gtk::Widget::on_realize();
//Create the GdkWindow:
GdkWindowAttr attributes;
memset(&attributes, 0, sizeof(attributes));
// Create the GdkWindow:
GdkWindowAttr attributes;
memset(&attributes, 0, sizeof(attributes));
Gtk::Allocation allocation = get_allocation();
Gtk::Allocation allocation = get_allocation();
//Set initial position and size of the Gdk::Window:
attributes.x = allocation.get_x();
attributes.y = allocation.get_y();
attributes.width = allocation.get_width();
attributes.height = allocation.get_height();
// Set initial position and size of the Gdk::Window:
attributes.x = allocation.get_x();
attributes.y = allocation.get_y();
attributes.width = allocation.get_width();
attributes.height = allocation.get_height();
attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
gdkWindow = Gdk::Window::create(get_window() /* parent */, &attributes,
GDK_WA_X | GDK_WA_Y);
unset_flags(Gtk::NO_WINDOW);
set_window(gdkWindow);
gdkWindow = Gdk::Window::create(get_window() /* parent */, &attributes,
GDK_WA_X | GDK_WA_Y);
unset_flags(Gtk::NO_WINDOW);
set_window(gdkWindow);
//set colors
modify_bg(Gtk::STATE_NORMAL, Gdk::Color("black"));
// Set colors
modify_bg(Gtk::STATE_NORMAL, Gdk::Color("black"));
//make the widget receive expose events
gdkWindow->set_user_data(gobj());
// Make the widget receive expose events
gdkWindow->set_user_data(gobj());
if(displayer != NULL)
delete displayer;
displayer = createDisplayer(this, 320, 240);
if(displayer != NULL)
delete displayer;
displayer = createDisplayer(this, 320, 240);
add_events(Gdk::ALL_EVENTS_MASK);
}
add_events(Gdk::ALL_EVENTS_MASK);
}
void
VideoDisplayWidget::on_unrealize()
{
gdkWindow.clear();
{
gdkWindow.clear();
//Call base class:
Gtk::Widget::on_unrealize();
}
//Call base class:
Gtk::Widget::on_unrealize();
}
bool
VideoDisplayWidget::on_button_press_event (GdkEventButton* event)
{
unsigned char buffer[320 * 240 * 4];
{
unsigned char buffer[320 * 240 * 4];
for(int i = 0; i < 320*240*4; i++)
buffer[i] = rand();
for(int i = 0; i < 320*240*4; i++)
buffer[i] = rand();
displayer->put((void*)buffer);
displayer->put((void*)buffer);
return true;
}
return true;
}
bool
VideoDisplayWidget::on_expose_event(GdkEventExpose* event)
{
// This is where we draw on the window
/*Glib::RefPtr<Gdk::Window> window = get_window();
if(window)
{
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
if(event)
// This is where we draw on the window
/*Glib::RefPtr<Gdk::Window> window = get_window();
if(window)
{
// clip to the area that needs to be re-exposed so we don't draw any
// more than we need to.
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
}
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
if(event)
{
// clip to the area that needs to be re-exposed so we don't draw any
// more than we need to.
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
}
// Paint the background
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->paint();
}*/
return true;
}
// Paint the background
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->paint();
}*/
return true;
}
Displayer*
VideoDisplayWidget::createDisplayer( Gtk::Widget *drawingArea, int width, int height )
{
Displayer *displayer = NULL;
displayer = new XvDisplayer( drawingArea, width, height );
if ( !displayer->usable() )
{
delete displayer;
displayer = NULL;
}
Displayer *displayer = NULL;
if ( displayer == NULL )
{
displayer = new GdkDisplayer( drawingArea, width, height );
}
displayer = new XvDisplayer( drawingArea, width, height );
if ( !displayer->usable() )
{
delete displayer;
displayer = NULL;
}
return displayer;
}
if ( displayer == NULL )
{
displayer = new GdkDisplayer( drawingArea, width, height );
}
return displayer;
}
} // namespace widgets
} // namespace gui

View file

@ -51,6 +51,7 @@ namespace widgets {
virtual bool on_expose_event(GdkEventExpose* event);
// TEST CODE!!!!
virtual bool on_button_press_event (GdkEventButton* event);
/* ===== Internals ===== */