merge
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
IoI_xD 2026-04-14 13:37:14 -07:00
commit 70c9d3a1f6
27 changed files with 724 additions and 1006 deletions

4
Jenkinsfile vendored
View file

@ -7,7 +7,11 @@ pipeline {
when { when {
branch "master" branch "master"
} }
agent {
label "built-in"
}
steps { steps {
sh("rm -rf include/Mw/LowLevel/Wayland")
sh("doxygen") sh("doxygen")
sh("rm -rf /var/www/milsko-doxygen") sh("rm -rf /var/www/milsko-doxygen")
sh("mv doxygen/html /var/www/milsko-doxygen") sh("mv doxygen/html /var/www/milsko-doxygen")

21
configure vendored
View file

@ -38,7 +38,6 @@ require("./pl/utils.pl");
param_set("classic-theme", 0); param_set("classic-theme", 0);
param_set("stb-image", 1); param_set("stb-image", 1);
param_set("stb-truetype", 0);
param_set("xrender", 1); param_set("xrender", 1);
param_set("opengl", 0); param_set("opengl", 0);
param_set("vulkan", 0); param_set("vulkan", 0);
@ -50,6 +49,9 @@ param_set("examples", 1);
if($target ne "Darwin") { if($target ne "Darwin") {
param_set("freetype2", 1); param_set("freetype2", 1);
param_set("stb-truetype", 0);
} else {
param_set("stb-truetype", 1);
} }
my %features = ( my %features = (
@ -64,6 +66,7 @@ my %features = (
"shared" => "build shared library", "shared" => "build shared library",
"static" => "build static library", "static" => "build static library",
"wayland" => "enable wayland backend", "wayland" => "enable wayland backend",
"gnustep" => "use gnustep",
); );
my @features_keys = ( my @features_keys = (
"1classic-theme", "1stb-image", "1classic-theme", "1stb-image",
@ -71,9 +74,16 @@ my @features_keys = (
"1opengl", "2xrender", "1opengl", "2xrender",
"1vulkan", "2vulkan-string-helper", "1vulkan", "2vulkan-string-helper",
"1shared", "1static", "1shared", "1static",
"1wayland", "1wayland", "1gnustep",
); );
if($target eq "Linux") {
param_set("x11", 1);
if(!param_get("tiny")){
param_set("wayland", 1);
}
}
foreach my $l (@ARGV) { foreach my $l (@ARGV) {
if ($l =~ /^--with-([^=]+)=(.+)$/) { if ($l =~ /^--with-([^=]+)=(.+)$/) {
param_set($1, $2); param_set($1, $2);
@ -136,13 +146,6 @@ foreach my $l (@ARGV) {
} }
} }
if($target eq "Linux") {
param_set("x11", 1);
if(!param_get("tiny")){
param_set("wayland", 1);
}
}
if (-f "./pl/ostype/${target}.pl") { if (-f "./pl/ostype/${target}.pl") {
require("./pl/ostype/${target}.pl"); require("./pl/ostype/${target}.pl");
} }

View file

@ -15,7 +15,7 @@ foreach(PATH IN LISTS EXAMPLES_GL_SOURCES)
${TARGET} ${TARGET}
PRIVATE PRIVATE
Mw Mw
OpenGL::GL OpenGL::GL OpenGL::GLU
) )
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries( target_link_libraries(

View file

@ -3,10 +3,16 @@ file(
EXAMPLES_VULKAN_SOURCES EXAMPLES_VULKAN_SOURCES
*.c *.c
) )
find_package(Vulkan)
foreach(PATH IN LISTS EXAMPLES_VULKAN_SOURCES) foreach(PATH IN LISTS EXAMPLES_VULKAN_SOURCES)
get_filename_component(TARGET ${PATH} NAME_WE) get_filename_component(TARGET ${PATH} NAME_WE)
add_executable(${TARGET} WIN32 MACOSX_BUNDLE ${PATH}) add_executable(${TARGET} WIN32 MACOSX_BUNDLE ${PATH})
target_include_directories(
${TARGET}
PRIVATE
${Vulkan_INCLUDE_DIR}
)
target_link_libraries( target_link_libraries(
${TARGET} ${TARGET}
PRIVATE PRIVATE

View file

@ -53,7 +53,7 @@ MWDECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
* @param rect Rectangle area * @param rect Rectangle area
* @param color Color * @param color Color
*/ */
MWDECL void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color, int rounded); MWDECL void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color);
/*! /*!
* @brief Draws a frame * @brief Draws a frame
@ -63,7 +63,7 @@ MWDECL void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color, int
* @param invert Invert the 3D border color or not * @param invert Invert the 3D border color or not
* @warning `rect` gets changed to the area of rectangle inside * @warning `rect` gets changed to the area of rectangle inside
*/ */
MWDECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int rounded); MWDECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert);
/*! /*!
* @brief Does the DrawFrame/DrawRect combo used for drawing widget. * @brief Does the DrawFrame/DrawRect combo used for drawing widget.
@ -96,7 +96,7 @@ MWDECL void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int i
* @param rounded Rounded or not * @param rounded Rounded or not
* @warning `rect` gets changed to the area of rectangle inside * @warning `rect` gets changed to the area of rectangle inside
*/ */
MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same, int rounded); MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same);
/*! /*!
* @brief Creates a pixmap from image * @brief Creates a pixmap from image

View file

@ -15,12 +15,6 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <Foundation/NSGeometry.h> #import <Foundation/NSGeometry.h>
#ifdef __APPLE__
#import <CoreServices/CoreServices.h>
#else
#import <CoreGraphics/CoreGraphics.h>
#endif
@interface MilskoCocoaApplication : NSApplication { @interface MilskoCocoaApplication : NSApplication {
MwBool doPending; MwBool doPending;
} }
@ -40,9 +34,9 @@
// Note: implements NSWindowDelegate // Note: implements NSWindowDelegate
@interface MilskoCocoaWindowDelegate : NSObject { @interface MilskoCocoaWindowDelegate : NSObject {
MilskoCocoaWindow* w; NSWindow* w;
} }
- (MilskoCocoaWindowDelegate*)initWithWin:(MilskoCocoaWindow*)win; - (MilskoCocoaWindowDelegate*)initWithWin:(NSWindow*)win;
@end @end
/* /*
@ -67,6 +61,7 @@
@end @end
@interface MilskoCocoaPixmap : NSObject { @interface MilskoCocoaPixmap : NSObject {
@public
MwBool valid; MwBool valid;
int width; int width;
int height; int height;
@ -86,18 +81,17 @@
@end @end
@interface MilskoCocoaView : NSView { @interface MilskoCocoaView : NSView {
@public
unsigned char* buf;
NSBitmapImageRep* rep; NSBitmapImageRep* rep;
NSGraphicsContext* context; NSGraphicsContext* context;
MwBool valid; MwBool valid;
CGColorSpaceRef space;
CGDataProviderRef provider;
NSRect givenRect; NSRect givenRect;
float x; float x;
float y; float y;
float width; float width;
float height; float height;
MwBool _child; MwBool _child;
IBOutlet NSViewController* viewController;
} }
- (void)initRepAndContextWithWidth:(float)w Height:(float)h; - (void)initRepAndContextWithWidth:(float)w Height:(float)h;
@ -105,14 +99,18 @@
- (void)destroy; - (void)destroy;
- (NSBitmapImageRep*)getRep; - (NSBitmapImageRep*)getRep;
- (void)setChild; - (void)setChild;
@end
@interface MilskoCocoaSubView : MilskoCocoaView {
}
@end @end
@interface MilskoCocoa : NSObject { @interface MilskoCocoa : NSObject {
@public
MilskoCocoaApplication* application; MilskoCocoaApplication* application;
MwBool _forceRender; MwBool _forceRender;
MwBool _eventsPending; MwBool _eventsPending;
MilskoCocoaWindow* window; NSWindow* window;
NSRect rect; NSRect rect;
MilskoCocoaView* view; MilskoCocoaView* view;
MwLL parent; MwLL parent;
@ -126,55 +124,21 @@
MwBool pointerLocked; MwBool pointerLocked;
MwBool mouseMoved; MwBool mouseMoved;
}
+ (MilskoCocoa*)newWithParent:(MwLL)parent MwBool rejectFirstTest;
x:(int)x }
y:(int)y
width:(int)width
height:(int)height
handle:(MwLL)handle;
- (void)polygonWithPoints:(MwPoint*)points
points_count:(int)points_count
color:(MwLLColor)color;
- (void)lineWithPoints:(MwPoint*)points color:(MwLLColor)color;
- (void)getX:(int*)x Y:(int*)y W:(unsigned int*)w H:(unsigned int*)h;
- (void)setX:(int)x Y:(int)y;
- (void)setW:(int)w H:(int)h;
- (int)pending;
- (void)getNextEvent;
- (void)setTitle:(const char*)title;
- (void)drawPixmap:(MwLLPixmap)pixmap rect:(MwRect*)rect;
- (void)setIcon:(MwLLPixmap)pixmap;
- (void)forceRender;
- (void)setCursor:(MwCursor*)image mask:(MwCursor*)mask;
- (void)detachWithPoint:(MwPoint*)point;
- (void)show:(int)show;
- (void)makePopupWithParent:(MwLL)parent;
- (void)setSizeHintsWithMinX:(int)minx
MinY:(int)miny
MaxX:(int)maxx
MaxY:(int)maxy;
- (void)makeBorderless:(int)toggle;
- (void)focus;
- (void)grabPointer:(int)toggle;
- (void)setClipboard:(const char*)text;
- (void)makeToolWindow;
- (void)getCursorCoord:(MwPoint*)point;
- (void)getScreenSize:(MwRect*)rect;
- (void)destroy; - (void)destroy;
- (void)sendClipboardEvent; - (void)sendClipboardEvent;
- (MwLL)getParent; - (MwLL)getParent;
- (NSView*)getView; - (NSView*)getView;
- (MilskoCocoaWindow*)getWindow; - (NSWindow*)getWindow;
- (void)nudge; - (void)nudge;
- (void)pushCursor; - (void)pushCursor;
- (void)popCursor; - (void)popCursor;
- (MilskoFakePointer*)getHandle; - (MilskoFakePointer*)getHandle;
+ (void)eventCanceller:(MilskoCocoa*)this;
@end @end
#define OBJC(x) x #define OBJC(x) x

View file

@ -57,17 +57,26 @@
#define M_PI 3.14159265 #define M_PI 3.14159265
#endif #endif
/* Windows */
#if defined(_MILSKO) && defined(_WIN32) #if defined(_MILSKO) && defined(_WIN32)
#define MWDECL extern __declspec(dllexport) #define MWDECL extern __declspec(dllexport)
#elif defined(_WIN32) #elif defined(_WIN32)
#define MWDECL extern __declspec(dllimport) #define MWDECL extern __declspec(dllimport)
/* GCC/Clang */
/* First check if we have __has_attribute and can check for the existence of visibility */
#elif defined(__has_attribute) #elif defined(__has_attribute)
#if __has_attribute(visibility) #if __has_attribute(visibility)
#define MWDECL extern __attribute__((visibility("default"))) #define MWDECL extern __attribute__((visibility("default")))
#else #else
#define MWDECL extern #define MWDECL extern
#endif #endif
/* It might be that we're on an old version of GCC (like the one Apple ships with older versions of Mac OS).
* If we're on gcc 3 or above, assume it's there
*/
#elif __GNUC__ >= 3
#define MWDECL extern __attribute__((visibility("default")))
#else #else
/* all else fails */
#define MWDECL extern #define MWDECL extern
#endif #endif

View file

@ -40,21 +40,7 @@
</struct> </struct>
</structs> </structs>
<!-- <!--
All widgets have: All widgets have properties that are common="yes".
- MwNbackground
- MwNsubBackground
- MwNforeground
- MwNsubForeground
- MwNx
- MwNy
- MwNwidth
- MwNheight
- MwNborderWidth
- MwNbackgroundPixmap
- MwNratio
- MwNfixedSize
- MwNbitmapFont
- MwNforceInverted
Integer properties must be prefixed with I. Integer properties must be prefixed with I.
String properties must be prefixed with S. String properties must be prefixed with S.
@ -62,10 +48,10 @@
Other properties must be prefixed with V. Other properties must be prefixed with V.
--> -->
<properties> <properties>
<integer name="x" /> <integer name="x" common="yes" />
<integer name="y" /> <integer name="y" common="yes" />
<integer name="width" /> <integer name="width" common="yes" />
<integer name="height" /> <integer name="height" common="yes" />
<integer name="orientation" /> <integer name="orientation" />
<integer name="minValue" /> <integer name="minValue" />
<integer name="maxValue" /> <integer name="maxValue" />
@ -80,38 +66,39 @@
<integer name="hasHeading" /> <integer name="hasHeading" />
<integer name="hasBorder" /> <integer name="hasBorder" />
<integer name="inverted" /> <integer name="inverted" />
<integer name="modernLook" /> <integer name="modernLook" common="yes" />
<integer name="waitMS" /> <integer name="waitMS" common="yes" /> <!-- This is a special property, only applies to toplevel widget -->
<integer name="hideInput" /> <integer name="hideInput" />
<integer name="singleClickSelectable" /> <integer name="singleClickSelectable" />
<integer name="flat" /> <integer name="flat" />
<integer name="showArrows" /> <integer name="showArrows" />
<integer name="padding" /> <integer name="padding" />
<integer name="borderWidth" /> <integer name="borderWidth" common="yes" />
<integer name="ratio" /> <integer name="ratio" common="yes" />
<integer name="fixedSize" /> <integer name="fixedSize" common="yes" />
<integer name="margin" /> <integer name="margin" />
<integer name="bitmapFont" /> <integer name="bitmapFont" common="yes" />
<integer name="sevenSegment" /> <integer name="sevenSegment" />
<integer name="length" /> <integer name="length" />
<integer name="forceInverted" /> <integer name="forceInverted" common="yes" />
<integer name="roundness" /> <integer name="roundness" />
<integer name="isRounded" /> <integer name="isRounded" common="yes" />
<integer name="darkTheme" /> <integer name="darkTheme" common="yes" />
<integer name="useMonospace" common="yes" />
<string name="title" /> <string name="title" />
<string name="text" /> <string name="text" />
<string name="background" /> <string name="background" common="yes" />
<string name="subBackground" /> <string name="subBackground" common="yes" />
<string name="foreground" /> <string name="foreground" common="yes" />
<string name="subForeground" /> <string name="subForeground" common="yes" />
<pixmap name="pixmap" /> <pixmap name="pixmap" />
<pixmap name="iconPixmap" /> <pixmap name="iconPixmap" />
<struct defname="MwSizeHints" pointer="yes" name="sizeHints" /> <struct defname="MwSizeHints" pointer="yes" name="sizeHints" />
<pointer name="font" /> <pointer name="font" />
<pointer name="boldFont" /> <pointer name="boldFont" />
<pixmap name="backgroundPixmap" /> <pixmap name="backgroundPixmap" common="yes" />
<pointer name="monospaceFont" /> <pointer name="monospaceFont" />
<pointer name="boldMonospaceFont" /> <pointer name="boldMonospaceFont" />

View file

@ -55,10 +55,17 @@ if (grep(/^wayland$/, @backends)) {
$gl_libs = "-lGL -lGLU"; $gl_libs = "-lGL -lGLU";
} }
if (grep(/^cocoa$/, @backends)) { if (grep(/^cocoa$/, @backends) || param_get("gnustep")) {
add_cflags("-DUSE_COCOA"); add_cflags("-DUSE_COCOA");
new_object("src/backend/cocoa.m"); new_object("src/backend/cocoa.m");
if(param_get("gnustep")){
add_incdir("-I".`gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS`);
add_libdir("-L".`gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARIES`);
add_cflags("-fobjc-runtime=gnustep-2.0 -fblocks");
add_ldflags("-lobjc -lgnustep-base -lm -lgnustep-gui");
}
if (param_get("opengl")) { if (param_get("opengl")) {
new_object("src/widget/opengl_cocoa.m"); new_object("src/widget/opengl_cocoa.m");
} }

File diff suppressed because it is too large Load diff

View file

@ -2646,7 +2646,6 @@ static int MwLLWaylandCallInitImpl(void) {
/* /*
* Order of precedence: * Order of precedence:
* - MILSKO_BACKEND * - MILSKO_BACKEND
* - XDG_SESSION_TYPE
* - manually checking environment variables * - manually checking environment variables
*/ */
#ifdef __linux__ #ifdef __linux__

View file

@ -1288,7 +1288,11 @@ static int MwLLX11CallInitImpl(void) {
return 1; return 1;
} }
#ifdef __APPLE__
xsymtbl.lib_xlib = MwDynamicOpen("libX11.dylib");
#else
xsymtbl.lib_xlib = MwDynamicOpen("libX11.so"); xsymtbl.lib_xlib = MwDynamicOpen("libX11.so");
#endif
if(!xsymtbl.lib_xlib) { if(!xsymtbl.lib_xlib) {
return 1; return 1;
} }

View file

@ -606,7 +606,6 @@ int MwGetInteger(MwWidget handle, const char* key) {
#else #else
if(strcmp(key, MwNmodernLook) == 0) return inherit_integer(handle, key, 1); if(strcmp(key, MwNmodernLook) == 0) return inherit_integer(handle, key, 1);
#endif #endif
if(strcmp(key, MwNisRounded) == 0) return inherit_integer(handle, key, 1);
if(strcmp(key, MwNdarkTheme) == 0) return inherit_integer(handle, key, 0); if(strcmp(key, MwNdarkTheme) == 0) return inherit_integer(handle, key, 0);
if(strcmp(key, MwNuseMonospace) == 0) return inherit_integer(handle, key, 0); if(strcmp(key, MwNuseMonospace) == 0) return inherit_integer(handle, key, 0);
} }
@ -856,15 +855,16 @@ MwWidget MwGetParent(MwWidget handle) {
typedef int (*call_t)(void); typedef int (*call_t)(void);
int MwLibraryInit(void) { int MwLibraryInit(void) {
call_t calls[] = { call_t calls[] = {
#ifdef USE_COCOA
MwLLCocoaCallInit,
#endif
#ifdef USE_WAYLAND #ifdef USE_WAYLAND
MwLLWaylandCallInit, MwLLWaylandCallInit,
#endif #endif
/* x11 has higher priority then cocoa until it works */
#ifdef USE_X11 #ifdef USE_X11
MwLLX11CallInit, MwLLX11CallInit,
#endif #endif
#ifdef USE_COCOA
MwLLCocoaCallInit,
#endif
#ifdef USE_GDI #ifdef USE_GDI
MwLLGDICallInit, MwLLGDICallInit,
#endif #endif

View file

@ -11,10 +11,6 @@
#include "../external/stb_ds.h" #include "../external/stb_ds.h"
#define DEFAULT_ROUNDNESS 5
#define MAX_ROUNDNESS 30
#define BORDER_SMOOTHNESS 50
static int get_color_diff(MwWidget handle) { static int get_color_diff(MwWidget handle) {
if(MwGetInteger(handle, MwNmodernLook)) { if(MwGetInteger(handle, MwNmodernLook)) {
return 40; return 40;
@ -106,7 +102,7 @@ void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color) {
MwLLPolygon(handle->lowlevel, p, 4, color); MwLLPolygon(handle->lowlevel, p, 4, color);
} }
void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color, int rounded) { void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
MwLLPixmap pixmap; MwLLPixmap pixmap;
int y, i; int y, i;
double darken = 0.; double darken = 0.;
@ -115,17 +111,18 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color, int rounde
unsigned long sz = 1 * rect->height * 4; unsigned long sz = 1 * rect->height * 4;
unsigned char* data = malloc(sz); unsigned char* data = malloc(sz);
MwRect r = *rect; MwRect r = *rect;
int roundness = MwGetInteger(handle, MwNroundness);
double div; double div;
if(rect->width <= 0 || rect->height <= 0) { if(rect->width <= 0 || rect->height <= 0) {
free(data); free(data);
return; return;
} }
if(roundness == MwDEFAULT) roundness = DEFAULT_ROUNDNESS;
if(roundness >= MAX_ROUNDNESS) roundness = MAX_ROUNDNESS;
div = (roundness <= 10) ? 7. : 10.;
memset(data, 0, sz); memset(data, 0, sz);
r.x += 1;
r.y += 1;
r.width -= 2;
r.height -= 2;
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);
int idx = y * 4; int idx = y * 4;
@ -138,42 +135,18 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color, int rounde
} }
pixmap = MwLLCreatePixmap(handle->lowlevel, data, 1, rect->height); pixmap = MwLLCreatePixmap(handle->lowlevel, data, 1, rect->height);
if(rounded && rect->height >= (roundness * 2) && rect->width >= (roundness * 2) && roundness > 0) {
for(i = 0; i < roundness; i++) {
int x = (roundness + 2);
int y = rect->y + (roundness + 2);
double point = ((i + (M_PI * 4)) / div);
r.x = (roundness + 4) - (sin(point) * roundness);
r.y = y + (cos(point) * roundness) + 1;
r.width = roundness;
r.height = (rect->height - ((r.y - rect->y) * 2) - 1);
MwLLDrawPixmap(handle->lowlevel, &r, pixmap); MwLLDrawPixmap(handle->lowlevel, &r, pixmap);
r.width = x + (sin(point + 1) * roundness);
r.x = ((rect->width - (roundness + 1)) + (sin(point) * roundness)) - r.width;
MwLLDrawPixmap(handle->lowlevel, &r, pixmap);
}
r = *rect;
r.x += roundness;
r.y += 3;
r.width -= (roundness * 2) + 1;
r.height -= 6;
MwLLDrawPixmap(handle->lowlevel, &r, pixmap);
} else {
MwLLDrawPixmap(handle->lowlevel, &r, pixmap);
}
MwLLDestroyPixmap(pixmap); MwLLDestroyPixmap(pixmap);
free(data); free(data);
} }
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int rounded) { void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
int inv; int inv;
if((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv) invert = 1; if((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv) invert = 1;
if(MwGetInteger(handle, MwNmodernLook)) { if(MwGetInteger(handle, MwNmodernLook)) {
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0, rounded); MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0);
} else { } else {
int diff = get_color_diff(handle) / 3 * 2; int diff = get_color_diff(handle) / 3 * 2;
@ -181,18 +154,17 @@ void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int
int i; int i;
int st = invert ? 1 : 0; int st = invert ? 1 : 0;
for(i = st; i < st + 2; i++) { for(i = st; i < st + 2; i++) {
if((i % 2) == 0) MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) - 1, -diff, (handle->parent == NULL || handle->parent->lowlevel == NULL) ? 1 : 0, 0); if((i % 2) == 0) MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle) - 1, -diff, (handle->parent == NULL || handle->parent->lowlevel == NULL) ? 1 : 0);
if((i % 2) == 1) MwDrawFrameEx(handle, rect, color, invert, 1, diff, 0, 0); if((i % 2) == 1) MwDrawFrameEx(handle, rect, color, invert, 1, diff, 0);
} }
} else { } else {
MwDrawFrameEx(handle, rect, color, invert, 1, 0, 0, 0); MwDrawFrameEx(handle, rect, color, invert, 1, 0, 0);
} }
} }
} }
void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) { void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
MwLLColor col; MwLLColor col;
MwBool rounded = MwGetInteger(handle, MwNroundness) != MwDEFAULT && MwGetInteger(handle, MwNisRounded) != 0;
if(rect->width <= 0 || rect->height <= 0) return; if(rect->width <= 0 || rect->height <= 0) return;
@ -206,11 +178,11 @@ void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert
} }
} }
MwDrawFrame(handle, rect, color, invert, rounded); MwDrawFrame(handle, rect, color, invert);
} }
col = invert ? MwLightenColor(handle, color, -8, -8, -8) : color; col = invert ? MwLightenColor(handle, color, -8, -8, -8) : color;
if(MwGetInteger(handle, MwNmodernLook)) { if(MwGetInteger(handle, MwNmodernLook)) {
MwDrawRectFading(handle, rect, col, rounded); MwDrawRectFading(handle, rect, col);
} else { } else {
MwDrawRect(handle, rect, col); MwDrawRect(handle, rect, col);
} }
@ -284,16 +256,11 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
MwLLFreeColor(darker); MwLLFreeColor(darker);
} }
static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same, int rounded) { static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
MwPoint p[7]; MwPoint p[7];
int ColorDiff = get_color_diff(handle); int ColorDiff = get_color_diff(handle);
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff); MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff);
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, ColorDiff - diff, ColorDiff - diff, ColorDiff - diff); MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, ColorDiff - diff, ColorDiff - diff, ColorDiff - diff);
int roundness = MwGetInteger(handle, MwNroundness);
if(roundness == MwDEFAULT) roundness = DEFAULT_ROUNDNESS;
if(roundness >= MAX_ROUNDNESS) roundness = MAX_ROUNDNESS;
if(!(rounded && rect->height >= (roundness * 2) && rect->width >= (roundness * 2) && roundness > 0)) {
p[0].x = rect->x; p[0].x = rect->x;
p[0].y = rect->y; p[0].y = rect->y;
@ -310,10 +277,8 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color,
p[5].x = rect->x; p[5].x = rect->x;
p[5].y = rect->y + rect->height; p[5].y = rect->y + rect->height;
}
MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter); MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter);
if(!(rounded && rect->height >= (roundness * 2) && rect->width >= (roundness * 2) && roundness > 0)) {
p[0].x = rect->x + rect->width; p[0].x = rect->x + rect->width;
p[0].y = rect->y; p[0].y = rect->y;
@ -332,7 +297,6 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color,
p[5].x = rect->x + rect->width; p[5].x = rect->x + rect->width;
p[5].y = rect->y + rect->height; p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker); MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
}
MwLLFreeColor(lighter); MwLLFreeColor(lighter);
MwLLFreeColor(darker); MwLLFreeColor(darker);
@ -343,64 +307,13 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color,
rect->height -= border * 2; rect->height -= border * 2;
} }
static void frame_border_complex(MwWidget handle, MwRect* rect, MwLLColor lighter, MwLLColor darker, int invert, int border, int diff, int same, int rounded) { static void frame_border_complex(MwWidget handle, MwRect* rect, MwLLColor lighter, MwLLColor darker, int invert, int border, int diff, int same) {
MwPoint p[7]; MwPoint p[7];
int roundness = MwGetInteger(handle, MwNroundness);
int i; int i;
(void)diff; (void)diff;
(void)same; (void)same;
if(roundness == MwDEFAULT) roundness = DEFAULT_ROUNDNESS;
if(roundness >= MAX_ROUNDNESS) roundness = MAX_ROUNDNESS;
if(rounded && rect->height >= (roundness * 4) && rect->width >= (roundness * 4) && roundness > 0) {
/* top left edge */
for(i = 0; i < BORDER_SMOOTHNESS; i += 2) {
MwPoint line[2];
double point = ((i + (M_PI * (BORDER_SMOOTHNESS / 2.))) / (BORDER_SMOOTHNESS));
int x = rect->x + (roundness + 2);
int y = rect->y + (roundness + 2);
line[0].x = x - (sin(point) * roundness);
line[0].y = y + (cos(point) * roundness);
line[1].x = x - (sin(point + 1) * roundness);
line[1].y = y + (cos(point + 1) * roundness);
MwLLLine(handle->lowlevel, line, invert ? lighter : darker);
}
p[0].x = rect->x + roundness;
p[0].y = rect->y + border;
p[1].x = rect->x + rect->width - border - roundness;
p[1].y = rect->y + border;
p[2].x = rect->x + rect->width - border - roundness;
p[2].y = rect->y + border + roundness;
p[3].x = rect->x + border;
p[3].y = rect->y + border + roundness;
p[4].x = rect->x + border;
p[4].y = (rect->y + border) + rect->height - roundness;
p[5].x = rect->x + roundness;
p[5].y = (rect->y + border) + rect->height - roundness;
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
/* top right edge */
for(i = 0; i < BORDER_SMOOTHNESS; i += 2) {
MwPoint line[2];
double point = ((i + (M_PI * (BORDER_SMOOTHNESS / 2.))) / (BORDER_SMOOTHNESS));
int x = (rect->x + rect->width) - (roundness + 2);
int y = rect->y + (roundness + 2);
double placeholder = (sin(point) * roundness);
line[0].x = x + placeholder;
line[0].y = y + (cos(point) * roundness);
line[1].x = x + (sin(point + 1) * roundness);
line[1].y = y + (cos(point + 1) * roundness);
MwLLLine(handle->lowlevel, line, invert ? lighter : darker);
}
} else {
p[0].x = rect->x; p[0].x = rect->x;
p[0].y = rect->y; p[0].y = rect->y;
@ -417,60 +330,8 @@ static void frame_border_complex(MwWidget handle, MwRect* rect, MwLLColor lighte
p[5].x = rect->x; p[5].x = rect->x;
p[5].y = rect->y + rect->height; p[5].y = rect->y + rect->height;
}
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker); MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
if(rounded && rect->height >= (roundness * 4) && rect->width >= (roundness * 4) && roundness > 0) {
/* bottom left edge */
for(i = 0; i < BORDER_SMOOTHNESS; i += 2) {
MwPoint line[2];
double point = ((i + (M_PI * (BORDER_SMOOTHNESS / 2.))) / (BORDER_SMOOTHNESS));
int x = rect->x + (roundness + 2);
int y = (rect->y + rect->height) - (roundness + 2);
line[0].x = x - (sin(point) * roundness);
line[0].y = y - (cos(point) * roundness);
line[1].x = x - (sin(point + 1) * roundness);
line[1].y = y - (cos(point + 1) * roundness);
MwLLLine(handle->lowlevel, line, invert ? lighter : darker);
}
p[0].x = rect->x + roundness;
p[0].y = rect->y + border + roundness;
p[1].x = rect->x + rect->width - border;
p[1].y = rect->y + border + roundness;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + rect->height - border - roundness;
p[3].x = rect->x + rect->width - border - roundness;
p[3].y = rect->y + rect->height - border;
p[4].x = rect->x + border + roundness;
p[4].y = rect->y + rect->height - border;
p[5].x = rect->x + roundness;
p[5].y = rect->y + rect->height - roundness;
p[6].x = rect->x + rect->width - border - roundness;
p[6].y = rect->y + rect->height - roundness;
MwLLPolygon(handle->lowlevel, p, 7, invert ? lighter : darker);
/* bottom right edge */
for(i = 0; i < BORDER_SMOOTHNESS; i += 2) {
MwPoint line[2];
double point = ((i + (M_PI * (BORDER_SMOOTHNESS / 2.))) / (BORDER_SMOOTHNESS));
int x = (rect->x + rect->width) - (roundness + 2);
int y = (rect->y + rect->height) - (roundness + 2);
line[0].x = x + (sin(point) * roundness);
line[0].y = y - (cos(point) * roundness);
line[1].x = x + (sin(point + 1) * roundness);
line[1].y = y - (cos(point + 1) * roundness);
MwLLLine(handle->lowlevel, line, invert ? lighter : darker);
}
} else {
p[0].x = rect->x + rect->width; p[0].x = rect->x + rect->width;
p[0].y = rect->y; p[0].y = rect->y;
@ -489,22 +350,21 @@ static void frame_border_complex(MwWidget handle, MwRect* rect, MwLLColor lighte
p[5].x = rect->x + rect->width; p[5].x = rect->x + rect->width;
p[5].y = rect->y + rect->height; p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker); MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
}
} }
static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same, int rounded) { static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
int ColorDiff = get_color_diff(handle); int ColorDiff = get_color_diff(handle);
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff); MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff);
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff); MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff);
MwRect r = *rect; MwRect r = *rect;
frame_border_complex(handle, rect, lighter, darker, invert, border, diff, same, rounded); frame_border_complex(handle, rect, lighter, darker, invert, border, diff, same);
r.x += 1; r.x += 1;
r.y += 1; r.y += 1;
r.width -= 2; r.width -= 2;
r.height -= 2; r.height -= 2;
frame_border_complex(handle, &r, lighter, darker, !invert, border, diff, same, rounded); frame_border_complex(handle, &r, lighter, darker, !invert, border, diff, same);
MwLLFreeColor(lighter); MwLLFreeColor(lighter);
MwLLFreeColor(darker); MwLLFreeColor(darker);
@ -515,11 +375,11 @@ static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color
rect->height -= border * 2; rect->height -= border * 2;
} }
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same, int rounded) { void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
if(MwGetInteger(handle, MwNmodernLook)) { if(MwGetInteger(handle, MwNmodernLook)) {
MwDrawFrameEx_complex(handle, rect, color, invert, border, diff, same, rounded); MwDrawFrameEx_complex(handle, rect, color, invert, border, diff, same);
} else { } else {
MwDrawFrameEx_simple(handle, rect, color, invert, border, diff, same, rounded); MwDrawFrameEx_simple(handle, rect, color, invert, border, diff, same);
} }
} }

