diff options
author | David Härdeman <david@hardeman.nu> | 2015-07-10 09:52:30 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2015-07-10 09:52:30 +0200 |
commit | 645161cce4c6c8480a60fc73f7ceb0a410a131cf (patch) | |
tree | 6831165b4b8dccb061b31125032cfad6f2ed4770 | |
parent | 28163dd2de67012f4d407127383aa8beafad7cd0 (diff) |
Indicate remote editing differently
-rw-r--r-- | rcm-client-receive.c | 111 |
1 files changed, 17 insertions, 94 deletions
diff --git a/rcm-client-receive.c b/rcm-client-receive.c index aaeca42..e1969b2 100644 --- a/rcm-client-receive.c +++ b/rcm-client-receive.c @@ -70,7 +70,8 @@ curve_rectangle(cairo_t * cr, gdouble x0, gdouble y0, cairo_close_path (cr); } -GdkRGBA *c; +GdkRGBA *remote_background_color; +GdkRGBA *remote_edit_background_color; GdkRGBA *cd; GdkRGBA *cre; GdkRGBA *cb; @@ -135,7 +136,9 @@ static gboolean draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data) guint w = 0, h = 0; /* Set color for background */ - gdk_cairo_set_source_rgba(cr, c); + gdk_cairo_set_source_rgba(cr, remote->editing ? + remote_edit_background_color : + remote_background_color); /* fill in the background color*/ cairo_paint(cr); @@ -202,20 +205,6 @@ button_calculate_position(struct rcbutton *rcb) rcb->height = BH + (rcb->rows - 1) * (BH + SPACING); } -static void -move_buttons(gint row, gint col) -{ - GList *l; - - for (l = remote->buttons; l; l = l->next) { - struct rcbutton *rcb = l->data; - - rcb->row += row; - rcb->col += col; - button_calculate_position(rcb); - } -} - static struct rcbutton * new_button_add(const char *name, GdkRGBA *color, guint x, guint y, guint w, guint h) @@ -401,40 +390,6 @@ void rcng_client_receive_destroy_ui() static gint own_page_num = -1; static GtkWidget *da; -#if 0 -static void -edit_keymap_done(GtkButton *button, gpointer user_data) -{ - -} -#endif -static void -on_hover_delete(struct rcbutton *rcb, GtkWidget *widget, bool hover) -{ - if (hover) { - if (rcb->col == 0 && rcb->cols == 1) { - rcb->cols = 2 + remote->width; - button_calculate_position(rcb); - button_redraw(rcb, widget); - } else if (rcb->row == 0 && rcb->rows == 1) { - rcb->rows = 2 + remote->height; - button_calculate_position(rcb); - button_redraw(rcb, widget); - } - } else { - if (rcb->col == 0 && rcb->cols != 1) { - button_redraw(rcb, widget); - rcb->cols = 1; - button_calculate_position(rcb); - } else if (rcb->row == 0 && rcb->rows != 1) { - button_redraw(rcb, widget); - rcb->rows = 1; - button_calculate_position(rcb); - } - } - -} - /* FIXME: These two functions should probably move to the core */ static void create_header_button(const gchar *label, const gchar *icon_name, @@ -466,57 +421,21 @@ remove_header_buttons(void) static void edit_keymap(GtkButton *button, gpointer user_data) { - guint i; //struct remote *remote = user_data; - struct rcbutton *rcb; g_print("Button clicked\n"); g_print("Remote width: %u x %u\n", remote->width, remote->height); if (remote->width < 1 || remote->height < 1) return; - if (!remote->editing) { - remove_header_buttons(); + remove_header_buttons(); + if (!remote->editing) create_header_button("Done Editing Keymap", "gtk-apply", G_CALLBACK(edit_keymap), &remote); - move_buttons(2, 2); - new_button_add("+", &cgreen, 2, 1, remote->width, 1); - new_button_add("+", &cgreen, 2, 2 + remote->height, remote->width, 1); - new_button_add("+", &cgreen, 1, 2, 1, remote->height); - new_button_add("+", &cgreen, 2 + remote->width, 2, 1, remote->height); - - for (i = 0; i < remote->height; i++) { - rcb = new_button_add("-", &cred, 0, 2 + i, 1, 1); - rcb->on_hover = on_hover_delete; - } - - for (i = 0; i < remote->width; i++) { - rcb = new_button_add("-", &cred, 2 + i, 0, 1, 1); - rcb->on_hover = on_hover_delete; - } - - gtk_widget_queue_draw(da); - } else { - GList *l; - - remove_header_buttons(); + else create_header_button("Edit Keymap", "list-add", G_CALLBACK(edit_keymap), &remote); - l = remote->buttons; - while (l) { - GList *next = l->next; - struct rcbutton *rcb = l->data; - - if (rcb->color) { - g_free(rcb); - remote->buttons = g_list_delete_link (remote->buttons, l); - } - - l = next; - } - move_buttons(-2, -2); - gtk_widget_queue_draw(da); - } remote->editing = !remote->editing; + gtk_widget_queue_draw(da); } static void @@ -579,17 +498,21 @@ void rcng_client_receive_init_ui(GDBusObject *new_hw) style_context = gtk_widget_get_style_context(GTK_WIDGET(global->window)); state = gtk_widget_get_state_flags(GTK_WIDGET(global->window)); - gtk_style_context_get(style_context, state, "background-color", &c, NULL); + gtk_style_context_get(style_context, state, "background-color", + &remote_background_color, NULL); + + remote_edit_background_color = gdk_rgba_copy(remote_background_color); + remote_edit_background_color->green *= 1.5; - cd = gdk_rgba_copy(c); + cd = gdk_rgba_copy(remote_background_color); cd->red *= 0.7; cd->green *= 0.7; cd->blue *= 0.7; - cre = gdk_rgba_copy(c); + cre = gdk_rgba_copy(remote_background_color); cre->red *= 2.0; - cb = gdk_rgba_copy(c); + cb = gdk_rgba_copy(remote_background_color); cb->red = 0.0; cb->green = 0.0; cb->blue = 0.0; |