diff --git a/examples/gldemos/clock.c b/examples/gldemos/clock.c index 993d4af..7bf74b6 100644 --- a/examples/gldemos/clock.c +++ b/examples/gldemos/clock.c @@ -142,10 +142,10 @@ int main() { NULL); bgcolor = MwParseColor(window, MwGetText(window, MwNbackground)); - MwGetColor(bgcolor, &br, &bg, &bb); + MwColorGet(bgcolor, &br, &bg, &bb); fgcolor = MwParseColor(window, MwGetText(window, MwNforeground)); - MwGetColor(fgcolor, &fr, &fg, &fb); + MwColorGet(fgcolor, &fr, &fg, &fb); opengl = MwCreateWidget(MwOpenGLClass, "clock", window, 0, 0, 100, 100); diff --git a/include/Mw/Draw.h b/include/Mw/Draw.h index 6ccc299..b90d4e4 100644 --- a/include/Mw/Draw.h +++ b/include/Mw/Draw.h @@ -112,7 +112,7 @@ MWDECL MwLLPixmap MwLoadImage(MwWidget handle, const char* path); * @param green Pointer to green color * @param blue Pointer to blue color */ -MWDECL void MwGetColor(MwLLColor color, int* red, int* green, int* blue); +MWDECL void MwColorGet(MwLLColor color, int* red, int* green, int* blue); /*! * @brief Creates a pixmap from raw data @@ -125,14 +125,25 @@ MWDECL void MwGetColor(MwLLColor color, int* red, int* green, int* blue); MWDECL MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height); /*! - * @brief Creates a pixmap from raw data - * @param handle Widget + * @brief Updates a pixmap using raw data * @param pixmap Pixmap to update * @param rgb RGBA data - * @param width Width - * @param height Height */ -MWDECL void MwReloadRaw(MwWidget handle, MwLLPixmap pixmap, unsigned char* rgb, int width, int height); +MWDECL void MwPixmapReloadRaw(MwLLPixmap pixmap, unsigned char* rgb); + +/*! + * @brief Gets the raw data of pixmap + * @param pixmap Pixmap + * @return RFBA data + */ +MWDECL unsigned char* MwPixmapGetRaw(MwLLPixmap pixmap); + +/*! + * @brief Gets the size of pixmap + * @param pixmap Pixmap + * @param rect Size + */ +MWDECL void MwPixmapGetSize(MwLLPixmap pixmap, MwRect* rect); /*! * @brief Creates a pixmap from XPM data diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index 167785a..0b0357d 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -47,6 +47,7 @@ struct _MwLLCommonPixmap { int width; int height; unsigned char* raw; + void* user; }; #ifdef _MILSKO diff --git a/src/dialog/colorpicker.c b/src/dialog/colorpicker.c index eeb9a4f..0a953e6 100644 --- a/src/dialog/colorpicker.c +++ b/src/dialog/colorpicker.c @@ -146,11 +146,11 @@ static void color_picker_image_update(color_picker_t* picker) { picker->color_picker_pixmap = MwLoadRaw( picker->parent, picker->color_picker_image_data, PICKER_SIZE, PICKER_SIZE); } else { - MwReloadRaw( - picker->parent, picker->color_picker_pixmap, picker->color_picker_image_data, PICKER_SIZE, PICKER_SIZE); + MwPixmapReloadRaw( + picker->color_picker_pixmap, picker->color_picker_image_data); } MwVaApply(picker->color_picker_img, MwNpixmap, picker->color_picker_pixmap, NULL); - // printf("%d\n", n); + /* printf("%d\n", n); */ } static void color_picker_click(MwWidget handle, void* user, void* call) { @@ -165,7 +165,7 @@ static void color_picker_click(MwWidget handle, void* user, void* call) { (void)user; (void)call; - // color_picker_image_update(picker); + /* color_picker_image_update(picker); */ i = ((mouse->point.y * PICKER_SIZE) + mouse->point.x) * 4; @@ -198,7 +198,7 @@ static void color_picker_on_change_value(MwWidget handle, void* user, picker->value = ((double)value / 1024.); picker->doUpdate = 1; - // color_picker_image_update(picker); + /* color_picker_image_update(picker); */ } static void color_picker_tick(MwWidget handle, void* user, @@ -282,12 +282,12 @@ color_picker_t* color_picker_setup(MwWidget parent, int w, int h) { MwVaCreateWidget(MwImageClass, "image", picker->parent, IMG_POS_X(w), IMG_POS_Y(h), PICKER_SIZE, PICKER_SIZE, NULL); - // picker->color_picker_image_data = malloc(PICKER_SIZE * PICKER_SIZE * 4); + /* picker->color_picker_image_data = malloc(PICKER_SIZE * PICKER_SIZE * 4); */ picker->color_picker_pixmap = NULL; picker->value = 0; - // color_picker_image_update(picker); + /* color_picker_image_update(picker); */ picker->doUpdate = 1; MwAddUserHandler(picker->color_picker_img, MwNmouseDownHandler, @@ -299,7 +299,7 @@ color_picker_t* color_picker_setup(MwWidget parent, int w, int h) { MwSetText(picker->color_display_text, MwNbackground, "#FFFFFF"); MwSetText(picker->color_display_text, MwNtext, "#FFFFFF"); - // MwSetInteger(picker->color_display_text, Mwnali, MwALIGNMENT_CENTER); + /* MwSetInteger(picker->color_display_text, Mwnali, MwALIGNMENT_CENTER); */ MwAddUserHandler(picker->color_display_text, MwNactivateHandler, color_display_text_change, picker); diff --git a/src/draw.c b/src/draw.c index 966666b..169b43c 100644 --- a/src/draw.c +++ b/src/draw.c @@ -658,17 +658,19 @@ MwLLPixmap MwLoadImage(MwWidget handle, const char* path) { MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height) { MwLLPixmap px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height); - MwReloadRaw(handle, px, rgb, width, height); + px->common.user = handle; + MwPixmapReloadRaw(px, rgb); return px; } -void MwReloadRaw(MwWidget handle, MwLLPixmap px, unsigned char* rgb, int width, int height) { +void MwPixmapReloadRaw(MwLLPixmap px, unsigned char* rgb) { int i; - MwLLColor base = handle->bgcolor == NULL ? MwParseColor(handle, MwGetText(handle, MwNbackground)) : handle->bgcolor; + MwWidget handle = px->common.user; + MwLLColor base = handle->bgcolor == NULL ? MwParseColor(handle, MwGetText(handle, MwNbackground)) : handle->bgcolor; - memset(px->common.raw, 0, width * height * 4); - for(i = 0; i < width * height; i++) { + memset(px->common.raw, 0, px->common.width * px->common.height * 4); + for(i = 0; i < px->common.width * px->common.height; i++) { unsigned char* pin = &rgb[i * 4]; unsigned char* pout = &px->common.raw[i * 4]; double a = pin[3]; @@ -691,7 +693,12 @@ void MwReloadRaw(MwWidget handle, MwLLPixmap px, unsigned char* rgb, int width, MwLLPixmapUpdate(px); } -void MwGetColor(MwLLColor color, int* red, int* green, int* blue) { +void MwPixmapGetSize(MwLLPixmap pixmap, MwRect* rect) { + rect->width = pixmap->common.width; + rect->height = pixmap->common.height; +} + +void MwColorGet(MwLLColor color, int* red, int* green, int* blue) { *red = color->common.red; *green = color->common.green; *blue = color->common.blue; diff --git a/src/widget/treeview.c b/src/widget/treeview.c index 19e1be1..2379937 100644 --- a/src/widget/treeview.c +++ b/src/widget/treeview.c @@ -114,7 +114,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry** if(tree->selected) { r.x = p->x; r.y = p->y - MwTextHeight(handle, "M") / 2; - r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding) - shift; // MwTextWidth(handle, tree->label); + r.width = MwGetInteger(handle, MwNwidth) - MwGetInteger(handle, MwNleftPadding) - shift; r.height = MwTextHeight(handle, "M"); MwDrawRect(handle, &r, text2); }