View file

@ -26,6 +26,7 @@ static int is_bold(MwWidget handle, MwFLFont ttf) {
return s; return s;
} }
#ifdef TTF
static int is_monospace(MwWidget handle, MwFLFont ttf) { static int is_monospace(MwWidget handle, MwFLFont ttf) {
size_t u = (size_t)ttf; size_t u = (size_t)ttf;
int s; int s;
@ -36,6 +37,7 @@ static int is_monospace(MwWidget handle, MwFLFont ttf) {
if(s == MwDEFAULT) return 0; if(s == MwDEFAULT) return 0;
return s; return s;
} }
#endif
#ifdef TTF #ifdef TTF

View file

@ -86,7 +86,7 @@ static void draw(MwWidget handle) {
r.height = MwGetInteger(handle, MwNheight); r.height = MwGetInteger(handle, MwNheight);
if(MwGetInteger(handle, MwNhasBorder)) { if(MwGetInteger(handle, MwNhasBorder)) {
MwDrawFrame(handle, &r, base, MwGetInteger(handle, MwNinverted), 0); MwDrawFrame(handle, &r, base, MwGetInteger(handle, MwNinverted));
} }
MwDrawRect(handle, &r, base); MwDrawRect(handle, &r, base);

View file

@ -72,7 +72,7 @@ static void draw(MwWidget handle) {
r.y += r.height; r.y += r.height;
r.height = MwDefaultBorderWidth(handle) * 2; r.height = MwDefaultBorderWidth(handle) * 2;
MwDrawFrame(handle, &r, base, 0, 0); MwDrawFrame(handle, &r, base, 0);
MwLLFreeColor(text); MwLLFreeColor(text);
MwLLFreeColor(base); MwLLFreeColor(base);

View file

@ -49,7 +49,7 @@ static void draw(MwWidget handle) {
int attr; int attr;
MwRect currc; MwRect currc;
p.x = (r.width - (r.width / w * w)) / 2 + (MwGetInteger(handle, MwNisRounded) ? MwGetInteger(handle, MwNroundness) : 0); p.x = (r.width - (r.width / w * w)) / 2;
p.y = r.height / 2; p.y = r.height / 2;
len = (r.width - p.x * 2) / w; len = (r.width - p.x * 2) / w;

View file

@ -22,7 +22,7 @@ static void draw(MwWidget handle) {
fr.y = 0; fr.y = 0;
fr.width = MwGetInteger(handle, MwNwidth); fr.width = MwGetInteger(handle, MwNwidth);
fr.height = MwGetInteger(handle, MwNheight); fr.height = MwGetInteger(handle, MwNheight);
MwDrawFrame(handle, &fr, base, inverted, 0); MwDrawFrame(handle, &fr, base, inverted);
rr.x = MwDefaultBorderWidth(handle); rr.x = MwDefaultBorderWidth(handle);
rr.y = MwDefaultBorderWidth(handle); rr.y = MwDefaultBorderWidth(handle);

View file

@ -20,7 +20,7 @@ static void draw(MwWidget handle) {
r.width = MwGetInteger(handle, MwNwidth); r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight); r.height = MwGetInteger(handle, MwNheight);
if(MwGetInteger(handle, MwNhasBorder)) MwDrawFrame(handle, &r, base, MwGetInteger(handle, MwNinverted), 0); if(MwGetInteger(handle, MwNhasBorder)) MwDrawFrame(handle, &r, base, MwGetInteger(handle, MwNinverted));
MwDrawRect(handle, &r, base); MwDrawRect(handle, &r, base);
if(px != NULL) { if(px != NULL) {

View file

@ -210,7 +210,7 @@ static void frame_draw(MwWidget handle) {
p.x = MwDefaultBorderWidth(handle); p.x = MwDefaultBorderWidth(handle);
p.y = MwDefaultBorderWidth(handle); p.y = MwDefaultBorderWidth(handle);
MwDrawFrame(handle, &r, base, 1, 0); MwDrawFrame(handle, &r, base, 1);
MwDrawRect(handle, &r, base2); MwDrawRect(handle, &r, base2);
r = r2; r = r2;
@ -284,7 +284,7 @@ static void frame_draw(MwWidget handle) {
handle->bgcolor = NULL; handle->bgcolor = NULL;
} }
MwDrawFrame(handle, &r, base, 1, 0); MwDrawFrame(handle, &r, base, 1);
MwLLFreeColor(text2); MwLLFreeColor(text2);
MwLLFreeColor(text); MwLLFreeColor(text);
@ -403,7 +403,7 @@ static void draw(MwWidget handle) {
r.y = 0; r.y = 0;
r.width = get_col_width(lb, i); r.width = get_col_width(lb, i);
r.height = MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, NULL, "M"); r.height = MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, NULL, "M");
MwDrawFrame(handle, &r, base, 0, 0); MwDrawFrame(handle, &r, base, 0);
x += MwDefaultBorderWidth(handle); x += MwDefaultBorderWidth(handle);

View file

@ -100,7 +100,7 @@ static void draw(MwWidget handle) {
BEGIN_MENU_LOOP; BEGIN_MENU_LOOP;
if(m->sub[i]->wsub != NULL || (in_area && handle->pressed)) { if(m->sub[i]->wsub != NULL || (in_area && handle->pressed)) {
MwDrawFrame(handle, &r, base, MwFALSE, 0); MwDrawFrame(handle, &r, base, MwFALSE);
MwDrawWidgetBack(handle, &r, base, 0, MwFALSE); MwDrawWidgetBack(handle, &r, base, 0, MwFALSE);
} }

View file

@ -23,7 +23,7 @@ static void draw(MwWidget handle) {
r.width = MwGetInteger(handle, MwNwidth); r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight); r.height = MwGetInteger(handle, MwNheight);
MwDrawFrame(handle, &r, base, 1, 0); MwDrawFrame(handle, &r, base, 1);
MwDrawRect(handle, &r, base); MwDrawRect(handle, &r, base);
w = MwGetInteger(handle, MwNvalue) - MwGetInteger(handle, MwNminValue); w = MwGetInteger(handle, MwNvalue) - MwGetInteger(handle, MwNminValue);
w = w / (MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue)); w = w / (MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue));

View file

@ -25,7 +25,7 @@ static void draw(MwWidget handle) {
r.y = (r.height - 2) / 2; r.y = (r.height - 2) / 2;
r.height = 2; r.height = 2;
} }
MwDrawFrameEx(handle, &r, base, 1, 1, 0, 0, MwGetInteger(handle, MwNmodernLook)); MwDrawFrameEx(handle, &r, base, 1, 1, 0, 0);
MwLLFreeColor(base); MwLLFreeColor(base);
} }

View file

@ -59,7 +59,7 @@ static void draw(MwWidget handle) {
rc.x += MwGetInteger(handle, MwNleftPadding); rc.x += MwGetInteger(handle, MwNleftPadding);
MwDrawFrameEx(handle, &rc, base, 1, 1, 0, 0, 0); MwDrawFrameEx(handle, &rc, base, 1, 1, 0, 0);
p.y += 2 + 1; p.y += 2 + 1;
} else { } else {

View file

@ -64,7 +64,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
const int len = 4; const int len = 4;
MwDrawRect(handle, &r, col); MwDrawRect(handle, &r, col);
MwDrawFrame(handle, &r, base, tree->opened, 0); MwDrawFrame(handle, &r, base, tree->opened);
if(tree->opened) { if(tree->opened) {
l[0].x = r.x + (r.width - len) / 2; l[0].x = r.x + (r.width - len) / 2;
l[0].y = r.y + r.height / 2; l[0].y = r.y + r.height / 2;
@ -91,7 +91,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
MwLLLine(handle->lowlevel, &l[0], text); MwLLLine(handle->lowlevel, &l[0], text);
} }
r = r2; r = r2;
MwDrawFrame(handle, &r, base, tree->opened, 0); MwDrawFrame(handle, &r, base, tree->opened);
if(col != base) MwLLFreeColor(col); if(col != base) MwLLFreeColor(col);
} else { } else {
@ -183,7 +183,7 @@ static void frame_draw(MwWidget handle) {
p.x = MwDefaultBorderWidth(handle); p.x = MwDefaultBorderWidth(handle);
p.y = MwDefaultBorderWidth(handle); p.y = MwDefaultBorderWidth(handle);
MwDrawFrame(handle, &r, base, 1, 0); MwDrawFrame(handle, &r, base, 1);
MwDrawRect(handle, &r, base2); MwDrawRect(handle, &r, base2);
r = r2; r = r2;
@ -193,7 +193,7 @@ static void frame_draw(MwWidget handle) {
recursion(handle, tv->tree[i], tv->tree, base, text, base2, text2, &p, 0, LineSpace, &skip, &shared, 1, NULL); recursion(handle, tv->tree[i], tv->tree, base, text, base2, text2, &p, 0, LineSpace, &skip, &shared, 1, NULL);
} }
MwDrawFrame(handle, &r, base, 1, 0); MwDrawFrame(handle, &r, base, 1);
MwLLFreeColor(text2); MwLLFreeColor(text2);
MwLLFreeColor(text); MwLLFreeColor(text);

View file

@ -18,7 +18,7 @@ static void draw(MwWidget handle) {
r.width = MwGetInteger(handle, MwNwidth); r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight); r.height = MwGetInteger(handle, MwNheight);
if(MwGetInteger(handle, MwNhasBorder)) MwDrawFrame(handle, &r, c, MwGetInteger(handle, MwNinverted), 0); if(MwGetInteger(handle, MwNhasBorder)) MwDrawFrame(handle, &r, c, MwGetInteger(handle, MwNinverted));
MwDrawRect(handle, &r, c); MwDrawRect(handle, &r, c);