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 {
branch "master"
}
agent {
label "built-in"
}
steps {
sh("rm -rf include/Mw/LowLevel/Wayland")
sh("doxygen")
sh("rm -rf /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("stb-image", 1);
param_set("stb-truetype", 0);
param_set("xrender", 1);
param_set("opengl", 0);
param_set("vulkan", 0);
@ -50,6 +49,9 @@ param_set("examples", 1);
if($target ne "Darwin") {
param_set("freetype2", 1);
param_set("stb-truetype", 0);
} else {
param_set("stb-truetype", 1);
}
my %features = (
@ -64,6 +66,7 @@ my %features = (
"shared" => "build shared library",
"static" => "build static library",
"wayland" => "enable wayland backend",
"gnustep" => "use gnustep",
);
my @features_keys = (
"1classic-theme", "1stb-image",
@ -71,9 +74,16 @@ my @features_keys = (
"1opengl", "2xrender",
"1vulkan", "2vulkan-string-helper",
"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) {
if ($l =~ /^--with-([^=]+)=(.+)$/) {
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") {
require("./pl/ostype/${target}.pl");
}

View file

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

View file

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

View file

@ -53,7 +53,7 @@ MWDECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color);
* @param rect Rectangle area
* @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
@ -63,7 +63,7 @@ MWDECL void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color, int
* @param invert Invert the 3D border color or not
* @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.
@ -96,7 +96,7 @@ MWDECL void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int i
* @param rounded Rounded or not
* @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

View file

@ -15,12 +15,6 @@
#import <Foundation/Foundation.h>
#import <Foundation/NSGeometry.h>
#ifdef __APPLE__
#import <CoreServices/CoreServices.h>
#else
#import <CoreGraphics/CoreGraphics.h>
#endif
@interface MilskoCocoaApplication : NSApplication {
MwBool doPending;
}
@ -40,9 +34,9 @@
// Note: implements NSWindowDelegate
@interface MilskoCocoaWindowDelegate : NSObject {
MilskoCocoaWindow* w;
NSWindow* w;
}
- (MilskoCocoaWindowDelegate*)initWithWin:(MilskoCocoaWindow*)win;
- (MilskoCocoaWindowDelegate*)initWithWin:(NSWindow*)win;
@end
/*
@ -67,6 +61,7 @@
@end
@interface MilskoCocoaPixmap : NSObject {
@public
MwBool valid;
int width;
int height;
@ -86,18 +81,17 @@
@end
@interface MilskoCocoaView : NSView {
NSBitmapImageRep* rep;
NSGraphicsContext* context;
MwBool valid;
CGColorSpaceRef space;
CGDataProviderRef provider;
NSRect givenRect;
float x;
float y;
float width;
float height;
MwBool _child;
IBOutlet NSViewController* viewController;
@public
unsigned char* buf;
NSBitmapImageRep* rep;
NSGraphicsContext* context;
MwBool valid;
NSRect givenRect;
float x;
float y;
float width;
float height;
MwBool _child;
}
- (void)initRepAndContextWithWidth:(float)w Height:(float)h;
@ -105,14 +99,18 @@
- (void)destroy;
- (NSBitmapImageRep*)getRep;
- (void)setChild;
@end
@interface MilskoCocoaSubView : MilskoCocoaView {
}
@end
@interface MilskoCocoa : NSObject {
@public
MilskoCocoaApplication* application;
MwBool _forceRender;
MwBool _eventsPending;
MilskoCocoaWindow* window;
NSWindow* window;
NSRect rect;
MilskoCocoaView* view;
MwLL parent;
@ -126,55 +124,21 @@
MwBool pointerLocked;
MwBool mouseMoved;
}
+ (MilskoCocoa*)newWithParent:(MwLL)parent
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;
MwBool rejectFirstTest;
}
- (void)destroy;
- (void)sendClipboardEvent;
- (MwLL)getParent;
- (NSView*)getView;
- (MilskoCocoaWindow*)getWindow;
- (NSWindow*)getWindow;
- (void)nudge;
- (void)pushCursor;
- (void)popCursor;
- (MilskoFakePointer*)getHandle;
+ (void)eventCanceller:(MilskoCocoa*)this;
@end
#define OBJC(x) x

View file

@ -57,17 +57,26 @@
#define M_PI 3.14159265
#endif
/* Windows */
#if defined(_MILSKO) && defined(_WIN32)
#define MWDECL extern __declspec(dllexport)
#elif defined(_WIN32)
#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)
#if __has_attribute(visibility)
#define MWDECL extern __attribute__((visibility("default")))
#else
#define MWDECL extern
#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
/* all else fails */
#define MWDECL extern
#endif

View file

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

View file

@ -55,10 +55,17 @@ if (grep(/^wayland$/, @backends)) {
$gl_libs = "-lGL -lGLU";
}
if (grep(/^cocoa$/, @backends)) {
if (grep(/^cocoa$/, @backends) || param_get("gnustep")) {
add_cflags("-DUSE_COCOA");
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")) {
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:
* - MILSKO_BACKEND
* - XDG_SESSION_TYPE
* - manually checking environment variables
*/
#ifdef __linux__

View file

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

View file

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

View file

@ -11,10 +11,6 @@
#include "../external/stb_ds.h"
#define DEFAULT_ROUNDNESS 5
#define MAX_ROUNDNESS 30
#define BORDER_SMOOTHNESS 50
static int get_color_diff(MwWidget handle) {
if(MwGetInteger(handle, MwNmodernLook)) {
return 40;
@ -106,7 +102,7 @@ void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor 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;
int y, i;
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 char* data = malloc(sz);
MwRect r = *rect;
int roundness = MwGetInteger(handle, MwNroundness);
double div;
if(rect->width <= 0 || rect->height <= 0) {
free(data);
return;
}
if(roundness == MwDEFAULT) roundness = DEFAULT_ROUNDNESS;
if(roundness >= MAX_ROUNDNESS) roundness = MAX_ROUNDNESS;
div = (roundness <= 10) ? 7. : 10.;
memset(data, 0, sz);
r.x += 1;
r.y += 1;
r.width -= 2;
r.height -= 2;
for(y = 0; y < rect->height; y++) {
MwLLColor col = MwLightenColor(handle, color, -darken, -darken, -darken);
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);
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);
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);
}
MwLLDrawPixmap(handle->lowlevel, &r, pixmap);
MwLLDestroyPixmap(pixmap);
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;
if((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv) invert = 1;
if(MwGetInteger(handle, MwNmodernLook)) {
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0, rounded);
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0);
} else {
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 st = invert ? 1 : 0;
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) == 1) MwDrawFrameEx(handle, rect, color, invert, 1, diff, 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);
}
} 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) {
MwLLColor col;
MwBool rounded = MwGetInteger(handle, MwNroundness) != MwDEFAULT && MwGetInteger(handle, MwNisRounded) != 0;
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;
if(MwGetInteger(handle, MwNmodernLook)) {
MwDrawRectFading(handle, rect, col, rounded);
MwDrawRectFading(handle, rect, col);
} else {
MwDrawRect(handle, rect, col);
}
@ -284,55 +256,47 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
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];
int ColorDiff = get_color_diff(handle);
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);
int roundness = MwGetInteger(handle, MwNroundness);
p[0].x = rect->x;
p[0].y = rect->y;
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].y = rect->y;
p[1].x = rect->x + rect->width;
p[1].y = rect->y;
p[1].x = rect->x + rect->width;
p[1].y = rect->y;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + border;
p[3].x = rect->x + border;
p[3].y = rect->y + border;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + border;
p[3].x = rect->x + border;
p[3].y = rect->y + border;
p[4].x = rect->x + border;
p[4].y = rect->y + rect->height - border;
p[4].x = rect->x + border;
p[4].y = rect->y + rect->height - border;
p[5].x = rect->x;
p[5].y = rect->y + rect->height;
}
p[5].x = rect->x;
p[5].y = rect->y + rect->height;
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].y = rect->y;
p[0].x = rect->x + rect->width;
p[0].y = rect->y;
p[1].x = rect->x + rect->width - border;
p[1].y = rect->y + border;
p[1].x = rect->x + rect->width - border;
p[1].y = rect->y + border;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + rect->height - border;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + rect->height - border;
p[3].x = rect->x + border;
p[3].y = rect->y + rect->height - border;
p[3].x = rect->x + border;
p[3].y = rect->y + rect->height - border;
p[4].x = rect->x;
p[4].y = rect->y + rect->height;
p[4].x = rect->x;
p[4].y = rect->y + rect->height;
p[5].x = rect->x + rect->width;
p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
}
p[5].x = rect->x + rect->width;
p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
MwLLFreeColor(lighter);
MwLLFreeColor(darker);
@ -343,168 +307,64 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color,
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];
int roundness = MwGetInteger(handle, MwNroundness);
int i;
(void)diff;
(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);
p[0].x = rect->x;
p[0].y = rect->y;
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[1].x = rect->x + rect->width;
p[1].y = rect->y;
p[0].x = rect->x + roundness;
p[0].y = rect->y + border;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + border;
p[3].x = rect->x + border;
p[3].y = rect->y + border;
p[1].x = rect->x + rect->width - border - roundness;
p[1].y = rect->y + border;
p[4].x = rect->x + border;
p[4].y = rect->y + rect->height - 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].y = rect->y;
p[1].x = rect->x + rect->width;
p[1].y = rect->y;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + border;
p[3].x = rect->x + border;
p[3].y = rect->y + border;
p[4].x = rect->x + border;
p[4].y = rect->y + rect->height - border;
p[5].x = rect->x;
p[5].y = rect->y + rect->height;
}
p[5].x = rect->x;
p[5].y = rect->y + rect->height;
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);
p[0].x = rect->x + rect->width;
p[0].y = rect->y;
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;
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;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + rect->height - border - roundness;
p[3].x = rect->x + border;
p[3].y = rect->y + rect->height - border;
p[3].x = rect->x + rect->width - border - roundness;
p[3].y = rect->y + rect->height - border;
p[4].x = rect->x;
p[4].y = rect->y + rect->height;
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].y = rect->y;
p[1].x = rect->x + rect->width - border;
p[1].y = rect->y + border;
p[2].x = rect->x + rect->width - border;
p[2].y = rect->y + rect->height - border;
p[3].x = rect->x + border;
p[3].y = rect->y + rect->height - border;
p[4].x = rect->x;
p[4].y = rect->y + rect->height;
p[5].x = rect->x + rect->width;
p[5].y = rect->y + rect->height;
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
}
p[5].x = rect->x + rect->width;
p[5].y = rect->y + rect->height;
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);
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);
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.y += 1;
r.width -= 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(darker);
@ -515,11 +375,11 @@ static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color
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)) {
MwDrawFrameEx_complex(handle, rect, color, invert, border, diff, same, rounded);
MwDrawFrameEx_complex(handle, rect, color, invert, border, diff, same);
} 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;
}
#ifdef TTF
static int is_monospace(MwWidget handle, MwFLFont ttf) {
size_t u = (size_t)ttf;
int s;
@ -36,6 +37,7 @@ static int is_monospace(MwWidget handle, MwFLFont ttf) {
if(s == MwDEFAULT) return 0;
return s;
}
#endif
#ifdef TTF

View file

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

View file

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

View file

@ -49,7 +49,7 @@ static void draw(MwWidget handle) {
int attr;
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;
len = (r.width - p.x * 2) / w;

View file

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

View file

@ -20,7 +20,7 @@ static void draw(MwWidget handle) {
r.width = MwGetInteger(handle, MwNwidth);
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);
if(px != NULL) {

View file

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

View file

@ -100,7 +100,7 @@ static void draw(MwWidget handle) {
BEGIN_MENU_LOOP;
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);
}

View file

@ -23,7 +23,7 @@ static void draw(MwWidget handle) {
r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight);
MwDrawFrame(handle, &r, base, 1, 0);
MwDrawFrame(handle, &r, base, 1);
MwDrawRect(handle, &r, base);
w = MwGetInteger(handle, MwNvalue) - 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.height = 2;
}
MwDrawFrameEx(handle, &r, base, 1, 1, 0, 0, MwGetInteger(handle, MwNmodernLook));
MwDrawFrameEx(handle, &r, base, 1, 1, 0, 0);
MwLLFreeColor(base);
}

