diff --git a/examples/basic/periodic.c b/examples/basic/periodic.c index 2aa6c431..8ff9811e 100644 --- a/examples/basic/periodic.c +++ b/examples/basic/periodic.c @@ -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, diff --git a/src/core.c b/src/core.c index 547b7b1e..0618ea3c 100644 --- a/src/core.c +++ b/src/core.c @@ -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; diff --git a/src/widget/scrollbar.c b/src/widget/scrollbar.c index 840cdb56..02832a72 100644 --- a/src/widget/scrollbar.c +++ b/src/widget/scrollbar.c @@ -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,8 +51,10 @@ static void add_value(MwWidget handle, int mul) { if(val < min) val = min; if(val > max) val = max; - MwSetInteger(handle, MwNvalue, val); - MwDispatchUserHandler(handle, MwNchangedHandler, NULL); + if(MwGetInteger(handle, MwNvalue) != val) { + MwSetInteger(handle, MwNvalue, val); + MwDispatchUserHandler(handle, MwNchangedHandler, NULL); + } } static void draw(MwWidget handle) { @@ -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) {