mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-07 01:49:47 +00:00
switchable theme
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@470 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#define MwNhasHeading "IhasHeading"
|
#define MwNhasHeading "IhasHeading"
|
||||||
#define MwnhasBorder "IhasBorder"
|
#define MwnhasBorder "IhasBorder"
|
||||||
#define MwNinverted "Iinverted"
|
#define MwNinverted "Iinverted"
|
||||||
|
#define MwNmodernLook "ImodernLook"
|
||||||
|
|
||||||
#define MwNtitle "Stitle"
|
#define MwNtitle "Stitle"
|
||||||
#define MwNtext "Stext"
|
#define MwNtext "Stext"
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
<integer name="hasHeading" />
|
<integer name="hasHeading" />
|
||||||
<integer name="hasBorder" />
|
<integer name="hasBorder" />
|
||||||
<integer name="inverted" />
|
<integer name="inverted" />
|
||||||
|
<integer name="modernLook" />
|
||||||
|
|
||||||
<string name="title" />
|
<string name="title" />
|
||||||
<string name="text" />
|
<string name="text" />
|
||||||
|
|||||||
18
src/core.c
18
src/core.c
@@ -420,11 +420,29 @@ static void inherit_text(MwWidget handle, const char* key, const char* default_v
|
|||||||
MwSetText(handle, key, default_value);
|
MwSetText(handle, key, default_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void inherit_integer(MwWidget handle, const char* key, int default_value) {
|
||||||
|
int n;
|
||||||
|
MwWidget h = handle;
|
||||||
|
while(h != NULL) {
|
||||||
|
if((n = MwGetInteger(h, key)) != -1) {
|
||||||
|
MwSetInteger(handle, key, n);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
h = h->parent;
|
||||||
|
}
|
||||||
|
MwSetInteger(handle, key, default_value);
|
||||||
|
}
|
||||||
|
|
||||||
void MwSetDefault(MwWidget handle) {
|
void MwSetDefault(MwWidget handle) {
|
||||||
MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
||||||
|
|
||||||
inherit_text(handle, MwNbackground, MwDefaultBackground);
|
inherit_text(handle, MwNbackground, MwDefaultBackground);
|
||||||
inherit_text(handle, MwNforeground, MwDefaultForeground);
|
inherit_text(handle, MwNforeground, MwDefaultForeground);
|
||||||
|
#ifdef MW_CLASSIC_THEME
|
||||||
|
inherit_integer(handle, MwNmodernLook, 0);
|
||||||
|
#else
|
||||||
|
inherit_integer(handle, MwNmodernLook, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwHideCursor(MwWidget handle) {
|
void MwHideCursor(MwWidget handle) {
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
#ifdef MW_CLASSIC_THEME
|
|
||||||
const int MwDefaultBorderWidth = 2;
|
const int MwDefaultBorderWidth = 2;
|
||||||
#else
|
|
||||||
const int MwDefaultBorderWidth = 1;
|
|
||||||
#endif
|
|
||||||
const char* MwDefaultBackground = "#ddd";
|
const char* MwDefaultBackground = "#ddd";
|
||||||
const char* MwDefaultForeground = "#000";
|
const char* MwDefaultForeground = "#000";
|
||||||
|
|||||||
39
src/draw.c
39
src/draw.c
@@ -11,11 +11,14 @@
|
|||||||
|
|
||||||
#include "../external/stb_ds.h"
|
#include "../external/stb_ds.h"
|
||||||
|
|
||||||
#ifdef MW_CLASSIC_THEME
|
static int get_color_diff(MwWidget handle){
|
||||||
#define ColorDiff 128
|
if(MwGetInteger(handle, MwNmodernLook)){
|
||||||
#else
|
return 48;
|
||||||
#define ColorDiff 48
|
}else{
|
||||||
#endif
|
return 128;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int hex(const char* txt, int len) {
|
static int hex(const char* txt, int len) {
|
||||||
int i;
|
int i;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
@@ -96,12 +99,11 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
|
|||||||
int y;
|
int y;
|
||||||
int x;
|
int x;
|
||||||
double darken = 0.;
|
double darken = 0.;
|
||||||
|
int ColorDiff = get_color_diff(handle);
|
||||||
double darkenStep = (ColorDiff / 2.) / rect->height;
|
double darkenStep = (ColorDiff / 2.) / rect->height;
|
||||||
|
unsigned long sz = rect->width * rect->height * 4;
|
||||||
#define SIZE (rect->width * rect->height * 4)
|
unsigned char* data = malloc(sz);
|
||||||
unsigned char* data = malloc(SIZE);
|
memset(data, 0, sz);
|
||||||
memset(data, 0, SIZE);
|
|
||||||
#undef SIZE
|
|
||||||
|
|
||||||
for(y = 0; y < rect->height; y++) {
|
for(y = 0; y < rect->height; y++) {
|
||||||
MwLLColor col = MwLightenColor(handle, color, -darken, -darken, -darken);
|
MwLLColor col = MwLightenColor(handle, color, -darken, -darken, -darken);
|
||||||
@@ -122,21 +124,23 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||||
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth);
|
MwDrawFrameEx(handle, rect, color, invert, MwGetInteger(handle, MwNmodernLook) ? 1 : MwDefaultBorderWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
||||||
if(border) {
|
if(border) {
|
||||||
MwDrawFrame(handle, rect, color, invert);
|
MwDrawFrame(handle, rect, color, invert);
|
||||||
}
|
}
|
||||||
#ifdef MW_CLASSIC_THEME
|
if(MwGetInteger(handle, MwNmodernLook)){
|
||||||
MwDrawRect(handle, rect, color);
|
MwDrawRectFading(handle, rect, color);
|
||||||
#else
|
}else{
|
||||||
MwDrawRectFading(handle, rect, color);
|
MwDrawRect(handle, rect, color);
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
||||||
MwPoint p[6];
|
MwPoint p[6];
|
||||||
|
int ColorDiff = get_color_diff(handle);
|
||||||
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
||||||
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
||||||
|
|
||||||
@@ -191,7 +195,8 @@ void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, i
|
|||||||
|
|
||||||
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
|
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
|
||||||
MwPoint p1[4], p2[4], p3[4], p4[3];
|
MwPoint p1[4], p2[4], p3[4], p4[3];
|
||||||
const int border = MwDefaultBorderWidth;
|
const int border = MwGetInteger(handle, MwNmodernLook) ? 1 : MwDefaultBorderWidth;
|
||||||
|
int ColorDiff = get_color_diff(handle);
|
||||||
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
||||||
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user