ref: 08aef1095811c8f436a469208b088002e8f4ed21
parent: a578dcbab74f736509dbe3e8fc1cefaa9919132c
author: sirjofri <sirjofri@sirjofri.de>
date: Sat Apr 12 10:54:50 EDT 2025
dirty state tracking, conditional redraw
--- a/nate.c
+++ b/nate.c
@@ -287,15 +287,27 @@
#undef A
}
+/* global "needs" */
+Dirtyflag Gdirty;
+
void
-nateredraw(int all)
+nateredraw(Dirtyflag flags)
{
if (!rootelem)
return;
- if (all)
+ if (flags&RESIZE || Gdirty&RESIZE)
ncallcalcrect(rootelem, screen, screen->r);
- ncalldraw(rootelem, screen);
+ if (flags&DRAW || flags&RESIZE || Gdirty&DRAW)
+ ncalldraw(rootelem, screen);
+}
+
+void
+nsetdirty(Nelem *nel, Dirtyflag flag)
+{
+ if (nel)
+ nel->dirty |= flag;
+ Gdirty |= flag;
}
void
--- a/nate.h
+++ b/nate.h
@@ -58,8 +58,13 @@
/* user functions */
/******************/
+typedef enum {
+ DRAW = 1,
+ RESIZE = 2,
+} Dirtyflag;
+
void nateinit(void);
-void nateredraw(int all);
+void nateredraw(Dirtyflag flags);
void ndebugprint(Nelem*, char*, ...);
int natemouseevent(Mouse);
@@ -102,6 +107,7 @@
char *type;
char *name;
Nslot slot;
+ Dirtyflag dirty;
Nlist children;
int nchildren; /* -1=inf, 0=none, n otherwise */
Nelemaccessors *accs;
@@ -149,6 +155,8 @@
int ncallhit(Nelem*, Mouse);
void ncallfree(Nelem*);
Nlist* ncallgetchildren(Nelem*);
+
+void nsetdirty(Nelem*, Dirtyflag);
/***********************/