ref: b8b6a0e523f7f780a66ad38327d34b8185533c90
parent: b101629fae68d14e5317de76a7216c3dc0ae60dc
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Jan 12 14:10:15 EST 2020
switch from float to double
--- a/demo/frame.c
+++ b/demo/frame.c
@@ -164,7 +164,7 @@
static int
uint8_slider(unsigned char *value, int low, int high)
{
- static float tmp;
+ static double tmp;
mu_push_id(&value, sizeof(value));
tmp = *value;
int res = mu_slider_ex(&tmp, low, high, 0, "%.0f", MU_OPT_ALIGNCENTER);
--- a/microui.c
+++ b/microui.c
@@ -951,7 +951,7 @@
static int
-number_textbox(float *value, mu_Rect r, mu_Id id)
+number_textbox(double *value, mu_Rect r, mu_Id id)
{
if (((mu_ctx.mouse_pressed == MU_MOUSE_LEFT && mu_ctx.key_down & MU_KEY_SHIFT) || mu_ctx.mouse_pressed == MU_MOUSE_RIGHT) && mu_ctx.hover == id) {
mu_ctx.number_editing = id;
@@ -987,12 +987,12 @@
int
-mu_slider_ex(float *value, float low, float high, float step, const char *fmt, int opt)
+mu_slider_ex(double *value, double low, double high, double step, const char *fmt, int opt)
{
char buf[MU_MAX_FMT + 1];
mu_Rect thumb;
int w, res = 0;
- float normalized, last = *value, v = last;
+ double normalized, last = *value, v = last;
mu_Id id = mu_get_id(&value, sizeof(value));
mu_Rect base = mu_layout_next();
@@ -1006,7 +1006,7 @@
/* handle input */
if (mu_ctx.focus == id) {
if (mu_ctx.mouse_down == MU_MOUSE_LEFT)
- v = low + ((float)(mu_ctx.mouse_pos.x - base.x) / base.w) * (high - low);
+ v = low + ((double)(mu_ctx.mouse_pos.x - base.x) / base.w) * (high - low);
} else if (mu_ctx.hover == id) {
if ((mu_ctx.key_pressed & (MU_KEY_LEFT | MU_KEY_RIGHT)) == MU_KEY_LEFT) {
v -= step ? step : 1;
@@ -1042,7 +1042,7 @@
int
-mu_slider(float *value, float low, float high)
+mu_slider(double *value, double low, double high)
{
return mu_slider_ex(value, low, high, 0, MU_SLIDER_FMT, MU_OPT_ALIGNCENTER);
}
@@ -1049,13 +1049,13 @@
int
-mu_number_ex(float *value, float step, const char *fmt, int opt)
+mu_number_ex(double *value, double step, const char *fmt, int opt)
{
char buf[MU_MAX_FMT + 1];
int res = 0;
mu_Id id = mu_get_id(&value, sizeof(value));
mu_Rect base = mu_layout_next();
- float last = *value;
+ double last = *value;
/* handle text input mode */
if (number_textbox(value, base, id))
@@ -1083,7 +1083,7 @@
int
-mu_number(float *value, float step)
+mu_number(double *value, double step)
{
return mu_number_ex(value, step, MU_SLIDER_FMT, MU_OPT_ALIGNCENTER);
}
--- a/microui.h
+++ b/microui.h
@@ -301,10 +301,10 @@
int mu_textbox_raw(char *buf, int bufsz, mu_Id id, mu_Rect r, int opt);
int mu_textbox_ex(char *buf, int bufsz, int opt);
int mu_textbox(char *buf, int bufsz);
-int mu_slider_ex(float *value, float low, float high, float step, const char *fmt, int opt);
-int mu_slider(float *value, float low, float high);
-int mu_number_ex(float *value, float step, const char *fmt, int opt);
-int mu_number(float *value, float step);
+int mu_slider_ex(double *value, double low, double high, double step, const char *fmt, int opt);
+int mu_slider(double *value, double low, double high);
+int mu_number_ex(double *value, double step, const char *fmt, int opt);
+int mu_number(double *value, double step);
int mu_header(int *state, const char *label);
int mu_begin_treenode(int *state, const char *label);
void mu_end_treenode(void);