Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HP Praktikum - Graphics Editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Younes Oubkis
HP Praktikum - Graphics Editor
Commits
702ec23d
Commit
702ec23d
authored
May 11, 2024
by
Younes Oubkis
Browse files
Options
Downloads
Patches
Plain Diff
finish
parent
2dfb4256
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
README.md
+16
-1
16 additions, 1 deletion
README.md
bin/app
+0
-0
0 additions, 0 deletions
bin/app
src/Makefile
+2
-2
2 additions, 2 deletions
src/Makefile
src/app.c
+22
-10
22 additions, 10 deletions
src/app.c
src/app.h
+2
-2
2 additions, 2 deletions
src/app.h
src/drawing.c
+6
-6
6 additions, 6 deletions
src/drawing.c
with
48 additions
and
21 deletions
README.md
+
16
−
1
View file @
702ec23d
...
@@ -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
This diff is collapsed.
Click to expand it.
bin/app
0 → 100755
+
0
−
0
View file @
702ec23d
File added
This diff is collapsed.
Click to expand it.
src/Makefile
+
2
−
2
View file @
702ec23d
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
)
...
...
This diff is collapsed.
Click to expand it.
src/app.c
+
22
−
10
View file @
702ec23d
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#include
"app.h"
#include
"app.h"
GtkWidget
*
window
;
GtkWidget
*
window
;
Gtk
Widget
*
colorbtn
;
Gtk
ColorButton
*
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
++
)
...
...
This diff is collapsed.
Click to expand it.
src/app.h
+
2
−
2
View file @
702ec23d
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
extern
GtkWidget
*
window
;
extern
GtkWidget
*
window
;
extern
GtkWidget
*
drawing_area
;
extern
GtkWidget
*
drawing_area
;
extern
Gtk
Widget
*
color_btn
;
extern
Gtk
ColorButton
*
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
;
...
...
This diff is collapsed.
Click to expand it.
src/drawing.c
+
6
−
6
View file @
702ec23d
...
@@ -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. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment