feat: add css logging
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
BasedOnStyle: LLVM
|
BasedOnStyle: LLVM
|
||||||
ColumnLimit: 80
|
ColumnLimit: 80
|
||||||
BreakBeforeBraces: Attach
|
BreakBeforeBraces: Attach
|
||||||
IndentWidth: 2
|
IndentWidth: 4
|
||||||
ContinuationIndentWidth: 4
|
ContinuationIndentWidth: 4
|
||||||
0
src/application/applicationstate.c
Normal file
0
src/application/applicationstate.c
Normal file
7
src/application/applicationstate.h
Normal file
7
src/application/applicationstate.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
typedef enum VektorAppTool {
|
||||||
|
CircleTool
|
||||||
|
} VektorAppTool;
|
||||||
|
|
||||||
|
typedef struct VektorAppState {
|
||||||
|
VektorAppTool selectedTool;
|
||||||
|
} VektorAppState;
|
||||||
11
src/main.c
11
src/main.c
@@ -13,7 +13,7 @@ static void on_map(GtkWidget *window, gpointer user_data) {
|
|||||||
void write_ppm(const char *path, const VektorFramebuffer *fb) {
|
void write_ppm(const char *path, const VektorFramebuffer *fb) {
|
||||||
FILE *f = fopen(path, "wb");
|
FILE *f = fopen(path, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
abort();
|
abort();
|
||||||
|
|
||||||
fprintf(f, "P6\n%d %d\n255\n", fb->width, fb->height);
|
fprintf(f, "P6\n%d %d\n255\n", fb->width, fb->height);
|
||||||
fwrite(fb->pixels, 1, fb->width * fb->height * 4, f);
|
fwrite(fb->pixels, 1, fb->width * fb->height * 4, f);
|
||||||
@@ -32,27 +32,26 @@ static void activate(GtkApplication *app, gpointer user_data) {
|
|||||||
vektor_edgebuffer_flatten_polygon(&edges, &pg);
|
vektor_edgebuffer_flatten_polygon(&edges, &pg);
|
||||||
|
|
||||||
for (size_t i = 0; i < edges.count; i++) {
|
for (size_t i = 0; i < edges.count; i++) {
|
||||||
vektor_framebuffer_drawline(&fb, edges.edges[i].p1, edges.edges[i].p2, 0, 0, 0);
|
vektor_framebuffer_drawline(&fb, edges.edges[i].p1, edges.edges[i].p2, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VektorWidgetState *widget_state =
|
VektorWidgetState *widget_state =
|
||||||
(VektorWidgetState *)malloc(sizeof(VektorWidgetState));
|
(VektorWidgetState *)malloc(sizeof(VektorWidgetState));
|
||||||
vektor_uictrl_init(app, widget_state);
|
vektor_uictrl_init(app, widget_state);
|
||||||
|
|
||||||
VektorCanvas *canvas = (VektorCanvas *)malloc(sizeof(VektorCanvas));
|
VektorCanvas *canvas = (VektorCanvas *)malloc(sizeof(VektorCanvas));
|
||||||
vektor_canvas_init(widget_state, canvas);
|
vektor_canvas_init(widget_state, canvas);
|
||||||
vektor_canvas_fill(canvas, vektor_color_new(255,0,0,255));
|
vektor_canvas_fill(canvas, vektor_color_new(0,0,0,255));
|
||||||
vektor_framebuffer_drawto(&fb, canvas);
|
vektor_framebuffer_drawto(&fb, canvas);
|
||||||
vektor_canvas_update(canvas);
|
vektor_canvas_update(canvas);
|
||||||
|
|
||||||
g_signal_connect(widget_state->window, "map", G_CALLBACK(on_map),
|
g_signal_connect(widget_state->window, "map", G_CALLBACK(on_map),
|
||||||
widget_state);
|
widget_state);
|
||||||
|
|
||||||
gtk_window_present(widget_state->window);
|
gtk_window_present(widget_state->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
//write_ppm("out.ppm", &fb);
|
|
||||||
|
|
||||||
GtkApplication *app;
|
GtkApplication *app;
|
||||||
int status;
|
int status;
|
||||||
|
|||||||
@@ -1,17 +1,24 @@
|
|||||||
#include "uicontroller.h"
|
#include "uicontroller.h"
|
||||||
|
#include "gdk/gdk.h"
|
||||||
#include "gtk/gtk.h"
|
#include "gtk/gtk.h"
|
||||||
|
#include "gtk/gtkcssprovider.h"
|
||||||
|
|
||||||
void vektor_uictrl_init(GtkApplication *app, VektorWidgetState *stateOut) {
|
void vektor_uictrl_init(GtkApplication *app, VektorWidgetState *stateOut) {
|
||||||
GtkBuilder *builder = gtk_builder_new();
|
GtkBuilder *builder = gtk_builder_new();
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
g_print("%s\n", g_get_current_dir());
|
|
||||||
|
|
||||||
// TODO: .ui files as resources instead of sketchy relative paths
|
// TODO: .ui files as resources instead of sketchy relative paths
|
||||||
if (!gtk_builder_add_from_file(builder, "./ui/main.ui", &error)) {
|
if (!gtk_builder_add_from_file(builder, "./ui/main.ui", &error)) {
|
||||||
g_error("Fatal: %s", error->message);
|
g_error("Fatal: %s", error->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkCssProvider* provider = gtk_css_provider_new();
|
||||||
|
gtk_css_provider_load_from_path(provider, "./ui/main.css");
|
||||||
|
gtk_style_context_add_provider_for_display(gdk_display_get_default(),
|
||||||
|
GTK_STYLE_PROVIDER(provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||||
|
);
|
||||||
|
|
||||||
stateOut->window = GTK_WINDOW(gtk_builder_get_object(builder, "main_window"));
|
stateOut->window = GTK_WINDOW(gtk_builder_get_object(builder, "main_window"));
|
||||||
stateOut->workspacePaned =
|
stateOut->workspacePaned =
|
||||||
GTK_PANED(gtk_builder_get_object(builder, "workspace_paned"));
|
GTK_PANED(gtk_builder_get_object(builder, "workspace_paned"));
|
||||||
|
|||||||
9
ui/main.css
Executable file
9
ui/main.css
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#toolstrip {
|
||||||
|
background: rgba(0,0,0,.6);
|
||||||
|
padding: 6px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
46
ui/main.ui
46
ui/main.ui
@@ -38,12 +38,48 @@
|
|||||||
<property name="vexpand">true</property>
|
<property name="vexpand">true</property>
|
||||||
<property name="wide-handle">true</property>
|
<property name="wide-handle">true</property>
|
||||||
|
|
||||||
<!--Main viewport area-->
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPicture" id="workspace">
|
<!--Overlay to hold tool selector and canvas-->
|
||||||
<property name="content-fit">cover</property>
|
<object class="GtkOverlay">
|
||||||
<property name="hexpand">true</property>
|
|
||||||
<property name="vexpand">true</property>
|
<!--Main canvas-->
|
||||||
|
<child>
|
||||||
|
<object class="GtkPicture" id="workspace">
|
||||||
|
<property name="content-fit">contain</property>
|
||||||
|
<property name="hexpand">true</property>
|
||||||
|
<property name="vexpand">true</property>
|
||||||
|
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<!--Tool selector-->
|
||||||
|
<child type="overlay">
|
||||||
|
<object class="GtkBox" id="toolstrip">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
|
||||||
|
<property name="margin-start">12</property>
|
||||||
|
<property name="margin-top">12</property>
|
||||||
|
<property name="margin-bottom">12</property>
|
||||||
|
|
||||||
|
<!--Tool buttons-->
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton">
|
||||||
|
<property name="icon-name">insert-object-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton">
|
||||||
|
<property name="icon-name">edit-copy-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|||||||
Reference in New Issue
Block a user