~rabbits/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH left 1/2] Window: Scale window with ctrl+ and ctrl-

Details
Message ID
<20210110064433.25177-1-zachdecook@librem.one>
DKIM signature
missing
Download raw message
Patch: +14 -0
---
 left.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/left.c b/left.c
index 1959854..6559922 100644
--- a/left.c
+++ b/left.c
@@ -649,6 +649,13 @@ domouse(SDL_Event *event)
	}
}

void doresize(int n)
{
	ZOOM = clamp(ZOOM+n,1,8);
	SDL_SetWindowSize(gWindow, WIDTH*ZOOM, HEIGHT*ZOOM);
	redraw(pixels);
}

void
dokey(SDL_Event *event)
{
@@ -693,6 +700,13 @@ dokey(SDL_Event *event)
		if(ctrl)
			savetxt();
		break;
	case SDLK_PLUS:
	case SDLK_EQUALS:
		if(ctrl)doresize(1);
		break;
	case SDLK_MINUS:
		if(ctrl)doresize(-1);
		break;
	}
}

-- 
2.29.2

[PATCH left 2/2] Window: Support HighDPI scaling

Details
Message ID
<20210110064433.25177-2-zachdecook@librem.one>
In-Reply-To
<20210110064433.25177-1-zachdecook@librem.one> (view parent)
DKIM signature
missing
Download raw message
Patch: +7 -6
---
 left.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/left.c b/left.c
index 6559922..0903680 100644
--- a/left.c
+++ b/left.c
@@ -34,7 +34,8 @@ typedef struct {

int WIDTH = 8 * HOR + 8 * PAD * 2;
int HEIGHT = 8 * (VER + 2) + 8 * PAD * 2;
int FPS = 30, GUIDES = 1, ZOOM = 1, DOWN = 0;
int FPS = 30, GUIDES = 1, DOWN = 0;
float ZOOM = 1;
int RULER = 60;

/* interface */
@@ -649,9 +650,9 @@ domouse(SDL_Event *event)
	}
}

void doresize(int n)
void doresize(float n)
{
	ZOOM = clamp(ZOOM+n,1,8);
	ZOOM = (ZOOM+n < 0.5) ? 0.5 : (ZOOM+n > 8) ? 8 : ZOOM+n;
	SDL_SetWindowSize(gWindow, WIDTH*ZOOM, HEIGHT*ZOOM);
	redraw(pixels);
}
@@ -702,10 +703,10 @@ dokey(SDL_Event *event)
		break;
	case SDLK_PLUS:
	case SDLK_EQUALS:
		if(ctrl)doresize(1);
		if(ctrl)doresize(0.5);
		break;
	case SDLK_MINUS:
		if(ctrl)doresize(-1);
		if(ctrl)doresize(-0.5);
		break;
	}
}
@@ -750,7 +751,7 @@ init(void)
		SDL_WINDOWPOS_UNDEFINED,
		WIDTH * ZOOM,
		HEIGHT * ZOOM,
		SDL_WINDOW_SHOWN);
		SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
	if(gWindow == NULL)
		return error("Window", SDL_GetError());
	gRenderer = SDL_CreateRenderer(gWindow, -1, 0);
-- 
2.29.2
Reply to thread Export thread (mbox)