[SCM] calf/master: + Line graph: add square mode (force 1:1 aspect ratio)
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:38:36 UTC 2013
The following commit has been merged in the master branch:
commit 4dc0b39a10efcfbc397364651afe8c76e3805619
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Tue Nov 25 21:46:58 2008 +0000
+ Line graph: add square mode (force 1:1 aspect ratio)
diff --git a/src/calf/custom_ctl.h b/src/calf/custom_ctl.h
index 6c7e907..1d4b786 100644
--- a/src/calf/custom_ctl.h
+++ b/src/calf/custom_ctl.h
@@ -37,6 +37,7 @@ struct CalfLineGraph
GtkWidget parent;
calf_plugins::line_graph_iface *source;
int source_id;
+ bool is_square;
};
struct CalfLineGraphClass
@@ -48,6 +49,8 @@ extern GtkWidget *calf_line_graph_new();
extern GType calf_line_graph_get_type();
+extern void calf_line_graph_set_square(CalfLineGraph *graph, bool is_square);
+
#define CALF_TYPE_VUMETER (calf_vumeter_get_type())
#define CALF_VUMETER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_VUMETER, CalfVUMeter))
#define CALF_IS_VUMETER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_VUMETER))
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index 452e109..c8a7f97 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -151,6 +151,12 @@ calf_line_graph_expose (GtkWidget *widget, GdkEventExpose *event)
return TRUE;
}
+void calf_line_graph_set_square(CalfLineGraph *graph, bool is_square)
+{
+ g_assert(CALF_IS_LINE_GRAPH(graph));
+ graph->is_square = is_square;
+}
+
static void
calf_line_graph_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -165,9 +171,23 @@ calf_line_graph_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
g_assert(CALF_IS_LINE_GRAPH(widget));
+ CalfLineGraph *lg = CALF_LINE_GRAPH(widget);
widget->allocation = *allocation;
- // printf("allocation %d x %d\n", allocation->width, allocation->height);
+ GtkAllocation &a = widget->allocation;
+ if (lg->is_square)
+ {
+ if (a.width > a.height)
+ {
+ a.x += (a.width - a.height) / 2;
+ a.width = a.height;
+ }
+ if (a.width < a.height)
+ {
+ a.y += (a.height - a.width) / 2;
+ a.height = a.width;
+ }
+ }
}
static void
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list