Browse Source

Add Numpad Enter support for windows backends...

Robert Winkler 7 months ago
parent
commit
f3d9f45b8d

+ 1 - 0
demo/d3d11/nuklear_d3d11.h

@@ -232,6 +232,7 @@ nk_d3d11_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
             return 1;
             return 1;
 
 
         case VK_RETURN:
         case VK_RETURN:
+        case VK_SEPARATOR:
             nk_input_key(&d3d11.ctx, NK_KEY_ENTER, down);
             nk_input_key(&d3d11.ctx, NK_KEY_ENTER, down);
             return 1;
             return 1;
 
 

+ 1 - 0
demo/d3d12/nuklear_d3d12.h

@@ -364,6 +364,7 @@ nk_d3d12_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
             return 1;
             return 1;
 
 
         case VK_RETURN:
         case VK_RETURN:
+        case VK_SEPARATOR:
             nk_input_key(&d3d12.ctx, NK_KEY_ENTER, down);
             nk_input_key(&d3d12.ctx, NK_KEY_ENTER, down);
             return 1;
             return 1;
 
 

+ 1 - 0
demo/d3d9/nuklear_d3d9.h

@@ -292,6 +292,7 @@ nk_d3d9_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
             return 1;
             return 1;
 
 
         case VK_RETURN:
         case VK_RETURN:
+        case VK_SEPARATOR:
             nk_input_key(&d3d9.ctx, NK_KEY_ENTER, down);
             nk_input_key(&d3d9.ctx, NK_KEY_ENTER, down);
             return 1;
             return 1;
 
 

+ 16 - 15
demo/gdi/nuklear_gdi.h

@@ -76,7 +76,7 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
         image->region[1] = 0;
         image->region[1] = 0;
         image->region[2] = width;
         image->region[2] = width;
         image->region[3] = height;
         image->region[3] = height;
-        
+
         bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
         bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
         bi.bmiHeader.biWidth = width;
         bi.bmiHeader.biWidth = width;
         bi.bmiHeader.biHeight = height;
         bi.bmiHeader.biHeight = height;
@@ -84,9 +84,9 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
         bi.bmiHeader.biBitCount = 24;
         bi.bmiHeader.biBitCount = 24;
         bi.bmiHeader.biCompression = BI_RGB;
         bi.bmiHeader.biCompression = BI_RGB;
         bi.bmiHeader.biSizeImage = row * height;
         bi.bmiHeader.biSizeImage = row * height;
-        
+
         hbm = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**)&lpBuf, NULL, 0);
         hbm = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**)&lpBuf, NULL, 0);
-        
+
         pb = lpBuf + row * height;
         pb = lpBuf + row * height;
         for (v = 0; v < height; v++)
         for (v = 0; v < height; v++)
         {
         {
@@ -98,7 +98,7 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
                 pb[i + 2] = src[2];
                 pb[i + 2] = src[2];
                 src += 3;
                 src += 3;
             }
             }
-        }        
+        }
         SetDIBits(NULL, hbm, 0, height, lpBuf, &bi, DIB_RGB_COLORS);
         SetDIBits(NULL, hbm, 0, height, lpBuf, &bi, DIB_RGB_COLORS);
         image->handle.ptr = hbm;
         image->handle.ptr = hbm;
     }
     }
@@ -122,10 +122,10 @@ nk_gdi_draw_image(short x, short y, unsigned short w, unsigned short h,
     HBITMAP hbm = (HBITMAP)img.handle.ptr;
     HBITMAP hbm = (HBITMAP)img.handle.ptr;
     HDC     hDCBits;
     HDC     hDCBits;
     BITMAP  bitmap;
     BITMAP  bitmap;
-    
+
     if (!gdi.memory_dc || !hbm)
     if (!gdi.memory_dc || !hbm)
         return;
         return;
-    
+
     hDCBits = CreateCompatibleDC(gdi.memory_dc);
     hDCBits = CreateCompatibleDC(gdi.memory_dc);
     GetObject(hbm, sizeof(BITMAP), (LPSTR)&bitmap);
     GetObject(hbm, sizeof(BITMAP), (LPSTR)&bitmap);
     SelectObject(hDCBits, hbm);
     SelectObject(hDCBits, hbm);
@@ -192,7 +192,7 @@ nk_gdi_stroke_rect(HDC dc, short x, short y, unsigned short w,
     }
     }
     SelectObject(dc, br);
     SelectObject(dc, br);
 
 
