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

This commit is contained in:
Nishi 2026-09-28 10:56:30 +09:00
commit eb8b945995
3 changed files with 21 additions and 5 deletions

View file

@ -341,7 +341,7 @@ int main() {
f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL);
f = frame("SubWindow", -PaddingContent, -PaddingContent, MwViewportClass,
MwNcolumnSpan, 2,
MwNcolumnSpan, 3,
NULL);
w = child(f);
MwViewportSetSize(w, 512, 512);
@ -352,7 +352,9 @@ int main() {
MwNtitle, "Sub window 2",
NULL);
f = frame("Tab", -PaddingContent, -PaddingContent, MwTabClass, NULL);
f = frame("Tab", -PaddingContent, -PaddingContent, MwTabClass,
MwNcolumnSpan, 2,
NULL);
w = child(f);
MwSetString(MwTabAdd(w, "ABC"), MwNbackground, "#f00");
MwSetString(MwTabAdd(w, "DEF"), MwNbackground, "#0f0");
@ -364,7 +366,14 @@ int main() {
v = MwTreeViewAdd(w, v, NULL, "def");
v = MwTreeViewAdd(w, v, NULL, "ghi");
f = frame("Viewport", -PaddingContent, -PaddingContent, MwViewportClass, NULL);
f = frame("Text", -PaddingContent, -PaddingContent, MwViewportClass,
MwNcolumnSpan, 2,
NULL);
w = child(f);
f = frame("Viewport", -PaddingContent, -PaddingContent, MwViewportClass,
MwNcolumnSpan, 2,
NULL);
w = child(f);
MwViewportSetSize(w, 256, 256);
MwVaCreateWidget(MwButtonClass, "btn", MwViewportGetViewport(w), 64, 64, 128, 128,

View file

@ -267,6 +267,8 @@ static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name,
h->lowlevel = NULL;
}
h->widget_class = widget_class;
h->mouse_point.x = 0;
h->mouse_point.y = 0;
h->pressed = 0;
h->close = 0;
h->destroy_queue = NULL;

View file

@ -27,6 +27,7 @@ static int calc_length(MwWidget handle) {
int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue);
int area = MwGetInteger(handle, MwNareaShown);
if(area > len) area = len;
if(len == 0) return max;
return (int)(max * (double)area / len);
}
@ -35,6 +36,7 @@ static int calc_position(MwWidget handle) {
int max = MwScrollBarGetVisibleLength(handle);
int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue);
int val = MwGetInteger(handle, MwNvalue);
if(len == 0) return 0;
return (int)((max - calc_length(handle)) * (double)val / len);
}
@ -49,9 +51,11 @@ static void add_value(MwWidget handle, int mul) {
if(val < min) val = min;
if(val > max) val = max;
if(MwGetInteger(handle, MwNvalue) != val) {
MwSetInteger(handle, MwNvalue, val);
MwDispatchUserHandler(handle, MwNchangedHandler, NULL);
}
}
static void draw(MwWidget handle) {
MwRect r = {0}, rt = {0}, rbar = {0};
@ -223,6 +227,7 @@ static void mouse_down(MwWidget handle, void* ptr) {
static void prop_change(MwWidget handle, const char* key) {
if(strcmp(key, MwNminValue) == 0 || strcmp(key, MwNvalue) == 0 || strcmp(key, MwNmaxValue) == 0) {
if(MwGetInteger(handle, MwNvalue) > MwGetInteger(handle, MwNmaxValue)) MwSetInteger(handle, MwNvalue, MwGetInteger(handle, MwNmaxValue));
if(MwGetInteger(handle, MwNvalue) < MwGetInteger(handle, MwNminValue)) MwSetInteger(handle, MwNvalue, MwGetInteger(handle, MwNminValue));
MwForceRender(handle);
}
if(strcmp(key, MwNshowArrows) == 0 || strcmp(key, MwNareaShown) == 0) {