[GTK3] Add vram_viewer_clear()

This commit is contained in:
Maximilian Mader 2020-05-17 23:13:59 +02:00
parent f74b1cd3d9
commit 6a15ff582e
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
3 changed files with 18 additions and 15 deletions

View File

@ -1716,18 +1716,7 @@ static void close_rom(void) {
gtk_gl_area_queue_render(gui_data.gl_area);
}
// Clear the VRAM viewer
// g_mutex_lock(&gui_data.tileset_buffer_mutex);
// memset(gui_data.tileset_buffer, 0, sizeof gui_data.tileset_buffer);
// g_mutex_unlock(&gui_data.tileset_buffer_mutex);
// g_mutex_lock(&gui_data.tilemap_buffer_mutex);
// memset(gui_data.tilemap_buffer, 0, sizeof gui_data.tilemap_buffer);
// g_mutex_unlock(&gui_data.tilemap_buffer_mutex);
gtk_stack_set_visible_child_name(builder_get(GTK_STACK, "vram_viewer_stack"), "vram_viewer_tileset");
gtk_tree_view_set_model(builder_get(GTK_TREE_VIEW, "vram_viewer_sprites"), NULL);
gtk_tree_view_set_model(builder_get(GTK_TREE_VIEW, "vram_viewer_palettes"), NULL);
vram_viewer_clear(gui_data.vram_viewer);
// Redraw the VRAM viewer
gtk_widget_queue_draw(GTK_WIDGET(gui_data.vram_viewer));

View File

@ -375,7 +375,7 @@ static gboolean update_sprite_list(VramViewerWindow *window) {
GtkListStore *store;
if (!model) {
g_autoptr(GtkListStore) new_store = gtk_list_store_new(7,
GtkListStore *new_store = gtk_list_store_new(7,
GDK_TYPE_PIXBUF, // Preview image
G_TYPE_STRING, // X position
G_TYPE_STRING, // Y position
@ -477,7 +477,7 @@ static gboolean update_palettes(VramViewerWindow *window) {
GtkListStore *store;
if (!model) {
g_autoptr(GtkListStore) new_store = gtk_list_store_new(9,
GtkListStore *new_store = gtk_list_store_new(9,
G_TYPE_STRING, // Name
G_TYPE_STRING, // Color 0 string
@ -613,4 +613,17 @@ void vram_viewer_update(VramViewerWindow *window, GB_gameboy_t *gb) {
g_idle_add((GSourceFunc) update_palettes, window);
}
}
}
void vram_viewer_clear(VramViewerWindow *window) {
g_idle_remove_by_data(window);
memset(window->tilemap_buffer, 0, tilemap_buffer_length * sizeof(uint32_t));
memset(window->tileset_buffer, 0, tileset_buffer_length * sizeof(uint32_t));
g_autoptr(GtkTreeModel) sprites_model = gtk_tree_view_get_model(window->sprites);
if (sprites_model) gtk_list_store_clear(GTK_LIST_STORE(sprites_model));
g_autoptr(GtkTreeModel) palettes_model = gtk_tree_view_get_model(window->palettes);
if (palettes_model) gtk_list_store_clear(GTK_LIST_STORE(palettes_model));
}

View File

@ -26,5 +26,6 @@ uint32_t *vram_viewer_get_tileset_buffer(VramViewerWindow *window);
uint32_t *vram_viewer_get_tilemap_buffer(VramViewerWindow *window);
void vram_viewer_update(VramViewerWindow *window, GB_gameboy_t *gb);
void vram_viewer_clear(VramViewerWindow *window);
#endif