feat(ui): life is full of colors and joy

This commit is contained in:
Jeremy Attali 2019-12-26 17:42:32 -05:00
parent a8c8be37ca
commit 606cd3459d
2 changed files with 33 additions and 15 deletions

View File

@ -330,7 +330,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@ -412,13 +411,28 @@
<property name="position">2</property>
</packing>
</child>
<style>
<class name="color-box"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">50</property>
<property name="spacing">5</property>
<child>
<object class="GtkRadioButton" id="color-button-custom">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="margin_left">20</property>
<property name="draw_indicator">False</property>
<property name="group">color-red-button</property>
<signal name="clicked" handler="color_custom_clicked_handler" swapped="no"/>
@ -433,7 +447,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">0</property>
</packing>
</child>
<child>
@ -443,22 +457,21 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="title" translatable="yes"/>
<property name="rgba">rgb(193,125,17)</property>
<signal name="color-set" handler="color_custom_color_set_handler" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="color-box"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
</object>

View File

@ -57,6 +57,16 @@ static void action_toggle_painting_pane(struct swappy_state *state) {
gtk_widget_set_visible(painting_box, !is_visible);
}
static void action_set_color_from_custom(struct swappy_state *state) {
GdkRGBA color;
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(state->ui->custom), &color);
state->painting.r = color.red;
state->painting.g = color.green;
state->painting.b = color.blue;
state->painting.a = color.alpha;
}
static void switch_mode_to_brush(struct swappy_state *state) {
g_debug("switching mode to brush");
state->mode = SWAPPY_PAINT_MODE_BRUSH;
@ -345,6 +355,7 @@ void color_blue_clicked_handler(GtkWidget *widget, struct swappy_state *state) {
void color_custom_clicked_handler(GtkWidget *widget,
struct swappy_state *state) {
gtk_widget_set_sensitive(GTK_WIDGET(state->ui->custom), true);
action_set_color_from_custom(state);
}
void color_group_set_inactive(gpointer data, gpointer user_data) {
@ -355,13 +366,7 @@ void color_group_set_inactive(gpointer data, gpointer user_data) {
void color_custom_color_set_handler(GtkWidget *widget,
struct swappy_state *state) {
GdkRGBA color;
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(widget), &color);
state->painting.r = color.red;
state->painting.g = color.green;
state->painting.b = color.blue;
state->painting.a = color.alpha;
action_set_color_from_custom(state);
}
static void apply_css(GtkWidget *widget, GtkStyleProvider *provider) {