Track backgrounds are now painted from the style
This commit is contained in:
parent
71b45acf54
commit
e9747b360c
4 changed files with 37 additions and 27 deletions
|
|
@ -112,7 +112,7 @@ class "GtkProgressBar" style:highest "lumiera_progressbars"
|
|||
|
||||
style "timeline_body"
|
||||
{
|
||||
gtkmm__CustomObject_TimelineBody::track_background = "#FF7F00"
|
||||
gtkmm__CustomObject_TimelineBody::track_background = "#7E838B"
|
||||
}
|
||||
|
||||
class "gtkmm__CustomObject_TimelineBody" style:highest "timeline_body"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ namespace lumiera {
|
|||
namespace gui {
|
||||
namespace widgets {
|
||||
|
||||
const int TimelineWidget::TrackPadding = 1;
|
||||
|
||||
TimelineWidget::TimelineWidget() :
|
||||
Table(2, 2),
|
||||
totalHeight(0),
|
||||
|
|
@ -39,7 +41,7 @@ TimelineWidget::TimelineWidget() :
|
|||
verticalScroll(verticalAdjustment),
|
||||
ruler("ruler")
|
||||
{
|
||||
rowHeaderLayout.set_size_request(100, 100);
|
||||
rowHeaderLayout.set_size_request(100, 0);
|
||||
|
||||
body = new TimelineBody(this);
|
||||
|
||||
|
|
@ -97,7 +99,7 @@ TimelineWidget::move_headers()
|
|||
|
||||
const int height = track->get_track_height();
|
||||
rowHeaderLayout.move(track->get_header_widget(), 0, offset - y_scroll_offset);
|
||||
offset += height;
|
||||
offset += height + TrackPadding;
|
||||
}
|
||||
totalHeight = offset;
|
||||
verticalAdjustment.set_upper(totalHeight);
|
||||
|
|
|
|||
|
|
@ -69,6 +69,10 @@ class TimelineWidget : public Gtk::Table
|
|||
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
|
||||
Gtk::HScrollbar horizontalScroll;
|
||||
Gtk::VScrollbar verticalScroll;
|
||||
|
||||
/* ===== Constants ===== */
|
||||
protected:
|
||||
static const int TrackPadding;
|
||||
|
||||
friend class timeline::TimelineBody;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
using namespace Gtk;
|
||||
using namespace std;
|
||||
using namespace lumiera::gui::widgets;
|
||||
using namespace lumiera::gui::widgets::timeline;
|
||||
|
||||
namespace lumiera {
|
||||
|
|
@ -69,41 +70,44 @@ TimelineBody::on_expose_event(GdkEventExpose* event)
|
|||
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||
if(!window)
|
||||
return false;
|
||||
|
||||
read_styles();
|
||||
|
||||
|
||||
Gtk::Allocation allocation = get_allocation();
|
||||
const int width = allocation.get_width();
|
||||
const int height = allocation.get_height();
|
||||
|
||||
Cairo::RefPtr<Cairo::Context> cairo = window->create_cairo_context();
|
||||
cairo->set_line_width(10.0);
|
||||
|
||||
cairo->rectangle(50, 50, 100, 100);
|
||||
gdk_cairo_set_source_color(cairo->cobj(), &track_background);
|
||||
|
||||
cairo->fill_preserve();
|
||||
|
||||
// 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(
|
||||
-timelineWidget->horizontalAdjustment.get_value(),
|
||||
-timelineWidget->verticalAdjustment.get_value());
|
||||
cairo->save();
|
||||
|
||||
-(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);
|
||||
track->draw_track(cairo);
|
||||
}
|
||||
g_assert(track != NULL);
|
||||
|
||||
cairo->restore();
|
||||
const int track_height = track->get_track_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
|
||||
|
|
|
|||
Loading…
Reference in a new issue