Compare commits

..

13 commits

Author SHA1 Message Date
270c87bca2
care abt DESTDIR 2025-12-15 07:21:45 +09:00
dabe62d475
forgot 2025-12-15 07:10:23 +09:00
1e74356db7
method name consistency 2025-12-15 07:05:42 +09:00
bc998806ee
oops 2025-12-15 06:51:31 +09:00
cf4fdc531a
update color things 2025-12-15 06:48:40 +09:00
f9c0ec987e
improvement 2025-12-12 17:51:26 +09:00
0c8715ec9f
bugfix 2025-12-12 17:26:57 +09:00
363897df74
background pixmap 2025-12-11 01:37:13 +09:00
e57f3fd910
update 2025-12-11 00:50:50 +09:00
82f9330bef
add MwNfillArea 2025-12-10 13:26:19 +09:00
bbc27d680a
that is simply wrong 2025-12-10 12:57:40 +09:00
0c787264c6
fix some stuff 2025-12-10 11:15:52 +09:00
9a4c74ad93 Unfinished Wayland PR (#1)
moved from the github repo.

current progress:

<img width="389" alt="image.png" src="attachments/6a2cb365-7348-44b4-8fa7-9980df965a67">

Other notes:

- took the opportunity to remove MwLLSetBackground which I was told was deprecated
- Updated .gitignore to more accurately cover/remove example binaries
- Uses OpenGL as the backend.
- New LL function for swapping buffers, MwLLEndDraw
- [TODO] Uses weak linking for all libraries so that systems that don't support Wayland or even have it installed can launch without it.

Reviewed-on: https://gitea.nishi.boats/pyrite-dev/milsko/pulls/1
Co-authored-by: IoIxD <alphaproject217@gmail.com>
Co-committed-by: IoIxD <alphaproject217@gmail.com>
2025-12-09 20:11:01 -06:00
25 changed files with 4881 additions and 904 deletions

View file

@ -1 +0,0 @@
header-insertion: never

View file

@ -171,10 +171,10 @@ print(OUT "\n");
print(OUT "all: lib examples\n");
print(OUT "\n");
print(OUT "install: lib\n");
print(OUT " mkdir -p \$(PREFIX)/lib \$(PREFIX)/include\n");
print(OUT " -cp src/${library_prefix}Mw${library_suffix} \$(PREFIX)/lib/\n");
print(OUT " -cp src/libMw.a \$(PREFIX)/lib/\n");
print(OUT " cp -rf include \$(PREFIX)/\n");
print(OUT " mkdir -p \$(DESTDIR)\$(PREFIX)/lib \$(DESTDIR)\$(PREFIX)/include\n");
print(OUT " -cp src/${library_prefix}Mw${library_suffix} \$(DESTDIR)\$(PREFIX)/lib/\n");
print(OUT " -cp src/libMw.a \$(DESTDIR)\$(PREFIX)/lib/\n");
print(OUT " cp -rf include \$(DESTDIR)\$(PREFIX)/\n");
print(OUT "\n");
print(OUT "format:\n");
print(OUT

View file

@ -142,10 +142,10 @@ int main() {
NULL);
bgcolor = MwParseColor(window, MwGetText(window, MwNbackground));
MwGetColor(bgcolor, &br, &bg, &bb);
MwColorGet(bgcolor, &br, &bg, &bb);
fgcolor = MwParseColor(window, MwGetText(window, MwNforeground));
MwGetColor(fgcolor, &fr, &fg, &fb);
MwColorGet(fgcolor, &fr, &fg, &fb);
opengl = MwCreateWidget(MwOpenGLClass, "clock", window, 0, 0, 100, 100);

View file

@ -31,7 +31,7 @@ typedef uint16_t MwU16;
typedef int8_t MwI8;
typedef uint8_t MwU8;
#define OTHER_TYPES_DEFINED
#define MW_OTHER_TYPES_DEFINED
#elif __GNUC__ > 2
typedef long long MwI64;
typedef unsigned long long MwU64;
@ -48,18 +48,18 @@ typedef unsigned __int16 MwU16;
typedef __int8 MwI8;
typedef unsigned __int8 MwU8;
#define OTHER_TYPES_DEFINED
#define MW_OTHER_TYPES_DEFINED
#else
/* out of hope */
typedef long MwI64;
typedef unsigned long MwU64;
#endif
#ifdef OTHER_TYPES_DEFINED
#undef OTHER_TYPES_DEFINED
#ifdef MW_OTHER_TYPES_DEFINED
#undef MW_OTHER_TYPES_DEFINED
#else
typedef int MwI32;
typedef unsigned int MwU32;
typedef int MwI32;
typedef unsigned int MwU32;
typedef short MwI16;
typedef unsigned short MwU16;

View file

@ -21,6 +21,13 @@ extern "C" {
*/
MWDECL MwLLColor MwParseColor(MwWidget handle, const char* text);
/*!
* @brief Parses a color text
* @param text Color text
* @param rgb RGB
*/
MWDECL void MwParseColorNoAllocate(const char* text, MwRGB* rgb);
/*!
* @brief Lighten a color
* @param handle Widget
@ -105,7 +112,7 @@ MWDECL MwLLPixmap MwLoadImage(MwWidget handle, const char* path);
* @param green Pointer to green color
* @param blue Pointer to blue color
*/
MWDECL void MwGetColor(MwLLColor color, int* red, int* green, int* blue);
MWDECL void MwColorGet(MwLLColor color, int* red, int* green, int* blue);
/*!
* @brief Creates a pixmap from raw data
@ -118,14 +125,25 @@ MWDECL void MwGetColor(MwLLColor color, int* red, int* green, int* blue);
MWDECL MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height);
/*!
* @brief Creates a pixmap from raw data
* @param handle Widget
* @brief Updates a pixmap using raw data
* @param pixmap Pixmap to update
* @param rgb RGBA data
* @param width Width
* @param height Height
* @return Pixmap
*/
MWDECL void MwReloadRaw(MwWidget handle, unsigned char* rgb, int width, int height, MwLLPixmap pixmap);
MWDECL void MwPixmapReloadRaw(MwLLPixmap pixmap, unsigned char* rgb);
/*!
* @brief Gets the raw data of pixmap
* @param pixmap Pixmap
* @return RFBA data
*/
MWDECL unsigned char* MwPixmapGetRaw(MwLLPixmap pixmap);
/*!
* @brief Gets the size of pixmap
* @param pixmap Pixmap
* @param rect Size
*/
MWDECL void MwPixmapGetSize(MwLLPixmap pixmap, MwRect* rect);
/*!
* @brief Creates a pixmap from XPM data
@ -191,6 +209,13 @@ MWDECL int MwTextHeight(MwWidget handle, const char* text);
*/
MWDECL MwLLColor MwParseColorName(MwWidget handle, const char* color);
/*!
* @brief Parses a color name
* @param color Color name
* @param rgb RGB
*/
MWDECL void MwParseColorNameNoAllocate(const char* color, MwRGB* rgb);
#ifdef __cplusplus
}
#endif

View file

@ -47,6 +47,7 @@ struct _MwLLCommonPixmap {
int width;
int height;
unsigned char* raw;
void* user;
};
#ifdef _MILSKO

View file

@ -1,7 +1,8 @@
/*!
* @file Mw/LowLevel/Wayland.h
* @brief Wayland Backend
* @warning This is used internally
* @brief Work in progress Wayland Backend
* @warning This is used internally.
* @warning This is disabled by default.
*/
#ifndef __MW_LOWLEVEL_WAYLAND_H__
#define __MW_LOWLEVEL_WAYLAND_H__

View file

@ -31,6 +31,7 @@
#define MwNshowArrows "IshowArrows"
#define MwNpadding "Ipadding"
#define MwNborderWidth "IborderWidth"
#define MwNfillArea "IfillArea"
#define MwNtitle "Stitle"
#define MwNtext "Stext"
@ -44,6 +45,7 @@
#define MwNsizeHints "VsizeHints"
#define MwNfont "Vfont"
#define MwNboldFont "VboldFont"
#define MwNbackgroundPixmap "VbackgroundPixmap"
#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox)/void* (MwTreeView) */
#define MwNresizeHandler "Cresize" /* NULL */

View file

@ -48,6 +48,7 @@
- MwNwidth
- MwNheight
- MwNborderWidth
- MwNbackgroundPixmap
Integer properties must be prefixed with I.
String properties must be prefixed with S.
@ -488,6 +489,7 @@
<property name="text" />
<property name="flat" />
<property name="padding" />
<property name="fillArea" />
</properties>
</widget>
<widget name="CheckBox">

View file

@ -53,7 +53,7 @@ static void sync_move(MwLL handle, int x, int y) {
XSync(handle->x11.display, False);
if(!XPending(handle->x11.display)) continue;
XNextEvent(handle->x11.display, &ev);
if(ev.type == ReparentNotify && ev.xreparent.window == handle->x11.window && ev.xreparent.window != RootWindow(handle->x11.display, DefaultScreen(handle->x11.display))) {
if(ev.type == ReparentNotify && ev.xreparent.window == handle->x11.window) {
break;
} else {
arrput(queue, ev);
@ -580,9 +580,7 @@ static void MwLLSetTitleImpl(MwLL handle, const char* title) {
}
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
MwLLPixmap r = malloc(sizeof(*r));
char* di = malloc(4 * width * height);
char* dm = malloc(4 * width * height);
MwLLPixmap r = malloc(sizeof(*r));
int evbase, erbase;
XWindowAttributes attr;
@ -603,8 +601,11 @@ static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int wid
r->x11.use_xrender = XRenderQueryExtension(handle->x11.display, &evbase, &erbase) ? 1 : 0;
#endif
r->x11.image = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), r->x11.depth, ZPixmap, 0, di, width, height, 32, width * 4);
r->x11.mask = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), 1, ZPixmap, 0, dm, width, height, 32, width * 4);
r->x11.image = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), r->x11.depth, ZPixmap, 0, NULL, width, height, 32, 0);
r->x11.mask = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), 1, ZPixmap, 0, NULL, width, height, 32, 0);
r->x11.image->data = malloc(r->x11.image->bytes_per_line * height);
r->x11.mask->data = malloc(r->x11.mask->bytes_per_line * height);
MwLLPixmapUpdate(r);
return r;
@ -1020,7 +1021,7 @@ static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
XWindowAttributes xwa;
XGetWindowAttributes(handle->x11.display, handle->x11.window, &xwa);
XGetWindowAttributes(handle->x11.display, DefaultRootWindow(handle->x11.display), &xwa);
rect->x = rect->y = 0;
rect->width = xwa.width;

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,6 @@
#include <Mw/Milsko.h>
#include "../external/stb_ds.h"
#include "Mw/LowLevel.h"
static void lldrawhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;

