Fix width/height when context is out of the Chart.
This commit is contained in:
parent
7d9ce0e2b4
commit
42b846fa75
|
@ -1,8 +1,8 @@
|
|||
namespace Gtk.CairoChart {
|
||||
public class Chart {
|
||||
|
||||
protected double width = 0;
|
||||
protected double height = 0;
|
||||
public double width = 0;
|
||||
public double height = 0;
|
||||
|
||||
public Cairo.Context context = null;
|
||||
|
||||
|
@ -35,9 +35,9 @@ namespace Gtk.CairoChart {
|
|||
}
|
||||
|
||||
protected double cur_x_min = 0.0;
|
||||
protected double cur_x_max = 0.0;
|
||||
protected double cur_x_max = 1.0;
|
||||
protected double cur_y_min = 0.0;
|
||||
protected double cur_y_max = 0.0;
|
||||
protected double cur_y_max = 1.0;
|
||||
|
||||
public virtual void check_cur_values () {
|
||||
if (cur_x_min > cur_x_max)
|
||||
|
@ -48,8 +48,6 @@ namespace Gtk.CairoChart {
|
|||
|
||||
public virtual bool draw () {
|
||||
|
||||
update_size ();
|
||||
|
||||
draw_background ();
|
||||
|
||||
cur_x_min = cur_y_min = 0.0;
|
||||
|
@ -84,13 +82,6 @@ namespace Gtk.CairoChart {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected virtual void update_size () {
|
||||
if (context != null) {
|
||||
width = context.copy_clip_rectangle_list().rectangles[0].width;
|
||||
height = context.copy_clip_rectangle_list().rectangles[0].height;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void set_source_rgba (Color color) {
|
||||
context.set_source_rgba (color.red, color.green, color.blue, color.alpha);
|
||||
}
|
||||
|
|
|
@ -341,6 +341,8 @@ int main (string[] args) {
|
|||
// user's pre draw operations here...
|
||||
|
||||
chart.context = context;
|
||||
chart.width = da.get_allocated_width();
|
||||
chart.height = da.get_allocated_height();
|
||||
/*var ret = */chart.draw();
|
||||
|
||||
// user's post draw operations here...
|
||||
|
|
Loading…
Reference in New Issue