-    if (pen) { 
+    if (pen) {
         SelectObject(dc, GetStockObject(DC_PEN));
         SelectObject(dc, GetStockObject(DC_PEN));
         DeleteObject(pen);
         DeleteObject(pen);
     }
     }
@@ -470,7 +470,7 @@ nk_gdi_stroke_circle(HDC dc, short x, short y, unsigned short w,
         pen = CreatePen(PS_SOLID, line_thickness, color);
         pen = CreatePen(PS_SOLID, line_thickness, color);
         SelectObject(dc, pen);
         SelectObject(dc, pen);
     }
     }
-    
+
     HGDIOBJ br = SelectObject(dc, GetStockObject(NULL_BRUSH));
     HGDIOBJ br = SelectObject(dc, GetStockObject(NULL_BRUSH));
     SetDCBrushColor(dc, OPAQUE);
     SetDCBrushColor(dc, OPAQUE);
     Ellipse(dc, x, y, x + w, y + h);
     Ellipse(dc, x, y, x + w, y + h);
@@ -524,7 +524,7 @@ nk_gdi_draw_text(HDC dc, short x, short y, unsigned short w, unsigned short h,
     wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
     wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
     wstr = (WCHAR*)_alloca(wsize * sizeof(wchar_t));
     wstr = (WCHAR*)_alloca(wsize * sizeof(wchar_t));
     MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
     MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
-    
+
     SetBkMode(dc, TRANSPARENT); /* Transparent Text Background */
     SetBkMode(dc, TRANSPARENT); /* Transparent Text Background */
     SetBkColor(dc, convert_color(cbg));
     SetBkColor(dc, convert_color(cbg));
     SetTextColor(dc, convert_color(cfg));
     SetTextColor(dc, convert_color(cfg));
@@ -599,14 +599,14 @@ nk_gdi_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
     (void)usr;
     (void)usr;
     if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
     if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
     {
     {
-        HGLOBAL mem = GetClipboardData(CF_UNICODETEXT); 
+        HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
         if (mem)
         if (mem)
         {
         {
             SIZE_T size = GlobalSize(mem) - 1;
             SIZE_T size = GlobalSize(mem) - 1;
             if (size)
             if (size)
             {
             {
                 LPCWSTR wstr = (LPCWSTR)GlobalLock(mem);
                 LPCWSTR wstr = (LPCWSTR)GlobalLock(mem);
-                if (wstr) 
+                if (wstr)
                 {
                 {
                     int utf8size = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)(size / sizeof(wchar_t)), NULL, 0, NULL, NULL);
                     int utf8size = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)(size / sizeof(wchar_t)), NULL, 0, NULL, NULL);
                     if (utf8size)
                     if (utf8size)
@@ -619,7 +619,7 @@ nk_gdi_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
                             free(utf8);
                             free(utf8);
                         }
                         }
                     }
                     }
-                    GlobalUnlock(mem); 
+                    GlobalUnlock(mem);
                 }
                 }
             }
             }
         }
         }
@@ -643,9 +643,9 @@ nk_gdi_clipboard_copy(nk_handle usr, const char *text, int len)
                 {
                 {
                     MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
                     MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
                     wstr[wsize] = 0;
                     wstr[wsize] = 0;
-                    GlobalUnlock(mem); 
+                    GlobalUnlock(mem);
 
 
-                    SetClipboardData(CF_UNICODETEXT, mem); 
+                    SetClipboardData(CF_UNICODETEXT, mem);
                 }
                 }
             }
             }
         }
         }
@@ -734,6 +734,7 @@ nk_gdi_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
             return 1;
             return 1;
 
 
         case VK_RETURN:
         case VK_RETURN:
+        case VK_SEPARATOR:
             nk_input_key(&gdi.ctx, NK_KEY_ENTER, down);
             nk_input_key(&gdi.ctx, NK_KEY_ENTER, down);
             return 1;
             return 1;
 
 
@@ -776,7 +777,7 @@ nk_gdi_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
         case VK_PRIOR:
         case VK_PRIOR:
             nk_input_key(&gdi.ctx, NK_KEY_SCROLL_UP, down);
             nk_input_key(&gdi.ctx, NK_KEY_SCROLL_UP, down);
             return 1;
             return 1;
