Merge branch '#137_custom_chart_position' into develop

This commit is contained in:
Kolan Sh 2017-10-22 23:06:31 +03:00
commit 0aa479a2be
3 changed files with 18 additions and 10 deletions

View File

@ -1,8 +1,10 @@
namespace Gtk.CairoChart {
public class Chart {
public double width = 0;
public double height = 0;
public double x_min = 0.0;
public double y_min = 0.0;
public double width = 0.0;
public double height = 0.0;
public Cairo.Context context = null;
@ -52,9 +54,10 @@ namespace Gtk.CairoChart {
public virtual bool draw () {
cur_x_min = cur_y_min = 0.0;
cur_x_max = width;
cur_y_max = height;
cur_x_min = x_min;
cur_y_min = y_min;
cur_x_max = x_min + width;
cur_y_max = y_min + height;
draw_chart_title ();
check_cur_values ();

View File

@ -1,6 +1,7 @@
SET (BinName chart_test)
FILE (GLOB_RECURSE BinSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ChartTest.vala)
SET (BinPackages gtk+-3.0)
SET (BinPkgModules gtk+-3.0)
SET (BinCustomVapis ${CMAKE_BINARY_DIR}/src/${PROJECT_LOWERCASE_NAME}-${MAJOR}.vapi ${CMAKE_SOURCE_DIR}/src/cairo-chart-float128type.vapi)
SET (BinLinkLibs ${PROJECT_LOWERCASE_NAME})
INCLUDE_DIRECTORIES ("${CMAKE_BINARY_DIR}/src;${CMAKE_SOURCE_DIR}/src")

View File

@ -367,15 +367,16 @@ int main (string[] args) {
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
da.button_press_event.connect((event) => {
if (!point_in_chart(chart, event.x, event.y)) return true;
if (event.button == 2 && point_in_chart(chart, event.x, event.y)) {
if (event.button == 2) {
draw_selection = true;
sel_x0 = sel_x1 = event.x;
sel_y0 = sel_y1 = event.y;
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
}
if (event.button == 3 && point_in_chart(chart, event.x, event.y)) {
if (event.button == 3) {
moving_chart = true;
mov_x0 = event.x;
mov_y0 = event.y;
@ -386,6 +387,8 @@ int main (string[] args) {
});
da.button_release_event.connect((event) => {
if (!point_in_chart(chart, event.x, event.y)) return true;
//var ret = chart.button_release_event(event);
if (event.button == 2) {
draw_selection = false;
@ -398,7 +401,7 @@ int main (string[] args) {
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
}
if (event.button == 3 && point_in_chart(chart, event.x, event.y)) {
if (event.button == 3) {
moving_chart = false;
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
}
@ -406,16 +409,17 @@ int main (string[] args) {
return true; // return ret;
});
da.motion_notify_event.connect((event) => {
if (!point_in_chart(chart, event.x, event.y)) return true;
//var ret = chart.motion_notify_event(event);
if (draw_selection && point_in_chart(chart, event.x, event.y)) {
if (draw_selection) {
sel_x1 = event.x;
sel_y1 = event.y;
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
}
if (moving_chart && point_in_chart(chart, event.x, event.y)) {
if (moving_chart) {
var delta_x = event.x - mov_x0, delta_y = event.y - mov_y0;
chart.move (delta_x, delta_y);
mov_x0 = event.x;