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
453c7c0c
Commit
453c7c0c
authored
Jul 10, 2023
by
Younes Oubkis
Browse files
Options
Downloads
Patches
Plain Diff
setup for clickable shapes
parent
4ce958c9
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
bin/app
+0
-0
0 additions, 0 deletions
bin/app
src/app.c
+1
-0
1 addition, 0 deletions
src/app.c
src/app.h
+1
-0
1 addition, 0 deletions
src/app.h
src/drawing.c
+25
-6
25 additions, 6 deletions
src/drawing.c
with
27 additions
and
6 deletions
bin/app
+
0
−
0
View file @
453c7c0c
No preview for this file type
This diff is collapsed.
Click to expand it.
src/app.c
+
1
−
0
View file @
453c7c0c
...
...
@@ -7,6 +7,7 @@ GtkWidget *window;
GtkWidget
*
drawing_area
;
enum
INPUTTYPE
current_input
;
t_shape
shapes
[
MAX_SHAPES
+
1
];
t_shape
selected_shape
;
int
shape_type
;
int
click_count
;
t_vertex
click_positions
[
4
];
...
...
This diff is collapsed.
Click to expand it.
src/app.h
+
1
−
0
View file @
453c7c0c
...
...
@@ -17,6 +17,7 @@ extern int shape_type;
extern
int
click_count
;
extern
t_vertex
click_positions
[
4
];
extern
t_shape
shapes
[
MAX_SHAPES
+
1
];
extern
t_shape
selected_shape
;
gboolean
on_clear
(
GtkWidget
*
button
,
gpointer
user_data
);
gboolean
drawing_area_click
(
GtkWidget
*
widget
,
GdkEventButton
*
event
,
gpointer
data
);
...
...
This diff is collapsed.
Click to expand it.
src/drawing.c
+
25
−
6
View file @
453c7c0c
...
...
@@ -6,11 +6,24 @@ GdkRGBA yellow = {1.0, 1.0, 0.0, 0.6};
GdkRGBA
blue
=
{
0
.
0
,
0
.
5
,
1
.
0
,
0
.
4
};
GdkRGBA
black
=
{
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
};
int
selection_flag
=
0
;
float
selectionX
,
selectionY
;
gboolean
drawing_area_click
(
GtkWidget
*
widget
,
GdkEventButton
*
event
,
gpointer
data
)
{
if
(
!
event
->
button
=
=
GDK_BUTTON_PRIMARY
)
// Left Click
if
(
event
->
button
!=
GDK_BUTTON_SECONDARY
&&
event
->
button
!
=
GDK_BUTTON_PRIMARY
)
// Left Click
return
FALSE
;
if
(
event
->
button
==
GDK_BUTTON_SECONDARY
)
// Left Click
{
selection_flag
=
1
;
selectionX
=
event
->
x
;
selectionY
=
event
->
y
;
gtk_widget_queue_draw
(
drawing_area
);
return
TRUE
;
}
double
clickX
=
event
->
x
;
double
clickY
=
event
->
y
;
...
...
@@ -75,7 +88,6 @@ void handle_shape_click(float x, float y)
}
void
handle_freehand_click
(
float
x
,
float
y
)
{
}
void
add_shape
(
t_shape
new_shape
)
{
...
...
@@ -130,11 +142,18 @@ gboolean draw(GtkWidget *widget, cairo_t *c, gpointer data)
}
cairo_close_path
(
c
);
}
cairo_fill
(
c
);
cairo_close_path
(
c
);
}
if
(
selection_flag
)
{
gboolean
isInside
=
cairo_in_fill
(
c
,
selectionX
,
selectionY
);
if
(
isInside
)
g_print
(
"HIT!"
);
else
g_print
(
"MISS!"
);
selection_flag
=
0
;
}
cairo_fill
(
c
);
for
(
int
i
=
0
;
i
<
click_count
;
i
++
)
{
set_source_color
(
c
,
&
black
);
...
...
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