View file

@ -59,7 +59,7 @@ static void draw(MwWidget handle) {
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;
} else {

View file

@ -64,7 +64,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
const int len = 4;
MwDrawRect(handle, &r, col);
MwDrawFrame(handle, &r, base, tree->opened, 0);
MwDrawFrame(handle, &r, base, tree->opened);
if(tree->opened) {
l[0].x = r.x + (r.width - len) / 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);
}
r = r2;
MwDrawFrame(handle, &r, base, tree->opened, 0);
MwDrawFrame(handle, &r, base, tree->opened);
if(col != base) MwLLFreeColor(col);
} else {
@ -183,7 +183,7 @@ static void frame_draw(MwWidget handle) {
p.x = MwDefaultBorderWidth(handle);
p.y = MwDefaultBorderWidth(handle);
MwDrawFrame(handle, &r, base, 1, 0);
MwDrawFrame(handle, &r, base, 1);
MwDrawRect(handle, &r, base2);
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);
}
MwDrawFrame(handle, &r, base, 1, 0);
MwDrawFrame(handle, &r, base, 1);
MwLLFreeColor(text2);
MwLLFreeColor(text);

View file

@ -18,7 +18,7 @@ static void draw(MwWidget handle) {
r.width = MwGetInteger(handle, MwNwidth);
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);