Skip to content

Commit

Permalink
gral_window_show
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelash committed Sep 20, 2024
1 parent f94f383 commit 8c8a82f
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions demos/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ static void create_window(void *user_data) {
&focus_leave
};
window->window = gral_window_create(application->application, 800, 600, "gral clipboard demo", &window_interface, window);
gral_window_show(window->window);
}

static void start(void *user_data) {
Expand Down
1 change: 1 addition & 0 deletions demos/cursors.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ static void create_window(void *user_data) {
};
window->window = gral_window_create(application->application, 400, 400, "gral cursors demo", &window_interface, window);
window->cursor = GRAL_CURSOR_DEFAULT;
gral_window_show(window->window);
}

static void start(void *user_data) {
Expand Down
1 change: 1 addition & 0 deletions demos/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ static void create_window(void *user_data) {
};
window->window = gral_window_create(application->application, 600, 400, "gral draw demo", &window_interface, window);
gral_window_set_minimum_size(window->window, 600, 400);
gral_window_show(window->window);
}

static void start(void *user_data) {
Expand Down
1 change: 1 addition & 0 deletions demos/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ static void create_window(void *user_data) {
};
window->window = gral_window_create(application->application, 600, 400, "gral events demo", &window_interface, window);
window->application = application;
gral_window_show(window->window);
}

static void start(void *user_data) {
Expand Down
1 change: 1 addition & 0 deletions demos/file_dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ static void create_window(void *user_data) {
&focus_leave
};
window->window = gral_window_create(application->application, 600, 400, "gral file dialog demo", &window_interface, window);
gral_window_show(window->window);
}

static void start(void *user_data) {
Expand Down
1 change: 1 addition & 0 deletions demos/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ static void create_window(void *user_data) {
window->cursor_x = 0.0f;
gral_font_get_metrics(window->window, font, &window->ascent, &window->descent);
gral_font_delete(font);
gral_window_show(window->window);
}

static void start(void *user_data) {
Expand Down
1 change: 1 addition & 0 deletions gral.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void gral_draw_context_draw_transformed(struct gral_draw_context *draw_context,
===========*/

struct gral_window *gral_window_create(struct gral_application *application, int width, int height, char const *title, struct gral_window_interface const *interface, void *user_data);
void gral_window_show(struct gral_window *window);
void gral_window_set_title(struct gral_window *window, char const *title);
void gral_window_request_redraw(struct gral_window *window, int x, int y, int width, int height);
void gral_window_set_minimum_size(struct gral_window *window, int minimum_width, int minimum_height);
Expand Down
5 changes: 4 additions & 1 deletion gral_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,13 @@ struct gral_window *gral_window_create(struct gral_application *application, int
gtk_window_set_title(GTK_WINDOW(window), title);
GtkWidget *area = g_object_new(GRAL_TYPE_AREA, NULL);
gtk_container_add(GTK_CONTAINER(window), area);
gtk_widget_show_all(GTK_WIDGET(window));
return (struct gral_window *)window;
}

void gral_window_show(struct gral_window *window) {
gtk_widget_show_all(GTK_WIDGET(window));
}

void gral_window_set_title(struct gral_window *window, char const *title) {
gtk_window_set_title(GTK_WINDOW(window), title);
}
Expand Down
12 changes: 8 additions & 4 deletions gral_macos.m
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,17 @@ - (void)doCommandBySelector:(SEL)selector {
window->user_data = user_data;
[window setDelegate:window];
[window setTitle:[NSString stringWithUTF8String:title]];
return (struct gral_window *)window;
}

void gral_window_show(struct gral_window *window_) {
GralWindow *window = (GralWindow *)window_;
GralView *view = [[GralView alloc] init];
view->interface = interface;
view->user_data = user_data;
view->interface = window->interface;
view->user_data = window->user_data;
view->is_pointer_locked = NO;
NSTrackingArea *trackingArea = [[NSTrackingArea alloc]
initWithRect:CGRectMake(0, 0, width, height)
initWithRect:NSZeroRect
options:NSTrackingMouseEnteredAndExited|NSTrackingMouseMoved|NSTrackingActiveAlways|NSTrackingInVisibleRect
owner:view
userInfo:nil
Expand All @@ -584,7 +589,6 @@ - (void)doCommandBySelector:(SEL)selector {
[window setContentView:view];
[view release];
[window makeKeyAndOrderFront:nil];
return (struct gral_window *)window;
}

void gral_window_set_title(struct gral_window *window, char const *title) {
Expand Down
5 changes: 4 additions & 1 deletion gral_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,11 +926,14 @@ gral_window *gral_window_create(gral_application *application, int width, int he
window_data->target = NULL;
window_data->cursor = LoadCursor(NULL, IDC_ARROW);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)window_data);
ShowWindow(hwnd, SW_SHOW);
window_count++;
return (gral_window *)hwnd;
}

void gral_window_show(gral_window *window) {
ShowWindow((HWND)window, SW_SHOW);
}

void gral_window_set_title(gral_window *window, char const *title) {
SetWindowText((HWND)window, utf8_to_utf16(title));
}
Expand Down

0 comments on commit 8c8a82f

Please sign in to comment.