-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[will be dropped]From my own purpose. #32
base: master
Are you sure you want to change the base?
Changes from all commits
b368afd
32820ac
020246d
0965228
1882f91
d135c57
f6bbf62
065da7a
f9bc1f8
5ecbe36
03c963b
35b69a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
project('live-chart', ['vala', 'c'], version: '1.9.1') | ||
project('live-chart', ['vala', 'c'], version: '1.9.1-RO') | ||
|
||
cc = meson.get_compiler('c') | ||
libm = cc.find_library('m', required: true) | ||
|
||
gtk = dependency('gtk+-3.0', version: '>= 3.22') | ||
#setting up GEE | ||
gee = dependency('gee-0.8') | ||
|
||
vala_args = ['--target-glib=2.50'] | ||
|
||
#setting up gtk | ||
gtk_major = 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GTK version should define in meson_options.txt:
then use it in the meson:
then change the GTK version by command: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, as talked in #37, the default build should be GTK3 for now if we don't provide any argument to meson. |
||
|
||
if gtk_major == 3 | ||
gtk = dependency('gtk+-3.0', version: '>= 3.22') | ||
vala_args += ['--define=GTK3'] | ||
endif | ||
|
||
if gtk_major == 4 | ||
gtk = dependency('gtk4') | ||
vala_args += ['--define=GTK4'] | ||
endif | ||
|
||
if meson.version().version_compare('>= 0.47') | ||
if get_option('debug') == true | ||
vala_args += ['--ccode', '--debug'] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,25 +17,48 @@ namespace LiveChart { | |
public Series series; | ||
|
||
private uint source_timeout = 0; | ||
|
||
private double play_ratio = 1.0; | ||
|
||
private int64 prev_time; | ||
|
||
public Chart(Config config = new Config()) { | ||
this.config = config; | ||
|
||
#if GTK3 | ||
this.size_allocate.connect((allocation) => { | ||
this.config.height = allocation.height; | ||
this.config.width = allocation.width; | ||
}); | ||
|
||
this.draw.connect(render); | ||
|
||
#endif | ||
#if GTK4 | ||
this.set_draw_func((_, ctx, width, height) => { | ||
this.config.height = height; | ||
this.config.width = width; | ||
this.render(_, ctx); | ||
}); | ||
#endif | ||
this.refresh_every(100); | ||
|
||
series = new Series(this); | ||
this.destroy.connect(() => { | ||
refresh_every(-1); | ||
remove_all_series(); | ||
}); | ||
} | ||
|
||
public void add_serie(Serie serie) { | ||
this.series.register(serie); | ||
} | ||
|
||
public void remove_serie(Serie serie){ | ||
this.series.remove_serie(serie); | ||
} | ||
|
||
public void remove_all_series(){ | ||
this.series.remove_all(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That kind of API improvements should be added to README. |
||
[Version (deprecated = true, deprecated_since = "1.7.0", replacement = "Retrieve the Serie from Chart.series (or from the serie you created) and add the value using serie.add")] | ||
public void add_value(Serie serie, double value) { | ||
serie.add(value); | ||
|
@@ -72,26 +95,36 @@ namespace LiveChart { | |
} | ||
|
||
public void to_png(string filename) throws Error { | ||
#if GTK3 | ||
var window = this.get_window(); | ||
if (window == null) { | ||
throw new ChartError.EXPORT_ERROR("Chart is not realized yet"); | ||
} | ||
var pixbuff = Gdk.pixbuf_get_from_window(window, 0, 0, window.get_width(), window.get_height()); | ||
pixbuff.savev(filename, "png", {}, {}); | ||
#endif | ||
} | ||
|
||
public void refresh_every(int ms) { | ||
public void refresh_every(int ms, double play_ratio = 1.0) { | ||
this.play_ratio = play_ratio; | ||
if (source_timeout != 0) { | ||
GLib.Source.remove(source_timeout); | ||
source_timeout = 0; | ||
} | ||
if(ms > 0){ | ||
this.prev_time = GLib.get_monotonic_time() / 1000; | ||
source_timeout = Timeout.add(ms, () => { | ||
var now = GLib.get_monotonic_time() / 1000; | ||
config.time.current += (int64)((now - this.prev_time) * this.play_ratio); | ||
this.prev_time = now; | ||
this.queue_draw(); | ||
return true; | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Documentation is welcome :) |
||
} | ||
source_timeout = Timeout.add(ms, () => { | ||
this.queue_draw(); | ||
return true; | ||
}); | ||
} | ||
|
||
private bool render(Gtk.Widget _, Context ctx) { | ||
|
||
ctx.set_antialias(Cairo.Antialias.NONE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we loose render quality if we disable antialias ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to forgot to revert it. It's my mistake. |
||
config.configure(ctx, legend); | ||
|
||
this.background.draw(ctx, config); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,11 +38,28 @@ namespace LiveChart { | |
public int width; | ||
public int height; | ||
} | ||
|
||
|
||
|
||
public class Config { | ||
|
||
private int _width = 0; | ||
public int width { | ||
get; set; default = 0; | ||
get{ | ||
return _width; | ||
} | ||
set{ | ||
if(_width != value){ | ||
//i = config.width - config.padding.right; i > config.padding.left; i -= config.x_axis.tick_length | ||
if(x_axis.tick_length <= 0.0){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's commented, it's certainly useless :) |
||
time.head_offset = -1.0; | ||
} | ||
else{ | ||
var tmp = value / x_axis.tick_length; | ||
time.head_offset = tmp * x_axis.tick_interval * 1000.0; | ||
} | ||
} | ||
_width = value; | ||
} | ||
} | ||
|
||
public int height { | ||
|
@@ -53,7 +70,16 @@ namespace LiveChart { | |
|
||
public YAxis y_axis = new YAxis(); | ||
public XAxis x_axis = new XAxis(); | ||
|
||
|
||
public struct TimeSeek { | ||
int64 current; | ||
double head_offset; | ||
} | ||
public TimeSeek time = { | ||
GLib.get_real_time() / 1000, | ||
0 | ||
}; | ||
|
||
internal Gee.ArrayList<string> categories; | ||
|
||
public Boundaries boundaries() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be a nice if we could have a button to remove that serie instead of waiting 20s