summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-06-11 23:33:25 +0200
committerThomas White <taw@physics.org>2019-06-11 23:33:25 +0200
commit35ecb47892057c6650fc661a1561a1927ab4e525 (patch)
tree0903b030118ee14fa57701986c8eb5a08c4d1533 /src
parente1adc561967013d7b775e807cd56bfa19fcdca6b (diff)
Show crosshairs for pan/tilt
Diffstat (limited to 'src')
-rw-r--r--src/nanolight.c55
1 files changed, 39 insertions, 16 deletions
diff --git a/src/nanolight.c b/src/nanolight.c
index 6f6ebab..c4cc480 100644
--- a/src/nanolight.c
+++ b/src/nanolight.c
@@ -71,18 +71,51 @@ static int fixture_selected(struct nanolight *nl, struct fixture *fix)
}
+static int find_attribute(struct fixture *fix, enum attr_class cls, int *n)
+{
+ int j;
+ for ( j=0; j<fix->cls->n_attrs; j++ ) {
+ if ( fix->cls->attrs[j].cls == cls ) {
+ *n = j;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
static void draw_fixture(cairo_t *cr, PangoContext *pc, PangoFontDescription *fontdesc,
struct nanolight *nl, struct fixture *fix)
{
PangoLayout *layout;
const double w = 40.0;
+ const double h = 3.0/2.0*w;
char tmp[32];
+ int n;
+
+ /* Pan/tilt (underneath rectangle) */
+ if ( find_attribute(fix, ATT_PAN, &n) ) {
+ double x = w*fix->attr_vals[n] / 65535;
+ cairo_move_to(cr, x, -1.0);
+ cairo_line_to(cr, x, h+2.0);
+ cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
+ cairo_set_line_width(cr, 1.0);
+ cairo_stroke(cr);
+ }
+ if ( find_attribute(fix, ATT_TILT, &n) ) {
+ double y = h*fix->attr_vals[n] / 65535;
+ cairo_move_to(cr, -1.0, y);
+ cairo_line_to(cr, w+2.0, y);
+ cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
+ cairo_set_line_width(cr, 1.0);
+ cairo_stroke(cr);
+ }
- cairo_rectangle(cr, 0.5, 0.5, w, 3.0/2.0*w);
+ cairo_rectangle(cr, 0.5, 0.5, w, h);
if ( fixture_selected(nl, fix) ) {
- cairo_set_source_rgb(cr, 0.3, 0.3, 0.9);
+ cairo_set_source_rgba(cr, 0.3, 0.3, 0.9, 0.9);
} else {
- cairo_set_source_rgb(cr, 0.3, 0.3, 0.3);
+ cairo_set_source_rgba(cr, 0.3, 0.3, 0.3, 0.9);
}
cairo_fill_preserve(cr);
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
@@ -257,19 +290,6 @@ static size_t delete_char(char *str)
}
-static int find_attribute(struct fixture *fix, enum attr_class cls, int *n)
-{
- int j;
- for ( j=0; j<fix->cls->n_attrs; j++ ) {
- if ( fix->cls->attrs[j].cls == cls ) {
- *n = j;
- return 1;
- }
- }
- return 0;
-}
-
-
static void cap_value(struct fixture *fix, int n, signed int *v)
{
if ( *v < 0 ) *v = 0;
@@ -320,6 +340,8 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, struct nanoligh
}
}
+ redraw(nl);
+
return FALSE;
}
@@ -366,6 +388,7 @@ static void home_value(struct nanolight *nl)
}
}
+ redraw(nl);
}