git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@706 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-11-14 12:13:31 +00:00
parent 51df555b5a
commit b7fee743dc
12 changed files with 48 additions and 12 deletions

View File

@@ -6,8 +6,9 @@ OUTPUT_DIRECTORY = doxygen
TAB_SIZE = 8 TAB_SIZE = 8
OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_FOR_C = YES
MARKDOWN_SUPPORT = YES MARKDOWN_SUPPORT = YES
FILE_PATTERNS = *.h FILE_PATTERNS = *.h *.md
INPUT = include/Mw INPUT = include/Mw
INPUT += doc
RECURSIVE = YES RECURSIVE = YES
SOURCE_BROWSER = YES SOURCE_BROWSER = YES
HTML_DYNAMIC_MENUS = YES HTML_DYNAMIC_MENUS = YES

11
doc/LOWLEVEL.md Normal file
View File

@@ -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`

View File

@@ -181,6 +181,9 @@ MWDECL void (*MwLLMakeBorderless)(MwLL handle, int toggle);
MWDECL void (*MwLLMakeToolWindow)(MwLL handle); MWDECL void (*MwLLMakeToolWindow)(MwLL handle);
MWDECL void (*MwLLMakePopup)(MwLL handle, MwLL parent); 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 (*MwLLSetBackground)(MwLL handle, MwLLColor color);
MWDECL void (*MwLLFocus)(MwLL handle); MWDECL void (*MwLLFocus)(MwLL handle);

View File

@@ -41,6 +41,9 @@
MwLLMakeBorderless = MwLLMakeBorderlessImpl; \ MwLLMakeBorderless = MwLLMakeBorderlessImpl; \
MwLLMakeToolWindow = MwLLMakeToolWindowImpl; \ MwLLMakeToolWindow = MwLLMakeToolWindowImpl; \
MwLLMakePopup = MwLLMakePopupImpl; \ MwLLMakePopup = MwLLMakePopupImpl; \
\
MwLLBeginStateChange = MwLLBeginStateChangeImpl; \
MwLLEndStateChange = MwLLEndStateChangeImpl; \
\ \
MwLLSetBackground = MwLLSetBackgroundImpl; \ MwLLSetBackground = MwLLSetBackgroundImpl; \
\ \

View File

@@ -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); 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) { static int MwLLGDICallInitImpl(void) {
/* TODO: check properly */ /* TODO: check properly */
return 0; return 0;

View File

@@ -80,7 +80,6 @@ static void wait_map(MwLL handle) {
XGetWindowAttributes(handle->x11.display, handle->x11.window, &xwa); XGetWindowAttributes(handle->x11.display, handle->x11.window, &xwa);
if(xwa.map_state != IsViewable) { if(xwa.map_state != IsViewable) {
XSync(handle->x11.display, False); XSync(handle->x11.display, False);
XMapWindow(handle->x11.display, handle->x11.window); 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); 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) { static int MwLLX11CallInitImpl(void) {
/* TODO: check properly */ /* TODO: check properly */
return 0; return 0;

View File

@@ -375,10 +375,10 @@ MwWidget MwColorPicker(MwWidget handle, const char* title) {
MwAddUserHandler(window, MwNtickHandler, color_picker_tick, wheel); MwAddUserHandler(window, MwNtickHandler, color_picker_tick, wheel);
MwAddTickList(window); MwAddTickList(window);
MwLLShow(window->lowlevel, 0); MwLLBeginStateChange(window->lowlevel);
MwLLDetach(window->lowlevel, &p); MwLLDetach(window->lowlevel, &p);
MwLLMakePopup(window->lowlevel, handle->lowlevel); MwLLMakePopup(window->lowlevel, handle->lowlevel);
MwLLShow(window->lowlevel, 1); MwLLEndStateChange(window->lowlevel);
return window; return window;
} }

View File

@@ -501,10 +501,10 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
scan(window, path, 1); scan(window, path, 1);
free(path); free(path);
MwLLShow(handle->lowlevel, 0); MwLLBeginStateChange(window->lowlevel);
MwLLDetach(window->lowlevel, &p); MwLLDetach(window->lowlevel, &p);
MwLLMakePopup(window->lowlevel, handle->lowlevel); MwLLMakePopup(window->lowlevel, handle->lowlevel);
MwLLShow(handle->lowlevel, 1); MwLLEndStateChange(window->lowlevel);
return window; return window;
} }

View File

@@ -99,11 +99,11 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
MwNalignment, MwALIGNMENT_BEGINNING, MwNalignment, MwALIGNMENT_BEGINNING,
NULL); NULL);
MwLLShow(window->lowlevel, 0); MwLLBeginStateChange(window->lowlevel);
MwLLDetach(window->lowlevel, &p); MwLLDetach(window->lowlevel, &p);
MwLLSetSizeHints(window->lowlevel, w, h, w, h); MwLLSetSizeHints(window->lowlevel, w, h, w, h);
MwLLMakePopup(window->lowlevel, handle->lowlevel); MwLLMakePopup(window->lowlevel, handle->lowlevel);
MwLLShow(window->lowlevel, 1); MwLLEndStateChange(window->lowlevel);
MwAddUserHandler(window, MwNcloseHandler, messagebox_close, NULL); MwAddUserHandler(window, MwNcloseHandler, messagebox_close, NULL);

View File

@@ -37,6 +37,9 @@ void (*MwLLMakeBorderless)(MwLL handle, int toggle);
void (*MwLLMakeToolWindow)(MwLL handle); void (*MwLLMakeToolWindow)(MwLL handle);
void (*MwLLMakePopup)(MwLL handle, MwLL parent); void (*MwLLMakePopup)(MwLL handle, MwLL parent);
void (*MwLLBeginStateChange)(MwLL handle);
void (*MwLLEndStateChange)(MwLL handle);
void (*MwLLSetBackground)(MwLL handle, MwLLColor color); void (*MwLLSetBackground)(MwLL handle, MwLLColor color);
void (*MwLLFocus)(MwLL handle); void (*MwLLFocus)(MwLL handle);

View File

@@ -4,7 +4,7 @@
#include "../../external/stb_ds.h" #include "../../external/stb_ds.h"
static int create(MwWidget handle) { static int create(MwWidget handle) {
MwLLShow(handle->lowlevel, 0); MwLLBeginStateChange(handle->lowlevel);
MwSetDefault(handle); MwSetDefault(handle);
@@ -167,7 +167,7 @@ static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point) {
MwLLMakeToolWindow(handle->lowlevel); MwLLMakeToolWindow(handle->lowlevel);
MwLLDetach(handle->lowlevel, point); MwLLDetach(handle->lowlevel, point);
MwLLShow(handle->lowlevel, 1); MwLLEndStateChange(handle->lowlevel);
for(i = 0; i < arrlen(menu->sub); i++) { for(i = 0; i < arrlen(menu->sub); i++) {
if(strcmp(menu->sub[i]->name, "----") == 0) { if(strcmp(menu->sub[i]->name, "----") == 0) {

View File

@@ -21,9 +21,9 @@ static void draw(MwWidget handle) {
MwLLFreeColor(c); MwLLFreeColor(c);
} }
static void mwWindowMakeBorderlessImpl(MwWidget handle, int toggle) { static void mwWindowMakeBorderlessImpl(MwWidget handle, int toggle) {
MwLLShow(handle->lowlevel, 0); MwLLBeginStateChange(handle->lowlevel);
MwLLMakeBorderless(handle->lowlevel, toggle); 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) { static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {