forked from pyrite-dev/milsko
color
This commit is contained in:
parent
1fe971e1df
commit
2e2833f57b
6 changed files with 844 additions and 4712 deletions
|
|
@ -28,6 +28,12 @@ MWDECL MwLLColor MWAPI MwParseColor(MwWidget handle, const char* text);
|
|||
*/
|
||||
MWDECL void MWAPI MwParseColorNoAllocate(const char* text, MwRGB* rgb);
|
||||
|
||||
/*!
|
||||
* @brief Initialize color table
|
||||
* @warning This is called in MwLibraryInit - you do not have to call this
|
||||
*/
|
||||
MWDECL void MWAPI MwColorTableInit(void);
|
||||
|
||||
/*!
|
||||
* @brief Lighten a color
|
||||
* @param handle Widget
|
||||
|
|
|
|||
5500
src/color.c
5500
src/color.c
File diff suppressed because it is too large
Load diff
|
|
@ -18,7 +18,7 @@
|
|||
MwLLEndDraw(handle->lowlevel); \
|
||||
}
|
||||
|
||||
static void MWAPI MwVaListApply_Internal(MwWidget handle, va_list va, int only_early);
|
||||
static void MWAPI MwVaListApply_Internal(MwWidget handle, va_list va, int only_early);
|
||||
static MwWidget MWAPI MwCreateWidget_Internal(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, int do_prop, va_list prop);
|
||||
|
||||
static void lldrawhandler(MwLL handle, void* data) {
|
||||
|
|
@ -998,6 +998,8 @@ int MwLibraryInit(void) {
|
|||
NULL};
|
||||
int i;
|
||||
|
||||
MwColorTableInit();
|
||||
|
||||
MwFLSetup();
|
||||
|
||||
for(i = 0; calls[i] != NULL; i++) {
|
||||
|
|
|
|||
|
|
@ -319,8 +319,8 @@ static void draw_normal(MwWidget handle) {
|
|||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||
MwLLColor shadow = MwLightenColor(handle, base, MwDefaultShadow, MwDefaultShadow, MwDefaultShadow);
|
||||
int align;
|
||||
const char* str = MwGetText(handle, MwNtext);
|
||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||
const char* str = MwGetText(handle, MwNtext);
|
||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||
|
||||
if(str == NULL) str = "";
|
||||
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ static int wcreate(MwWidget handle) {
|
|||
EGLDisplay display;
|
||||
waylandopengl_t* o = r = malloc(sizeof(*o));
|
||||
int gbm_format = 0;
|
||||
EGLConfig egl_configs[1024];
|
||||
EGLConfig egl_configs[1024];
|
||||
memset(o, 0, sizeof(waylandopengl_t));
|
||||
|
||||
o->gllib = MwDynamicOpen("libEGL.so");
|
||||
|
|
@ -346,7 +346,7 @@ static int wcreate(MwWidget handle) {
|
|||
} else {
|
||||
if(gbm_format == GBM_FORMAT_ARGB8888) {
|
||||
o->egl_config = egl_configs[i];
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -513,8 +513,8 @@ static void mwOpenGLSwapBufferImpl(MwWidget handle) {
|
|||
#ifdef USE_WAYLAND
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
waylandopengl_t* o = handle->internal;
|
||||
struct gbm_bo* bo;
|
||||
eglSwapInterval(o->egl_display, 0);
|
||||
struct gbm_bo* bo;
|
||||
eglSwapInterval(o->egl_display, 0);
|
||||
if(!eglSwapBuffers(o->egl_display, o->egl_surface)) {
|
||||
printf("ERROR: eglSwapBuffers, %0X\n", eglGetError());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@ open(OUT, ">", "src/color.c");
|
|||
|
||||
print(OUT "#include <Mw/Milsko.h>\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "#include \"../external/stb_ds.h\"\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "struct color {\n");
|
||||
print(OUT " char* key;\n");
|
||||
print(OUT " MwU32 value;\n");
|
||||
print(OUT "};\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "static struct color* colors = NULL;\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");
|
||||
|
|
@ -13,21 +22,26 @@ print(OUT
|
|||
print(OUT "}\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "void MwParseColorNameNoAllocate(const char* color, MwRGB* rgb){\n");
|
||||
|
||||
print(OUT " MwU32 v = shget(colors, color);");
|
||||
print(OUT " rgb->red = (v >> 16) & 0xff;");
|
||||
print(OUT " rgb->green = (v >> 8) & 0xff;");
|
||||
print(OUT " rgb->blue = (v >> 0) & 0xff;");
|
||||
print(OUT "}\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "static void add_color(const char* name, int red, int green, int blue){\n");
|
||||
print(OUT " MwU32 v = (red << 16) | (green << 8) | (blue << 0);\n");
|
||||
print(OUT " shput(colors, name, v);\n");
|
||||
print(OUT "}\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "void MwColorTableInit(void){\n");
|
||||
print(OUT " sh_new_strdup(colors);\n");
|
||||
print(OUT " shdefault(colors, 0);\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){\n");
|
||||
print(OUT " rgb->red = $1;\n");
|
||||
print(OUT " rgb->green = $2;\n");
|
||||
print(OUT " rgb->blue = $3;\n");
|
||||
print(OUT " return;\n");
|
||||
print(OUT " }\n");
|
||||
print(OUT " add_color(\"$4\", $1, $2, $3);\n");
|
||||
}
|
||||
}
|
||||
print(OUT " rgb->red = 0;\n");
|
||||
print(OUT " rgb->green = 0;\n");
|
||||
print(OUT " rgb->blue = 0;\n");
|
||||
print(OUT "}\n");
|
||||
|
||||
close(OUT);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue