/* timeline-ruler.cpp - Implementation of the time ruler 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-ruler.hpp" #include "../../window-manager.hpp" extern "C" { #include "../../../lib/time.h" } using namespace Gtk; using namespace std; using namespace lumiera::gui; using namespace lumiera::gui::widgets; using namespace lumiera::gui::widgets::timeline; namespace lumiera { namespace gui { namespace widgets { namespace timeline { TimelineRuler::TimelineRuler() : Glib::ObjectBase("TimelineRuler"), timeOffset(0), timeScale(1), annotationHorzMargin(0), annotationVertMargin(0), majorTickHeight(0), minorLongTickHeight(0), minorShortTickHeight(0), minDivisionWidth(100) { set_flags(Gtk::NO_WINDOW); // This widget will not have a window // Install style properties register_styles(); } void TimelineRuler::set_time_offset(gavl_time_t time_offset) { timeOffset = time_offset; queue_draw(); } void TimelineRuler::set_time_scale(int64_t time_scale) { REQUIRE(time_scale > 0); timeScale = time_scale; queue_draw(); } void TimelineRuler::on_realize() { Widget::on_realize(); // Load styles read_styles(); } bool TimelineRuler::on_expose_event(GdkEventExpose* event) { // This is where we draw on the window Glib::RefPtr window = get_window(); if(!window) return false; // Prepare to render via cairo Allocation allocation = get_allocation(); const int height = allocation.get_height(); Glib::RefPtr