Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColorPicker in GDI Rendring #620

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions demo/gdi/nuklear_gdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ nk_gdi_set_vertexColor(PTRIVERTEX tri, struct nk_color col)
tri->Red = col.r << 8;
tri->Green = col.g << 8;
tri->Blue = col.b << 8;
tri->Alpha = 0xff << 8;
tri->Alpha = col.a << 8;
}

static void
Expand All @@ -235,26 +235,26 @@ nk_gdi_rect_multi_color(HDC dc, short x, short y, unsigned short w,
TRIVERTEX vt[4];
alphaFunction.BlendOp = AC_SRC_OVER;
alphaFunction.BlendFlags = 0;
alphaFunction.SourceConstantAlpha = 0;
alphaFunction.SourceConstantAlpha = 255;
alphaFunction.AlphaFormat = AC_SRC_ALPHA;

/* TODO: This Case Needs Repair.*/
/* Top Left Corner */
vt[0].x = x;
vt[0].y = y;
vt[0].x = 0;
vt[0].y = 0;
nk_gdi_set_vertexColor(&vt[0], left);
/* Top Right Corner */
vt[1].x = x+w;
vt[1].y = y;
vt[1].x = 0+w;
vt[1].y = 0;
nk_gdi_set_vertexColor(&vt[1], top);
/* Bottom Left Corner */
vt[2].x = x;
vt[2].y = y+h;
vt[2].x = 0;
vt[2].y = 0+h;
nk_gdi_set_vertexColor(&vt[2], right);

/* Bottom Right Corner */
vt[3].x = x+w;
vt[3].y = y+h;
vt[3].x = 0+w;
vt[3].y = 0+h;
nk_gdi_set_vertexColor(&vt[3], bottom);

gTri[0].Vertex1 = 0;
Expand All @@ -263,9 +263,17 @@ nk_gdi_rect_multi_color(HDC dc, short x, short y, unsigned short w,
gTri[1].Vertex1 = 2;
gTri[1].Vertex2 = 1;
gTri[1].Vertex3 = 3;
GdiGradientFill(dc, vt, 4, gTri, 2 , GRADIENT_FILL_TRIANGLE);
AlphaBlend(gdi.window_dc, x, y, x+w, y+h,gdi.memory_dc, x, y, x+w, y+h,alphaFunction);

HDC memdc = CreateCompatibleDC(dc);
HBITMAP bitmap = CreateCompatibleBitmap(dc, w, h);
HGDIOBJ old = SelectObject(memdc, bitmap);

GdiGradientFill(memdc, vt, 4, gTri, 2 , GRADIENT_FILL_TRIANGLE);

GdiAlphaBlend(dc, x, y, w, h, memdc, 0, 0, w, h, alphaFunction);

DeleteDC(memdc);
DeleteObject(bitmap);
}

static BOOL
Expand Down
9 changes: 6 additions & 3 deletions demo/gdip/nuklear_gdip.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ static void
nk_gdip_draw_image(short x, short y, unsigned short w, unsigned short h,
struct nk_image img, struct nk_color col)
{
GpImage *image = img.handle.ptr;
GpImage *image = (GpImage *)img.handle.ptr;
GdipDrawImageRectI(gdip.memory, image, x, y, w, h);
}

Expand Down Expand Up @@ -675,7 +675,10 @@ nk_gdip_load_image_from_memory(const void *membuf, nk_uint membufSize)
return nk_image_id(0);

status = GdipLoadImageFromStream(stream, &image);
stream->lpVtbl->Release(stream);

/// TODO: 'IStream' {aka 'struct IStream'} has no member named 'lpVtbl'GCC
stream->Release();
//stream->lpVtbl->Release(stream);
Comment on lines +679 to +681
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a remaining TODO?


if (status)
return nk_image_id(0);
Expand All @@ -688,7 +691,7 @@ nk_gdip_image_free(struct nk_image image)
{
if (!image.handle.ptr)
return;
GdipDisposeImage(image.handle.ptr);
GdipDisposeImage((GpImage*)image.handle.ptr);
}

GdipFont*
Expand Down
6 changes: 3 additions & 3 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ extern "C" {
#define NK_SIZE_TYPE unsigned __int32
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
#define NK_SIZE_TYPE unsigned long
#define NK_SIZE_TYPE unsigned long long
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define NK_SIZE_TYPE unsigned long long
#define NK_SIZE_TYPE unsigned long

#else
#define NK_SIZE_TYPE unsigned int
#endif
Expand All @@ -389,7 +389,7 @@ extern "C" {
#define NK_POINTER_TYPE unsigned __int32
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
#define NK_POINTER_TYPE unsigned long
#define NK_POINTER_TYPE unsigned long long
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in nuklear.h will have to be replicated in the src directory too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about changing this as part of the GDI demo updates. Going to recommend pushing that to a different change request.

Suggested change
#define NK_POINTER_TYPE unsigned long long
#define NK_POINTER_TYPE unsigned long

#else
#define NK_POINTER_TYPE unsigned int
#endif
Expand Down Expand Up @@ -29012,7 +29012,7 @@ nk_draw_color_picker(struct nk_command_buffer *o, const struct nk_rect *matrix,

/* draw color matrix */
temp = nk_hsv_f(hsva[0], 1.0f, 1.0f);
nk_fill_rect_multi_color(o, *matrix, white, temp, temp, white);
nk_fill_rect_multi_color(o, *matrix, white, temp, white, temp);
nk_fill_rect_multi_color(o, *matrix, black_trans, black_trans, black, black);

/* draw cross-hair */
Expand Down