summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-07-02 23:44:02 +0200
committerThomas White <taw@physics.org>2019-07-02 23:44:02 +0200
commitf5bbe15d3c39a8f6fe891c4d6be23071e142a7ec (patch)
tree13e55f3297eba0272d8cfef6d38e870e703d9cb0
parentd4179a12792269f2af090d27a4307c6a570ef8a2 (diff)
Attribute bar at bottom of screen
-rw-r--r--src/display.c48
-rw-r--r--src/lightctx.c11
-rw-r--r--src/lightctx.h2
3 files changed, 50 insertions, 11 deletions
diff --git a/src/display.c b/src/display.c
index 5c27999..735a603 100644
--- a/src/display.c
+++ b/src/display.c
@@ -169,17 +169,20 @@ static gboolean draw_sig(GtkWidget *widget, cairo_t *cr, struct lightctx *nl)
cairo_set_source_rgb(cr, 0.0, 0.0, 0.2);
cairo_paint(cr);
+ cairo_save(cr);
+ cairo_translate(cr, OVERALL_BORDER, OVERALL_BORDER);
+ w -= OVERALL_BORDER*2.0;
+ h -= OVERALL_BORDER*2.0;
+
/* Separator between fixture and cue areas */
- cairo_move_to(cr, w*OVERALL_SPLIT, OVERALL_BORDER);
- cairo_line_to(cr, w*OVERALL_SPLIT, h - OVERALL_BORDER);
+ cairo_move_to(cr, w*OVERALL_SPLIT, 0.0);
+ cairo_line_to(cr, w*OVERALL_SPLIT, h - 50.0);
cairo_set_line_width(cr, 3.0);
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
cairo_stroke(cr);
/* Fixtures */
- cairo_save(cr);
- cairo_translate(cr, OVERALL_BORDER, OVERALL_BORDER);
x = FIXTURE_BORDER;
y = FIXTURE_BORDER;
fontdesc = pango_font_description_from_string("Comfortaa Bold 8");
@@ -195,13 +198,12 @@ static gboolean draw_sig(GtkWidget *widget, cairo_t *cr, struct lightctx *nl)
y += nl->fixture_width*3.0/2.0 + FIXTURE_BORDER*2;
}
}
- cairo_restore(cr);
/* Command line */
pango_layout_set_text(nl->layout, nl->cmdline, -1);
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_save(cr);
- cairo_translate(cr, OVERALL_BORDER, h - OVERALL_BORDER - 20.0);
+ cairo_translate(cr, 0.0, h - 50.0);
cairo_move_to(cr, 0.0, 0.0);
pango_cairo_show_layout(cr, nl->layout);
pango_layout_get_cursor_pos(nl->layout, nl->cursor_idx, &cursor, NULL);
@@ -217,14 +219,38 @@ static gboolean draw_sig(GtkWidget *widget, cairo_t *cr, struct lightctx *nl)
cairo_restore(cr);
/* Selected attribute indicator */
- if ( nl->n_sel > 0 ) {
- pango_layout_set_text(nl->sa_layout, attr_text(nl->sel_attr), -1);
+ for ( i=0; i<12; i++ ) {
+
+ if ( !any_selected_fixture_has(nl, key_attrs[i+1]) ) continue;
+
+ if ( nl->sel_attr == key_attrs[i+1] ) {
+ cairo_rectangle(cr, (w/12.0)*i, h-25.0, w/12.0, 30.0);
+ cairo_set_line_width(cr, 3.0);
+ cairo_set_source_rgb(cr, 0.2, 0.2, 0.2);
+ cairo_fill(cr);
+ }
+ pango_layout_set_text(nl->sa_layout, attr_text(key_attrs[i+1]), -1);
cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
- pango_layout_set_width(nl->sa_layout, pango_units_from_double(200.0));
- cairo_move_to(cr, w - 200.0 - OVERALL_BORDER, h-OVERALL_BORDER-20.0);
+ pango_layout_set_width(nl->sa_layout, pango_units_from_double(w/12.0));
+ cairo_move_to(cr, (w/12.0)*i, h-20.0);
pango_cairo_show_layout(cr, nl->sa_layout);
+
}
+ /* Separator between F4 and F5 */
+ cairo_move_to(cr, w/3.0, h);
+ cairo_line_to(cr, w/3.0, h-20.0);
+ cairo_set_line_width(cr, 3.0);
+ cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+ cairo_stroke(cr);
+
+ /* ... and between F8 and F9 */
+ cairo_move_to(cr, 2.0*w/3.0, h);
+ cairo_line_to(cr, 2.0*w/3.0, h-20.0);
+ cairo_stroke(cr);
+
+ cairo_restore(cr);
+
return FALSE;
}
@@ -559,7 +585,7 @@ static gint realise_sig(GtkWidget *da, struct lightctx *nl)
pango_layout_set_font_description(nl->layout, fontdesc);
nl->sa_layout = pango_layout_new(pc);
- pango_layout_set_alignment(nl->sa_layout, PANGO_ALIGN_RIGHT);
+ pango_layout_set_alignment(nl->sa_layout, PANGO_ALIGN_CENTER);
pango_layout_set_font_description(nl->sa_layout, fontdesc);
return FALSE;
diff --git a/src/lightctx.c b/src/lightctx.c
index cbd5c24..cfa140f 100644
--- a/src/lightctx.c
+++ b/src/lightctx.c
@@ -159,3 +159,14 @@ void attr_movey(struct lightctx *nl, signed int d, int fine)
}
}
+
+
+int any_selected_fixture_has(struct lightctx *nl, int attr)
+{
+ int i;
+ for ( i=0; i<nl->n_sel; i++ ) {
+ struct fixture *fix = &nl->fixtures[nl->selection[i]];
+ if ( fix->cls->attributes & attr ) return 1;
+ }
+ return 0;
+}
diff --git a/src/lightctx.h b/src/lightctx.h
index 8c25699..3084f50 100644
--- a/src/lightctx.h
+++ b/src/lightctx.h
@@ -163,6 +163,8 @@ struct lightctx
extern void attr_movex(struct lightctx *nl, signed int d, int fine);
extern void attr_movey(struct lightctx *nl, signed int d, int fine);
+extern int any_selected_fixture_has(struct lightctx *nl, int attr);
+
extern struct fixture *create_fixture(struct lightctx *nl, struct fixture_class *cls,
const char *label, int universe, int base_addr,
int flags);