-                
+
         case 'A':
         case 'A':
             if (ctrl) {
             if (ctrl) {
                 nk_input_key(&gdi.ctx, NK_KEY_TEXT_SELECT_ALL, down);
                 nk_input_key(&gdi.ctx, NK_KEY_TEXT_SELECT_ALL, down);

+ 3 - 2
demo/gdi_native_nuklear/nuklear_gdi.h

@@ -2,11 +2,11 @@
  * Nuklear - 1.32.0 - public domain
  * Nuklear - 1.32.0 - public domain
  * no warrenty implied; use at your own risk.
  * no warrenty implied; use at your own risk.
  * authored from 2015-2016 by Micha Mettke
  * authored from 2015-2016 by Micha Mettke
- * 
+ *
  * Modified GDI backend 2022
  * Modified GDI backend 2022
  * Now based on a context that is required for each API function call.
  * Now based on a context that is required for each API function call.
  * Removes the global state --> you can have multiple windows :-)
  * Removes the global state --> you can have multiple windows :-)
- * 
+ *
  */
  */
  /*
  /*
   * ==============================================================
   * ==============================================================
@@ -698,6 +698,7 @@ nk_gdi_handle_event(nk_gdi_ctx gdi, HWND wnd, UINT msg, WPARAM wparam, LPARAM lp
             return 1;
             return 1;
 
 
         case VK_RETURN:
         case VK_RETURN:
+        case VK_SEPARATOR:
             nk_input_key(&gdi->ctx, NK_KEY_ENTER, down);
             nk_input_key(&gdi->ctx, NK_KEY_ENTER, down);
             return 1;
             return 1;
 
 

+ 17 - 16
demo/gdip/nuklear_gdip.h

@@ -92,7 +92,7 @@ typedef enum {
     StringFormatFlagsMeasureTrailingSpaces   = 0x00000800,
     StringFormatFlagsMeasureTrailingSpaces   = 0x00000800,
     StringFormatFlagsNoWrap                  = 0x00001000,
     StringFormatFlagsNoWrap                  = 0x00001000,
     StringFormatFlagsLineLimit               = 0x00002000,
     StringFormatFlagsLineLimit               = 0x00002000,
-    StringFormatFlagsNoClip                  = 0x00004000 
+    StringFormatFlagsNoClip                  = 0x00004000
 } StringFormatFlags;
 } StringFormatFlags;
 
 
 typedef enum
 typedef enum
@@ -272,25 +272,25 @@ GdipSetStringFormatFlags(GpStringFormat *format, INT flags);
 GpStatus WINGDIPAPI
 GpStatus WINGDIPAPI
 GdipDeleteStringFormat(GpStringFormat *format);
 GdipDeleteStringFormat(GpStringFormat *format);
 
 
-GpStatus WINGDIPAPI 
-GdipPrivateAddMemoryFont(GpFontCollection* fontCollection, 
+GpStatus WINGDIPAPI
+GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
                          GDIPCONST void* memory, INT length);
                          GDIPCONST void* memory, INT length);
 
 
-GpStatus WINGDIPAPI 
-GdipPrivateAddFontFile(GpFontCollection* fontCollection, 
+GpStatus WINGDIPAPI
+GdipPrivateAddFontFile(GpFontCollection* fontCollection,
                        GDIPCONST WCHAR* filename);
                        GDIPCONST WCHAR* filename);
 
 
-GpStatus WINGDIPAPI 
+GpStatus WINGDIPAPI
 GdipNewPrivateFontCollection(GpFontCollection** fontCollection);
 GdipNewPrivateFontCollection(GpFontCollection** fontCollection);
 
 
-GpStatus WINGDIPAPI 
+GpStatus WINGDIPAPI
 GdipDeletePrivateFontCollection(GpFontCollection** fontCollection);
 GdipDeletePrivateFontCollection(GpFontCollection** fontCollection);
 
 
-GpStatus WINGDIPAPI 
-GdipGetFontCollectionFamilyList(GpFontCollection* fontCollection, 
+GpStatus WINGDIPAPI
+GdipGetFontCollectionFamilyList(GpFontCollection* fontCollection,
                         INT numSought, GpFontFamily* gpfamilies[], INT* numFound);
                         INT numSought, GpFontFamily* gpfamilies[], INT* numFound);
 
 
-GpStatus WINGDIPAPI 
+GpStatus WINGDIPAPI
 GdipGetFontCollectionFamilyCount(GpFontCollection* fontCollection, INT* numFound);
 GdipGetFontCollectionFamilyCount(GpFontCollection* fontCollection, INT* numFound);
 
 
 
 
@@ -374,8 +374,8 @@ GdipGraphicsClear(GpGraphics *graphics, ARGB color);
 GpStatus WINGDIPAPI
 GpStatus WINGDIPAPI
 GdipDrawImageI(GpGraphics *graphics, GpImage *image, INT x, INT y);
 GdipDrawImageI(GpGraphics *graphics, GpImage *image, INT x, INT y);
 
 
-GpStatus WINGDIPAPI 
-GdipDrawImageRectI(GpGraphics *graphics, GpImage *image, INT x, INT y, 
+GpStatus WINGDIPAPI
+GdipDrawImageRectI(GpGraphics *graphics, GpImage *image, INT x, INT y,
                    INT width, INT height);
                    INT width, INT height);
 
 
 GpStatus WINGDIPAPI
 GpStatus WINGDIPAPI
@@ -673,7 +673,7 @@ nk_gdip_load_image_from_memory(const void *membuf, nk_uint membufSize)
     IStream *stream = SHCreateMemStream((const BYTE*)membuf, membufSize);
     IStream *stream = SHCreateMemStream((const BYTE*)membuf, membufSize);
     if (!stream)
     if (!stream)
         return nk_image_id(0);
         return nk_image_id(0);
-    
+
     status = GdipLoadImageFromStream(stream, &image);
     status = GdipLoadImageFromStream(stream, &image);
     stream->lpVtbl->Release(stream);
     stream->lpVtbl->Release(stream);
 
 
@@ -709,7 +709,7 @@ nk_gdipfont_create(const char *name, int size)
     return font;
     return font;
 }
 }
 
 
-GpFontCollection* 
+GpFontCollection*
 nk_gdip_getCurFontCollection(){
 nk_gdip_getCurFontCollection(){
     return gdip.fontCollection[gdip.curFontCollection];
     return gdip.fontCollection[gdip.curFontCollection];
 }
 }
@@ -744,7 +744,7 @@ nk_gdipfont_create_from_file(const WCHAR* filename, int size)
 {
 {
     if( !nk_gdip_getCurFontCollection() )
     if( !nk_gdip_getCurFontCollection() )
         if( GdipNewPrivateFontCollection(&gdip.fontCollection[gdip.curFontCollection]) ) return NULL;
         if( GdipNewPrivateFontCollection(&gdip.fontCollection[gdip.curFontCollection]) ) return NULL;
-    if( GdipPrivateAddFontFile(nk_gdip_getCurFontCollection(), filename) ) return NULL;    
+    if( GdipPrivateAddFontFile(nk_gdip_getCurFontCollection(), filename) ) return NULL;
     return nk_gdipfont_create_from_collection(size);
     return nk_gdipfont_create_from_collection(size);
 }
 }
 
 
@@ -849,7 +849,7 @@ nk_gdip_init(HWND hwnd, unsigned int width, unsigned int height)
     GdipCreatePen1(0, 1.0f, UnitPixel, &gdip.pen);
     GdipCreatePen1(0, 1.0f, UnitPixel, &gdip.pen);
     GdipCreateSolidFill(0, &gdip.brush);
     GdipCreateSolidFill(0, &gdip.brush);
     GdipStringFormatGetGenericTypographic(&gdip.format);
     GdipStringFormatGetGenericTypographic(&gdip.format);
-    GdipSetStringFormatFlags(gdip.format, StringFormatFlagsNoFitBlackBox | 
+    GdipSetStringFormatFlags(gdip.format, StringFormatFlagsNoFitBlackBox |
         StringFormatFlagsMeasureTrailingSpaces | StringFormatFlagsNoWrap |
         StringFormatFlagsMeasureTrailingSpaces | StringFormatFlagsNoWrap |
         StringFormatFlagsNoClip);
         StringFormatFlagsNoClip);
 
 
@@ -924,6 +924,7 @@ nk_gdip_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
             return 1;
             return 1;
 
 
         case VK_RETURN:
         case VK_RETURN:
+        case VK_SEPARATOR:
             nk_input_key(&gdip.ctx, NK_KEY_ENTER, down);
             nk_input_key(&gdip.ctx, NK_KEY_ENTER, down);
             return 1;
             return 1;