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"
|
style "timeline_body"
|
||||||
{
|
{
|
||||||
gtkmm__CustomObject_TimelineBody::track_background = "#FF7F00"
|
gtkmm__CustomObject_TimelineBody::track_background = "#7E838B"
|
||||||
}
|
}
|
||||||
|
|
||||||
class "gtkmm__CustomObject_TimelineBody" style:highest "timeline_body"
|
class "gtkmm__CustomObject_TimelineBody" style:highest "timeline_body"
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ namespace lumiera {
|
||||||
namespace gui {
|
namespace gui {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
const int TimelineWidget::TrackPadding = 1;
|
||||||
|
|
||||||
TimelineWidget::TimelineWidget() :
|
TimelineWidget::TimelineWidget() :
|
||||||
Table(2, 2),
|
Table(2, 2),
|
||||||
totalHeight(0),
|
totalHeight(0),
|
||||||
|
|
@ -39,7 +41,7 @@ TimelineWidget::TimelineWidget() :
|
||||||
verticalScroll(verticalAdjustment),
|
verticalScroll(verticalAdjustment),
|
||||||
ruler("ruler")
|
ruler("ruler")
|
||||||
{
|
{
|
||||||
rowHeaderLayout.set_size_request(100, 100);
|
rowHeaderLayout.set_size_request(100, 0);
|
||||||
|
|
||||||
body = new TimelineBody(this);
|
body = new TimelineBody(this);
|
||||||
|
|
||||||
|
|
@ -97,7 +99,7 @@ TimelineWidget::move_headers()
|
||||||
|
|
||||||
const int height = track->get_track_height();
|
const int height = track->get_track_height();
|
||||||
rowHeaderLayout.move(track->get_header_widget(), 0, offset - y_scroll_offset);
|
rowHeaderLayout.move(track->get_header_widget(), 0, offset - y_scroll_offset);
|
||||||
offset += height;
|
offset += height + TrackPadding;
|
||||||
}
|
}
|
||||||
totalHeight = offset;
|
totalHeight = offset;
|
||||||
verticalAdjustment.set_upper(totalHeight);
|
verticalAdjustment.set_upper(totalHeight);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,10 @@ class TimelineWidget : public Gtk::Table
|
||||||
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
|
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
|
||||||
Gtk::HScrollbar horizontalScroll;
|
Gtk::HScrollbar horizontalScroll;
|
||||||
Gtk::VScrollbar verticalScroll;
|
Gtk::VScrollbar verticalScroll;
|
||||||
|
|
||||||
|
/* ===== Constants ===== */
|
||||||
|
protected:
|
||||||
|
static const int TrackPadding;
|
||||||
|
|
||||||
friend class timeline::TimelineBody;
|
friend class timeline::TimelineBody;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using namespace Gtk;
|
using namespace Gtk;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace lumiera::gui::widgets;
|
||||||
using namespace lumiera::gui::widgets::timeline;
|
using namespace lumiera::gui::widgets::timeline;
|
||||||
|
|
||||||
namespace lumiera {
|
namespace lumiera {
|
||||||
|
|
@ -69,41 +70,44 @@ TimelineBody::on_expose_event(GdkEventExpose* event)
|
||||||
Glib::RefPtr<Gdk::Window> window = get_window();
|
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||||
if(!window)
|
if(!window)
|
||||||
return false;
|
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);
|
// Makes sure the widget styles have been loaded
|
||||||
gdk_cairo_set_source_color(cairo->cobj(), &track_background);
|
read_styles();
|
||||||
|
|
||||||
cairo->fill_preserve();
|
// 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(
|
cairo->translate(
|
||||||
-timelineWidget->horizontalAdjustment.get_value(),
|
-(int)timelineWidget->horizontalAdjustment.get_value(),
|
||||||
-timelineWidget->verticalAdjustment.get_value());
|
-(int)timelineWidget->verticalAdjustment.get_value());
|
||||||
cairo->save();
|
|
||||||
|
// Interate drawing each track
|
||||||
vector<timeline::Track*>::iterator i;
|
vector<timeline::Track*>::iterator i;
|
||||||
for(i = timelineWidget->tracks.begin();
|
for(i = timelineWidget->tracks.begin();
|
||||||
i != timelineWidget->tracks.end(); i++)
|
i != timelineWidget->tracks.end(); i++)
|
||||||
{
|
{
|
||||||
timeline::Track *track = *i;
|
timeline::Track *track = *i;
|
||||||
g_assert(track != NULL);
|
g_assert(track != NULL);
|
||||||
track->draw_track(cairo);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue