- [NEW] Les finestres guarden la posició i el zoom

This commit is contained in:
2025-07-29 11:29:35 +02:00
parent 913450fadb
commit 2a0febc6b7
5 changed files with 352 additions and 7 deletions

View File

@@ -11,6 +11,7 @@
#include "ui_window.h"
#include "zx_screen.h"
#include "ay-3-8912.h"
#include "file.h"
#define RESIZING_NONE 0
#define RESIZING_MEMORY 1
@@ -28,7 +29,7 @@ namespace z80debug
int mem_h = 8;
int con_h = 6;
int sym_h = 14;
int zoom = 1;
int resizing_type = RESIZING_MEMORY;
bool resizing = false;
@@ -94,6 +95,15 @@ namespace z80debug
return temp;
}
void saveWindowConfiguration()
{
file::setConfigValueInteger("debug_zoom", zoom);
int x, y;
SDL_GetWindowPosition(win, &x, &y);
file::setConfigValueInteger("debug_x", x);
file::setConfigValueInteger("debug_y", y);
}
bool eventHandler(SDL_Event *e)
{
if (e->type == SDL_MOUSEMOTION) {
@@ -104,7 +114,7 @@ namespace z80debug
if ((e->window.event==SDL_WINDOWEVENT_SHOWN) || (e->window.event==SDL_WINDOWEVENT_EXPOSED)) {
int w; int h;
SDL_GetWindowSize(win, &w, &h);
w/=2; h/=2;
w/=zoom; h/=zoom;
midx = (w/CHR_W) - 25;
win_h = (h/CHR_H);
mem_y = win_h - mem_h - con_h;
@@ -115,6 +125,8 @@ namespace z80debug
} else if (e->window.event == SDL_WINDOWEVENT_CLOSE) {
hide();
zxscreen::focus();
} else if (e->window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
saveWindowConfiguration();
}
}
if (e->type == SDL_MOUSEWHEEL) {
@@ -144,9 +156,15 @@ namespace z80debug
z80debug::refresh();
z80analyze::refresh();
} else if (e->key.keysym.scancode==SDL_SCANCODE_F2) {
z80debug::history::goback();
z80debug::refresh();
z80analyze::refresh();
if (e->key.keysym.mod & KMOD_CTRL) {
zoom = zoom==1?2:1;
hide();
show();
} else {
z80debug::history::goback();
z80debug::refresh();
z80analyze::refresh();
}
} else if (e->key.keysym.scancode==SDL_SCANCODE_F3) {
z80debug::history::goforward();
z80debug::refresh();
@@ -333,7 +351,10 @@ namespace z80debug
void show()
{
if (!win) {
win = SDL_CreateWindow("Z80 Debugger", 10, 50, 98*CHR_W*2, 44*CHR_H*2, SDL_WINDOW_SHOWN);
zoom = file::getConfigValueInteger("debug_zoom", 1);
const int x = file::getConfigValueInteger("debug_x", SDL_WINDOWPOS_UNDEFINED);
const int y = file::getConfigValueInteger("debug_y", SDL_WINDOWPOS_UNDEFINED);
win = SDL_CreateWindow("Z80 Debugger", x, y, 98*CHR_W*zoom, 44*CHR_H*zoom, SDL_WINDOW_SHOWN);
ren = SDL_CreateRenderer(win, -1, 0);
SDL_RenderSetLogicalSize(ren, 98*CHR_W, 44*CHR_H);
ui::window::registerWindow(SDL_GetWindowID(win), eventHandler);
@@ -353,6 +374,7 @@ namespace z80debug
void hide()
{
saveWindowConfiguration();
ui::window::unregisterWindow(SDL_GetWindowID(win));
if (tex) SDL_DestroyTexture(tex);
if (ren) SDL_DestroyRenderer(ren);