working on scrollbar, wip

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@163 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-04 16:34:24 +00:00
parent c2246783f8
commit 4452531d90
18 changed files with 140 additions and 36 deletions

View File

@@ -48,6 +48,21 @@ MwLLColor MwParseColor(MwWidget handle, const char* text) {
return MwLLAllocColor(handle->lowlevel, r, g, b);
}
MwLLColor MwLightenColor(MwWidget handle, MwLLColor color, int r, int g, int b) {
int cr = color->red + r;
int cg = color->green + g;
int cb = color->blue + b;
if(cr < 0) cr = 0;
if(cg < 0) cg = 0;
if(cb < 0) cb = 0;
if(cr > 255) cr = 255;
if(cg > 255) cg = 255;
if(cb > 255) cb = 255;
return MwLLAllocColor(handle->lowlevel, cr, cg, cb);
}
void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color) {
MwPoint p[4];
@@ -177,3 +192,6 @@ MwLLPixmap MwLoadImage(MwWidget handle, const char* path) {
return px;
}
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
}

View File

@@ -1,6 +1,6 @@
/* $Id$ */
#include <Mw/Milsko.h>
#include <Mw/OpenGL.h>
#include <Mw/Widget/OpenGL.h>
#ifdef _WIN32
/* nothing */

38
src/widget/scrollbar.c Normal file
View File

@@ -0,0 +1,38 @@
/* $Id $*/
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
MwSetDefault(handle);
return 0;
}
static void draw(MwWidget handle) {
MwRect r, rt;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
r.x = 0;
r.y = 0;
r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight);
MwDrawFrame(handle, &r, dark, 1);
MwDrawRect(handle, &r, dark);
rt = r;
rt.height = rt.width;
MwDrawTriangle(handle, &r, base, 0, MwNORTH);
MwLLFreeColor(dark);
MwLLFreeColor(base);
}
MwClassRec MwScrollBarClassRec = {
create, /* create */
NULL, /* destroy */
draw, /* draw */
NULL, /* click */
NULL /* parent_resize */
};
MwClass MwScrollBarClass = &MwScrollBarClassRec;

View File

@@ -1,6 +1,6 @@
/* $Id$ */
#include <Mw/Milsko.h>
#include <Mw/Vulkan.h>
#include <Mw/Widget/Vulkan.h>
#include "../error_internal.h"