shapes: got it to work with radio button

This commit is contained in:
Jeremy Attali 2019-12-16 23:06:15 -05:00
parent 5a006cf1f6
commit 65d4e516ca
4 changed files with 84 additions and 5 deletions

View File

@ -6,4 +6,7 @@ bool application_init(struct swappy_state *state);
int application_run(struct swappy_state *state);
void application_finish(struct swappy_state *state);
void brush_clicked_handler(GtkWidget *widget, struct swappy_state *state);
void brush_clicked_handler(GtkWidget *widget, struct swappy_state *state);
void text_clicked_handler(GtkWidget *widget, struct swappy_state *state);
void arrow_clicked_handler(GtkWidget *widget, struct swappy_state *state);
void shape_clicked_handler(GtkWidget *widget, struct swappy_state *state);

View File

@ -24,6 +24,7 @@ enum swappy_brush_point_kind {
enum swappy_paint_mode_type {
SWAPPY_PAINT_MODE_BRUSH = 0, /* Brush mode to draw arbitrary shapes */
SWAPPY_PAINT_MODE_TEXT, /* Mode to draw texts */
SWAPPY_PAINT_MODE_ARROW, /* Rectangle shapes */
SWAPPY_PAINT_MODE_RECTANGLE, /* Rectangle shapes */
};

View File

@ -157,7 +157,7 @@
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="brus">
<object class="GtkToggleButton" id="brus">
<property name="label" translatable="yes"></property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -174,7 +174,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="tex">
<object class="GtkToggleButton" id="tex">
<property name="label" translatable="yes"></property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -190,7 +190,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="shapes">
<object class="GtkToggleButton" id="shapes">
<property name="label" translatable="yes"></property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -216,7 +216,67 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkRadioButton">
<property name="label" translatable="yes"></property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">False</property>
<property name="group">brush</property>
<signal name="clicked" handler="brush_clicked_handler" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton">
<property name="label" translatable="yes"></property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">False</property>
<property name="group">brush</property>
<signal name="clicked" handler="text_clicked_handler" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton">
<property name="label" translatable="yes"></property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">False</property>
<property name="group">brush</property>
<signal name="clicked" handler="rectangle_clicked_handler" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<style>
<class name="drawing"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>

View File

@ -23,6 +23,21 @@ static void switch_mode_to_brush(struct swappy_state *state) {
state->mode = SWAPPY_PAINT_MODE_BRUSH;
}
void text_clicked_handler(GtkWidget *widget, struct swappy_state *state) {
g_debug("switching mode to arrow");
state->mode = SWAPPY_PAINT_MODE_ARROW;
}
void arrow_clicked_handler(GtkWidget *widget, struct swappy_state *state) {
g_debug("switching mode to arrow");
state->mode = SWAPPY_PAINT_MODE_ARROW;
}
void rectangle_clicked_handler(GtkWidget *widget, struct swappy_state *state) {
g_debug("switching mode to rectangle");
state->mode = SWAPPY_PAINT_MODE_RECTANGLE;
}
void application_finish(struct swappy_state *state) {
g_debug("application is shutting down");
swappy_overlay_clear(state);