diff --git a/README.md b/README.md index 5c7dc679..3ba91ad6 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ This README is being written.
* uiAreas on Windows and some internal Direct2D areas now respond to `WM_PRINTCLIENT` properly, which should hopefully increase the quality of screenshots. * uiDateTimePicker on GTK+ works properly on RTL layouts and no longer disappears off the bottom of the screen if not enough room is available. It will also no longer be marked for localization of the time format (what the separator should be and whether to use 24-hour time), as that information is not provided by the locale system. :( * Added `uiUserBugCannotSetParentOnToplevel()`, which should be used by implementations of toplevel controls in their `SetParent()` implementations. This will also be the beginning of consolidating common user bug messages into a single place, though this will be one of the only few exported user bug functions. + * uiSpinbox and uiSlider now merely swap their min and max if min ≥ max. They will no longer panic and do nothing, respectively. ## Runtime Requirements diff --git a/darwin/slider.m b/darwin/slider.m index d280ba2e..4cee88c5 100644 --- a/darwin/slider.m +++ b/darwin/slider.m @@ -114,6 +114,13 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max) { uiSlider *s; NSSliderCell *cell; + intmax_t temp; + + if (min >= max) { + temp = min; + min = max; + max = temp; + } uiDarwinNewControl(uiSlider, s); diff --git a/darwin/spinbox.m b/darwin/spinbox.m index 5817efae..24ed9195 100644 --- a/darwin/spinbox.m +++ b/darwin/spinbox.m @@ -182,10 +182,13 @@ static void defaultOnChanged(uiSpinbox *s, void *data) uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) { uiSpinbox *s; + intmax_t temp; - // TODO implicitly swap instead? - if (min >= max) - userbug("min >= max is invalid for a uiSpinbox."); + if (min >= max) { + temp = min; + min = max; + max = temp; + } uiDarwinNewControl(uiSpinbox, s); diff --git a/doc/slider b/doc/slider new file mode 100644 index 00000000..5a6ac040 --- /dev/null +++ b/doc/slider @@ -0,0 +1 @@ +if min >= max then they are swapped diff --git a/doc/spinbox b/doc/spinbox new file mode 100644 index 00000000..5a6ac040 --- /dev/null +++ b/doc/spinbox @@ -0,0 +1 @@ +if min >= max then they are swapped diff --git a/unix/drawtext.c b/unix/drawtext.c index 597f2643..bc12f22e 100644 --- a/unix/drawtext.c +++ b/unix/drawtext.c @@ -100,7 +100,7 @@ PangoFont *pangoDescToPangoFont(PangoFontDescription *pdesc) context = mkGenericPangoCairoContext(); f = pango_font_map_load_font(pango_cairo_font_map_get_default(), context, pdesc); if (f == NULL) { - // TODO + // LONGTERM g_error("[libui] no match in pangoDescToPangoFont(); report to andlabs"); } g_object_unref(context); diff --git a/unix/slider.c b/unix/slider.c index 81b261d8..b34fac1f 100644 --- a/unix/slider.c +++ b/unix/slider.c @@ -47,6 +47,13 @@ void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *, void *), void *data) uiSlider *uiNewSlider(intmax_t min, intmax_t max) { uiSlider *s; + intmax_t temp; + + if (min >= max) { + temp = min; + min = max; + max = temp; + } uiUnixNewControl(uiSlider, s); diff --git a/unix/spinbox.c b/unix/spinbox.c index 433c3965..16be68f9 100644 --- a/unix/spinbox.c +++ b/unix/spinbox.c @@ -34,7 +34,7 @@ void uiSpinboxSetValue(uiSpinbox *s, intmax_t value) { // we need to inhibit sending of ::value-changed because this WILL send a ::value-changed otherwise g_signal_handler_block(s->spinButton, s->onChangedSignal); - // TODO does this clamp? + // this clamps for us gtk_spin_button_set_value(s->spinButton, (gdouble) value); g_signal_handler_unblock(s->spinButton, s->onChangedSignal); } @@ -48,10 +48,13 @@ void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *, void *), void *data uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) { uiSpinbox *s; + intmax_t temp; - // TODO just swap? - if (min >= max) - userbug("min >= max not allowed in uiNewSpinbox()."); + if (min >= max) { + temp = min; + min = max; + max = temp; + } uiUnixNewControl(uiSpinbox, s); diff --git a/windows/drawtext.cpp b/windows/drawtext.cpp index 453b4c10..7a03f65d 100644 --- a/windows/drawtext.cpp +++ b/windows/drawtext.cpp @@ -244,7 +244,7 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc) if (hr != S_OK) logHRESULT(L"error finding font family", hr); if (!exists) - implbug("TODO family not found in uiDrawLoadClosestFont()", hr); + implbug("LONGTERM family not found in uiDrawLoadClosestFont()", hr); hr = collection->GetFontFamily(index, &family); if (hr != S_OK) logHRESULT(L"error loading font family", hr); diff --git a/windows/slider.cpp b/windows/slider.cpp index 83017e3b..0783627c 100644 --- a/windows/slider.cpp +++ b/windows/slider.cpp @@ -71,6 +71,13 @@ void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *, void *), void *data) uiSlider *uiNewSlider(intmax_t min, intmax_t max) { uiSlider *s; + intmax_t temp; + + if (min >= max) { + temp = min; + min = max; + max = temp; + } uiWindowsNewControl(uiSlider, s); diff --git a/windows/spinbox.cpp b/windows/spinbox.cpp index a9a9ed4b..f8c79d95 100644 --- a/windows/spinbox.cpp +++ b/windows/spinbox.cpp @@ -182,10 +182,13 @@ static void onResize(uiWindowsControl *c) uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) { uiSpinbox *s; + intmax_t temp; - if (min >= max) - // TODO - implbug("error: min >= max in uiNewSpinbox()"); + if (min >= max) { + temp = min; + min = max; + max = temp; + } uiWindowsNewControl(uiSpinbox, s);