Styles for custom widgets now load
This commit is contained in:
parent
7e2092825e
commit
71b45acf54
8 changed files with 119 additions and 1440 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -41,7 +41,7 @@ TimelineWidget::TimelineWidget() :
|
|||
{
|
||||
rowHeaderLayout.set_size_request(100, 100);
|
||||
|
||||
body = new TimelineBody(horizontalAdjustment, verticalAdjustment);
|
||||
body = new TimelineBody(this);
|
||||
|
||||
verticalAdjustment.signal_value_changed().connect(
|
||||
sigc::mem_fun(this, &TimelineWidget::on_scroll) );
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include <cairomm-1.0/cairomm/cairomm.h>
|
||||
|
||||
#include "timeline-body.hpp"
|
||||
#include "../timeline-widget.hpp"
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace std;
|
||||
|
|
@ -33,13 +34,26 @@ namespace gui {
|
|||
namespace widgets {
|
||||
namespace timeline {
|
||||
|
||||
TimelineBody::TimelineBody(lumiera::gui::widgets::TimelineWidget &timeline_widget) :
|
||||
TimelineBody::TimelineBody(lumiera::gui::widgets::TimelineWidget *timeline_widget) :
|
||||
Glib::ObjectBase("TimelineBody"),
|
||||
timelineWidget(timeline_widget)
|
||||
{
|
||||
timelineWidget.horizontalAdjustment.signal_value_changed().connect(
|
||||
g_assert(timelineWidget != NULL);
|
||||
|
||||
// Connect up some events
|
||||
timelineWidget->horizontalAdjustment.signal_value_changed().connect(
|
||||
sigc::mem_fun(this, &TimelineBody::on_scroll) );
|
||||
timelineWidget.verticalAdjustment.signal_value_changed().connect(
|
||||
timelineWidget->verticalAdjustment.signal_value_changed().connect(
|
||||
sigc::mem_fun(this, &TimelineBody::on_scroll) );
|
||||
|
||||
// Install style properties
|
||||
gtk_widget_class_install_style_property(
|
||||
GTK_WIDGET_CLASS(G_OBJECT_GET_CLASS(gobj())),
|
||||
g_param_spec_boxed("track_background",
|
||||
"Track Background",
|
||||
"The background colour of timeline tracks",
|
||||
GDK_TYPE_COLOR, G_PARAM_READABLE));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -53,32 +67,64 @@ TimelineBody::on_expose_event(GdkEventExpose* event)
|
|||
{
|
||||
// This is where we draw on the window
|
||||
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||
if(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();
|
||||
|
||||
|
||||
cairo->translate(
|
||||
-timelineWidget->horizontalAdjustment.get_value(),
|
||||
-timelineWidget->verticalAdjustment.get_value());
|
||||
cairo->save();
|
||||
|
||||
vector<timeline::Track*>::iterator i;
|
||||
for(i = timelineWidget->tracks.begin();
|
||||
i != timelineWidget->tracks.end(); i++)
|
||||
{
|
||||
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();
|
||||
timeline::Track *track = *i;
|
||||
g_assert(track != NULL);
|
||||
track->draw_track(cairo);
|
||||
}
|
||||
|
||||
cairo->restore();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
TimelineBody::read_styles()
|
||||
{
|
||||
GdkColor *colour;
|
||||
|
||||
gtk_widget_style_get(Widget::gobj(), "track_background", &colour, NULL);
|
||||
|
||||
// Did the color load successfully?
|
||||
if(colour != NULL)
|
||||
track_background = *colour;
|
||||
else
|
||||
{
|
||||
g_warning("track_background style value failed to load");
|
||||
track_background.red = 0x0000;
|
||||
track_background.green = 0x0000;
|
||||
track_background.blue = 0x0000;
|
||||
track_background.pixel = 0x00000000;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace timeline
|
||||
} // namespace widgets
|
||||
|
|
|
|||
|
|
@ -31,21 +31,31 @@
|
|||
namespace lumiera {
|
||||
namespace gui {
|
||||
namespace widgets {
|
||||
|
||||
class TimelineWidget;
|
||||
|
||||
namespace timeline {
|
||||
|
||||
class TimelineBody : public Gtk::DrawingArea
|
||||
{
|
||||
public:
|
||||
TimelineBody(lumiera::gui::widgets::TimelineWidget &timeline_widget);
|
||||
TimelineBody(lumiera::gui::widgets::TimelineWidget *timeline_widget);
|
||||
|
||||
protected:
|
||||
lumiera::gui::widgets::TimelineWidget &timelineWidget;
|
||||
lumiera::gui::widgets::TimelineWidget *timelineWidget;
|
||||
|
||||
/* ===== Events ===== */
|
||||
protected:
|
||||
void on_scroll();
|
||||
|
||||
virtual bool on_expose_event(GdkEventExpose* event);
|
||||
|
||||
/* ===== Internals ===== */
|
||||
private:
|
||||
void read_styles();
|
||||
|
||||
private:
|
||||
GdkColor track_background;
|
||||
};
|
||||
|
||||
} // namespace timeline
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Track::get_title()
|
|||
}
|
||||
|
||||
void
|
||||
Track::draw_track()
|
||||
Track::draw_track(Cairo::RefPtr<Cairo::Context> cairo)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class Track
|
|||
|
||||
virtual int get_track_height() = 0;
|
||||
|
||||
virtual void draw_track();
|
||||
virtual void draw_track(Cairo::RefPtr<Cairo::Context> cairo);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ int VideoTrack::get_track_height()
|
|||
return 100;
|
||||
}
|
||||
|
||||
void VideoTrack::draw_track()
|
||||
void VideoTrack::draw_track(Cairo::RefPtr<Cairo::Context> cairo)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class VideoTrack : public Track
|
|||
|
||||
virtual int get_track_height();
|
||||
|
||||
virtual void draw_track();
|
||||
virtual void draw_track(Cairo::RefPtr<Cairo::Context> cairo);
|
||||
|
||||
protected:
|
||||
Gtk::Label headerWidget;
|
||||
|
|
|
|||
Loading…
Reference in a new issue