Add gtk46
This commit is contained in:
parent
d5a4ac08da
commit
fc563e87e3
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
//For linux amd64 and linux on arm64,some include path may different
|
||||
//Commet and uncomment these lines to compile on a specificed archtiecture
|
||||
//Arm64 linux libs
|
||||
/*
|
||||
"/usr/lib/aarch64-linux-gnu/dbus-1.0/include/**",
|
||||
"/usr/lib/aarch64-linux-gnu/glib-2.0/include",
|
||||
*/
|
||||
//amd64 linux libs(For ubuntu)
|
||||
/*
|
||||
"/usr/lib/x86_64-linux-gnu/dbus-1.0/include",
|
||||
"/usr/lib/x86_64-linux-gnu/glib-2.0/include",
|
||||
*/
|
||||
//For debian and ubuntu,kali
|
||||
/*
|
||||
"/usr/include/gtk-3.0/gtk/**",
|
||||
"/usr/include/uuid/**",
|
||||
*/
|
||||
//For manjaro(Arch linux)
|
||||
"/usr/lib/dbus-1.0/include/**",
|
||||
"/usr/lib/glib-2.0/include/**",
|
||||
"/usr/include/lzo/**",
|
||||
"/usr/include/cloudproviders/**",
|
||||
"${workspaceFolder}/**",
|
||||
"/usr/include/gtk-3.0/**",
|
||||
"/usr/include/at-spi2-atk/2.0/**",
|
||||
"/usr/include/at-spi-2.0/**",
|
||||
"/usr/include/dbus-1.0/**",
|
||||
"/usr/include/gio-unix-2.0/**",
|
||||
"/usr/include/cairo/**",
|
||||
"/usr/include/pango-1.0/**",
|
||||
"/usr/include/fribidi/**",
|
||||
"/usr/include/harfbuzz/**",
|
||||
"/usr/include/atk-1.0/**",
|
||||
"/usr/include/pixman-1/**",
|
||||
"/usr/include/freetype2/**",
|
||||
"/usr/include/libpng16/**",
|
||||
"/usr/include/gdk-pixbuf-2.0/**",
|
||||
"/usr/include/libmount/**",
|
||||
"/usr/include/blkid/**",
|
||||
"/usr/include/glib-2.0/**"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "gnu17",
|
||||
"cppStandard": "gnu++14",
|
||||
"intelliSenseMode": "gcc-arm64",
|
||||
"compilerArgs": [
|
||||
"`pkg-config --cflags --libs gtk+-3.0`"
|
||||
],
|
||||
"configurationProvider": "ms-vscode.cmake-tools"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "g++ - Build and debug active file",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/bin/gtk46",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "C/C++: g++ build active file",
|
||||
"miDebuggerPath": "/usr/bin/gdb"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"C_Cpp.errorSquiggles": "Disabled",
|
||||
"cmake.configureOnOpen": false
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++ build active file",
|
||||
"command": "/usr/bin/g++",
|
||||
"args": [
|
||||
"-g",
|
||||
"src/*.cpp",
|
||||
"-o",
|
||||
"${workspaceFolder}/bin/gtk46",
|
||||
"-pthread",
|
||||
//For Arm64 linux
|
||||
/*
|
||||
"-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include",
|
||||
"-I/usr/lib/aarch64-linux-gnu/glib-2.0/include",
|
||||
*/
|
||||
//For amd64 linux
|
||||
/*
|
||||
"-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include",
|
||||
"-I/usr/lib/x86_64-linux-gnu/glib-2.0/include",
|
||||
*/
|
||||
//Ubuntu and kali include paths
|
||||
/*
|
||||
"-I/usr/include/uuid",
|
||||
*/
|
||||
//Manjaro linux and Arch linux include args
|
||||
|
||||
"-I${workspaceFolder}",
|
||||
"-I/usr/lib/glib-2.0/include",
|
||||
"-I/usr/lib/dbus-1.0/include",
|
||||
"-I/usr/include/lzo",
|
||||
"-I/usr/include/cloudproviders",
|
||||
|
||||
"-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/include/gio-unix-2.0",
|
||||
"-I/usr/include/cairo",
|
||||
"-I/usr/include/pango-1.0",
|
||||
"-I/usr/include/fribidi",
|
||||
"-I/usr/include/harfbuzz",
|
||||
"-I/usr/include/atk-1.0",
|
||||
"-I/usr/include/pixman-1",
|
||||
"-I/usr/include/freetype2",
|
||||
"-I/usr/include/libpng16",
|
||||
"-I/usr/include/gdk-pixbuf-2.0",
|
||||
"-I/usr/include/libmount",
|
||||
"-I/usr/include/blkid",
|
||||
"-I/usr/include/glib-2.0",
|
||||
//Manjaro linux lib args
|
||||
"-lz",
|
||||
|
||||
"-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",
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
101.000000 45.000000
|
||||
103.000000 45.000000
|
||||
104.000000 47.000000
|
||||
107.000000 48.000000
|
||||
112.000000 51.000000
|
||||
118.000000 55.000000
|
||||
124.000000 59.000000
|
||||
128.000000 63.000000
|
||||
131.000000 64.000000
|
||||
137.000000 65.000000
|
||||
145.000000 69.000000
|
||||
158.000000 78.000000
|
||||
173.000000 83.000000
|
||||
186.000000 91.000000
|
||||
204.000000 98.000000
|
||||
222.000000 108.000000
|
||||
237.000000 115.000000
|
||||
250.000000 122.000000
|
||||
262.000000 131.000000
|
||||
276.000000 138.000000
|
||||
290.000000 145.000000
|
||||
302.000000 154.000000
|
||||
317.000000 163.000000
|
||||
330.000000 174.000000
|
||||
344.000000 183.000000
|
||||
358.000000 193.000000
|
||||
368.000000 201.000000
|
||||
380.000000 208.000000
|
||||
390.000000 216.000000
|
||||
401.000000 223.000000
|
||||
411.000000 231.000000
|
||||
423.000000 238.000000
|
||||
433.000000 246.000000
|
||||
444.000000 253.000000
|
||||
454.000000 261.000000
|
||||
462.000000 267.000000
|
||||
469.000000 273.000000
|
||||
474.000000 277.000000
|
||||
476.000000 278.000000
|
||||
477.000000 280.000000
|
||||
479.000000 279.000000
|
||||
479.000000 279.000000
|
||||
460.000000 118.000000
|
||||
459.000000 118.000000
|
||||
457.000000 118.000000
|
||||
451.000000 121.000000
|
||||
448.000000 122.000000
|
||||
442.000000 125.000000
|
||||
430.000000 128.000000
|
||||
416.000000 131.000000
|
||||
402.000000 134.000000
|
||||
394.000000 138.000000
|
||||
384.000000 142.000000
|
||||
373.000000 145.000000
|
||||
360.000000 148.000000
|
||||
346.000000 152.000000
|
||||
333.000000 157.000000
|
||||
319.000000 160.000000
|
||||
305.000000 164.000000
|
||||
296.000000 167.000000
|
||||
286.000000 168.000000
|
||||
275.000000 171.000000
|
||||
263.000000 175.000000
|
||||
252.000000 178.000000
|
||||
241.000000 181.000000
|
||||
232.000000 184.000000
|
||||
224.000000 186.000000
|
||||
215.000000 187.000000
|
||||
210.000000 188.000000
|
||||
204.000000 189.000000
|
||||
199.000000 191.000000
|
||||
198.000000 191.000000
|
||||
196.000000 191.000000
|
||||
191.000000 191.000000
|
||||
186.000000 191.000000
|
||||
182.000000 193.000000
|
||||
180.000000 193.000000
|
||||
178.000000 194.000000
|
||||
175.000000 194.000000
|
||||
172.000000 196.000000
|
||||
169.000000 196.000000
|
||||
167.000000 196.000000
|
||||
165.000000 196.000000
|
||||
163.000000 197.000000
|
||||
161.000000 197.000000
|
||||
160.000000 197.000000
|
||||
158.000000 199.000000
|
||||
157.000000 199.000000
|
||||
155.000000 199.000000
|
||||
155.000000 199.000000
|
|
@ -0,0 +1,151 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <cstdio>
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *draw_area1;
|
||||
double x;
|
||||
double y;
|
||||
}MousePos;
|
||||
|
||||
static cairo_surface_t *surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32,640,360);
|
||||
|
||||
//static double start_x,start_y;
|
||||
|
||||
static void
|
||||
clear_surface (void)
|
||||
{
|
||||
cairo_t *cr;
|
||||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
gboolean draw_cb(GtkWidget *widget,cairo_t *cr,gpointer data){
|
||||
cairo_set_source_surface(cr,surface,0,0);
|
||||
cairo_paint(cr);
|
||||
/*
|
||||
guint width, height;
|
||||
width = gtk_widget_get_allocated_width (widget);
|
||||
height = gtk_widget_get_allocated_height (widget);
|
||||
cairo_arc (cr,
|
||||
width / 2.0, height / 2.0,
|
||||
MIN (width, height) / 2.0,
|
||||
0, 2 * G_PI);
|
||||
cairo_fill(cr);*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void draw_brush(GtkWidget *widget,double x,double y){
|
||||
cairo_t *cr;
|
||||
//Draw on the surface
|
||||
cr=cairo_create(surface);
|
||||
|
||||
GdkRGBA color;
|
||||
//gdk_rgba_parse(&color,"66CCFF");
|
||||
|
||||
//Draw and fill in color
|
||||
cairo_rectangle(cr,x-3,y-3,6,6);
|
||||
//gdk_cairo_set_source_rgba(cr,&color);
|
||||
cairo_fill(cr);
|
||||
|
||||
cairo_destroy(cr);
|
||||
|
||||
gtk_widget_queue_draw(widget);
|
||||
|
||||
}
|
||||
|
||||
void drag_begin(GtkGesture *gesture,double x,double y,MousePos *pos){
|
||||
pos->x=x;
|
||||
pos->y=y;
|
||||
draw_brush(pos->draw_area1,x,y);
|
||||
/*
|
||||
freopen("drag.txt","a",stdout);
|
||||
g_print("%lf %lf\n",x,y);
|
||||
fclose(stdout);
|
||||
*/
|
||||
}
|
||||
|
||||
void drag_update(GtkGesture *gesture,double x,double y,MousePos *pos){
|
||||
draw_brush(pos->draw_area1,x+pos->x,y+pos->y);
|
||||
/*
|
||||
freopen("drag.txt","a",stdout);
|
||||
g_print("%lf %lf\n",x+pos->x,y+pos->y);
|
||||
fclose(stdout);
|
||||
*/
|
||||
}
|
||||
|
||||
void drag_end(GtkGesture *gesture,double x,double y,MousePos *pos){
|
||||
draw_brush(pos->draw_area1,x+pos->x,y+pos->y);
|
||||
/*
|
||||
freopen("drag.txt","a",stdout);
|
||||
g_print("%lf %lf\n",x+pos->x,y+pos->y);
|
||||
fclose(stdout);
|
||||
*/
|
||||
}
|
||||
|
||||
void pressed(GtkGestureMultiPress *gesture,int n_press,double x,double y,GtkWidget *widget){
|
||||
clear_surface();
|
||||
gtk_widget_queue_draw(widget);
|
||||
/*
|
||||
g_print("%d\n",n_press);
|
||||
freopen("drag.txt","w",stdout);
|
||||
printf("\0");
|
||||
fclose(stdout);
|
||||
*/
|
||||
}
|
||||
|
||||
void close_window(void){
|
||||
if(surface){
|
||||
cairo_surface_destroy(surface);
|
||||
}
|
||||
}
|
||||
|
||||
static void gtkmain(GtkApplication *app,gpointer user_data){
|
||||
GtkWidget *window,*draw_area;
|
||||
GtkGesture *press,*drag;
|
||||
//Create a window
|
||||
window=gtk_application_window_new(app);
|
||||
gtk_window_set_title(GTK_WINDOW(window),"Mouse Event Test");
|
||||
gtk_window_set_default_size(GTK_WINDOW(window),640,360);
|
||||
gtk_window_set_icon_name(GTK_WINDOW(window),"org.gtk.daleclack");
|
||||
|
||||
g_signal_connect(window,"destroy",G_CALLBACK(close_window),NULL);
|
||||
|
||||
//Create a draw area
|
||||
draw_area=gtk_drawing_area_new();
|
||||
g_signal_connect(draw_area,"draw",G_CALLBACK(draw_cb),NULL);
|
||||
//Create gestures
|
||||
|
||||
static MousePos pos;
|
||||
pos.draw_area1=draw_area;
|
||||
//"Drag" gesture
|
||||
drag=gtk_gesture_drag_new(draw_area);
|
||||
|
||||
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(drag),GDK_BUTTON_PRIMARY);
|
||||
g_signal_connect(drag,"drag-begin",G_CALLBACK(drag_begin),&pos);
|
||||
g_signal_connect(drag,"drag-update",G_CALLBACK(drag_update),&pos);
|
||||
g_signal_connect(drag,"drag-end",G_CALLBACK(drag_end),&pos);
|
||||
|
||||
//"Press" gesture
|
||||
|
||||
press=gtk_gesture_multi_press_new(draw_area);
|
||||
|
||||
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(press),GDK_BUTTON_SECONDARY);
|
||||
g_signal_connect(press,"pressed",G_CALLBACK(pressed),draw_area);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(window),draw_area);
|
||||
gtk_widget_show_all(window);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
GtkApplication *app;
|
||||
int status;
|
||||
app=gtk_application_new("org.gtk.daleclack",G_APPLICATION_NON_UNIQUE);
|
||||
g_signal_connect(app,"activate",G_CALLBACK(gtkmain),NULL);
|
||||
status=g_application_run(G_APPLICATION(app),argc,argv);
|
||||
return status;
|
||||
}
|
Loading…
Reference in New Issue