View file

@ -146,11 +146,11 @@ static void color_picker_image_update(color_picker_t* picker) {
picker->color_picker_pixmap = MwLoadRaw(
picker->parent, picker->color_picker_image_data, PICKER_SIZE, PICKER_SIZE);
} else {
MwReloadRaw(
picker->parent, picker->color_picker_image_data, PICKER_SIZE, PICKER_SIZE, picker->color_picker_pixmap);
MwPixmapReloadRaw(
picker->color_picker_pixmap, picker->color_picker_image_data);
}
MwVaApply(picker->color_picker_img, MwNpixmap, picker->color_picker_pixmap, NULL);
// printf("%d\n", n);
/* printf("%d\n", n); */
}
static void color_picker_click(MwWidget handle, void* user, void* call) {
@ -165,7 +165,7 @@ static void color_picker_click(MwWidget handle, void* user, void* call) {
(void)user;
(void)call;
// color_picker_image_update(picker);
/* color_picker_image_update(picker); */
i = ((mouse->point.y * PICKER_SIZE) + mouse->point.x) * 4;
@ -198,7 +198,7 @@ static void color_picker_on_change_value(MwWidget handle, void* user,
picker->value = ((double)value / 1024.);
picker->doUpdate = 1;
// color_picker_image_update(picker);
/* color_picker_image_update(picker); */
}
static void color_picker_tick(MwWidget handle, void* user,
@ -282,12 +282,12 @@ color_picker_t* color_picker_setup(MwWidget parent, int w, int h) {
MwVaCreateWidget(MwImageClass, "image", picker->parent, IMG_POS_X(w), IMG_POS_Y(h),
PICKER_SIZE, PICKER_SIZE, NULL);
// picker->color_picker_image_data = malloc(PICKER_SIZE * PICKER_SIZE * 4);
/* picker->color_picker_image_data = malloc(PICKER_SIZE * PICKER_SIZE * 4); */
picker->color_picker_pixmap = NULL;
picker->value = 0;
// color_picker_image_update(picker);
/* color_picker_image_update(picker); */
picker->doUpdate = 1;
MwAddUserHandler(picker->color_picker_img, MwNmouseDownHandler,
@ -299,7 +299,7 @@ color_picker_t* color_picker_setup(MwWidget parent, int w, int h) {
MwSetText(picker->color_display_text, MwNbackground, "#FFFFFF");
MwSetText(picker->color_display_text, MwNtext, "#FFFFFF");
// MwSetInteger(picker->color_display_text, Mwnali, MwALIGNMENT_CENTER);
/* MwSetInteger(picker->color_display_text, Mwnali, MwALIGNMENT_CENTER); */
MwAddUserHandler(picker->color_display_text, MwNactivateHandler,
color_display_text_change, picker);

View file

@ -37,28 +37,35 @@ static int hex(const char* txt, int len) {
return r;
}
MwLLColor MwParseColor(MwWidget handle, const char* text) {
int r;
int g;
int b;
void MwParseColorNoAllocate(const char* text, MwRGB* rgb) {
if(text[0] == '#' && strlen(text) == 4) {
r = hex(text + 1, 1);
g = hex(text + 2, 1);
b = hex(text + 3, 1);
rgb->red = hex(text + 1, 1);
rgb->green = hex(text + 2, 1);
rgb->blue = hex(text + 3, 1);
r |= r << 4;
g |= g << 4;
b |= b << 4;
rgb->red |= rgb->red << 4;
rgb->green |= rgb->green << 4;
rgb->blue |= rgb->blue << 4;
} else if(text[0] == '#' && strlen(text) == 7) {
r = hex(text + 1, 2);
g = hex(text + 3, 2);
b = hex(text + 5, 2);
rgb->red = hex(text + 1, 2);
rgb->green = hex(text + 3, 2);
rgb->blue = hex(text + 5, 2);
} else {
return MwParseColorName(handle, text);
MwParseColorNameNoAllocate(text, rgb);
return;
}
}
return MwLLAllocColor(handle->lowlevel, r, g, b);
MwLLColor MwParseColor(MwWidget handle, const char* text) {
MwRGB rgb;
rgb.red = 0;
rgb.green = 0;
rgb.blue = 0;
MwParseColorNoAllocate(text, &rgb);
return MwLLAllocColor(handle->lowlevel, rgb.red, rgb.green, rgb.blue);
}
MwLLColor MwLightenColor(MwWidget handle, MwLLColor color, int r, int g, int b) {
@ -649,45 +656,21 @@ MwLLPixmap MwLoadImage(MwWidget handle, const char* path) {
}
MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height) {
MwLLPixmap px;
unsigned char* out = malloc(width * height * 4);
int i;
MwLLColor base = handle->bgcolor == NULL ? MwParseColor(handle, MwGetText(handle, MwNbackground)) : handle->bgcolor;
MwLLPixmap px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height);
memset(out, 0, width * height * 4);
for(i = 0; i < width * height; i++) {
unsigned char* pin = &rgb[i * 4];
unsigned char* pout = &out[i * 4];
double a = pin[3];
a /= 255;
if(a != 0) {
pout[0] = pin[0] * a;
pout[1] = pin[1] * a;
pout[2] = pin[2] * a;
pout[0] += base->common.red * (1 - a);
pout[1] += base->common.green * (1 - a);
pout[2] += base->common.blue * (1 - a);
pout[3] = 255;
}
}
if(handle->bgcolor == NULL) MwLLFreeColor(base);
px = MwLLCreatePixmap(handle->lowlevel, out, width, height);
free(out);
px->common.user = handle;
MwPixmapReloadRaw(px, rgb);
return px;
}
void MwReloadRaw(MwWidget handle, unsigned char* rgb, int width, int height, MwLLPixmap px) {
void MwPixmapReloadRaw(MwLLPixmap px, unsigned char* rgb) {
int i;
MwLLColor base = handle->bgcolor == NULL ? MwParseColor(handle, MwGetText(handle, MwNbackground)) : handle->bgcolor;
MwWidget handle = px->common.user;
MwLLColor base = handle->bgcolor == NULL ? MwParseColor(handle, MwGetText(handle, MwNbackground)) : handle->bgcolor;
memset(px->common.raw, 0, width * height * 4);
for(i = 0; i < width * height; i++) {
memset(px->common.raw, 0, px->common.width * px->common.height * 4);
for(i = 0; i < px->common.width * px->common.height; i++) {
unsigned char* pin = &rgb[i * 4];
unsigned char* pout = &px->common.raw[i * 4];
double a = pin[3];
@ -710,7 +693,16 @@ void MwReloadRaw(MwWidget handle, unsigned char* rgb, int width, int height, MwL
MwLLPixmapUpdate(px);
}
void MwGetColor(MwLLColor color, int* red, int* green, int* blue) {
unsigned char* MwPixmapGetRaw(MwLLPixmap pixmap) {
return pixmap->common.raw;
}
void MwPixmapGetSize(MwLLPixmap pixmap, MwRect* rect) {
rect->width = pixmap->common.width;
rect->height = pixmap->common.height;
}
void MwColorGet(MwLLColor color, int* red, int* green, int* blue) {
*red = color->common.red;
*green = color->common.green;
*blue = color->common.blue;

View file

@ -292,6 +292,7 @@ static int ttf_MwTextHeight(MwWidget handle, int count) {
#endif
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
if(strlen(text) == 0) return;
#ifdef TTF
if(ttf_MwDrawText(handle, point, text, bold, align, color))
#endif

View file

@ -5,6 +5,7 @@ static int create(MwWidget handle) {
MwSetInteger(handle, MwNflat, 0);
MwSetInteger(handle, MwNpadding, 0);
MwSetInteger(handle, MwNfillArea, 1);
return 0;
}
@ -16,6 +17,7 @@ static void draw(MwWidget handle) {
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
const char* str = MwGetText(handle, MwNtext);
MwLLPixmap px = MwGetVoid(handle, MwNpixmap);
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
if(str == NULL) str = "";
@ -33,6 +35,7 @@ static void draw(MwWidget handle) {
} else {
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
}
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
if(MwGetInteger(handle, MwNflat) && !handle->pressed) {
r.x += MwDefaultBorderWidth(handle);
r.y += MwDefaultBorderWidth(handle);
@ -44,18 +47,23 @@ static void draw(MwWidget handle) {
int ow = r.width;
int oh = r.height;
double sw = (double)ow / px->common.width;
double sh = (double)oh / px->common.height;
if(MwGetInteger(handle, MwNfillArea)) {
double sw = (double)ow / px->common.width;
double sh = (double)oh / px->common.height;
if(sw < sh) {
r.width = px->common.width * sw;
r.height = px->common.height * sw;
if(sw < sh) {
r.width = px->common.width * sw;
r.height = px->common.height * sw;
} else {
r.width = px->common.width * sh;
r.height = px->common.height * sh;
}
r.width -= MwGetInteger(handle, MwNpadding) * 2;
r.height -= MwGetInteger(handle, MwNpadding) * 2;
} else {
r.width = px->common.width * sh;
r.height = px->common.height * sh;
r.width = px->common.width;
r.height = px->common.height;
}
r.width -= MwGetInteger(handle, MwNpadding) * 2;
r.height -= MwGetInteger(handle, MwNpadding) * 2;
r.x += (double)(ow - r.width) / 2;
r.y += (double)(oh - r.height) / 2;
@ -77,7 +85,7 @@ static void click(MwWidget handle) {
}
static void prop_change(MwWidget handle, const char* key) {
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNpixmap) == 0 || strcmp(key, MwNflat) == 0 || strcmp(key, MwNpadding) == 0) MwForceRender(handle);
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNpixmap) == 0 || strcmp(key, MwNflat) == 0 || strcmp(key, MwNpadding) == 0 || strcmp(key, MwNfillArea) == 0) MwForceRender(handle);
}
MwClassRec MwButtonClassRec = {

View file

@ -9,8 +9,9 @@ static int create(MwWidget handle) {
}
static void draw(MwWidget handle) {
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
r.x = 0;
r.y = 0;
@ -18,6 +19,7 @@ static void draw(MwWidget handle) {
r.height = MwGetInteger(handle, MwNheight);
MwDrawWidgetBack(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0, MwTRUE);
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
if(handle->pressed || MwGetInteger(handle, MwNchecked)) {
/* TODO: write check mark */
}

View file

@ -25,6 +25,7 @@ static void draw(MwWidget handle) {
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
const char* str = MwGetText(handle, MwNtext);
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
if(str == NULL) str = "";
r.x = 0;
@ -33,6 +34,7 @@ static void draw(MwWidget handle) {
r.height = MwGetInteger(handle, MwNheight);
MwDrawWidgetBack(handle, &r, base, 1, 1);
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
if(str != NULL) {
int w = MwTextWidth(handle, "M");
int h = MwTextHeight(handle, "M");

View file

@ -10,10 +10,11 @@ static int create(MwWidget handle) {
}
static void draw(MwWidget handle) {
MwRect fr;
MwRect rr;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
int inverted;
MwRect fr;
MwRect rr;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
int inverted;
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
if(MwGetInteger(handle, MwNhasBorder)) {
inverted = MwGetInteger(handle, MwNinverted);
@ -36,6 +37,7 @@ static void draw(MwWidget handle) {
}
MwDrawRect(handle, &rr, base);
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &rr, bgpx);
MwLLFreeColor(base);
}

View file

@ -14,7 +14,8 @@ static void draw(MwWidget handle) {
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
int align;
const char* str = MwGetText(handle, MwNtext);
const char* str = MwGetText(handle, MwNtext);
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
if(str == NULL) str = "";
@ -24,6 +25,7 @@ static void draw(MwWidget handle) {
r.height = MwGetInteger(handle, MwNheight);
MwDrawRect(handle, &r, base);
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
align = MwGetInteger(handle, MwNalignment);
if(align == MwALIGNMENT_CENTER) {

View file

@ -12,10 +12,11 @@ static int create(MwWidget handle) {
}
static void draw(MwWidget handle) {
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor fill = MwParseColor(handle, MwGetText(handle, MwNforeground));
double w;
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor fill = MwParseColor(handle, MwGetText(handle, MwNforeground));
double w;
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
r.x = 0;
r.y = 0;
@ -26,6 +27,7 @@ static void draw(MwWidget handle) {
MwDrawRect(handle, &r, base);
w = MwGetInteger(handle, MwNvalue) - MwGetInteger(handle, MwNminValue);
w = w / (MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue));
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
r.x += MwDefaultBorderWidth(handle);
r.y += MwDefaultBorderWidth(handle);

View file

@ -11,8 +11,9 @@ static int create(MwWidget handle) {
}
static void draw(MwWidget handle) {
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
r.x = 0;
r.y = 0;
@ -20,6 +21,7 @@ static void draw(MwWidget handle) {
r.height = MwGetInteger(handle, MwNheight);
MwDrawRect(handle, &r, base);
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
MwDrawDiamond(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0);
MwLLFreeColor(base);

View file

@ -65,7 +65,8 @@ static void draw(MwWidget handle) {
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
scrollbar_t* scr = handle->internal;
int or ;
int uy, dy, ux, dx;
int uy, dy, ux, dx;
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
r.x = 0;
r.y = 0;
@ -79,6 +80,7 @@ static void draw(MwWidget handle) {
dx = r.width - r.height;
MwDrawWidgetBack(handle, &r, dark, 1, MwTRUE);
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
rt = r;
@ -142,7 +144,7 @@ static void draw(MwWidget handle) {
}
static void mouse_move(MwWidget handle) {
int or = MwGetInteger(handle, MwNorientation);
int or = MwGetInteger(handle, MwNorientation);
scrollbar_t* scr = handle->internal;
if(!handle->pressed) return;
@ -170,9 +172,9 @@ static void mouse_move(MwWidget handle) {
}
static void mouse_down(MwWidget handle, void* ptr) {
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight);
int or = MwGetInteger(handle, MwNorientation);
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight);
int or = MwGetInteger(handle, MwNorientation);
scrollbar_t* scr = handle->internal;
MwLLMouse* m = ptr;

View file

@ -114,7 +114,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
if(tree->selected) {
r.x = p->x;
r.y = p->y - MwTextHeight(handle, "M") / 2;
r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding) - shift; // MwTextWidth(handle, tree->label);
r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding) - shift;
r.height = MwTextHeight(handle, "M");
MwDrawRect(handle, &r, text2);
}

View file

@ -5,15 +5,29 @@ open(OUT, ">", "src/color.c");
print(OUT "#include <Mw/Milsko.h>\n");
print(OUT "\n");
print(OUT "MwLLColor MwParseColorName(MwWidget handle, const char* color){\n");
print(OUT " MwRGB rgb;\n");
print(OUT " MwParseColorNameNoAllocate(color, &rgb);\n");
print(OUT
" return MwLLAllocColor(handle->lowlevel, rgb.red, rgb.green, rgb.blue);\n"
);
print(OUT "}\n");
print(OUT "\n");
print(OUT "void MwParseColorNameNoAllocate(const char* color, MwRGB* rgb){\n");
while (my $l = <IN>) {
$l =~ s/\r?\n$//;
if ($l =~ /^[ \t]*([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)$/) {
print(OUT
" if(strcmp(color, \"$4\") == 0) return MwLLAllocColor(handle->lowlevel, $1, $2, $3);\n"
);
print(OUT " if(strcmp(color, \"$4\") == 0){\n");
print(OUT " rgb->red = $1;\n");
print(OUT " rgb->green = $2;\n");
print(OUT " rgb->green = $3;\n");
print(OUT " return;\n");
print(OUT " }\n");
}
}
print(OUT " return MwLLAllocColor(handle->lowlevel, 0, 0, 0);\n");
print(OUT " rgb->red = 0;\n");
print(OUT " rgb->green = 0;\n");
print(OUT " rgb->blue = 0;\n");
print(OUT "}\n");
close(OUT);