From 7e2092825e25a3523ec229ac7edae6934f9be497 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sat, 31 May 2008 13:22:15 +0100 Subject: [PATCH] Simple scrolling and drawing added --- src/gui/Makefile.am | 78 ++++++++++--------- src/gui/widgets/timeline-widget.cpp | 88 +++++++++++++++------- src/gui/widgets/timeline-widget.hpp | 59 ++++++++++----- src/gui/widgets/timeline/timeline-body.cpp | 87 +++++++++++++++++++++ src/gui/widgets/timeline/timeline-body.hpp | 56 ++++++++++++++ src/gui/widgets/timeline/track.cpp | 51 +++++++++++++ src/gui/widgets/timeline/track.hpp | 59 +++++++++++++++ src/gui/widgets/timeline/video-track.cpp | 56 ++++++++++++++ src/gui/widgets/timeline/video-track.hpp | 57 ++++++++++++++ src/gui/widgets/video-display-widget.hpp | 1 + 10 files changed, 512 insertions(+), 80 deletions(-) create mode 100644 src/gui/widgets/timeline/timeline-body.cpp create mode 100644 src/gui/widgets/timeline/timeline-body.hpp create mode 100644 src/gui/widgets/timeline/track.cpp create mode 100644 src/gui/widgets/timeline/track.hpp create mode 100644 src/gui/widgets/timeline/video-track.cpp create mode 100644 src/gui/widgets/timeline/video-track.hpp diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index e056225fa..b498fa3e8 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -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: diff --git a/src/gui/widgets/timeline-widget.cpp b/src/gui/widgets/timeline-widget.cpp index 4e60ba7b8..3665ec98b 100644 --- a/src/gui/widgets/timeline-widget.cpp +++ b/src/gui/widgets/timeline-widget.cpp @@ -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 @@ -20,13 +20,11 @@ * *****************************************************/ -#include -#include -#include - #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::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::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 diff --git a/src/gui/widgets/timeline-widget.hpp b/src/gui/widgets/timeline-widget.hpp index e89e684e0..7ceb3f125 100644 --- a/src/gui/widgets/timeline-widget.hpp +++ b/src/gui/widgets/timeline-widget.hpp @@ -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 @@ -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 +#include 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 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 + diff --git a/src/gui/widgets/timeline/timeline-body.cpp b/src/gui/widgets/timeline/timeline-body.cpp new file mode 100644 index 000000000..f3e204cf9 --- /dev/null +++ b/src/gui/widgets/timeline/timeline-body.cpp @@ -0,0 +1,87 @@ +/* + timeline.cpp - Implementation of the timeline widget + + Copyright (C) Lumiera.org + 2008, Joel Holdsworth + + 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 + +#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 window = get_window(); + if(window) + { + Gtk::Allocation allocation = get_allocation(); + const int width = allocation.get_width(); + const int height = allocation.get_height(); + + Cairo::RefPtr cr = window->create_cairo_context(); + cr->set_line_width(10.0); + + cr->translate(-horizontalAdjustment.get_value(), -verticalAdjustment.get_value()); + cr->save(); + + vector::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 + diff --git a/src/gui/widgets/timeline/timeline-body.hpp b/src/gui/widgets/timeline/timeline-body.hpp new file mode 100644 index 000000000..39fd8773a --- /dev/null +++ b/src/gui/widgets/timeline/timeline-body.hpp @@ -0,0 +1,56 @@ +/* + timeline-body.hpp - Declaration of the timeline body widget + + Copyright (C) Lumiera.org + 2008, Joel Holdsworth + + 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 + +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 diff --git a/src/gui/widgets/timeline/track.cpp b/src/gui/widgets/timeline/track.cpp new file mode 100644 index 000000000..c0564e37f --- /dev/null +++ b/src/gui/widgets/timeline/track.cpp @@ -0,0 +1,51 @@ +/* + track.cpp - Implementation of the timeline track object + + Copyright (C) Lumiera.org + 2008, Joel Holdsworth + + 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 + diff --git a/src/gui/widgets/timeline/track.hpp b/src/gui/widgets/timeline/track.hpp new file mode 100644 index 000000000..204b650a0 --- /dev/null +++ b/src/gui/widgets/timeline/track.hpp @@ -0,0 +1,59 @@ +/* + track.hpp - Declaration of the timeline track object + + Copyright (C) Lumiera.org + 2008, Joel Holdsworth + + 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 + +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 diff --git a/src/gui/widgets/timeline/video-track.cpp b/src/gui/widgets/timeline/video-track.cpp new file mode 100644 index 000000000..b3b45c543 --- /dev/null +++ b/src/gui/widgets/timeline/video-track.cpp @@ -0,0 +1,56 @@ +/* + video-track.cpp - Implementation of the timeline video track object + + Copyright (C) Lumiera.org + 2008, Joel Holdsworth + + 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 diff --git a/src/gui/widgets/timeline/video-track.hpp b/src/gui/widgets/timeline/video-track.hpp new file mode 100644 index 000000000..e82a178bd --- /dev/null +++ b/src/gui/widgets/timeline/video-track.hpp @@ -0,0 +1,57 @@ +/* + video-track.hpp - Declaration of the timeline video track object + + Copyright (C) Lumiera.org + 2008, Joel Holdsworth + + 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 + diff --git a/src/gui/widgets/video-display-widget.hpp b/src/gui/widgets/video-display-widget.hpp index 7a80a4b04..66e224c18 100644 --- a/src/gui/widgets/video-display-widget.hpp +++ b/src/gui/widgets/video-display-widget.hpp @@ -51,6 +51,7 @@ namespace widgets { virtual bool on_expose_event(GdkEventExpose* event); + // TEST CODE!!!! virtual bool on_button_press_event (GdkEventButton* event); /* ===== Internals ===== */