Simple scrolling and drawing added

This commit is contained in:
Joel Holdsworth 2008-05-31 13:22:15 +01:00
parent fe975a701d
commit 7e2092825e
10 changed files with 512 additions and 80 deletions

View file

@ -33,47 +33,53 @@ 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/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:

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,13 +20,11 @@
* *****************************************************/
#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 {
@ -34,38 +32,76 @@ namespace widgets {
TimelineWidget::TimelineWidget() :
Table(2, 2),
horizontalAdjustment(0, 200, 400),
verticalAdjustment(0, 200, 400),
totalHeight(0),
horizontalAdjustment(0, 0, 0),
verticalAdjustment(0, 0, 0),
horizontalScroll(horizontalAdjustment),
verticalScroll(verticalAdjustment),
rowHeaderViewport(),
label1("label1"), label2("label2"), label3("label3"), label4("label4"),
label5("label5"), label6("label6"), label7("label7"), label8("label8"),
label9("label1"), label10("label10"), label11("label11"), ruler("ruler")
ruler("ruler")
{
rowHeaderBox.pack_start(label1);
rowHeaderBox.pack_start(label2);
rowHeaderBox.pack_start(label3);
rowHeaderBox.pack_start(label4);
rowHeaderBox.pack_start(label5);
rowHeaderBox.pack_start(label6);
rowHeaderBox.pack_start(label7);
rowHeaderBox.pack_start(label8);
rowHeaderBox.pack_start(label9);
rowHeaderBox.pack_start(label10);
rowHeaderBox.pack_start(label11);
rowHeaderViewport.add(rowHeaderBox);
rowHeaderLayout.set_size_request(100, 100);
rowHeaderViewport.set_hadjustment(horizontalAdjustment);
rowHeaderViewport.set_vadjustment(verticalAdjustment);
body = new TimelineBody(horizontalAdjustment, verticalAdjustment);
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(rowHeaderViewport, 0, 1, 1, 2, SHRINK, FILL|EXPAND);
attach(rowHeaderLayout, 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);
layout_tracks();
}
TimelineWidget::~TimelineWidget()
{
delete body;
}
void
TimelineWidget::on_scroll()
{
move_headers();
}
void
TimelineWidget::layout_tracks()
{
vector<timeline::Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
rowHeaderLayout.put(track->get_header_widget(), 0, 0);
}
move_headers();
}
void
TimelineWidget::move_headers()
{
int offset = 0;
const int y_scroll_offset = (int)verticalAdjustment.get_value();
vector<Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
const int height = track->get_track_height();
rowHeaderLayout.move(track->get_header_widget(), 0, offset - y_scroll_offset);
offset += height;
}
totalHeight = offset;
verticalAdjustment.set_upper(totalHeight);
}
} // 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,40 +19,63 @@
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/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::Table
{
public:
TimelineWidget();
class TimelineWidget : public Gtk::Table
{
public:
TimelineWidget();
/* ===== Overrides ===== */
protected:
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
Gtk::HScrollbar horizontalScroll;
Gtk::VScrollbar verticalScroll;
~TimelineWidget();
Gtk::Viewport rowHeaderViewport;
Gtk::VBox rowHeaderBox;
Gtk::Label label1, label2, label3, label4;
Gtk::Label label5, label6, label7, label8;
Gtk::Label label9, label10, label11, label12;
Gtk::Label ruler;
};
/* ===== Events ===== */
protected:
void on_scroll();
/* ===== Internals ===== */
protected:
void layout_tracks();
void move_headers();
protected:
int totalHeight;
timeline::VideoTrack video1;
timeline::VideoTrack video2;
std::vector<timeline::Track*> tracks;
Gtk::Layout rowHeaderLayout;
Gtk::Label ruler;
timeline::TimelineBody *body;
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
Gtk::HScrollbar horizontalScroll;
Gtk::VScrollbar verticalScroll;
friend class timeline::TimelineBody;
};
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // TIMELINE_WIDGET_HPP

View file

@ -0,0 +1,87 @@
/*
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"
using namespace Gtk;
using namespace std;
using namespace lumiera::gui::widgets::timeline;
namespace lumiera {
namespace gui {
namespace widgets {
namespace timeline {
TimelineBody::TimelineBody(lumiera::gui::widgets::TimelineWidget &timeline_widget) :
timelineWidget(timeline_widget)
{
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) );
}
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)
{
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
cr->set_line_width(10.0);
cr->translate(-horizontalAdjustment.get_value(), -verticalAdjustment.get_value());
cr->save();
vector<timeline::Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
track->draw_track();
}
cr->restore();
}
return true;
}
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera

View file

@ -0,0 +1,56 @@
/*
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 {
namespace timeline {
class TimelineBody : public Gtk::DrawingArea
{
public:
TimelineBody(lumiera::gui::widgets::TimelineWidget &timeline_widget);
protected:
lumiera::gui::widgets::TimelineWidget &timelineWidget;
/* ===== Events ===== */
protected:
void on_scroll();
virtual bool on_expose_event(GdkEventExpose* event);
};
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // TIMELINE_BODY_HPP

View file

@ -0,0 +1,51 @@
/*
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";
}
void
Track::draw_track()
{
}
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera

View file

@ -0,0 +1,59 @@
/*
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_track_height() = 0;
virtual void draw_track();
protected:
};
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // TRACK_HPP

View file

@ -0,0 +1,56 @@
/*
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")
{
}
Gtk::Widget& VideoTrack::get_header_widget()
{
return headerWidget;
}
int VideoTrack::get_track_height()
{
return 100;
}
void VideoTrack::draw_track()
{
}
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera

View file

@ -0,0 +1,57 @@
/*
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_track_height();
virtual void draw_track();
protected:
Gtk::Label headerWidget;
};
} // namespace timeline
} // namespace widgets
} // namespace gui
} // namespace lumiera
#endif // VIDEO_TRACK_HPP

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 ===== */