Skip to content
Snippets Groups Projects
Commit 702ec23d authored by Younes Oubkis's avatar Younes Oubkis
Browse files

finish

parent 2dfb4256
Branches
No related tags found
No related merge requests found
...@@ -15,5 +15,20 @@ Run ```make``` in the src Directory ...@@ -15,5 +15,20 @@ Run ```make``` in the src Directory
Alternatively for VS Code Run the Task ```Build using Make``` Alternatively for VS Code Run the Task ```Build using Make```
# Screenshots (TODO) # Using the App
Run using ```./app``` in the bin Directory
# Manual
First, select the type of shape you want to create in the toolbar.
Then Click on the Canvas to add the points for the Shape:
A rectangle is defined by two diagnoals,
a circle is defined by a center point and a point on the radius,
a triangle is defined by three corner points.
Right click a shape to select it.
Move the shape using arrow keys.
Rotate it using the scroll wheel.
Change its color by selecting it and then selecting a color on the right.s
bin/app 0 → 100755
File added
CFLAGS := -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g CFLAGS := `pkg-config --cflags gtk+-3.0`
LIBS := -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 LIBS := `pkg-config --libs gtk+-3.0`
LINKS := $(wildcard lib/*.c) LINKS := $(wildcard lib/*.c)
LOCAL := $(wildcard *.c) LOCAL := $(wildcard *.c)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "app.h" #include "app.h"
GtkWidget *window; GtkWidget *window;
GtkWidget *colorbtn; GtkColorButton *color_btn;
GtkWidget *drawing_area; GtkWidget *drawing_area;
GdkRGBA cur_col; GdkRGBA cur_col;
const GdkRGBA *current_color; const GdkRGBA *current_color;
...@@ -18,6 +18,15 @@ t_custom_toolbar *toolbar; ...@@ -18,6 +18,15 @@ t_custom_toolbar *toolbar;
int width = 800; int width = 800;
int height = 600; int height = 600;
void on_color_set(GtkColorButton *self, gpointer user_data)
{
if (selected_shape != 0 && current_input == SELECTION)
{
gtk_color_button_get_rgba(color_btn, &(selected_shape->color));
}
gtk_widget_queue_draw(drawing_area);
}
gboolean on_button_clicked(GtkWidget *button, gpointer user_data) gboolean on_button_clicked(GtkWidget *button, gpointer user_data)
{ {
g_print("Button clicked!\n"); g_print("Button clicked!\n");
...@@ -139,13 +148,11 @@ int create_window_layout(int argc, char **argv) ...@@ -139,13 +148,11 @@ int create_window_layout(int argc, char **argv)
gtk_widget_set_size_request(drawing_area, width, height); gtk_widget_set_size_request(drawing_area, width, height);
toolbar = create_toolbar(4); toolbar = create_toolbar(4);
GtkToolItem *triangle_btn = create_and_bind_toolbutton(toolbar, "Triangle"); GtkToolItem *triangle_btn = create_and_bind_toolbutton(toolbar, "Dreieck");
GtkToolItem *rectangle_btn = create_and_bind_toolbutton(toolbar, "Rectangle"); GtkToolItem *rectangle_btn = create_and_bind_toolbutton(toolbar, "Rechteck");
GtkToolItem *circle_btn = create_and_bind_toolbutton(toolbar, "Circle"); GtkToolItem *circle_btn = create_and_bind_toolbutton(toolbar, "Kreis");
GtkToolItem *clear_btn = create_and_bind_toolbutton(toolbar, "Clear"); GtkToolItem *clear_btn = create_and_bind_toolbutton(toolbar, "Alle Loeschen");
GtkToolItem *select_btn = create_and_bind_toolbutton(toolbar, "Select"); GtkToolItem *delete_btn = create_and_bind_toolbutton(toolbar, "Auswahl Loeschen");
GtkToolItem *delete_btn = create_and_bind_toolbutton(toolbar, "Delete Shape");
bind_click_signal(triangle_btn, on_shape_choice, TRIANGLE); bind_click_signal(triangle_btn, on_shape_choice, TRIANGLE);
bind_click_signal(rectangle_btn, on_shape_choice, RECTANGLE); bind_click_signal(rectangle_btn, on_shape_choice, RECTANGLE);
...@@ -154,8 +161,11 @@ int create_window_layout(int argc, char **argv) ...@@ -154,8 +161,11 @@ int create_window_layout(int argc, char **argv)
bind_click_signal(clear_btn, on_select_clicked, NULL); bind_click_signal(clear_btn, on_select_clicked, NULL);
bind_click_signal(delete_btn, on_delete_clicked, NULL); bind_click_signal(delete_btn, on_delete_clicked, NULL);
shapes_list = gtk_list_box_new(); shapes_list = gtk_list_box_new();
GtkWidget *lbTest = gtk_label_new("TestItem"); GtkWidget *lbTest = gtk_label_new("Farbauswahl");
color_btn = gtk_color_button_new_with_rgba(current_color); color_btn = gtk_color_button_new_with_rgba(current_color);
g_signal_connect(GTK_WIDGET(color_btn), "color-set", G_CALLBACK(on_color_set), NULL);
gtk_list_box_insert(GTK_LIST_BOX(shapes_list), lbTest, 0); gtk_list_box_insert(GTK_LIST_BOX(shapes_list), lbTest, 0);
gtk_list_box_insert(GTK_LIST_BOX(shapes_list), color_btn, 1); gtk_list_box_insert(GTK_LIST_BOX(shapes_list), color_btn, 1);
...@@ -172,6 +182,8 @@ int create_window_layout(int argc, char **argv) ...@@ -172,6 +182,8 @@ int create_window_layout(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
cur_col.alpha = 1;
cur_col.red = 1;
current_color = &cur_col; current_color = &cur_col;
current_input = SELECTION; current_input = SELECTION;
for (int i = 0; i < MAX_SHAPES; i++) for (int i = 0; i < MAX_SHAPES; i++)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
extern GtkWidget *window; extern GtkWidget *window;
extern GtkWidget *drawing_area; extern GtkWidget *drawing_area;
extern GtkWidget *color_btn; extern GtkColorButton *color_btn;
extern enum INPUTTYPE current_input; extern enum INPUTTYPE current_input;
extern int shape_type; extern int shape_type;
extern int click_count; extern int click_count;
......
...@@ -236,13 +236,13 @@ gboolean draw(GtkWidget *widget, cairo_t *c, gpointer data) ...@@ -236,13 +236,13 @@ gboolean draw(GtkWidget *widget, cairo_t *c, gpointer data)
else if (current_input == CREATE_SHAPE) else if (current_input == CREATE_SHAPE)
cur_inp = "CREATE"; cur_inp = "CREATE";
sprintf(txt, "%s", cur_inp); //sprintf(txt, "%s", cur_inp);
cairo_move_to(c, 200, 200); //cairo_move_to(c, 200, 200);
cairo_show_text(c, txt); //cairo_show_text(c, txt);
sprintf(txt, "Selected Shape: %d", (int)selected_shape); //sprintf(txt, "Selected Shape: %d", (int)selected_shape);
cairo_move_to(c, 200, 220); //cairo_move_to(c, 200, 220);
cairo_show_text(c, txt); //cairo_show_text(c, txt);
return FALSE; /* TRUE to stop other handlers from being invoked for the event. return FALSE; /* TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. */ FALSE to propagate the event further. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment