diff --git a/Doxyfile b/Doxyfile index 3fad410..d14de6b 100644 --- a/Doxyfile +++ b/Doxyfile @@ -6,8 +6,9 @@ OUTPUT_DIRECTORY = doxygen TAB_SIZE = 8 OPTIMIZE_OUTPUT_FOR_C = YES MARKDOWN_SUPPORT = YES -FILE_PATTERNS = *.h +FILE_PATTERNS = *.h *.md INPUT = include/Mw +INPUT += doc RECURSIVE = YES SOURCE_BROWSER = YES HTML_DYNAMIC_MENUS = YES diff --git a/doc/LOWLEVEL.md b/doc/LOWLEVEL.md new file mode 100644 index 0000000..f372979 --- /dev/null +++ b/doc/LOWLEVEL.md @@ -0,0 +1,11 @@ +# Writing a new widget +@warning This is mainly for developers + +1. Create new file in src/widget with lower case +2. Create new header in include/Mw/Widget with pascal case +3. Add the header include to include/Mw/Milsko.h, if new widget does not require some extension (like OpenGL and Vulkan) +4. See another widget for example + +## LowLevel.h function tips +1. `MwLLSetSizeHints`, `MwLLMakeBorderless`, `MwLLMakeToolWindow`, `MwLLMakePopup` have to be called between `MwLLBeginStateChange` and `MwLLEndStateChange` + diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index fc4f666..cc1d570 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -181,6 +181,9 @@ MWDECL void (*MwLLMakeBorderless)(MwLL handle, int toggle); MWDECL void (*MwLLMakeToolWindow)(MwLL handle); MWDECL void (*MwLLMakePopup)(MwLL handle, MwLL parent); +MWDECL void (*MwLLBeginStateChange)(MwLL handle); +MWDECL void (*MwLLEndStateChange)(MwLL handle); + MWDECL void (*MwLLSetBackground)(MwLL handle, MwLLColor color); MWDECL void (*MwLLFocus)(MwLL handle); diff --git a/src/backend/call.c b/src/backend/call.c index 75475c6..117f5f9 100644 --- a/src/backend/call.c +++ b/src/backend/call.c @@ -41,6 +41,9 @@ MwLLMakeBorderless = MwLLMakeBorderlessImpl; \ MwLLMakeToolWindow = MwLLMakeToolWindowImpl; \ MwLLMakePopup = MwLLMakePopupImpl; \ +\ + MwLLBeginStateChange = MwLLBeginStateChangeImpl; \ + MwLLEndStateChange = MwLLEndStateChangeImpl; \ \ MwLLSetBackground = MwLLSetBackgroundImpl; \ \ diff --git a/src/backend/gdi.c b/src/backend/gdi.c index 94615a6..cd1f2f2 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -706,6 +706,14 @@ static void MwLLMakeToolWindowImpl(MwLL handle) { SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); } +static void MwLLBeginStateChangeImpl(MwLL handle){ + (void)handle; +} + +static void MwLLEndStateChangeImpl(MwLL handle){ + (void)handle; +} + static int MwLLGDICallInitImpl(void) { /* TODO: check properly */ return 0; diff --git a/src/backend/x11.c b/src/backend/x11.c index cf6f13f..afc5e73 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -80,7 +80,6 @@ static void wait_map(MwLL handle) { XGetWindowAttributes(handle->x11.display, handle->x11.window, &xwa); if(xwa.map_state != IsViewable) { - XSync(handle->x11.display, False); XMapWindow(handle->x11.display, handle->x11.window); @@ -972,6 +971,14 @@ static void MwLLMakeToolWindowImpl(MwLL handle) { XChangeProperty(handle->x11.display, handle->x11.window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1); } +static void MwLLBeginStateChangeImpl(MwLL handle){ + MwLLShow(handle, 0); +} + +static void MwLLEndStateChangeImpl(MwLL handle){ + MwLLShow(handle, 1); +} + static int MwLLX11CallInitImpl(void) { /* TODO: check properly */ return 0; diff --git a/src/dialog/colorpicker.c b/src/dialog/colorpicker.c index 8254595..0a7032c 100644 --- a/src/dialog/colorpicker.c +++ b/src/dialog/colorpicker.c @@ -375,10 +375,10 @@ MwWidget MwColorPicker(MwWidget handle, const char* title) { MwAddUserHandler(window, MwNtickHandler, color_picker_tick, wheel); MwAddTickList(window); - MwLLShow(window->lowlevel, 0); + MwLLBeginStateChange(window->lowlevel); MwLLDetach(window->lowlevel, &p); MwLLMakePopup(window->lowlevel, handle->lowlevel); - MwLLShow(window->lowlevel, 1); + MwLLEndStateChange(window->lowlevel); return window; } diff --git a/src/dialog/filechooser.c b/src/dialog/filechooser.c index ee87160..fe73d23 100644 --- a/src/dialog/filechooser.c +++ b/src/dialog/filechooser.c @@ -501,10 +501,10 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) { scan(window, path, 1); free(path); - MwLLShow(handle->lowlevel, 0); + MwLLBeginStateChange(window->lowlevel); MwLLDetach(window->lowlevel, &p); MwLLMakePopup(window->lowlevel, handle->lowlevel); - MwLLShow(handle->lowlevel, 1); + MwLLEndStateChange(window->lowlevel); return window; } diff --git a/src/dialog/messagebox.c b/src/dialog/messagebox.c index a87902b..a4fb0cb 100644 --- a/src/dialog/messagebox.c +++ b/src/dialog/messagebox.c @@ -99,11 +99,11 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi MwNalignment, MwALIGNMENT_BEGINNING, NULL); - MwLLShow(window->lowlevel, 0); + MwLLBeginStateChange(window->lowlevel); MwLLDetach(window->lowlevel, &p); MwLLSetSizeHints(window->lowlevel, w, h, w, h); MwLLMakePopup(window->lowlevel, handle->lowlevel); - MwLLShow(window->lowlevel, 1); + MwLLEndStateChange(window->lowlevel); MwAddUserHandler(window, MwNcloseHandler, messagebox_close, NULL); diff --git a/src/lowlevel.c b/src/lowlevel.c index 41736d3..6a06e29 100644 --- a/src/lowlevel.c +++ b/src/lowlevel.c @@ -37,6 +37,9 @@ void (*MwLLMakeBorderless)(MwLL handle, int toggle); void (*MwLLMakeToolWindow)(MwLL handle); void (*MwLLMakePopup)(MwLL handle, MwLL parent); +void (*MwLLBeginStateChange)(MwLL handle); +void (*MwLLEndStateChange)(MwLL handle); + void (*MwLLSetBackground)(MwLL handle, MwLLColor color); void (*MwLLFocus)(MwLL handle); diff --git a/src/widget/submenu.c b/src/widget/submenu.c index 56bbf34..0dd0ad5 100644 --- a/src/widget/submenu.c +++ b/src/widget/submenu.c @@ -4,7 +4,7 @@ #include "../../external/stb_ds.h" static int create(MwWidget handle) { - MwLLShow(handle->lowlevel, 0); + MwLLBeginStateChange(handle->lowlevel); MwSetDefault(handle); @@ -167,7 +167,7 @@ static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point) { MwLLMakeToolWindow(handle->lowlevel); MwLLDetach(handle->lowlevel, point); - MwLLShow(handle->lowlevel, 1); + MwLLEndStateChange(handle->lowlevel); for(i = 0; i < arrlen(menu->sub); i++) { if(strcmp(menu->sub[i]->name, "----") == 0) { diff --git a/src/widget/window.c b/src/widget/window.c index fff2ce9..b5b594a 100644 --- a/src/widget/window.c +++ b/src/widget/window.c @@ -21,9 +21,9 @@ static void draw(MwWidget handle) { MwLLFreeColor(c); } static void mwWindowMakeBorderlessImpl(MwWidget handle, int toggle) { - MwLLShow(handle->lowlevel, 0); + MwLLBeginStateChange(handle->lowlevel); MwLLMakeBorderless(handle->lowlevel, toggle); - MwLLShow(handle->lowlevel, 1); + MwLLEndStateChange(handle->lowlevel); } static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {