forked from pyrite-dev/milsko
Compare commits
8 commits
master
...
wayland-p2
| Author | SHA1 | Date | |
|---|---|---|---|
| bd47bdab41 | |||
| c6c2028646 | |||
|
7f823e2d34 |
|||
| 7f43a974cd | |||
|
bee6cb81ca |
|||
| 7a81af9922 | |||
| 4951e8995e | |||
| f68b9a9aae |
120 changed files with 1993 additions and 16230 deletions
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
Language: Cpp
|
||||
UseTab: Always
|
||||
TabWidth: 8
|
||||
AlignConsecutiveAssignments:
|
||||
|
|
|
|||
3
.clangd
3
.clangd
|
|
@ -1,3 +0,0 @@
|
|||
Completion:
|
||||
HeaderInsertion: Never
|
||||
ClangFormat: Tab
|
||||
14
.gitignore
vendored
14
.gitignore
vendored
|
|
@ -5,24 +5,10 @@ examples/*/*.exe
|
|||
!examples/*/
|
||||
!examples/*.*
|
||||
!examples/*/*.*
|
||||
*.exe
|
||||
*.o
|
||||
*.obj
|
||||
*.core
|
||||
*.so
|
||||
*.dll
|
||||
*.lib
|
||||
*.dylib
|
||||
*.a
|
||||
/Makefile
|
||||
/build
|
||||
compile_flags.txt
|
||||
.cache
|
||||
.DS_Store
|
||||
|
||||
*.pef
|
||||
*.dsk
|
||||
*.bin
|
||||
*.rsrc
|
||||
*.finf
|
||||
*.gdb
|
||||
|
|
|
|||
36
BorMakefile
generated
36
BorMakefile
generated
|
|
@ -1,26 +1,11 @@
|
|||
CC = bcc32 -c
|
||||
LD = bcc32
|
||||
|
||||
CFLAGS = -Iinclude -Iexternal\libz\include -D_MILSKO -DUSE_GDI -DUSE_STB_TRUETYPE -DUSE_STB_IMAGE -DSTBI_NO_SIMD
|
||||
CFLAGS = -Iinclude -D_MILSKO -DUSE_GDI -DUSE_STB_TRUETYPE -DUSE_STB_IMAGE -DSTBI_NO_SIMD
|
||||
LDFLAGS = -tWD
|
||||
.SUFFIXES: .obj .c
|
||||
all: src\Mw.dll
|
||||
clean:
|
||||
del /f /q external\libz\src\adler32.obj
|
||||
del /f /q external\libz\src\compress.obj
|
||||
del /f /q external\libz\src\crc32.obj
|
||||
del /f /q external\libz\src\deflate.obj
|
||||
del /f /q external\libz\src\gzclose.obj
|
||||
del /f /q external\libz\src\gzlib.obj
|
||||
del /f /q external\libz\src\gzread.obj
|
||||
del /f /q external\libz\src\gzwrite.obj
|
||||
del /f /q external\libz\src\infback.obj
|
||||
del /f /q external\libz\src\inffast.obj
|
||||
del /f /q external\libz\src\inflate.obj
|
||||
del /f /q external\libz\src\inftrees.obj
|
||||
del /f /q external\libz\src\trees.obj
|
||||
del /f /q external\libz\src\uncompr.obj
|
||||
del /f /q external\libz\src\zutil.obj
|
||||
del /f /q external\stb_ds.obj
|
||||
del /f /q external\stb_image.obj
|
||||
del /f /q external\stb_truetype.obj
|
||||
|
|
@ -41,6 +26,11 @@ clean:
|
|||
del /f /q src\dialog\filechooser.obj
|
||||
del /f /q src\dialog\messagebox.obj
|
||||
del /f /q src\draw.obj
|
||||
del /f /q src\error.obj
|
||||
del /f /q src\font\boldfont.obj
|
||||
del /f /q src\font\boldttf.obj
|
||||
del /f /q src\font\font.obj
|
||||
del /f /q src\font\ttf.obj
|
||||
del /f /q src\icon\back.obj
|
||||
del /f /q src\icon\clock.obj
|
||||
del /f /q src\icon\computer.obj
|
||||
|
|
@ -59,15 +49,7 @@ clean:
|
|||
del /f /q src\icon\warning.obj
|
||||
del /f /q src\lowlevel.obj
|
||||
del /f /q src\string.obj
|
||||
del /f /q src\text\font\boldfont.obj
|
||||
del /f /q src\text\font\boldmonottf.obj
|
||||
del /f /q src\text\font\boldttf.obj
|
||||
del /f /q src\text\font\font.obj
|
||||
del /f /q src\text\font\monottf.obj
|
||||
del /f /q src\text\font\ttf.obj
|
||||
del /f /q src\text\ft2.obj
|
||||
del /f /q src\text\stbtt.obj
|
||||
del /f /q src\text\text.obj
|
||||
del /f /q src\text.obj
|
||||
del /f /q src\unicode.obj
|
||||
del /f /q src\widget\box.obj
|
||||
del /f /q src\widget\button.obj
|
||||
|
|
@ -92,8 +74,8 @@ clean:
|
|||
del /f /q src\Mw.dll
|
||||
del /f /q src\Mw.lib
|
||||
|
||||
src\Mw.dll: external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\stbtt.obj src\text\text.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj
|
||||
$(LD) $(LDFLAGS) -e$@ external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\stbtt.obj src\text\text.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj -lopengl32.lib -lgdi32.lib -luser32.lib -ladvapi32.lib
|
||||
src\Mw.dll: external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\error.obj src\font\boldfont.obj src\font\boldttf.obj src\font\font.obj src\font\ttf.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj
|
||||
$(LD) $(LDFLAGS) -e$@ external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\error.obj src\font\boldfont.obj src\font\boldttf.obj src\font\font.obj src\font\ttf.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj -lopengl32.lib -lgdi32.lib -luser32.lib
|
||||
implib src\Mw.lib src\Mw.dll
|
||||
|
||||
.c.obj:
|
||||
|
|
|
|||
255
CMakeLists.txt
255
CMakeLists.txt
|
|
@ -9,47 +9,28 @@ include(GNUInstallDirs)
|
|||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
|
||||
option(MW_CLASSIC_THEME "Use classic theme" OFF)
|
||||
option(MW_BUILD_EXAMPLES "Build examples" OFF)
|
||||
option(MW_USE_STB_IMAGE "Use stb_image" ON)
|
||||
option(MW_USE_STB_TRUETYPE "Use stb_truetype" OFF)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES Retro)
|
||||
option(MW_BUILD_SHARED "Build a shared library" OFF)
|
||||
option(MW_BUILD_STATIC "Build a static library" ON)
|
||||
option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" OFF)
|
||||
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" OFF)
|
||||
else()
|
||||
option(MW_BUILD_SHARED "Build a shared library" ON)
|
||||
option(MW_BUILD_STATIC "Build a static library" OFF)
|
||||
option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" ON)
|
||||
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON)
|
||||
endif()
|
||||
|
||||
option(MW_INSTALL_HEADERS "Install headers" ON)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin OR ${CMAKE_SYSTEM_NAME} MATCHES Retro)
|
||||
option(MW_USE_FREETYPE2 "Use FreeType 2" OFF)
|
||||
else()
|
||||
option(MW_USE_FREETYPE2 "Use FreeType 2" ON)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
||||
option(MW_USE_WAYLAND "Enable Wayland backend" ON)
|
||||
endif()
|
||||
option(TRY_OPENGL "Try to compile OpenGL widget or not" ON)
|
||||
option(TRY_VULKAN "Try to compile Vulkan widget or not" ON)
|
||||
option(CLASSIC_THEME "Use classic theme" OFF)
|
||||
option(BUILD_EXAMPLES "Build examples" OFF)
|
||||
option(USE_STB_IMAGE "Use stb_image" ON)
|
||||
option(USE_STB_TRUETYPE "Use stb_truetype" OFF)
|
||||
option(USE_FREETYPE2 "Use FreeType 2" ON)
|
||||
|
||||
file(
|
||||
GLOB
|
||||
SOURCES
|
||||
external/libz/src/*.c src/*.c src/cursor/*.c src/icon/*.c src/widget/*.c src/text/*.c src/text/font/*.c src/dialog/*.c src/abstract/*.c external/*.c
|
||||
src/*.c src/cursor/*.c src/icon/*.c src/text.c src/widget/*.c src/math/*.c src/font/*.c src/dialog/*.c src/abstract/*.c external/*.c
|
||||
)
|
||||
|
||||
if(NOT MW_USE_STB_IMAGE)
|
||||
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c")
|
||||
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c")
|
||||
|
||||
if(NOT USE_STB_IMAGE)
|
||||
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_image.c")
|
||||
endif()
|
||||
|
||||
if(NOT MW_USE_STB_TRUETYPE)
|
||||
if(NOT USE_STB_TRUETYPE)
|
||||
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_truetype.c")
|
||||
endif()
|
||||
|
||||
|
|
@ -58,47 +39,35 @@ if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
|||
list(APPEND CMAKE_REQUIRED_INCLUDES "/usr/pkg/include")
|
||||
endif()
|
||||
|
||||
if(MW_TRY_OPENGL)
|
||||
find_package(OpenGL)
|
||||
if(OpenGL_FOUND)
|
||||
set(MW_BUILD_OPENGL ON)
|
||||
if(APPLE)
|
||||
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl_cocoa.m")
|
||||
endif()
|
||||
if(TRY_OPENGL)
|
||||
check_include_files(GL/gl.h HAVE_GL_GL_H)
|
||||
if(HAVE_GL_GL_H)
|
||||
set(BUILD_OPENGL ON)
|
||||
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c")
|
||||
message(STATUS "OpenGL widget has been enabled")
|
||||
else()
|
||||
message(WARNING "OpenGL widget has been disabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MW_TRY_VULKAN)
|
||||
if(TRY_OPENGL)
|
||||
check_include_files(vulkan/vulkan.h HAVE_VULKAN_VULKAN_H)
|
||||
if(HAVE_VULKAN_VULKAN_H)
|
||||
set(MW_BUILD_VULKAN ON)
|
||||
set(BUILD_VULKAN ON)
|
||||
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c")
|
||||
message(STATUS "Vulkan widget has been enabled")
|
||||
else()
|
||||
message(WARNING "Vulkan widget has been disabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MW_BUILD_STATIC)
|
||||
message(STATUS "Building Milsko as a static library")
|
||||
add_library(
|
||||
Mw
|
||||
${SOURCES}
|
||||
)
|
||||
elseif(MW_BUILD_SHARED)
|
||||
message(STATUS "Building Milsko as a shared library")
|
||||
add_library(
|
||||
Mw
|
||||
SHARED
|
||||
${SOURCES}
|
||||
)
|
||||
else()
|
||||
message(ERROR "Must either build a shared library or a static library")
|
||||
endif()
|
||||
|
||||
if(MW_USE_STB_IMAGE)
|
||||
if(USE_STB_IMAGE)
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
|
|
@ -108,21 +77,21 @@ else()
|
|||
file(
|
||||
GLOB
|
||||
IMAGE_SOURCES
|
||||
external/libjpeg/src/*.c external/libpng/src/*.c
|
||||
external/libz/src/*.c external/libjpeg/src/*.c external/libpng/src/*.c
|
||||
)
|
||||
target_sources(
|
||||
Mw
|
||||
PRIVATE
|
||||
${MW_IMAGE_SOURCES}
|
||||
${IMAGE_SOURCES}
|
||||
)
|
||||
target_include_directories(
|
||||
Mw
|
||||
PRIVATE
|
||||
external/libjpeg/include external/libpng/include
|
||||
external/libz/include external/libjpeg/include external/libpng/include
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MW_USE_STB_TRUETYPE)
|
||||
if(USE_STB_TRUETYPE)
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
|
|
@ -130,7 +99,7 @@ if(MW_USE_STB_TRUETYPE)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(MW_USE_FREETYPE2)
|
||||
if(USE_FREETYPE2)
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
|
|
@ -144,119 +113,13 @@ if(MW_USE_FREETYPE2)
|
|||
list(APPEND LIBRARIES ${FT2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(MW_USE_WAYLAND)
|
||||
function(scan_wayland_protocol_core)
|
||||
execute_process(
|
||||
COMMAND wayland-scanner private-code /usr/share/wayland/wayland.xml ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-core-protocol.c
|
||||
OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT
|
||||
ERROR_VARIABLE WAYLAND_SCANNER_ERROR
|
||||
ECHO_OUTPUT_VARIABLE
|
||||
ECHO_ERROR_VARIABLE
|
||||
COMMAND_ECHO STDOUT
|
||||
)
|
||||
target_sources(
|
||||
Mw
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-core-protocol.c
|
||||
)
|
||||
execute_process(
|
||||
COMMAND wayland-scanner client-header /usr/share/wayland/wayland.xml ${CMAKE_CURRENT_SOURCE_DIR}/include/Mw/LowLevel/Wayland/wayland-core-protocol.h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT
|
||||
ERROR_VARIABLE WAYLAND_SCANNER_ERROR
|
||||
ECHO_OUTPUT_VARIABLE
|
||||
ECHO_ERROR_VARIABLE
|
||||
COMMAND_ECHO STDOUT
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(scan_wayland_protocol tier proto ver)
|
||||
SET(proto_c ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-${proto}-protocol.c)
|
||||
execute_process(
|
||||
COMMAND wayland-scanner private-code /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml ${proto_c}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT
|
||||
ERROR_VARIABLE WAYLAND_SCANNER_ERROR
|
||||
ECHO_OUTPUT_VARIABLE
|
||||
ECHO_ERROR_VARIABLE
|
||||
COMMAND_ECHO STDOUT
|
||||
)
|
||||
target_sources(
|
||||
Mw
|
||||
PRIVATE
|
||||
${proto_c}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND wayland-scanner client-header /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml ${CMAKE_CURRENT_SOURCE_DIR}/include/Mw/LowLevel/Wayland/${proto}-client-protocol.h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT
|
||||
ERROR_VARIABLE WAYLAND_SCANNER_ERROR
|
||||
ECHO_OUTPUT_VARIABLE
|
||||
ECHO_ERROR_VARIABLE
|
||||
COMMAND_ECHO STDOUT
|
||||
)
|
||||
endfunction()
|
||||
|
||||
check_include_files(wayland-client.h HAVE_WL_H)
|
||||
check_include_files(xkbcommon/xkbcommon.h HAVE_XKBCOMMON_H)
|
||||
check_include_files(cairo/cairo.h HAVE_CAIRO_H)
|
||||
if(HAVE_WL_H)
|
||||
if(HAVE_XKBCOMMON_H)
|
||||
if(HAVE_CAIRO_H)
|
||||
scan_wayland_protocol_core()
|
||||
scan_wayland_protocol("stable" "xdg-shell" "")
|
||||
scan_wayland_protocol("stable" "viewporter" "")
|
||||
scan_wayland_protocol("stable" "tablet" "-v2")
|
||||
scan_wayland_protocol("staging" "xdg-toplevel-icon" "-v1")
|
||||
scan_wayland_protocol("staging" "cursor-shape" "-v1")
|
||||
scan_wayland_protocol("unstable" "xdg-decoration" "-unstable-v1")
|
||||
scan_wayland_protocol("unstable" "primary-selection" "-unstable-v1")
|
||||
scan_wayland_protocol("unstable" "pointer-constraints" "-unstable-v1")
|
||||
scan_wayland_protocol("unstable" "relative-pointer" "-unstable-v1")
|
||||
|
||||
target_sources(
|
||||
Mw
|
||||
PRIVATE
|
||||
src/backend/wayland.c
|
||||
)
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
USE_WAYLAND
|
||||
)
|
||||
message(STATUS "Wayland backend has been enabled")
|
||||
else()
|
||||
message(WARNING "Wayland backend has been disabled")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Wayland backend has been disabled")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Wayland backend has been disabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE AND MW_BUILD_OPENGL)
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
GL_SILENCE_DEPRECATION
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(
|
||||
Mw
|
||||
PRIVATE
|
||||
external/libz/include
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
Mw
|
||||
PUBLIC
|
||||
include
|
||||
)
|
||||
|
||||
if(MW_CLASSIC_THEME)
|
||||
if(CLASSIC_THEME)
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
|
|
@ -276,46 +139,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|||
USE_GDI
|
||||
)
|
||||
list(APPEND LIBRARIES gdi32)
|
||||
target_link_options(
|
||||
Mw
|
||||
PRIVATE
|
||||
-static-libgcc
|
||||
)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
target_sources(
|
||||
Mw
|
||||
PRIVATE
|
||||
src/backend/cocoa.m
|
||||
)
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
USE_COCOA
|
||||
)
|
||||
list(APPEND LIBRARIES objc)
|
||||
target_link_options(
|
||||
Mw
|
||||
PRIVATE
|
||||
-framework Cocoa
|
||||
)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Retro")
|
||||
target_sources(
|
||||
Mw
|
||||
PRIVATE
|
||||
src/backend/classicmacos.c
|
||||
)
|
||||
if(PLATFORM MATCHES retroppc)
|
||||
set_target_properties(Mw PROPERTIES COMPILE_FLAGS "-ffunction-sections -mcpu=601 -Os -Wall -Wextra -Wno-unused-parameter")
|
||||
set_target_properties(Mw PROPERTIES LINK_FLAGS "-Wl,-gc-sections")
|
||||
endif()
|
||||
|
||||
list(APPEND LIBRARIES InterfaceLib WindowsLib ThreadsLib)
|
||||
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
CLASSIC_MAC_OS
|
||||
)
|
||||
else()
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(X11 REQUIRED x11)
|
||||
|
|
@ -355,15 +178,7 @@ target_link_libraries(
|
|||
${LIBRARIES}
|
||||
)
|
||||
|
||||
if(MW_BUILD_OPENGL)
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
MW_OPENGL
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MW_BUILD_VULKAN)
|
||||
if(BUILD_VULKAN)
|
||||
check_include_files(vulkan/vk_enum_string_helper.h HAS_VK_ENUM_STRING_HELPER)
|
||||
if(HAS_VK_ENUM_STRING_HELPER)
|
||||
target_compile_definitions(
|
||||
|
|
@ -372,12 +187,6 @@ if(MW_BUILD_VULKAN)
|
|||
HAS_VK_ENUM_STRING_HELPER
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(
|
||||
Mw
|
||||
PRIVATE
|
||||
MW_VULKAN
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(
|
||||
|
|
@ -386,21 +195,19 @@ target_compile_definitions(
|
|||
_MILSKO
|
||||
)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(
|
||||
TARGETS Mw
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
|
||||
if(MW_INSTALL_HEADERS)
|
||||
install(
|
||||
DIRECTORY include/
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MW_BUILD_EXAMPLES)
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
|
|
|||
74
Jenkinsfile
vendored
74
Jenkinsfile
vendored
|
|
@ -1,74 +0,0 @@
|
|||
pipeline {
|
||||
agent {
|
||||
label "built-in"
|
||||
}
|
||||
stages {
|
||||
stage("Build document") {
|
||||
when {
|
||||
branch "master"
|
||||
}
|
||||
agent {
|
||||
label "built-in"
|
||||
}
|
||||
steps {
|
||||
sh("rm -rf include/Mw/LowLevel/Wayland")
|
||||
sh("doxygen")
|
||||
sh("rm -rf /var/www/milsko-doxygen")
|
||||
sh("mv doxygen/html /var/www/milsko-doxygen")
|
||||
}
|
||||
post {
|
||||
always {
|
||||
notifyDiscord()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Build") {
|
||||
parallel {
|
||||
stage("Build for Linux 64-bit") {
|
||||
agent {
|
||||
label "built-in"
|
||||
}
|
||||
steps {
|
||||
sh("./configure --enable-opengl --enable-vulkan --without-vulkan-string-helper")
|
||||
sh("make clean")
|
||||
sh("make -j4")
|
||||
}
|
||||
}
|
||||
stage("Build for Windows 32-bit") {
|
||||
agent {
|
||||
label "built-in"
|
||||
}
|
||||
steps {
|
||||
sh("./configure --enable-opengl --enable-stb-truetype --disable-freetype2 --cross --target=Windows --host=i686-w64-mingw32")
|
||||
sh("make clean")
|
||||
sh("make -j4")
|
||||
}
|
||||
}
|
||||
stage("Build for Windows 64-bit") {
|
||||
agent {
|
||||
label "built-in"
|
||||
}
|
||||
steps {
|
||||
sh("./configure --enable-opengl --enable-stb-truetype --disable-freetype2 --cross --target=Windows --host=x86_64-w64-mingw32")
|
||||
sh("make clean")
|
||||
sh("make -j4")
|
||||
}
|
||||
}
|
||||
stage("Build for Windows 32-bit (MSVC)") {
|
||||
agent {
|
||||
label "2012r2"
|
||||
}
|
||||
steps {
|
||||
bat("nmake -f NTMakefile clean")
|
||||
bat("nmake -f NTMakefile")
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
notifyDiscord()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Koakumafile
Executable file
24
Koakumafile
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
# vim: syntax=tcl
|
||||
|
||||
proc run {project_name} {
|
||||
if { "$project_name" == "MilskoDoxygen" } {
|
||||
RunCommand "doxygen"
|
||||
RunCommand "rm -rf /var/www/milsko-doxygen"
|
||||
RunCommand "mv doxygen/html /var/www/milsko-doxygen"
|
||||
} else {
|
||||
foreach target {"Linux" "Win32" "Win64"} {
|
||||
if { [file exists "Makefile"] == 1 } {
|
||||
RunCommand "make distclean"
|
||||
}
|
||||
if { "$target" == "Linux" } {
|
||||
RunCommand "./Makefile.pl --enable-opengl --enable-vulkan --without-vulkan-string-helper"
|
||||
} elseif { "$target" == "Win32" } {
|
||||
RunCommand "./Makefile.pl --enable-opengl --enable-stb-truetype --disable-freetype2 --cross --target=Windows --host=i686-w64-mingw32"
|
||||
} elseif { "$target" == "Win64" } {
|
||||
RunCommand "./Makefile.pl --enable-opengl --enable-stb-truetype --disable-freetype2 --cross --target=Windows --host=x86_64-w64-mingw32"
|
||||
}
|
||||
RunCommand "make clean"
|
||||
RunCommand "make -j4"
|
||||
}
|
||||
}
|
||||
}
|
||||
2
LICENSE
2
LICENSE
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2025-2026, Pyrite development team
|
||||
Copyright (c) 2025, Pyrite development team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
|||
|
|
@ -14,12 +14,11 @@ our $prefix = "/usr/local";
|
|||
our $cc = defined($ENV{CC}) ? $ENV{CC} : "*host*gcc";
|
||||
our $ar = defined($ENV{AR}) ? $ENV{AR} : "*host*ar";
|
||||
our $incdir = "-I include";
|
||||
our $incdir2 = "";
|
||||
our $cflags = "-fPIC -D_MILSKO -fvisibility=hidden";
|
||||
our $cflags = "-fPIC -D_MILSKO";
|
||||
our $libdir = "";
|
||||
our $ldflags = "";
|
||||
our $math = "-lm";
|
||||
our @shared = "-shared";
|
||||
our $shared = "-shared";
|
||||
our @backends = ();
|
||||
|
||||
our $library_prefix = "lib";
|
||||
|
|
@ -38,18 +37,18 @@ require("./pl/utils.pl");
|
|||
|
||||
param_set("classic-theme", 0);
|
||||
param_set("stb-image", 1);
|
||||
param_set("stb-truetype", 0);
|
||||
param_set("freetype2", 1);
|
||||
param_set("xrender", 1);
|
||||
param_set("opengl", 0);
|
||||
param_set("vulkan", 0);
|
||||
param_set("vulkan-string-helper", 1);
|
||||
param_set("shared", 1);
|
||||
param_set("static", 1);
|
||||
param_set("examples", 1);
|
||||
|
||||
|
||||
my %features = (
|
||||
"classic-theme" => "use classic theme",
|
||||
"stb-image" => "use stb_image, instead use libjpeg/libpng",
|
||||
"stb-image" => "use stb_image instead of libjpeg/libpng",
|
||||
"stb-truetype" => "use stb_truetype",
|
||||
"freetype2" => "use FreeType2",
|
||||
"xrender" => "use XRender",
|
||||
|
|
@ -58,8 +57,7 @@ my %features = (
|
|||
"vulkan-string-helper" => "use Vulkan string helper",
|
||||
"shared" => "build shared library",
|
||||
"static" => "build static library",
|
||||
"wayland" => "enable wayland backend",
|
||||
"gnustep" => "use gnustep",
|
||||
"experimental-wayland" => "enable WIP wayland backend",
|
||||
);
|
||||
my @features_keys = (
|
||||
"1classic-theme", "1stb-image",
|
||||
|
|
@ -67,7 +65,7 @@ my @features_keys = (
|
|||
"1opengl", "2xrender",
|
||||
"1vulkan", "2vulkan-string-helper",
|
||||
"1shared", "1static",
|
||||
"1wayland", "1gnustep",
|
||||
"1experimental-wayland"
|
||||
);
|
||||
|
||||
foreach my $l (@ARGV) {
|
||||
|
|
@ -86,15 +84,9 @@ foreach my $l (@ARGV) {
|
|||
elsif ($l =~ /^--host=(.+)$/) {
|
||||
$host = $1 . "-";
|
||||
}
|
||||
elsif ($l =~ /^--cflags=(.+)$/) {
|
||||
add_cflags($1);
|
||||
}
|
||||
elsif ($l eq "--cross") {
|
||||
$cross = 1;
|
||||
}
|
||||
elsif ($l eq "--tiny") {
|
||||
param_set("tiny",1);
|
||||
}
|
||||
elsif (($l eq "-h") or ($l eq "--help")) {
|
||||
print("Milsko Toolkit Configuration Utility\n");
|
||||
print("\n");
|
||||
|
|
@ -105,8 +97,6 @@ foreach my $l (@ARGV) {
|
|||
print(" --prefix=PREFIX Installation prefix\n");
|
||||
print(" --host=TARGET Host for compiler/archiver\n");
|
||||
print(" --target=TARGET Specify target\n");
|
||||
print(" --cflags=CFLAGS Add cflags\n");
|
||||
print(" --tiny Build smallest possible library\n");
|
||||
print(" --cross Indicate cross compilation\n");
|
||||
print("\n");
|
||||
print("Features:\n");
|
||||
|
|
@ -132,21 +122,6 @@ foreach my $l (@ARGV) {
|
|||
}
|
||||
}
|
||||
|
||||
if($target ne "Darwin" and $target ne "ClassicMacOS" and $target ne "Windows") {
|
||||
param_set("freetype2", 1);
|
||||
param_set("stb-truetype", 0);
|
||||
} else {
|
||||
param_set("freetype2", 0);
|
||||
param_set("stb-truetype", 0);
|
||||
}
|
||||
|
||||
if($target eq "Linux") {
|
||||
param_set("x11", 1);
|
||||
if(!param_get("tiny")){
|
||||
param_set("wayland", 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (-f "./pl/ostype/${target}.pl") {
|
||||
require("./pl/ostype/${target}.pl");
|
||||
}
|
||||
|
|
@ -185,13 +160,13 @@ open(OUT, ">", "Makefile");
|
|||
print(OUT "PREFIX = ${prefix}\n");
|
||||
print(OUT "AR = ${ar}\n");
|
||||
print(OUT "CC = ${cc}\n");
|
||||
print(OUT "INCDIR = ${incdir} ${incdir2}\n");
|
||||
print(OUT "INCDIR = ${incdir}\n");
|
||||
print(OUT "CFLAGS = ${cflags}\n");
|
||||
print(OUT "LIBDIR = ${libdir}\n");
|
||||
print(OUT "LDFLAGS = ${ldflags}\n");
|
||||
print(OUT "LIBS = ${math} ${libs}\n");
|
||||
print(OUT "MATH = ${math}\n");
|
||||
print(OUT "SHARED = @{shared}\n");
|
||||
print(OUT "SHARED = ${shared}\n");
|
||||
print(OUT "\n");
|
||||
print(OUT ".PHONY: all format clean distclean lib examples install\n");
|
||||
print(OUT "\n");
|
||||
|
|
@ -208,10 +183,10 @@ print(OUT " cp -rf include \$(DESTDIR)\$(PREFIX)/\n");
|
|||
print(OUT "\n");
|
||||
print(OUT "format:\n");
|
||||
print(OUT
|
||||
" clang-format --verbose -i `find src include examples \"(\" -name \"*.c\" -or -name \"*.h\" -or -name \"*.m\" \")\" -and -not -name \"*ttf.c\"`\n"
|
||||
" clang-format --verbose -i `find src include examples -name \"*.c\" -or -name \"*.h\"`\n"
|
||||
);
|
||||
print(OUT
|
||||
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl configure -name \"*.pl\"`\n"
|
||||
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl Makefile.pl -name \"*.pl\"`\n"
|
||||
);
|
||||
print(OUT "\n");
|
||||
print(OUT "lib:");
|
||||
|
|
@ -244,24 +219,17 @@ foreach my $l (@library_targets) {
|
|||
my $s = $l;
|
||||
my $o = $object_suffix;
|
||||
$o =~ s/\./\\\./g;
|
||||
|
||||
if ($l =~ /cocoa/) {
|
||||
$s =~ s/$o$/.m/;
|
||||
}
|
||||
else {
|
||||
$s =~ s/$o$/.c/;
|
||||
}
|
||||
|
||||
if ($l =~ /^external\//) {
|
||||
$warn = "";
|
||||
}
|
||||
|
||||
print(OUT "${l}: ${s}\n");
|
||||
print(OUT " \$(CC) $warn \$\(INCDIR) \$(CFLAGS\) -c -o ${l} ${s}\n");
|
||||
print(OUT " \$(CC) $warn \$(CFLAGS\) \$\(INCDIR) -c -o ${l} ${s}\n");
|
||||
}
|
||||
print(OUT "\n");
|
||||
print(OUT "\n");
|
||||
if (param_get("examples")) {
|
||||
print(OUT "examples: " . join(" ", @examples_targets) . "\n");
|
||||
print(OUT "\n");
|
||||
foreach my $l (@examples_targets) {
|
||||
|
|
@ -275,44 +243,21 @@ if (param_get("examples")) {
|
|||
$libs = $examples_libs{$l};
|
||||
}
|
||||
|
||||
if (param_get("shared")) {
|
||||
print(OUT
|
||||
"${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"
|
||||
);
|
||||
} else {
|
||||
print(OUT
|
||||
"${l}: ${s}${object_suffix} src/${library_prefix}Mw.a\n"
|
||||
);
|
||||
}
|
||||
if (grep(/^cocoa$/, @backends)) {
|
||||
print(OUT
|
||||
" \$(CC) -L./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
||||
);
|
||||
}
|
||||
else {
|
||||
print(OUT
|
||||
" \$(CC) -L src -Wl,-R./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
||||
);
|
||||
}
|
||||
|
||||
if($target eq "ClassicMacOS") {
|
||||
print(OUT
|
||||
" ".$ENV{RETRO68_TOOLCHAIN_PATH}."/bin/MakePEF ${l} -o ${s}.pef\n");
|
||||
print(OUT
|
||||
" Rez -I ".$ENV{RETRO68_TOOLCHAIN_PATH}."/RIncludes ".$ENV{RETRO68_TOOLCHAIN_PATH}."/RIncludes/Retro68APPL.r -DCFRAG_NAME=\"example\" --data ${l}.pef --cc ${l}.dsk -t APPL\n"
|
||||
);
|
||||
}
|
||||
|
||||
print(OUT "${s}${object_suffix}: ${s}.c\n");
|
||||
print(OUT
|
||||
" \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
print(OUT "\n");
|
||||
print(OUT "clean:\n");
|
||||
print(OUT
|
||||
" rm -f */*.o */*/*.o */*/*/*.o */*.exe */*/*.exe */*/*/*.exe src/*.so src/*.dll src/*.dylib src/*.a "
|
||||
" rm -f */*.o */*/*.o */*/*/*.o */*.exe */*/*.exe */*/*/*.exe src/*.so src/*.dll src/*.a "
|
||||
. join(" ", @examples_targets)
|
||||
. "\n");
|
||||
print(OUT "\n");
|
||||
36
NTMakefile
generated
36
NTMakefile
generated
|
|
@ -1,26 +1,11 @@
|
|||
CC = cl /TC /c /nologo
|
||||
LD = link /nologo
|
||||
|
||||
CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /DUSE_GDI /DUSE_STB_TRUETYPE /DUSE_STB_IMAGE /DSTBI_NO_SIMD
|
||||
CFLAGS = /Iinclude /D_MILSKO /DUSE_GDI /DUSE_STB_TRUETYPE /DUSE_STB_IMAGE /DSTBI_NO_SIMD
|
||||
LDFLAGS = /DLL
|
||||
.SUFFIXES: .obj .c
|
||||
all: src\Mw.dll
|
||||
clean:
|
||||
del /f /q external\libz\src\adler32.obj
|
||||
del /f /q external\libz\src\compress.obj
|
||||
del /f /q external\libz\src\crc32.obj
|
||||
del /f /q external\libz\src\deflate.obj
|
||||
del /f /q external\libz\src\gzclose.obj
|
||||
del /f /q external\libz\src\gzlib.obj
|
||||
del /f /q external\libz\src\gzread.obj
|
||||
del /f /q external\libz\src\gzwrite.obj
|
||||
del /f /q external\libz\src\infback.obj
|
||||
del /f /q external\libz\src\inffast.obj
|
||||
del /f /q external\libz\src\inflate.obj
|
||||
del /f /q external\libz\src\inftrees.obj
|
||||
del /f /q external\libz\src\trees.obj
|
||||
del /f /q external\libz\src\uncompr.obj
|
||||
del /f /q external\libz\src\zutil.obj
|
||||
del /f /q external\stb_ds.obj
|
||||
del /f /q external\stb_image.obj
|
||||
del /f /q external\stb_truetype.obj
|
||||
|
|
@ -41,6 +26,11 @@ clean:
|
|||
del /f /q src\dialog\filechooser.obj
|
||||
del /f /q src\dialog\messagebox.obj
|
||||
del /f /q src\draw.obj
|
||||
del /f /q src\error.obj
|
||||
del /f /q src\font\boldfont.obj
|
||||
del /f /q src\font\boldttf.obj
|
||||
del /f /q src\font\font.obj
|
||||
del /f /q src\font\ttf.obj
|
||||
del /f /q src\icon\back.obj
|
||||
del /f /q src\icon\clock.obj
|
||||
del /f /q src\icon\computer.obj
|
||||
|
|
@ -59,15 +49,7 @@ clean:
|
|||
del /f /q src\icon\warning.obj
|
||||
del /f /q src\lowlevel.obj
|
||||
del /f /q src\string.obj
|
||||
del /f /q src\text\font\boldfont.obj
|
||||
del /f /q src\text\font\boldmonottf.obj
|
||||
del /f /q src\text\font\boldttf.obj
|
||||
del /f /q src\text\font\font.obj
|
||||
del /f /q src\text\font\monottf.obj
|
||||
del /f /q src\text\font\ttf.obj
|
||||
del /f /q src\text\ft2.obj
|
||||
del /f /q src\text\stbtt.obj
|
||||
del /f /q src\text\text.obj
|
||||
del /f /q src\text.obj
|
||||
del /f /q src\unicode.obj
|
||||
del /f /q src\widget\box.obj
|
||||
del /f /q src\widget\button.obj
|
||||
|
|
@ -92,8 +74,8 @@ clean:
|
|||
del /f /q src\Mw.dll
|
||||
del /f /q src\Mw.lib
|
||||
|
||||
src\Mw.dll: external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\stbtt.obj src\text\text.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj
|
||||
$(LD) $(LDFLAGS) /OUT:$@ external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\stbtt.obj src\text\text.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib user32.lib advapi32.lib
|
||||
src\Mw.dll: external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\error.obj src\font\boldfont.obj src\font\boldttf.obj src\font\font.obj src\font\ttf.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj
|
||||
$(LD) $(LDFLAGS) /OUT:$@ external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\error.obj src\font\boldfont.obj src\font\boldttf.obj src\font\font.obj src\font\ttf.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib user32.lib
|
||||
|
||||
|
||||
.c.obj:
|
||||
|
|
|
|||
12
README.txt
12
README.txt
|
|
@ -6,10 +6,8 @@ distributions and building instructions for Milsko GUI Toolkit.
|
|||
|
||||
Requirements
|
||||
|
||||
Milsko requires either
|
||||
* A Windows environment with GDI (so anything NT or 9x)
|
||||
* A MacOS environment with Cocoa (10.4 or above supported)
|
||||
* A Unix-like environment with X11 for runtime.
|
||||
Milsko requires the Windows environment with GDI (so anything NT or 9x) or
|
||||
the Unix-like environment with X11 for runtime.
|
||||
|
||||
To build Milsko for Windows, you must have one of following compilers:
|
||||
* Visual C++ 6.0 or newer
|
||||
|
|
@ -17,7 +15,7 @@ distributions and building instructions for Milsko GUI Toolkit.
|
|||
* Open Watcom 2.0 or newer
|
||||
* MinGW-w64
|
||||
|
||||
and for Unix-like and MacOS:
|
||||
and for Unix-like:
|
||||
* GNU C Compiler
|
||||
* Clang
|
||||
|
||||
|
|
@ -63,8 +61,8 @@ D. MinGW-w64/GCC/Clang
|
|||
|
||||
1) Determine if you need Vulkan and/or OpenGL.
|
||||
|
||||
2) Run `./configure'.
|
||||
For help, run `./configure --help'.
|
||||
2) Run `./Makefile.pl'.
|
||||
For help, run `./Makefile.pl --help'.
|
||||
|
||||
3) Run `make'.
|
||||
|
||||
|
|
|
|||
96
WatMakefile
generated
96
WatMakefile
generated
|
|
@ -1,25 +1,10 @@
|
|||
CC = wcc386 -bt=nt -q -bd -d3
|
||||
CC = wcc386 -bt=nt -q -bd
|
||||
LD = wlink option quiet
|
||||
|
||||
CFLAGS = -i=include -i=external/libz/include -d_MILSKO -dUSE_GDI -dUSE_STB_TRUETYPE -dUSE_STB_IMAGE -dSTBI_NO_SIMD
|
||||
CFLAGS = -i=include -d_MILSKO -dUSE_GDI -dUSE_STB_TRUETYPE -dUSE_STB_IMAGE -dSTBI_NO_SIMD
|
||||
LDFLAGS = system nt_dll
|
||||
all: src/Mw.dll
|
||||
clean: .SYMBOLIC
|
||||
%erase external/libz/src/adler32.obj
|
||||
%erase external/libz/src/compress.obj
|
||||
%erase external/libz/src/crc32.obj
|
||||
%erase external/libz/src/deflate.obj
|
||||
%erase external/libz/src/gzclose.obj
|
||||
%erase external/libz/src/gzlib.obj
|
||||
%erase external/libz/src/gzread.obj
|
||||
%erase external/libz/src/gzwrite.obj
|
||||
%erase external/libz/src/infback.obj
|
||||
%erase external/libz/src/inffast.obj
|
||||
%erase external/libz/src/inflate.obj
|
||||
%erase external/libz/src/inftrees.obj
|
||||
%erase external/libz/src/trees.obj
|
||||
%erase external/libz/src/uncompr.obj
|
||||
%erase external/libz/src/zutil.obj
|
||||
%erase external/stb_ds.obj
|
||||
%erase external/stb_image.obj
|
||||
%erase external/stb_truetype.obj
|
||||
|
|
@ -40,6 +25,11 @@ clean: .SYMBOLIC
|
|||
%erase src/dialog/filechooser.obj
|
||||
%erase src/dialog/messagebox.obj
|
||||
%erase src/draw.obj
|
||||
%erase src/error.obj
|
||||
%erase src/font/boldfont.obj
|
||||
%erase src/font/boldttf.obj
|
||||
%erase src/font/font.obj
|
||||
%erase src/font/ttf.obj
|
||||
%erase src/icon/back.obj
|
||||
%erase src/icon/clock.obj
|
||||
%erase src/icon/computer.obj
|
||||
|
|
@ -58,15 +48,7 @@ clean: .SYMBOLIC
|
|||
%erase src/icon/warning.obj
|
||||
%erase src/lowlevel.obj
|
||||
%erase src/string.obj
|
||||
%erase src/text/font/boldfont.obj
|
||||
%erase src/text/font/boldmonottf.obj
|
||||
%erase src/text/font/boldttf.obj
|
||||
%erase src/text/font/font.obj
|
||||
%erase src/text/font/monottf.obj
|
||||
%erase src/text/font/ttf.obj
|
||||
%erase src/text/ft2.obj
|
||||
%erase src/text/stbtt.obj
|
||||
%erase src/text/text.obj
|
||||
%erase src/text.obj
|
||||
%erase src/unicode.obj
|
||||
%erase src/widget/box.obj
|
||||
%erase src/widget/button.obj
|
||||
|
|
@ -91,41 +73,11 @@ clean: .SYMBOLIC
|
|||
%erase src/Mw.dll
|
||||
%erase src/Mw.lib
|
||||
|
||||
src/Mw.dll: external/libz/src/adler32.obj external/libz/src/compress.obj external/libz/src/crc32.obj external/libz/src/deflate.obj external/libz/src/gzclose.obj external/libz/src/gzlib.obj external/libz/src/gzread.obj external/libz/src/gzwrite.obj external/libz/src/infback.obj external/libz/src/inffast.obj external/libz/src/inflate.obj external/libz/src/inftrees.obj external/libz/src/trees.obj external/libz/src/uncompr.obj external/libz/src/zutil.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/abstract/directory.obj src/abstract/dynamic.obj src/abstract/time.obj src/backend/gdi.obj src/color.obj src/core.obj src/cursor/arrow.obj src/cursor/cross.obj src/cursor/default.obj src/cursor/hidden.obj src/cursor/text.obj src/default.obj src/dialog/colorpicker.obj src/dialog/directorychooser.obj src/dialog/filechooser.obj src/dialog/messagebox.obj src/draw.obj src/icon/back.obj src/icon/clock.obj src/icon/computer.obj src/icon/directory.obj src/icon/down.obj src/icon/error.obj src/icon/file.obj src/icon/forward.obj src/icon/info.obj src/icon/left.obj src/icon/news.obj src/icon/note.obj src/icon/right.obj src/icon/search.obj src/icon/up.obj src/icon/warning.obj src/lowlevel.obj src/string.obj src/text/font/boldfont.obj src/text/font/boldmonottf.obj src/text/font/boldttf.obj src/text/font/font.obj src/text/font/monottf.obj src/text/font/ttf.obj src/text/ft2.obj src/text/stbtt.obj src/text/text.obj src/unicode.obj src/widget/box.obj src/widget/button.obj src/widget/checkbox.obj src/widget/combobox.obj src/widget/entry.obj src/widget/frame.obj src/widget/image.obj src/widget/label.obj src/widget/listbox.obj src/widget/menu.obj src/widget/numberentry.obj src/widget/opengl.obj src/widget/progressbar.obj src/widget/radiobox.obj src/widget/scrollbar.obj src/widget/separator.obj src/widget/submenu.obj src/widget/treeview.obj src/widget/viewport.obj src/widget/window.obj
|
||||
$(LD) $(LDFLAGS) option implib=src/Mw.lib name $@ file external/libz/src/adler32.obj file external/libz/src/compress.obj file external/libz/src/crc32.obj file external/libz/src/deflate.obj file external/libz/src/gzclose.obj file external/libz/src/gzlib.obj file external/libz/src/gzread.obj file external/libz/src/gzwrite.obj file external/libz/src/infback.obj file external/libz/src/inffast.obj file external/libz/src/inflate.obj file external/libz/src/inftrees.obj file external/libz/src/trees.obj file external/libz/src/uncompr.obj file external/libz/src/zutil.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/abstract/directory.obj file src/abstract/dynamic.obj file src/abstract/time.obj file src/backend/gdi.obj file src/color.obj file src/core.obj file src/cursor/arrow.obj file src/cursor/cross.obj file src/cursor/default.obj file src/cursor/hidden.obj file src/cursor/text.obj file src/default.obj file src/dialog/colorpicker.obj file src/dialog/directorychooser.obj file src/dialog/filechooser.obj file src/dialog/messagebox.obj file src/draw.obj file src/icon/back.obj file src/icon/clock.obj file src/icon/computer.obj file src/icon/directory.obj file src/icon/down.obj file src/icon/error.obj file src/icon/file.obj file src/icon/forward.obj file src/icon/info.obj file src/icon/left.obj file src/icon/news.obj file src/icon/note.obj file src/icon/right.obj file src/icon/search.obj file src/icon/up.obj file src/icon/warning.obj file src/lowlevel.obj file src/string.obj file src/text/font/boldfont.obj file src/text/font/boldmonottf.obj file src/text/font/boldttf.obj file src/text/font/font.obj file src/text/font/monottf.obj file src/text/font/ttf.obj file src/text/ft2.obj file src/text/stbtt.obj file src/text/text.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.obj file src/widget/checkbox.obj file src/widget/combobox.obj file src/widget/entry.obj file src/widget/frame.obj file src/widget/image.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/menu.obj file src/widget/numberentry.obj file src/widget/opengl.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/widget/scrollbar.obj file src/widget/separator.obj file src/widget/submenu.obj file src/widget/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library user32.lib library advapi32.lib
|
||||
src/Mw.dll: external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/abstract/directory.obj src/abstract/dynamic.obj src/abstract/time.obj src/backend/gdi.obj src/color.obj src/core.obj src/cursor/arrow.obj src/cursor/cross.obj src/cursor/default.obj src/cursor/hidden.obj src/cursor/text.obj src/default.obj src/dialog/colorpicker.obj src/dialog/directorychooser.obj src/dialog/filechooser.obj src/dialog/messagebox.obj src/draw.obj src/error.obj src/font/boldfont.obj src/font/boldttf.obj src/font/font.obj src/font/ttf.obj src/icon/back.obj src/icon/clock.obj src/icon/computer.obj src/icon/directory.obj src/icon/down.obj src/icon/error.obj src/icon/file.obj src/icon/forward.obj src/icon/info.obj src/icon/left.obj src/icon/news.obj src/icon/note.obj src/icon/right.obj src/icon/search.obj src/icon/up.obj src/icon/warning.obj src/lowlevel.obj src/string.obj src/text.obj src/unicode.obj src/widget/box.obj src/widget/button.obj src/widget/checkbox.obj src/widget/combobox.obj src/widget/entry.obj src/widget/frame.obj src/widget/image.obj src/widget/label.obj src/widget/listbox.obj src/widget/menu.obj src/widget/numberentry.obj src/widget/opengl.obj src/widget/progressbar.obj src/widget/radiobox.obj src/widget/scrollbar.obj src/widget/separator.obj src/widget/submenu.obj src/widget/treeview.obj src/widget/viewport.obj src/widget/window.obj
|
||||
$(LD) $(LDFLAGS) option implib=src/Mw.lib name $@ file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/abstract/directory.obj file src/abstract/dynamic.obj file src/abstract/time.obj file src/backend/gdi.obj file src/color.obj file src/core.obj file src/cursor/arrow.obj file src/cursor/cross.obj file src/cursor/default.obj file src/cursor/hidden.obj file src/cursor/text.obj file src/default.obj file src/dialog/colorpicker.obj file src/dialog/directorychooser.obj file src/dialog/filechooser.obj file src/dialog/messagebox.obj file src/draw.obj file src/error.obj file src/font/boldfont.obj file src/font/boldttf.obj file src/font/font.obj file src/font/ttf.obj file src/icon/back.obj file src/icon/clock.obj file src/icon/computer.obj file src/icon/directory.obj file src/icon/down.obj file src/icon/error.obj file src/icon/file.obj file src/icon/forward.obj file src/icon/info.obj file src/icon/left.obj file src/icon/news.obj file src/icon/note.obj file src/icon/right.obj file src/icon/search.obj file src/icon/up.obj file src/icon/warning.obj file src/lowlevel.obj file src/string.obj file src/text.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.obj file src/widget/checkbox.obj file src/widget/combobox.obj file src/widget/entry.obj file src/widget/frame.obj file src/widget/image.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/menu.obj file src/widget/numberentry.obj file src/widget/opengl.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/widget/scrollbar.obj file src/widget/separator.obj file src/widget/submenu.obj file src/widget/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library user32.lib
|
||||
|
||||
|
||||
|
||||
external/libz/src/adler32.obj: external/libz/src/adler32.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/compress.obj: external/libz/src/compress.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/crc32.obj: external/libz/src/crc32.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/deflate.obj: external/libz/src/deflate.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/gzclose.obj: external/libz/src/gzclose.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/gzlib.obj: external/libz/src/gzlib.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/gzread.obj: external/libz/src/gzread.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/gzwrite.obj: external/libz/src/gzwrite.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/infback.obj: external/libz/src/infback.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/inffast.obj: external/libz/src/inffast.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/inflate.obj: external/libz/src/inflate.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/inftrees.obj: external/libz/src/inftrees.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/trees.obj: external/libz/src/trees.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/uncompr.obj: external/libz/src/uncompr.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/libz/src/zutil.obj: external/libz/src/zutil.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/stb_ds.obj: external/stb_ds.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
external/stb_image.obj: external/stb_image.c
|
||||
|
|
@ -166,6 +118,16 @@ src/dialog/messagebox.obj: src/dialog/messagebox.c
|
|||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/draw.obj: src/draw.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/error.obj: src/error.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/font/boldfont.obj: src/font/boldfont.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/font/boldttf.obj: src/font/boldttf.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/font/font.obj: src/font/font.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/font/ttf.obj: src/font/ttf.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/icon/back.obj: src/icon/back.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/icon/clock.obj: src/icon/clock.c
|
||||
|
|
@ -202,23 +164,7 @@ src/lowlevel.obj: src/lowlevel.c
|
|||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/string.obj: src/string.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/font/boldfont.obj: src/text/font/boldfont.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/font/boldmonottf.obj: src/text/font/boldmonottf.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/font/boldttf.obj: src/text/font/boldttf.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/font/font.obj: src/text/font/font.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/font/monottf.obj: src/text/font/monottf.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/font/ttf.obj: src/text/font/ttf.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/ft2.obj: src/text/ft2.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/stbtt.obj: src/text/stbtt.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/text/text.obj: src/text/text.c
|
||||
src/text.obj: src/text.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
src/unicode.obj: src/unicode.c
|
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
# Tiny Config
|
||||
|
||||
Milsko's configure script supports the `--tiny` option for building the tiniest possible Milsko library (~400kb as of writing). Currently, what it does is:
|
||||
|
||||
- Add `-Oz` to the cflags
|
||||
- (clang only) add `-flto=thin` to the cflags and linker flags
|
||||
- Build stb-image with `STB_IMAGE_STATIC` (this is why you get warnings with stb_image when you use it)
|
||||
- Disable the Wayland backend
|
||||
|
|
@ -1,7 +1 @@
|
|||
add_subdirectory(basic)
|
||||
if(${MW_TRY_OPENGL})
|
||||
add_subdirectory(gldemos)
|
||||
endif()
|
||||
if(${MW_TRY_VULKAN})
|
||||
add_subdirectory(vkdemos)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@ file(
|
|||
|
||||
foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES)
|
||||
get_filename_component(TARGET ${PATH} NAME_WE)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Retro)
|
||||
add_application(${TARGET} ${PATH})
|
||||
else()
|
||||
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
|
||||
endif()
|
||||
add_executable(${TARGET} ${PATH})
|
||||
target_link_libraries(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
|
|
|
|||
|
|
@ -1,185 +0,0 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
MwWidget widgets[18];
|
||||
MwWidget inp;
|
||||
|
||||
/* probably enough for most tasks */
|
||||
double stack[512];
|
||||
int sp = 0;
|
||||
|
||||
static void resize(MwWidget handle, void* client, void* user) {
|
||||
int ww = MwGetInteger(handle, MwNwidth);
|
||||
int wh = MwGetInteger(handle, MwNheight) - MwGetInteger(inp, MwNheight);
|
||||
int i;
|
||||
|
||||
MwVaApply(inp,
|
||||
MwNwidth, ww,
|
||||
NULL);
|
||||
|
||||
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) {
|
||||
int x = i % 4;
|
||||
int y = i / 4;
|
||||
if(widgets[i] != NULL) {
|
||||
MwVaApply(widgets[i],
|
||||
MwNwidth, ww / 4,
|
||||
MwNheight, wh / 5,
|
||||
MwNx, ww / 4 * x,
|
||||
MwNy, wh / 5 * y + MwGetInteger(inp, MwNheight),
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void activate(MwWidget handle, void* client, void* user) {
|
||||
const char* n = MwGetText(handle, MwNtext);
|
||||
|
||||
if(('0' <= n[0] && n[0] <= '9') || n[0] == '.') {
|
||||
const char* s = MwGetText(inp, MwNtext);
|
||||
char* r;
|
||||
|
||||
if(n[0] == '.' && s != NULL) {
|
||||
int i;
|
||||
for(i = 0; s[i] != 0; i++) {
|
||||
if(s[i] == '.') return;
|
||||
}
|
||||
}
|
||||
|
||||
if(s == NULL) s = "";
|
||||
|
||||
r = MwStringConcat(s, n);
|
||||
MwVaApply(inp,
|
||||
MwNtext, r,
|
||||
NULL);
|
||||
free(r);
|
||||
} else if(n[0] == 'E') {
|
||||
const char* s = MwGetText(inp, MwNtext);
|
||||
|
||||
if(s != NULL) {
|
||||
stack[sp++] = atof(s);
|
||||
|
||||
MwVaApply(inp,
|
||||
MwNtext, "",
|
||||
NULL);
|
||||
}
|
||||
} else if(n[0] == 'C') {
|
||||
MwVaApply(inp,
|
||||
MwNtext, "",
|
||||
NULL);
|
||||
} else if(n[0] == '+' || n[0] == '-' || n[0] == '*' || n[0] == '/') {
|
||||
if(sp >= 2) {
|
||||
double sv = stack[--sp];
|
||||
double fv = stack[--sp];
|
||||
double v;
|
||||
char buf[256];
|
||||
|
||||
if(n[0] == '+') {
|
||||
v = fv + sv;
|
||||
} else if(n[0] == '-') {
|
||||
v = fv - sv;
|
||||
} else if(n[0] == '*') {
|
||||
v = fv * sv;
|
||||
} else if(n[0] == '/') {
|
||||
v = fv / sv;
|
||||
}
|
||||
|
||||
MwStringPrintIntoBuffer(buf, 256, "%g", v);
|
||||
|
||||
MwVaApply(inp,
|
||||
MwNtext, buf,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
MwWidget w;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) widgets[i] = NULL;
|
||||
|
||||
MwLibraryInit();
|
||||
|
||||
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 150, 150,
|
||||
MwNtitle, "Calculator",
|
||||
NULL);
|
||||
|
||||
inp = MwCreateWidget(MwEntryClass, "entry", w, 0, 0, 0, 24);
|
||||
|
||||
widgets[0] = MwVaCreateWidget(MwButtonClass, "7", w, 0, 0, 0, 0,
|
||||
MwNtext, "7",
|
||||
NULL);
|
||||
|
||||
widgets[1] = MwVaCreateWidget(MwButtonClass, "8", w, 0, 0, 0, 0,
|
||||
MwNtext, "8",
|
||||
NULL);
|
||||
|
||||
widgets[2] = MwVaCreateWidget(MwButtonClass, "9", w, 0, 0, 0, 0,
|
||||
MwNtext, "9",
|
||||
NULL);
|
||||
|
||||
widgets[3] = MwVaCreateWidget(MwButtonClass, "/", w, 0, 0, 0, 0,
|
||||
MwNtext, "/",
|
||||
NULL);
|
||||
|
||||
widgets[4] = MwVaCreateWidget(MwButtonClass, "4", w, 0, 0, 0, 0,
|
||||
MwNtext, "4",
|
||||
NULL);
|
||||
|
||||
widgets[5] = MwVaCreateWidget(MwButtonClass, "5", w, 0, 0, 0, 0,
|
||||
MwNtext, "5",
|
||||
NULL);
|
||||
|
||||
widgets[6] = MwVaCreateWidget(MwButtonClass, "6", w, 0, 0, 0, 0,
|
||||
MwNtext, "6",
|
||||
NULL);
|
||||
|
||||
widgets[7] = MwVaCreateWidget(MwButtonClass, "*", w, 0, 0, 0, 0,
|
||||
MwNtext, "*",
|
||||
NULL);
|
||||
|
||||
widgets[8] = MwVaCreateWidget(MwButtonClass, "1", w, 0, 0, 0, 0,
|
||||
MwNtext, "1",
|
||||
NULL);
|
||||
|
||||
widgets[9] = MwVaCreateWidget(MwButtonClass, "2", w, 0, 0, 0, 0,
|
||||
MwNtext, "2",
|
||||
NULL);
|
||||
|
||||
widgets[10] = MwVaCreateWidget(MwButtonClass, "3", w, 0, 0, 0, 0,
|
||||
MwNtext, "3",
|
||||
NULL);
|
||||
|
||||
widgets[11] = MwVaCreateWidget(MwButtonClass, "-", w, 0, 0, 0, 0,
|
||||
MwNtext, "-",
|
||||
NULL);
|
||||
|
||||
widgets[12] = MwVaCreateWidget(MwButtonClass, "0", w, 0, 0, 0, 0,
|
||||
MwNtext, "0",
|
||||
NULL);
|
||||
|
||||
widgets[13] = MwVaCreateWidget(MwButtonClass, ".", w, 0, 0, 0, 0,
|
||||
MwNtext, ".",
|
||||
NULL);
|
||||
|
||||
widgets[16] = MwVaCreateWidget(MwButtonClass, "E", w, 0, 0, 0, 0,
|
||||
MwNtext, "E",
|
||||
NULL);
|
||||
|
||||
widgets[15] = MwVaCreateWidget(MwButtonClass, "+", w, 0, 0, 0, 0,
|
||||
MwNtext, "+",
|
||||
NULL);
|
||||
|
||||
widgets[17] = MwVaCreateWidget(MwButtonClass, "C", w, 0, 0, 0, 0,
|
||||
MwNtext, "C",
|
||||
NULL);
|
||||
|
||||
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) {
|
||||
if(widgets[i] != NULL) MwAddUserHandler(widgets[i], MwNactivateHandler, activate, NULL);
|
||||
}
|
||||
|
||||
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
|
||||
|
||||
resize(w, NULL, NULL);
|
||||
|
||||
MwLoop(w);
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
MwWidget window, instructions, text1, text2, cur_text;
|
||||
|
||||
static void resize(MwWidget handle, void* user_data, void* call_data) {
|
||||
unsigned int w, h;
|
||||
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
w = MwGetInteger(handle, MwNwidth);
|
||||
h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
MwVaApply(instructions,
|
||||
MwNy, 50,
|
||||
MwNwidth, w - 50 * 2,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(text1,
|
||||
MwNy, 150,
|
||||
MwNwidth, w - 25 * 2,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
NULL);
|
||||
MwVaApply(text2,
|
||||
MwNy, 250,
|
||||
MwNwidth, w - 25 * 2,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
NULL);
|
||||
}
|
||||
static void clipboard(MwWidget handle, void* user_data, void* call_data) {
|
||||
char* clipboard = call_data;
|
||||
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
|
||||
if(clipboard != NULL) {
|
||||
MwVaApply(cur_text, MwNtext, clipboard, NULL);
|
||||
MwForceRender(cur_text);
|
||||
}
|
||||
}
|
||||
|
||||
static void tick(MwWidget handle, void* user_data, void* call_data) {
|
||||
cur_text = text1;
|
||||
MwGetClipboard(handle, MwCLIPBOARD_MAIN);
|
||||
cur_text = text2;
|
||||
MwGetClipboard(handle, MwCLIPBOARD_PRIMARY);
|
||||
MwForceRender(window);
|
||||
}
|
||||
|
||||
int main() {
|
||||
MwLibraryInit();
|
||||
|
||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 400, 400,
|
||||
MwNtitle, "clipboard",
|
||||
NULL);
|
||||
instructions = MwVaCreateWidget(MwLabelClass, "button", window, 50, 50, 300, 125,
|
||||
MwNtext, "clipboard contents will show up below.",
|
||||
NULL);
|
||||
text1 = MwVaCreateWidget(MwLabelClass, "label", window, 25, 150, 300, 75,
|
||||
MwNtext, "",
|
||||
NULL);
|
||||
text2 = MwVaCreateWidget(MwLabelClass, "label2", window, 25, 250, 300, 75,
|
||||
MwNtext, "",
|
||||
NULL);
|
||||
|
||||
cur_text = text1;
|
||||
|
||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||
MwAddUserHandler(window, MwNclipboardHandler, clipboard, NULL);
|
||||
MwAddUserHandler(instructions, MwNclipboardHandler, clipboard, NULL);
|
||||
MwAddUserHandler(cur_text, MwNclipboardHandler, clipboard, NULL);
|
||||
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
|
||||
|
||||
resize(window, NULL, NULL);
|
||||
|
||||
MwLoop(window);
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
MwWidget cpicker;
|
||||
|
|
@ -14,7 +15,7 @@ void color_callback(MwWidget handle, void* user_data, void* call_data) {
|
|||
rgb->red &= 0xff;
|
||||
rgb->green &= 0xff;
|
||||
rgb->blue &= 0xff;
|
||||
MwStringPrintIntoBuffer(hexColor, 8, "#%02X%02X%02X", rgb->red, rgb->green, rgb->blue);
|
||||
sprintf(hexColor, "#%02X%02X%02X", rgb->red, rgb->green, rgb->blue);
|
||||
MwSetText(window, MwNbackground, hexColor);
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ void color_picker(MwWidget handle, void* user_data, void* call_data) {
|
|||
|
||||
MwAddUserHandler(cpicker, MwNcolorChosenHandler, color_callback, NULL);
|
||||
|
||||
MwSetText(cpicker, MwNbackground, MwGetInteger(cpicker, MwNdarkTheme) ? MwDefaultDarkBackground : MwDefaultBackground);
|
||||
MwSetText(cpicker, MwNbackground, MwDefaultBackground);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
@ -35,12 +36,12 @@ int main() {
|
|||
|
||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
|
||||
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
|
||||
MwSetText(window, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
|
||||
MwSetText(window, MwNbackground, "#000000");
|
||||
|
||||
button = MwVaCreateWidget(MwButtonClass, "button", window, 160, 180, 320, 120,
|
||||
MwNtext, "change window background",
|
||||
NULL);
|
||||
MwSetText(button, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
|
||||
MwSetText(button, MwNbackground, MwDefaultBackground);
|
||||
|
||||
MwAddUserHandler(button, MwNactivateHandler, color_picker, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
MwWidget window, menu, button, button2, button3, button4, button5, button6;
|
||||
MwWidget window, menu, button, button2, button3, button4;
|
||||
|
||||
void handler(MwWidget handle, void* user_data, void* call_data) {
|
||||
(void)handle;
|
||||
|
|
@ -10,34 +10,14 @@ void handler(MwWidget handle, void* user_data, void* call_data) {
|
|||
printf("hello world!\n");
|
||||
}
|
||||
|
||||
void handler_theme(MwWidget handle, void* user_data, void* call_data) {
|
||||
int toggle = 0;
|
||||
void handler_dark(MwWidget handle, void* user_data, void* call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
MwVaApply(window,
|
||||
MwNdarkTheme, MwGetInteger(window, MwNdarkTheme) == 0 ? 1 : 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void handler_look(MwWidget handle, void* user_data, void* call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
MwVaApply(window,
|
||||
MwNmodernLook, MwGetInteger(window, MwNmodernLook) == 0 ? 1 : 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void handler_font(MwWidget handle, void* user_data, void* call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
MwVaApply(window,
|
||||
MwNbitmapFont, MwGetInteger(window, MwNbitmapFont) == 0 ? 1 : 0,
|
||||
NULL);
|
||||
toggle = toggle ? 0 : 1;
|
||||
MwToggleDarkTheme(window, toggle);
|
||||
}
|
||||
|
||||
void resize(MwWidget handle, void* user_data, void* call_data) {
|
||||
|
|
@ -51,37 +31,23 @@ void resize(MwWidget handle, void* user_data, void* call_data) {
|
|||
|
||||
MwVaApply(button,
|
||||
MwNy, 50 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
MwNwidth, w - 50 * 2,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(button2,
|
||||
MwNx, 50 + (w - 50 * 2) / 3,
|
||||
MwNy, 50 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(button3,
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 2,
|
||||
MwNy, 50 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(button4,
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 0,
|
||||
MwNy, h - 50 - 125 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(button5,
|
||||
MwVaApply(button3,
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 1,
|
||||
MwNy, h - 50 - 125 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(button6,
|
||||
MwVaApply(button4,
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 2,
|
||||
MwNy, h - 50 - 125 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
|
|
@ -97,38 +63,30 @@ int main() {
|
|||
MwNtitle, "hello world",
|
||||
NULL);
|
||||
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
|
||||
button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 100, 125,
|
||||
MwNtext, "theme",
|
||||
button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 125,
|
||||
MwNtext, "toggle dark theme",
|
||||
NULL);
|
||||
button2 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 50, 100, 125,
|
||||
MwNtext, "look",
|
||||
NULL);
|
||||
button3 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 50, 100, 125,
|
||||
MwNtext, "font",
|
||||
NULL);
|
||||
button4 = MwVaCreateWidget(MwButtonClass, "button", window, 50, 225, 100, 125,
|
||||
button2 = MwVaCreateWidget(MwButtonClass, "button", window, 50, 225, 100, 125,
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#f66",
|
||||
MwNforeground, "#000",
|
||||
NULL);
|
||||
button5 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 225, 100, 125,
|
||||
button3 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 225, 100, 125,
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#6f6",
|
||||
MwNforeground, "#000",
|
||||
NULL);
|
||||
button6 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 225, 100, 125,
|
||||
button4 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 225, 100, 125,
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#66f",
|
||||
MwNforeground, "#000",
|
||||
NULL);
|
||||
|
||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||
MwAddUserHandler(button, MwNactivateHandler, handler_theme, NULL);
|
||||
MwAddUserHandler(button2, MwNactivateHandler, handler_look, NULL);
|
||||
MwAddUserHandler(button3, MwNactivateHandler, handler_font, NULL);
|
||||
MwAddUserHandler(button, MwNactivateHandler, handler_dark, NULL);
|
||||
MwAddUserHandler(button2, MwNactivateHandler, handler, NULL);
|
||||
MwAddUserHandler(button3, MwNactivateHandler, handler, NULL);
|
||||
MwAddUserHandler(button4, MwNactivateHandler, handler, NULL);
|
||||
MwAddUserHandler(button5, MwNactivateHandler, handler, NULL);
|
||||
MwAddUserHandler(button6, MwNactivateHandler, handler, NULL);
|
||||
|
||||
resize(window, NULL, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ void activate(MwWidget handle, void* user, void* call) {
|
|||
|
||||
(void)user;
|
||||
|
||||
MwStringPrintIntoBuffer(msg, 256, "You pressed: %s", MwListBoxGet(handle, *(int*)call));
|
||||
sprintf(msg, "You pressed: %s", MwListBoxGet(handle, *(int*)call));
|
||||
|
||||
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
|
||||
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
|
||||
|
|
@ -48,7 +48,7 @@ int main() {
|
|||
|
||||
for(i = 0; i < len; i++) {
|
||||
char sz[16];
|
||||
MwStringPrintIntoBuffer(sz, 16, "%d", (int)strlen(harvard[i]));
|
||||
sprintf(sz, "%d", (int)strlen(harvard[i]));
|
||||
index = MwListBoxPacketInsert(packet, -1);
|
||||
MwListBoxPacketSetIcon(packet, index, px);
|
||||
MwListBoxPacketSet(packet, index, 0, harvard[i]);
|
||||
|
|
|
|||
|
|
@ -1,285 +0,0 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define Columns 5
|
||||
#define Padding 20
|
||||
#define PaddingContent 2
|
||||
|
||||
MwWidget window, menu, box;
|
||||
MwWidget boxes[32];
|
||||
int n = 0, row = -1;
|
||||
MwMenu e;
|
||||
|
||||
static void resize(MwWidget handle, void* user, void* call) {
|
||||
int w = MwGetInteger(window, MwNwidth);
|
||||
int h = MwGetInteger(window, MwNheight);
|
||||
|
||||
MwVaApply(box,
|
||||
MwNx, Padding,
|
||||
MwNy, MwGetInteger(menu, MwNheight) + Padding,
|
||||
MwNwidth, w - Padding * 2,
|
||||
MwNheight, h - MwGetInteger(menu, MwNheight) - Padding * 2,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void newrow(void) {
|
||||
if(row >= 0) {
|
||||
int i;
|
||||
|
||||
for(i = n; i < Columns; i++) MwCreateWidget(MwFrameClass, "frame", boxes[row], 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
boxes[++row] = MwCreateWidget(MwBoxClass, "box", box, 0, 0, 0, 0);
|
||||
|
||||
n = 0;
|
||||
}
|
||||
|
||||
static void add(MwWidget w) {
|
||||
int r = MwGetInteger(w, MwNratio);
|
||||
|
||||
if(r == MwDEFAULT) r = 1;
|
||||
|
||||
n += r;
|
||||
|
||||
if(n == Columns) {
|
||||
newrow();
|
||||
}
|
||||
}
|
||||
|
||||
static void resize_content(MwWidget handle, void* user, void* call) {
|
||||
MwWidget* ws = MwGetChildren(handle);
|
||||
if(ws != NULL) {
|
||||
int pw = MwGetInteger(ws[0], "IpWidth");
|
||||
int ph = MwGetInteger(ws[0], "IpHeight");
|
||||
|
||||
if(pw < 0) {
|
||||
pw += MwGetInteger(handle, MwNwidth);
|
||||
} else if(pw == 0) {
|
||||
pw = MwGetInteger(handle, MwNwidth);
|
||||
}
|
||||
|
||||
if(ph < 0) {
|
||||
ph += MwGetInteger(handle, MwNheight);
|
||||
} else if(ph == 0) {
|
||||
ph = MwGetInteger(handle, MwNheight);
|
||||
}
|
||||
|
||||
MwVaApply(ws[0],
|
||||
MwNx, (MwGetInteger(handle, MwNwidth) - pw) / 2,
|
||||
MwNy, (MwGetInteger(handle, MwNheight) - ph) / 2,
|
||||
MwNwidth, pw,
|
||||
MwNheight, ph,
|
||||
NULL);
|
||||
|
||||
free(ws);
|
||||
}
|
||||
}
|
||||
|
||||
static void resize_frame(MwWidget handle, void* user, void* call) {
|
||||
MwWidget* ws = MwGetChildren(handle);
|
||||
if(ws != NULL) {
|
||||
int w = MwGetInteger(handle, MwNwidth);
|
||||
int h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
if(ws[0] != NULL) {
|
||||
MwVaApply(ws[0],
|
||||
MwNx, MwDefaultBorderWidth(handle) + PaddingContent,
|
||||
MwNy, MwDefaultBorderWidth(handle) + PaddingContent,
|
||||
MwNwidth, w - (MwDefaultBorderWidth(handle) + PaddingContent) * 2,
|
||||
MwNheight, h - (MwDefaultBorderWidth(handle) + PaddingContent) * 2,
|
||||
NULL);
|
||||
}
|
||||
free(ws);
|
||||
}
|
||||
}
|
||||
|
||||
static MwWidget frame(const char* name, int width, int height, MwClass cl, ...) {
|
||||
MwWidget f = MwVaCreateWidget(MwFrameClass, "frame", boxes[row], 0, 0, 0, 0,
|
||||
MwNhasBorder, 1,
|
||||
MwNinverted, 1,
|
||||
NULL);
|
||||
MwWidget box = MwVaCreateWidget(MwBoxClass, "box", f, 0, 0, 0, 0,
|
||||
MwNorientation, MwVERTICAL,
|
||||
NULL);
|
||||
MwWidget label = MwVaCreateWidget(MwLabelClass, "label", box, 0, 0, 0, 0,
|
||||
MwNtext, name,
|
||||
MwNalignment, MwALIGNMENT_BEGINNING,
|
||||
MwNfixedSize, 20,
|
||||
NULL);
|
||||
va_list va;
|
||||
|
||||
if(cl != NULL) {
|
||||
MwWidget frame = MwCreateWidget(MwFrameClass, "frame", box, 0, 0, 0, 0);
|
||||
MwWidget w;
|
||||
|
||||
va_start(va, cl);
|
||||
w = MwVaListCreateWidget(cl, "widget", frame, 0, 0, 0, 0, va);
|
||||
va_end(va);
|
||||
|
||||
MwVaApply(w,
|
||||
"IpWidth", width,
|
||||
"IpHeight", height,
|
||||
NULL);
|
||||
|
||||
MwAddUserHandler(frame, MwNresizeHandler, resize_content, NULL);
|
||||
|
||||
MwVaApply(f,
|
||||
"VhandledWidget", w,
|
||||
NULL);
|
||||
}
|
||||
|
||||
MwAddUserHandler(f, MwNresizeHandler, resize_frame, NULL);
|
||||
|
||||
resize_frame(f, NULL, NULL);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
static MwWidget child(MwWidget w) {
|
||||
return MwGetVoid(w, "VhandledWidget");
|
||||
}
|
||||
|
||||
static void menu_handler(MwWidget handle, void* user, void* call) {
|
||||
if(call == e) MwDestroyWidget(window);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
MwWidget f, w;
|
||||
MwListBoxPacket* pkt;
|
||||
int index;
|
||||
MwMenu m, m2;
|
||||
void* v;
|
||||
|
||||
MwLibraryInit();
|
||||
|
||||
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 800, 800,
|
||||
MwNtitle, "Milsko Periodic Table",
|
||||
NULL);
|
||||
|
||||
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "File");
|
||||
MwMenuAdd(menu, m, "New");
|
||||
MwMenuAdd(menu, m, "Open");
|
||||
MwMenuAdd(menu, m, "Save");
|
||||
MwMenuAdd(menu, m, "Save As");
|
||||
MwMenuAdd(menu, m, "Print");
|
||||
e = MwMenuAdd(menu, m, "Exit");
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "Edit");
|
||||
MwMenuAdd(menu, m, "Undo");
|
||||
MwMenuAdd(menu, m, "----");
|
||||
MwMenuAdd(menu, m, "Cut");
|
||||
MwMenuAdd(menu, m, "Copy");
|
||||
MwMenuAdd(menu, m, "Paste");
|
||||
MwMenuAdd(menu, m, "----");
|
||||
MwMenuAdd(menu, m, "Clear");
|
||||
MwMenuAdd(menu, m, "Delete");
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "View");
|
||||
MwMenuAdd(menu, m, "Stack");
|
||||
MwMenuAdd(menu, m, "Tile");
|
||||
MwMenuAdd(menu, m, "----");
|
||||
MwMenuAdd(menu, m, "Day");
|
||||
MwMenuAdd(menu, m, "Week");
|
||||
MwMenuAdd(menu, m, "Month");
|
||||
MwMenuAdd(menu, m, "Year");
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "Options");
|
||||
m2 = MwMenuAdd(menu, m, "Font");
|
||||
MwMenuAdd(menu, m2, "Small");
|
||||
MwMenuAdd(menu, m2, "Medium");
|
||||
MwMenuAdd(menu, m2, "Large");
|
||||
m2 = MwMenuAdd(menu, m, "Direction");
|
||||
MwMenuAdd(menu, m2, "Up");
|
||||
MwMenuAdd(menu, m2, "Down");
|
||||
MwMenuAdd(menu, m2, "Left");
|
||||
MwMenuAdd(menu, m2, "Right");
|
||||
MwMenuAdd(menu, m, "Case Sensitive");
|
||||
MwMenuAdd(menu, m, "Word Wrap");
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "?Help");
|
||||
MwMenuAdd(menu, m, "On Context");
|
||||
MwMenuAdd(menu, m, "On Window");
|
||||
MwMenuAdd(menu, m, "Tutorial");
|
||||
MwMenuAdd(menu, m, "On Version");
|
||||
|
||||
MwAddUserHandler(menu, MwNmenuHandler, menu_handler, NULL);
|
||||
|
||||
box = MwVaCreateWidget(MwBoxClass, "box", window, 0, 0, 0, 0,
|
||||
MwNorientation, MwVERTICAL,
|
||||
NULL);
|
||||
|
||||
newrow();
|
||||
|
||||
f = frame("Button", -PaddingContent, -PaddingContent, MwButtonClass,
|
||||
MwNtext, "Press me",
|
||||
NULL);
|
||||
add(f);
|
||||
|
||||
add(MwVaCreateWidget(MwLabelClass, "label", boxes[row], 0, 0, 0, 0,
|
||||
MwNbold, 1,
|
||||
MwNtext, "The Periodic Table of Milsko Widgets",
|
||||
MwNratio, Columns - 2,
|
||||
NULL));
|
||||
|
||||
f = frame("ComboBox", -PaddingContent, 24, MwComboBoxClass, NULL);
|
||||
w = child(f);
|
||||
MwComboBoxAdd(w, -1, "Hello!");
|
||||
add(f);
|
||||
|
||||
f = frame("Entry", -PaddingContent, 24, MwEntryClass, NULL);
|
||||
add(f);
|
||||
|
||||
f = frame("Label", -PaddingContent, -PaddingContent, MwLabelClass,
|
||||
MwNtext, "Epic text",
|
||||
NULL);
|
||||
add(f);
|
||||
|
||||
f = frame("ListBox", -PaddingContent, -PaddingContent, MwListBoxClass,
|
||||
MwNhasHeading, 1,
|
||||
NULL);
|
||||
w = child(f);
|
||||
pkt = MwListBoxCreatePacket();
|
||||
index = MwListBoxPacketInsert(pkt, -1);
|
||||
MwListBoxPacketSet(pkt, index, 0, "Epic title...");
|
||||
index = MwListBoxPacketInsert(pkt, -1);
|
||||
MwListBoxPacketSet(pkt, index, 0, "Hello");
|
||||
MwListBoxInsert(w, -1, pkt);
|
||||
MwListBoxDestroyPacket(pkt);
|
||||
add(f);
|
||||
|
||||
f = frame("NumberEntry", -PaddingContent, 24, MwNumberEntryClass, NULL);
|
||||
add(f);
|
||||
|
||||
f = frame("ProgressBar", -PaddingContent, 24, MwProgressBarClass,
|
||||
MwNvalue, 25,
|
||||
NULL);
|
||||
add(f);
|
||||
|
||||
f = frame("ScrollBar", -PaddingContent, 16, MwScrollBarClass,
|
||||
MwNorientation, MwHORIZONTAL,
|
||||
NULL);
|
||||
add(f);
|
||||
|
||||
f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL);
|
||||
add(f);
|
||||
|
||||
f = frame("TreeView", -PaddingContent, -PaddingContent, MwTreeViewClass, NULL);
|
||||
w = child(f);
|
||||
v = MwTreeViewAdd(w, NULL, NULL, "abc");
|
||||
v = MwTreeViewAdd(w, v, NULL, "def");
|
||||
v = MwTreeViewAdd(w, v, NULL, "ghi");
|
||||
add(f);
|
||||
|
||||
if(n != 0) newrow();
|
||||
if(n == 0) MwDestroyWidget(boxes[row]);
|
||||
|
||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||
|
||||
resize(window, NULL, NULL);
|
||||
|
||||
MwLoop(window);
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
int main() {
|
||||
MwWidget wnd, label;
|
||||
int W = 480, H = 40;
|
||||
|
||||
MwLibraryInit();
|
||||
|
||||
wnd = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, W, H,
|
||||
MwNtitle, "seven segment",
|
||||
NULL);
|
||||
|
||||
label = MwVaCreateWidget(MwLabelClass, "label", wnd, 0, 0, W, H,
|
||||
MwNtext, " 123456:78.90 abcdef",
|
||||
MwNsevenSegment, 1,
|
||||
MwNalignment, MwALIGNMENT_BEGINNING,
|
||||
MwNlength, 8,
|
||||
NULL);
|
||||
|
||||
MwLabelSetSevenSegment(label, 0, (1 << 0) | (1 << 3) | (1 << 6));
|
||||
|
||||
MwLoop(wnd);
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ void activate(MwWidget handle, void* user, void* call) {
|
|||
|
||||
(void)user;
|
||||
|
||||
MwStringPrintIntoBuffer(msg, 256, "You pressed: %s", MwTreeViewGet(handle, call));
|
||||
sprintf(msg, "You pressed: %s", MwTreeViewGet(handle, call));
|
||||
|
||||
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
|
||||
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
file(
|
||||
GLOB
|
||||
EXAMPLES_GL_SOURCES
|
||||
*.c
|
||||
)
|
||||
find_package(OpenGL)
|
||||
|
||||
foreach(PATH IN LISTS EXAMPLES_GL_SOURCES)
|
||||
get_filename_component(TARGET ${PATH} NAME_WE)
|
||||
if(${TARGET} STREQUAL "glutlayer")
|
||||
continue()
|
||||
endif()
|
||||
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
|
||||
target_link_libraries(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
Mw
|
||||
OpenGL::GL OpenGL::GLU
|
||||
)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_link_libraries(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
m
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
|
@ -32,10 +32,10 @@ void tick(MwWidget handle, void* user, void* call) {
|
|||
char buf[512];
|
||||
tm = localtime(&t);
|
||||
|
||||
MwStringPrintIntoBuffer(buf, 512, "%s %02d %s", mon[tm->tm_mon], tm->tm_mday, wday[tm->tm_wday]);
|
||||
sprintf(buf, "%s %02d %s", mon[tm->tm_mon], tm->tm_mday, wday[tm->tm_wday]);
|
||||
MwSetText(ldate, MwNtext, buf);
|
||||
|
||||
MwStringPrintIntoBuffer(buf, 512, "%02d:%02d %s", tm->tm_hour % 12, tm->tm_min, tm->tm_hour >= 12 ? "PM" : "AM");
|
||||
sprintf(buf, "%02d:%02d %s", tm->tm_hour % 12, tm->tm_min, tm->tm_hour >= 12 ? "PM" : "AM");
|
||||
MwSetText(ltime, MwNtext, buf);
|
||||
|
||||
render = 1;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,7 @@
|
|||
#define TITLE "cube"
|
||||
#include "glutlayer.c"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
static double deg = 0;
|
||||
|
||||
|
|
@ -21,18 +15,12 @@ static void draw(void) {
|
|||
glRotatef(deg, 0, 0, 1);
|
||||
|
||||
for(i = 0; i < 6; i++) {
|
||||
if(i == 0)
|
||||
glColor3f(1, 0, 0);
|
||||
if(i == 1)
|
||||
glColor3f(0, 1, 0);
|
||||
if(i == 2)
|
||||
glColor3f(1, 1, 0);
|
||||
if(i == 3)
|
||||
glColor3f(0, 0, 1);
|
||||
if(i == 4)
|
||||
glColor3f(1, 0, 1);
|
||||
if(i == 5)
|
||||
glColor3f(0, 1, 1);
|
||||
if(i == 0) glColor3f(1, 0, 0);
|
||||
if(i == 1) glColor3f(0, 1, 0);
|
||||
if(i == 2) glColor3f(1, 1, 0);
|
||||
if(i == 3) glColor3f(0, 0, 1);
|
||||
if(i == 4) glColor3f(1, 0, 1);
|
||||
if(i == 5) glColor3f(0, 1, 1);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glNormal3f(0, 1, 0);
|
||||
|
|
@ -42,12 +30,9 @@ static void draw(void) {
|
|||
glVertex3f(1, 1, -1);
|
||||
glEnd();
|
||||
|
||||
if(i < 3)
|
||||
glRotatef(90, 0, 0, 1);
|
||||
if(i == 3)
|
||||
glRotatef(90, 1, 0, 0);
|
||||
if(i == 4)
|
||||
glRotatef(180, 0, 0, 1);
|
||||
if(i < 3) glRotatef(90, 0, 0, 1);
|
||||
if(i == 3) glRotatef(90, 1, 0, 0);
|
||||
if(i == 4) glRotatef(180, 0, 0, 1);
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,12 +51,12 @@ static void tick(MwWidget handle, void* user, void* call) {
|
|||
}
|
||||
|
||||
static void mouse(MwWidget handle, void* user, void* call) {
|
||||
MwMouse* mouse = call;
|
||||
MwLLMouse* mouse = call;
|
||||
|
||||
(void)handle;
|
||||
(void)user;
|
||||
|
||||
if(mouse->button == MwMOUSE_LEFT) {
|
||||
if(mouse->button == MwLLMouseLeft) {
|
||||
t[ct].points[click * 2 + 0] = mouse->point.x;
|
||||
t[ct].points[click * 2 + 1] = mouse->point.y;
|
||||
click++;
|
||||
|
|
@ -82,7 +82,7 @@ static void mouse(MwWidget handle, void* user, void* call) {
|
|||
for(i = 0; i < ct; i++) t[i] = old[i];
|
||||
free(old);
|
||||
}
|
||||
} else if(mouse->button == MwMOUSE_RIGHT) {
|
||||
} else if(mouse->button == MwLLMouseRight) {
|
||||
if(click > 0) {
|
||||
click = 0;
|
||||
} else if(ct > 0) {
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
file(
|
||||
GLOB
|
||||
EXAMPLES_VULKAN_SOURCES
|
||||
*.c
|
||||
)
|
||||
find_package(Vulkan)
|
||||
|
||||
foreach(PATH IN LISTS EXAMPLES_VULKAN_SOURCES)
|
||||
get_filename_component(TARGET ${PATH} NAME_WE)
|
||||
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
|
||||
target_include_directories(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
${Vulkan_INCLUDE_DIR}
|
||||
)
|
||||
target_link_libraries(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
Mw
|
||||
)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_link_libraries(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
m
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
* ioixd maintains this file. nishi doesn't know vulkan at all
|
||||
*/
|
||||
|
||||
#include "Mw/Error.h"
|
||||
#include <Mw/Milsko.h>
|
||||
#include <Mw/Widget/Vulkan.h>
|
||||
|
||||
|
|
@ -16,7 +17,7 @@
|
|||
char buffer[512];
|
||||
|
||||
char* string_VkResult(VkResult res) {
|
||||
MwStringPrintIntoBuffer(buffer, 512, "%d", res);
|
||||
sprintf(buffer, "%d", res);
|
||||
|
||||
return &buffer[0];
|
||||
}
|
||||
|
|
@ -26,8 +27,6 @@ MwWidget window, vulkan;
|
|||
int ow = 300;
|
||||
int oh = 250;
|
||||
|
||||
double timer = 0;
|
||||
|
||||
PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr;
|
||||
VkInstance instance;
|
||||
VkDevice device;
|
||||
|
|
@ -76,10 +75,9 @@ void tick(MwWidget handle, void* user_data, void* call_data) {
|
|||
VkSubmitInfo submitInfo = {};
|
||||
VkPresentInfoKHR presentInfo = {};
|
||||
|
||||
VkClearValue clearColor = {{{sin(timer) / 10., cos(timer) / 10., atan(timer) / 10., 1.0f}}};
|
||||
VkClearValue clearColor = {{{0.0f, 0.0f, 0.0f, 1.0f}}};
|
||||
uint32_t vertexCount = 3;
|
||||
uint32_t instanceCount = 1;
|
||||
timer += (float)(rand() % 1000) / 1000.;
|
||||
|
||||
VkPipelineStageFlags waitStages[] = {VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT};
|
||||
|
||||
|
|
@ -231,16 +229,43 @@ void vulkan_setup(MwWidget handle) {
|
|||
VkSemaphoreCreateInfo semaphoreInfo = {};
|
||||
VkFenceCreateInfo fenceInfo = {};
|
||||
|
||||
int err = 0;
|
||||
_vkGetInstanceProcAddr = MwVulkanGetField(handle, MwVULKANFIELD_GETINSTANCEPROCADDR, &err);
|
||||
instance = MwVulkanGetField(handle, MwVULKANFIELD_INSTANCE, &err);
|
||||
device = MwVulkanGetField(handle, MwVULKANFIELD_LOGICALDEVICE, &err);
|
||||
physicalDevice = MwVulkanGetField(handle, MwVULKANFIELD_PHYSICALDEVICE, &err);
|
||||
graphicsQueue = MwVulkanGetField(handle, MwVULKANFIELD_GRAPHICSQUEUE, &err);
|
||||
presentQueue = MwVulkanGetField(handle, MwVULKANFIELD_PRESENTQUEUE, &err);
|
||||
surface = MwVulkanGetField(handle, MwVULKANFIELD_SURFACE, &err);
|
||||
presentQueueIndex = MwVulkanGetField(handle, MwVULKANFIELD_PRESENTQUEUEINDEX, &err);
|
||||
graphicsQueueIndex = MwVulkanGetField(handle, MwVULKANFIELD_GRAPHICSQUEUEINDEX, &err);
|
||||
MwErrorEnum err = MwEsuccess;
|
||||
_vkGetInstanceProcAddr = MwVulkanGetField(handle, MwVulkanField_GetInstanceProcAddr, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting vkGetInstanceProcAddr!\n%s\n", MwGetLastError());
|
||||
}
|
||||
instance = MwVulkanGetField(handle, MwVulkanField_Instance, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting vulkan instance!\n%s\n", MwGetLastError());
|
||||
}
|
||||
device = MwVulkanGetField(handle, MwVulkanField_LogicalDevice, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting VkDevice!\n%s\n", MwGetLastError());
|
||||
}
|
||||
physicalDevice = MwVulkanGetField(handle, MwVulkanField_PhysicalDevice, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting physical device!\n%s\n", MwGetLastError());
|
||||
}
|
||||
graphicsQueue = MwVulkanGetField(handle, MwVulkanField_GraphicsQueue, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting graphics queue!\n%s\n", MwGetLastError());
|
||||
}
|
||||
presentQueue = MwVulkanGetField(handle, MwVulkanField_PresentQueue, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting present queue!\n%s\n", MwGetLastError());
|
||||
}
|
||||
surface = MwVulkanGetField(handle, MwVulkanField_Surface, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting surface!\n%s\n", MwGetLastError());
|
||||
}
|
||||
presentQueueIndex = MwVulkanGetField(handle, MwVulkanField_PresentQueueIndex, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting present queue index!\n%s\n", MwGetLastError());
|
||||
}
|
||||
graphicsQueueIndex = MwVulkanGetField(handle, MwVulkanField_GraphicsQueueIndex, &err);
|
||||
if(err != MwEsuccess) {
|
||||
printf("Error getting graphics queue index!\n%s\n", MwGetLastError());
|
||||
}
|
||||
|
||||
LOAD_VK_FUNCTION(vkCreateShaderModule);
|
||||
LOAD_VK_FUNCTION(vkCreatePipelineLayout);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ typedef int8_t MwI8;
|
|||
typedef uint8_t MwU8;
|
||||
|
||||
#define MW_OTHER_TYPES_DEFINED
|
||||
#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) || defined(__clang__))
|
||||
#elif __GNUC__ > 2
|
||||
typedef long long MwI64;
|
||||
typedef unsigned long long MwU64;
|
||||
#elif defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
|
||||
|
|
@ -78,8 +78,8 @@ struct _MwPoint {
|
|||
struct _MwRect {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
};
|
||||
|
||||
struct _MwSizeHints {
|
||||
|
|
|
|||
|
|
@ -99,26 +99,4 @@ enum MwMB_ICON {
|
|||
*/
|
||||
#define MwMB_BUTTONYESNOCANCEL (MwMB_BUTTONYES | MwMB_BUTTONNO | MwMB_BUTTONCANCEL)
|
||||
|
||||
/* Whether or not GetXY/SetXY works with global or local coordinates */
|
||||
enum MwCOORDINATE {
|
||||
MwCOORDINATE_GLOBAL = 0,
|
||||
MwCOORDINATE_LOCAL,
|
||||
};
|
||||
|
||||
/* The clipboard type that MwGetClipboard should return */
|
||||
enum MwCLIPBOARD {
|
||||
/* the clipboard that is present on every platform that supports it */
|
||||
MwCLIPBOARD_MAIN = 0,
|
||||
/* the "primary" clipboard that Wayland stores to emulate X11's behavior. */
|
||||
MwCLIPBOARD_PRIMARY,
|
||||
};
|
||||
|
||||
enum MwMOUSE {
|
||||
MwMOUSE_LEFT = 1,
|
||||
MwMOUSE_MIDDLE,
|
||||
MwMOUSE_RIGHT,
|
||||
MwMOUSE_WHEELUP,
|
||||
MwMOUSE_WHEELDOWN
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -295,9 +295,8 @@ MWDECL void MwHideCursor(MwWidget handle);
|
|||
* @brief Toggles the dark theme
|
||||
* @param handle Widget
|
||||
* @param toggle Toggle
|
||||
* @deprecated Use MwNdarkTheme instead
|
||||
*/
|
||||
MWDECL void MwSetDarkTheme(MwWidget handle, int toggle);
|
||||
MWDECL void MwToggleDarkTheme(MwWidget handle, int toggle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the parent widget
|
||||
|
|
@ -355,19 +354,6 @@ MWDECL void MwGetCursorCoord(MwWidget handle, MwPoint* point);
|
|||
*/
|
||||
MWDECL void MwGetScreenSize(MwWidget handle, MwRect* rect);
|
||||
|
||||
/*!
|
||||
* @brief Reports whether a widget reports global or local coordinates upon GetXY/SetXY. Anything with a parent reports local, and most backends report global coordinates being supported for top level windows, but some (Wayland) do not.
|
||||
* @param handle Widget
|
||||
*/
|
||||
MWDECL int MwGetCoordinateType(MwWidget handle);
|
||||
|
||||
/*!
|
||||
* @brief Queue to get clipboard content.
|
||||
* @param handle Widget
|
||||
* @param clipboard_type The Clipboard Type to get. See MwClipboardType. This is ignored on backends that aren't X11/Wayland, so if you're unsure, just use MwClipboardMain
|
||||
*/
|
||||
MWDECL void MwGetClipboard(MwWidget handle, int clipboard_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -52,11 +52,6 @@ MWDECL const char* MwDefaultDarkSubBackground;
|
|||
*/
|
||||
MWDECL const char* MwDefaultDarkSubForeground;
|
||||
|
||||
/*!
|
||||
* @brief Default shadow difference
|
||||
*/
|
||||
MWDECL const int MwDefaultShadow;
|
||||
|
||||
/*!
|
||||
* @brief Gets default border width
|
||||
* @param handle Widget
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ MWDECL void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int i
|
|||
* @param border Border width
|
||||
* @param diff Difference (set this to 0 if you don't know what this does)
|
||||
* @param same Same as dark color
|
||||
* @param rounded Rounded or not
|
||||
* @warning `rect` gets changed to the area of rectangle inside
|
||||
*/
|
||||
MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same);
|
||||
|
|
@ -176,31 +175,29 @@ MWDECL void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int in
|
|||
/*!
|
||||
* @brief Draws a text
|
||||
* @param handle Widget
|
||||
* @param ttf TTF, NULLable
|
||||
* @param point Center point of the text
|
||||
* @param text Text
|
||||
* @param bold Bold
|
||||
* @param align Align
|
||||
* @param color Color
|
||||
*/
|
||||
MWDECL void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color);
|
||||
MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
||||
|
||||
/*!
|
||||
* @brief Calculates a text width
|
||||
* @param handle Widget
|
||||
* @param text Text
|
||||
* @param font Font, NULLable
|
||||
* @return Text width
|
||||
*/
|
||||
MWDECL int MwTextWidth(MwWidget handle, MwFLFont font, const char* text);
|
||||
MWDECL int MwTextWidth(MwWidget handle, const char* text);
|
||||
|
||||
/*!
|
||||
* @brief Calculates a text height
|
||||
* @param handle Widget
|
||||
* @param text Text
|
||||
* @param font Font, NULLable
|
||||
* @return Text height
|
||||
*/
|
||||
MWDECL int MwTextHeight(MwWidget handle, MwFLFont font, const char* text);
|
||||
MWDECL int MwTextHeight(MwWidget handle, const char* text);
|
||||
|
||||
/* color.c */
|
||||
|
||||
|
|
|
|||
29
include/Mw/Error.h
Normal file
29
include/Mw/Error.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*!
|
||||
* @file Mw/Error.h
|
||||
* @brief Error codes
|
||||
*/
|
||||
#ifndef __MW_ERROR_H__
|
||||
#define __MW_ERROR_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
/*!
|
||||
* @brief Error code enumeration
|
||||
*/
|
||||
typedef enum MwErrorEnum_T {
|
||||
/*!
|
||||
* @brief No error
|
||||
*/
|
||||
MwEsuccess = 0,
|
||||
/*!
|
||||
* @brief There was an error
|
||||
*/
|
||||
MwEerror,
|
||||
} MwErrorEnum;
|
||||
|
||||
/*!
|
||||
* @brief Get the last error
|
||||
*/
|
||||
MWDECL const char* MwGetLastError(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -6,10 +6,10 @@
|
|||
#ifndef __MW_LOWLEVEL_H__
|
||||
#define __MW_LOWLEVEL_H__
|
||||
|
||||
#include <Mw/BaseTypes.h>
|
||||
#include <Mw/MachDep.h>
|
||||
|
||||
typedef struct _MwLLHandler* MwLLHandler;
|
||||
typedef struct _MwLLMouse MwLLMouse;
|
||||
typedef struct _MwLLCommon* MwLLCommon;
|
||||
typedef struct _MwLLCommonColor* MwLLCommonColor;
|
||||
typedef struct _MwLLCommonPixmap* MwLLCommonPixmap;
|
||||
|
|
@ -17,35 +17,30 @@ typedef struct _MwLLCommonPixmap* MwLLCommonPixmap;
|
|||
typedef union _MwLL* MwLL;
|
||||
typedef union _MwLLColor* MwLLColor;
|
||||
typedef union _MwLLPixmap* MwLLPixmap;
|
||||
typedef struct _MwFLFont* MwFLFont;
|
||||
#else
|
||||
typedef void* MwLL;
|
||||
typedef void* MwLLColor;
|
||||
typedef void* MwLLPixmap;
|
||||
typedef void* MwFLFont;
|
||||
#endif
|
||||
|
||||
enum MwLLBackends {
|
||||
MwLLBackendX11 = 0,
|
||||
MwLLBackendGDI,
|
||||
MwLLBackendWayland,
|
||||
MwLLBackendCocoa,
|
||||
};
|
||||
|
||||
struct _MwLLCommon {
|
||||
void* user;
|
||||
int copy_buffer;
|
||||
int type;
|
||||
int coordinate_type;
|
||||
MwBool supports_transparency;
|
||||
|
||||
MwLLHandler handler;
|
||||
};
|
||||
|
||||
struct _MwLLCommonColor {
|
||||
MwU8 red;
|
||||
MwU8 green;
|
||||
MwU8 blue;
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
};
|
||||
|
||||
struct _MwLLCommonPixmap {
|
||||
|
|
@ -55,52 +50,6 @@ struct _MwLLCommonPixmap {
|
|||
void* user;
|
||||
};
|
||||
|
||||
#ifdef USE_DBUS
|
||||
typedef struct _MwLLDBusFuncTable {
|
||||
void* lib;
|
||||
|
||||
void (*dbus_error_init)(DBusError* error);
|
||||
DBusConnection* (*dbus_bus_get)(DBusBusType type, DBusError* error);
|
||||
dbus_bool_t (*dbus_error_is_set)(const DBusError* error);
|
||||
void (*dbus_error_free)(DBusError* error);
|
||||
DBusMessage* (*dbus_message_new_method_call)(const char* bus_name, const char* path, const char* iface, const char* method);
|
||||
void (*dbus_message_iter_init_append)(DBusMessage* message, DBusMessageIter* iter);
|
||||
dbus_bool_t (*dbus_message_iter_append_basic)(DBusMessageIter* iter, int type, const void* value);
|
||||
void (*dbus_connection_flush)(DBusConnection* connection);
|
||||
dbus_bool_t (*dbus_connection_read_write)(DBusConnection* connection, int timeout_milliseconds);
|
||||
DBusMessage* (*dbus_connection_send_with_reply_and_block)(DBusConnection* connection, DBusMessage* message, int timeout_milliseconds, DBusError* error);
|
||||
DBusMessage* (*dbus_connection_pop_message)(DBusConnection* connection);
|
||||
void (*dbus_bus_add_match)(DBusConnection* connection, const char* rule, DBusError* error);
|
||||
void (*dbus_message_unref)(DBusMessage* message);
|
||||
dbus_bool_t (*dbus_message_iter_init)(DBusMessage* message, DBusMessageIter* iter);
|
||||
dbus_bool_t (*dbus_message_is_signal)(DBusMessage* message, const char* iface, const char* signal_name);
|
||||
int (*dbus_message_iter_get_arg_type)(DBusMessageIter* iter);
|
||||
void (*dbus_message_iter_recurse)(DBusMessageIter* iter, DBusMessageIter* sub);
|
||||
void (*dbus_message_iter_next)(DBusMessageIter* iter);
|
||||
void (*dbus_connection_unref)(DBusConnection* connection);
|
||||
void (*dbus_message_iter_get_basic)(DBusMessageIter* iter, void* value);
|
||||
} MwLLDBusFuncTable;
|
||||
|
||||
typedef struct _MwLLDBusContext {
|
||||
DBusConnection* dbus_conn;
|
||||
DBusError dbus_err;
|
||||
DBusMessage* dbus_msg;
|
||||
DBusMessage* dbus_reply;
|
||||
} MwLLDBusContext;
|
||||
|
||||
typedef void (*MwLLDBusPortalPollListener)(MwLL handle, MwU32 new_value);
|
||||
|
||||
/* setup the dbus func table. Returns false and prints a warning if dbus couldn't be found. */
|
||||
MWDECL MwBool MwLLDBusFuncSetup(MwLLDBusFuncTable* tbl);
|
||||
|
||||
MWDECL MwBool MwLLDBusNewContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx);
|
||||
MWDECL MwBool MwLLDBusPortalGet(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal, const char* namespace, const char* key, void* out);
|
||||
MWDECL MwBool MwLLDBusPortalWatch(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal);
|
||||
MWDECL MwBool MwLLDBusPortalPoll(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, MwLL handle, const char* portal, const char* namespace, const char* key, MwLLDBusPortalPollListener);
|
||||
MWDECL void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MILSKO
|
||||
#ifdef USE_X11
|
||||
#include <Mw/LowLevel/X11.h>
|
||||
|
|
@ -111,12 +60,6 @@ MWDECL void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx);
|
|||
#ifdef USE_WAYLAND
|
||||
#include <Mw/LowLevel/Wayland.h>
|
||||
#endif
|
||||
#ifdef USE_COCOA
|
||||
#include <Mw/LowLevel/Cocoa.h>
|
||||
#endif
|
||||
#ifdef CLASSIC_MAC_OS
|
||||
#include <Mw/LowLevel/ClassicMacOS.h>
|
||||
#endif
|
||||
|
||||
union _MwLL {
|
||||
struct _MwLLCommon common;
|
||||
|
|
@ -129,12 +72,6 @@ union _MwLL {
|
|||
#ifdef USE_WAYLAND
|
||||
struct _MwLLWayland wayland;
|
||||
#endif
|
||||
#ifdef USE_COCOA
|
||||
struct _MwLLCocoa cocoa;
|
||||
#endif
|
||||
#ifdef CLASSIC_MAC_OS
|
||||
struct _MwLLClassicMacOS cmacos;
|
||||
#endif
|
||||
};
|
||||
|
||||
union _MwLLColor {
|
||||
|
|
@ -148,9 +85,6 @@ union _MwLLColor {
|
|||
#ifdef USE_WAYLAND
|
||||
struct _MwLLWaylandColor wayland;
|
||||
#endif
|
||||
#ifdef USE_COCOA
|
||||
struct _MwLLCocoaColor cocoa;
|
||||
#endif
|
||||
};
|
||||
|
||||
union _MwLLPixmap {
|
||||
|
|
@ -164,12 +98,6 @@ union _MwLLPixmap {
|
|||
#ifdef USE_WAYLAND
|
||||
struct _MwLLWaylandPixmap wayland;
|
||||
#endif
|
||||
#ifdef USE_COCOA
|
||||
struct _MwLLCocoaPixmap cocoa;
|
||||
#endif
|
||||
#ifdef CLASSIC_MAC_OS
|
||||
struct _MwLLClassicMacOSPixmap cmacos;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
|
@ -195,6 +123,19 @@ enum MwLLKeyEnum {
|
|||
#define MwLLControlMask MwLLKeyMask | (1 << 30)
|
||||
#define MwLLAltMask MwLLKeyMask | (1 << 29)
|
||||
|
||||
enum MwLLMouseEnum {
|
||||
MwLLMouseLeft = 1,
|
||||
MwLLMouseMiddle,
|
||||
MwLLMouseRight,
|
||||
MwLLMouseWheelUp,
|
||||
MwLLMouseWheelDown
|
||||
};
|
||||
|
||||
struct _MwLLMouse {
|
||||
MwPoint point;
|
||||
int button;
|
||||
};
|
||||
|
||||
struct _MwLLHandler {
|
||||
void (*draw)(MwLL handle, void* data);
|
||||
void (*up)(MwLL handle, void* data);
|
||||
|
|
@ -206,22 +147,8 @@ struct _MwLLHandler {
|
|||
void (*key_released)(MwLL handle, void* data);
|
||||
void (*focus_in)(MwLL handle, void* data);
|
||||
void (*focus_out)(MwLL handle, void* data);
|
||||
void (*clipboard)(MwLL handle, void* data);
|
||||
void (*dark_theme)(MwLL handle, void* data);
|
||||
};
|
||||
|
||||
struct _MwLLTextDispatchTable {
|
||||
int (*drawText)(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
||||
int (*textWidth)(MwWidget handle, const char* text);
|
||||
int (*textHeight)(MwWidget handle, int count);
|
||||
void* (*fontLoad)(unsigned char* data, unsigned int size);
|
||||
void (*fontFree)(void* handle);
|
||||
};
|
||||
|
||||
#define MwFLFlagMonospace (1 << 0)
|
||||
#define MwFLFlagBold (1 << 1)
|
||||
#define MwFLBuildFont(x) ((MwFLFont)(void*)(size_t)(x))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -275,30 +202,12 @@ MWDECL void (*MwLLEndStateChange)(MwLL handle);
|
|||
MWDECL void (*MwLLFocus)(MwLL handle);
|
||||
MWDECL void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
||||
|
||||
MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text, int clipboard_type);
|
||||
MWDECL void (*MwLLGetClipboard)(MwLL handle, int clipboard_type);
|
||||
MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text);
|
||||
MWDECL char* (*MwLLGetClipboard)(MwLL handle);
|
||||
|
||||
MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
||||
MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
||||
|
||||
MWDECL void (*MwLLSetDarkTheme)(MwLL handle, int toggle);
|
||||
|
||||
/* font renderer */
|
||||
MWDECL void MwFLSetup(void);
|
||||
|
||||
#ifdef USE_FREETYPE2
|
||||
MWDECL int MWFL_FT2Setup(void);
|
||||
#endif
|
||||
#ifdef USE_STB_TRUETYPE
|
||||
MWDECL int MwFL_STBTTSetup(void);
|
||||
#endif
|
||||
|
||||
MWDECL int (*MwFLDrawText)(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color);
|
||||
MWDECL int (*MwFLTextWidth)(MwFLFont ttf, const char* text);
|
||||
MWDECL int (*MwFLTextHeight)(MwFLFont ttf, int count);
|
||||
MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px);
|
||||
MWDECL void (*MwFLFontFree)(void* handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
/*!
|
||||
* @file Mw/LowLevel/ClassicMacOS.h
|
||||
* @brief ClassicMacOS Backend
|
||||
* @warning This is used internally
|
||||
*/
|
||||
#ifndef __MW_LOWLEVEL_ClassicMacOS_H__
|
||||
#define __MW_LOWLEVEL_ClassicMacOS_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
#include <Mw/LowLevel.h>
|
||||
|
||||
struct _MwLLClassicMacOS {
|
||||
struct _MwLLCommon common;
|
||||
|
||||
MwLL parent;
|
||||
|
||||
WindowRef window;
|
||||
ControlHandle control;
|
||||
EventRecord event;
|
||||
Rect winRect;
|
||||
};
|
||||
|
||||
struct _MwLLClassicMacOSColor {
|
||||
struct _MwLLCommonColor common;
|
||||
};
|
||||
|
||||
struct _MwLLClassicMacOSPixmap {
|
||||
struct _MwLLCommonPixmap common;
|
||||
BitMap bmp;
|
||||
};
|
||||
|
||||
MWDECL int MwLLClassicMacOSCallInit(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,180 +0,0 @@
|
|||
/*!
|
||||
* @file Mw/LowLevel/Cocoa.h
|
||||
* @brief Work in progress Cocoa Backend
|
||||
* @warning This is used internally.
|
||||
*/
|
||||
#ifndef __MW_LOWLEVEL_COCOA_H__
|
||||
#define __MW_LOWLEVEL_COCOA_H__
|
||||
|
||||
#include <Mw/LowLevel.h>
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
COCOA_DRAW_COMMAND_POLY = 0,
|
||||
COCOA_DRAW_COMMAND_LINES,
|
||||
COCOA_DRAW_COMMAND_PIXMAP,
|
||||
} type;
|
||||
union {
|
||||
struct {
|
||||
MwPoint* points;
|
||||
int points_count;
|
||||
struct _MwLLCommonColor color;
|
||||
} poly;
|
||||
struct {
|
||||
MwPoint* points;
|
||||
struct _MwLLCommonColor color;
|
||||
} lines;
|
||||
struct {
|
||||
MwRect rect;
|
||||
MwLLPixmap pixmap;
|
||||
} pixmap;
|
||||
};
|
||||
} draw_command;
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Foundation/NSGeometry.h>
|
||||
|
||||
@interface MilskoCocoaApplication : NSApplication {
|
||||
MwBool doPending;
|
||||
}
|
||||
- (MwBool)pending;
|
||||
@end
|
||||
|
||||
// Note: implements NSApplicationDelegate
|
||||
@interface MilskoCocoaApplicationDelegate : NSObject {
|
||||
MilskoCocoaApplication* appl;
|
||||
}
|
||||
- (MilskoCocoaApplicationDelegate*)initWithAppl:(MilskoCocoaApplication*)appl;
|
||||
@end
|
||||
|
||||
@interface MilskoCocoaWindow : NSWindow {
|
||||
}
|
||||
@end
|
||||
|
||||
// Note: implements NSWindowDelegate
|
||||
@interface MilskoCocoaWindowDelegate : NSObject {
|
||||
NSWindow* w;
|
||||
}
|
||||
- (MilskoCocoaWindowDelegate*)initWithWin:(NSWindow*)win;
|
||||
@end
|
||||
|
||||
/*
|
||||
So we want to associate each NSWindow with its corresponding MwLL handle. The
|
||||
conventional way of doing this is through "associative pointers", however
|
||||
this is a feature that Apple added in 10.6 (marketted back then as "Objective
|
||||
C 2" iirc). For 10.4 compatibility, we have to do a bit of an ugly hack that
|
||||
might seem like horrifically undefined behavior, but I've tested this on
|
||||
both 10.4 and modern Mac OS and as long as we're careful there's no
|
||||
problems: we override NSView, use NSView's "frame" property to store the
|
||||
pointer, and then override functions appropriately so that this frame is never
|
||||
actually used. This can then be attached to an NSWindow with addSubview and
|
||||
retrieved appropriately.
|
||||
*/
|
||||
@interface MilskoFakePointer : NSView {
|
||||
void* ptr;
|
||||
}
|
||||
|
||||
- (void)setPointer:(void*)ptr;
|
||||
- (void*)pointer;
|
||||
|
||||
@end
|
||||
|
||||
@interface MilskoCocoaPixmap : NSObject {
|
||||
@public
|
||||
MwBool valid;
|
||||
int width;
|
||||
int height;
|
||||
unsigned char* buf;
|
||||
NSImage* image;
|
||||
NSBitmapImageRep* rep;
|
||||
}
|
||||
|
||||
+ (MilskoCocoaPixmap*)newWithWidth:(int)width height:(int)height;
|
||||
- (void)updateWithData:(unsigned char*)data;
|
||||
- (void)destroy;
|
||||
|
||||
/* using @property to create instance variables fucks up 10.4 gcc for some
|
||||
* reason? */
|
||||
- (NSImage*)image;
|
||||
|
||||
@end
|
||||
|
||||
@interface MilskoCocoaView : NSView {
|
||||
MwBool _child;
|
||||
|
||||
@public
|
||||
draw_command* commands;
|
||||
}
|
||||
|
||||
- (void)destroy;
|
||||
- (void)setChild;
|
||||
@end
|
||||
|
||||
@interface MilskoCocoaSubView : MilskoCocoaView {
|
||||
}
|
||||
@end
|
||||
|
||||
@interface MilskoCocoa : NSObject {
|
||||
@public
|
||||
MilskoCocoaApplication* application;
|
||||
MwBool _forceRender;
|
||||
MwBool _eventsPending;
|
||||
NSWindow* window;
|
||||
NSRect rect;
|
||||
MilskoCocoaView* view;
|
||||
MwLL parent;
|
||||
MilskoFakePointer* handle;
|
||||
unsigned int strHash;
|
||||
NSEvent* lastEvent;
|
||||
|
||||
MilskoCocoaPixmap* cursorPixmap;
|
||||
NSCursor* cursor;
|
||||
NSModalSession modalSession;
|
||||
|
||||
MwBool pointerLocked;
|
||||
MwBool mouseMoved;
|
||||
|
||||
MwBool rejectFirstTest;
|
||||
}
|
||||
- (void)destroy;
|
||||
- (void)sendClipboardEvent;
|
||||
|
||||
- (MwLL)getParent;
|
||||
- (NSView*)getView;
|
||||
- (NSWindow*)getWindow;
|
||||
- (void)nudge;
|
||||
|
||||
- (void)pushCursor;
|
||||
- (void)popCursor;
|
||||
|
||||
- (MilskoFakePointer*)getHandle;
|
||||
|
||||
@end
|
||||
#define OBJC(x) x
|
||||
#else
|
||||
#define OBJC(x) void*
|
||||
#endif
|
||||
|
||||
MWDECL int MwLLCocoaCallInit(void);
|
||||
|
||||
struct _MwLLCocoa {
|
||||
struct _MwLLCommon common;
|
||||
OBJC(MilskoCocoa*)
|
||||
real;
|
||||
};
|
||||
|
||||
struct _MwLLCocoaColor {
|
||||
struct _MwLLCommonColor common;
|
||||
};
|
||||
|
||||
struct _MwLLCocoaPixmap {
|
||||
struct _MwLLCommonPixmap common;
|
||||
OBJC(MilskoCocoaPixmap*)
|
||||
real;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -21,8 +21,6 @@ struct _MwLLGDI {
|
|||
|
||||
int grabbed;
|
||||
int force_render;
|
||||
int get_clipboard;
|
||||
int get_darktheme;
|
||||
};
|
||||
|
||||
struct _MwLLGDIColor {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
/*!
|
||||
* @file Mw/LowLevel/Wayland.h
|
||||
* @brief Wayland Backend
|
||||
* @brief Work in progress Wayland Backend
|
||||
* @warning This is used internally.
|
||||
* @warning This is disabled by default.
|
||||
*/
|
||||
#ifndef __MW_LOWLEVEL_WAYLAND_H__
|
||||
#define __MW_LOWLEVEL_WAYLAND_H__
|
||||
|
|
@ -9,317 +10,30 @@
|
|||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
#include <Mw/LowLevel.h>
|
||||
#include <Mw/Abstract/Dynamic.h>
|
||||
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <cairo/cairo.h>
|
||||
#include <pthread.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
MWDECL int MwLLWaylandCallInit(void);
|
||||
|
||||
#define CSD_BORDER_FRAME_LEFT 5
|
||||
#define CSD_BORDER_FRAME_RIGHT 5
|
||||
#define CSD_BORDER_FRAME_TOP 24
|
||||
#define CSD_BORDER_FRAME_BOTTOM 5
|
||||
|
||||
struct _MwLLWayland;
|
||||
|
||||
#include <wayland-client-core.h>
|
||||
|
||||
#if WAYLAND_LOAD_OPENGL
|
||||
#include <EGL/egl.h>
|
||||
#include <wayland-egl-core.h>
|
||||
#endif
|
||||
|
||||
typedef struct wayland_call_table {
|
||||
void* lib;
|
||||
void* xkb_lib;
|
||||
void* cairo_lib;
|
||||
#ifdef USE_DBUS
|
||||
MwLLDBusFuncTable dbus;
|
||||
MwBool has_dbus;
|
||||
#endif
|
||||
|
||||
int (*wl_display_dispatch)(struct wl_display* display);
|
||||
int (*wl_display_dispatch_pending)(struct wl_display* display);
|
||||
void (*wl_display_disconnect)(struct wl_display* display);
|
||||
void (*wl_display_cancel_read)(struct wl_display* display);
|
||||
int (*wl_display_prepare_read)(struct wl_display* display);
|
||||
int (*wl_display_read_events)(struct wl_display* display);
|
||||
int (*wl_display_flush)(struct wl_display* display);
|
||||
int (*wl_display_get_fd)(struct wl_display* display);
|
||||
int (*wl_display_roundtrip)(struct wl_display* display);
|
||||
int (*wl_proxy_add_listener)(struct wl_proxy* proxy, void (**implementation)(void), void* data);
|
||||
void (*wl_proxy_destroy)(struct wl_proxy* proxy);
|
||||
void (*wl_log_set_handler_client)(wl_log_func_t handler);
|
||||
struct wl_proxy* (*wl_proxy_marshal_flags)(struct wl_proxy* proxy, uint32_t opcode,
|
||||
const struct wl_interface* interface,
|
||||
uint32_t version,
|
||||
uint32_t flags, ...);
|
||||
struct wl_display* (*wl_display_connect)(const char* name);
|
||||
uint32_t (*wl_proxy_get_version)(struct wl_proxy* proxy);
|
||||
struct wl_display* (*wl_display_connect_to_fd)(int fd);
|
||||
|
||||
struct xkb_context* (*xkb_context_new)(enum xkb_context_flags flags);
|
||||
void (*xkb_context_unref)(struct xkb_context* context);
|
||||
struct xkb_state* (*xkb_state_new)(struct xkb_keymap* keymap);
|
||||
void (*xkb_state_unref)(struct xkb_state* state);
|
||||
struct xkb_keymap* (*xkb_keymap_new_from_string)(struct xkb_context* context, const char* string, enum xkb_keymap_format format, enum xkb_keymap_compile_flags flags);
|
||||
xkb_level_index_t (*xkb_keymap_num_levels_for_key)(struct xkb_keymap* keymap, xkb_keycode_t key, xkb_layout_index_t layout);
|
||||
int (*xkb_keymap_key_get_syms_by_level)(struct xkb_keymap* keymap, xkb_keycode_t key, xkb_layout_index_t layout, xkb_level_index_t level, const xkb_keysym_t** syms_out);
|
||||
xkb_layout_index_t (*xkb_state_key_get_layout)(struct xkb_state* state, xkb_keycode_t key);
|
||||
void (*xkb_keymap_unref)(struct xkb_keymap* keymap);
|
||||
|
||||
void (*cairo_set_line_width)(cairo_t* cr,
|
||||
double width);
|
||||
void (*cairo_scale)(cairo_t* cr,
|
||||
double sx,
|
||||
double sy);
|
||||
cairo_t* (*cairo_create)(cairo_surface_t* target);
|
||||
void (*cairo_move_to)(cairo_t* cr,
|
||||
double x,
|
||||
double y);
|
||||
|
||||
void (*cairo_rectangle)(cairo_t* cr,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height);
|
||||
void (*cairo_new_path)(cairo_t* cr);
|
||||
void (*cairo_set_line_cap)(cairo_t* cr,
|
||||
cairo_line_cap_t line_cap);
|
||||
void (*cairo_set_source_rgba)(cairo_t* cr,
|
||||
double red,
|
||||
double green,
|
||||
double blue,
|
||||
double alpha);
|
||||
void (*cairo_set_source_rgb)(cairo_t* cr,
|
||||
double red,
|
||||
double green,
|
||||
double blue);
|
||||
void (*cairo_reset_clip)(cairo_t* cr);
|
||||
unsigned char* (*cairo_image_surface_get_data)(cairo_surface_t* surface);
|
||||
void (*cairo_line_to)(cairo_t* cr,
|
||||
double x,
|
||||
double y);
|
||||
void (*cairo_surface_destroy)(cairo_surface_t* surface);
|
||||
cairo_surface_t* (*cairo_image_surface_create_for_data)(unsigned char* data,
|
||||
cairo_format_t format,
|
||||
int width,
|
||||
int height,
|
||||
int stride);
|
||||
cairo_surface_t* (*cairo_image_surface_create)(cairo_format_t format,
|
||||
int width,
|
||||
int height);
|
||||
void (*cairo_destroy)(cairo_t* cr);
|
||||
cairo_pattern_t* (*cairo_get_source)(cairo_t* cr);
|
||||
void (*cairo_close_path)(cairo_t* cr);
|
||||
void (*cairo_paint)(cairo_t* cr);
|
||||
void (*cairo_surface_flush)(cairo_surface_t* surface);
|
||||
void (*cairo_clip)(cairo_t* cr);
|
||||
void (*cairo_surface_mark_dirty)(cairo_surface_t* surface);
|
||||
void (*cairo_stroke)(cairo_t* cr);
|
||||
void (*cairo_set_source_surface)(cairo_t* cr,
|
||||
cairo_surface_t* surface,
|
||||
double x,
|
||||
double y);
|
||||
void (*cairo_fill)(cairo_t* cr);
|
||||
void (*cairo_pattern_set_filter)(cairo_pattern_t* pattern,
|
||||
cairo_filter_t filter);
|
||||
void (*cairo_set_antialias)(cairo_t*, cairo_antialias_t);
|
||||
void (*cairo_set_operator)(cairo_t* cr, cairo_operator_t op);
|
||||
|
||||
} wayland_call_table_t;
|
||||
|
||||
extern wayland_call_table_t wl_call_tbl;
|
||||
extern MwBool MwWaylandAlwaysRender;
|
||||
/* defined inline right here so that it doesn't conflict with the other macros */
|
||||
MwInline int wayland_load_funcs() {
|
||||
wl_call_tbl.lib = MwDynamicOpen("libwayland-client.so");
|
||||
if(!wl_call_tbl.lib) {
|
||||
printf("(libwayland-client.so not found, falling back to X11)\n");
|
||||
return 1;
|
||||
}
|
||||
wl_call_tbl.xkb_lib = MwDynamicOpen("libxkbcommon.so");
|
||||
if(!wl_call_tbl.xkb_lib) {
|
||||
printf("(libxkbcommon.so not found, cannot use Wayland backend.)\n");
|
||||
return 1;
|
||||
}
|
||||
wl_call_tbl.cairo_lib = MwDynamicOpen("libcairo.so");
|
||||
if(!wl_call_tbl.cairo_lib) {
|
||||
printf("(libcairo.so not found, cannot use Wayland backend.)\n");
|
||||
return 1;
|
||||
}
|
||||
#define WAYLAND_FUNC(x) \
|
||||
wl_call_tbl.x = MwDynamicSymbol(wl_call_tbl.lib, #x); \
|
||||
if(!wl_call_tbl.x) { \
|
||||
printf("WARNING: Could use Wayland backend if " #x " was found.\n"); \
|
||||
return 1; \
|
||||
};
|
||||
|
||||
WAYLAND_FUNC(wl_display_dispatch)
|
||||
WAYLAND_FUNC(wl_display_dispatch_pending)
|
||||
WAYLAND_FUNC(wl_display_disconnect)
|
||||
WAYLAND_FUNC(wl_display_cancel_read)
|
||||
WAYLAND_FUNC(wl_display_prepare_read)
|
||||
WAYLAND_FUNC(wl_display_read_events)
|
||||
WAYLAND_FUNC(wl_display_flush)
|
||||
WAYLAND_FUNC(wl_display_get_fd)
|
||||
WAYLAND_FUNC(wl_display_roundtrip)
|
||||
WAYLAND_FUNC(wl_proxy_add_listener)
|
||||
WAYLAND_FUNC(wl_proxy_destroy)
|
||||
WAYLAND_FUNC(wl_log_set_handler_client)
|
||||
WAYLAND_FUNC(wl_proxy_marshal_flags)
|
||||
WAYLAND_FUNC(wl_display_connect)
|
||||
WAYLAND_FUNC(wl_proxy_get_version)
|
||||
WAYLAND_FUNC(wl_display_connect_to_fd)
|
||||
|
||||
#undef WAYLAND_FUNC
|
||||
|
||||
#define XKB_FUNC(x) \
|
||||
wl_call_tbl.x = MwDynamicSymbol(wl_call_tbl.xkb_lib, #x); \
|
||||
if(!wl_call_tbl.x) { \
|
||||
printf("WARNING: Could use Wayland backend if " #x " was found. Do you have libxkbcommon?\n"); \
|
||||
return 1; \
|
||||
};
|
||||
|
||||
XKB_FUNC(xkb_state_unref)
|
||||
XKB_FUNC(xkb_context_new)
|
||||
XKB_FUNC(xkb_context_unref)
|
||||
XKB_FUNC(xkb_state_new)
|
||||
XKB_FUNC(xkb_keymap_new_from_string)
|
||||
XKB_FUNC(xkb_keymap_unref)
|
||||
XKB_FUNC(xkb_keymap_num_levels_for_key)
|
||||
XKB_FUNC(xkb_keymap_key_get_syms_by_level)
|
||||
XKB_FUNC(xkb_state_key_get_layout)
|
||||
#undef XKB_FUNC
|
||||
|
||||
#define CAIRO_FUNC(x) \
|
||||
wl_call_tbl.x = MwDynamicSymbol(wl_call_tbl.cairo_lib, #x); \
|
||||
if(!wl_call_tbl.x) { \
|
||||
printf("WARNING: Could use Wayland backend if " #x " was found. Do you have libcairo?\n"); \
|
||||
return 1; \
|
||||
};
|
||||
|
||||
CAIRO_FUNC(cairo_set_line_width);
|
||||
CAIRO_FUNC(cairo_scale);
|
||||
CAIRO_FUNC(cairo_create);
|
||||
CAIRO_FUNC(cairo_move_to);
|
||||
CAIRO_FUNC(cairo_rectangle);
|
||||
CAIRO_FUNC(cairo_new_path);
|
||||
CAIRO_FUNC(cairo_set_line_cap);
|
||||
CAIRO_FUNC(cairo_set_antialias);
|
||||
CAIRO_FUNC(cairo_set_source_rgba);
|
||||
CAIRO_FUNC(cairo_set_source_rgb);
|
||||
CAIRO_FUNC(cairo_reset_clip);
|
||||
CAIRO_FUNC(cairo_image_surface_get_data);
|
||||
CAIRO_FUNC(cairo_line_to);
|
||||
CAIRO_FUNC(cairo_surface_destroy);
|
||||
CAIRO_FUNC(cairo_image_surface_create_for_data);
|
||||
CAIRO_FUNC(cairo_image_surface_create);
|
||||
CAIRO_FUNC(cairo_destroy);
|
||||
CAIRO_FUNC(cairo_get_source);
|
||||
CAIRO_FUNC(cairo_close_path);
|
||||
CAIRO_FUNC(cairo_paint);
|
||||
CAIRO_FUNC(cairo_surface_flush);
|
||||
CAIRO_FUNC(cairo_clip);
|
||||
CAIRO_FUNC(cairo_surface_mark_dirty);
|
||||
CAIRO_FUNC(cairo_stroke);
|
||||
CAIRO_FUNC(cairo_set_source_surface);
|
||||
CAIRO_FUNC(cairo_fill);
|
||||
CAIRO_FUNC(cairo_set_operator);
|
||||
CAIRO_FUNC(cairo_pattern_set_filter);
|
||||
#undef CAIRO_FUNC
|
||||
|
||||
#ifdef USE_DBUS
|
||||
wl_call_tbl.has_dbus = MwLLDBusFuncSetup(&wl_call_tbl.dbus);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define wl_display_dispatch wl_call_tbl.wl_display_dispatch
|
||||
#define wl_display_dispatch_pending wl_call_tbl.wl_display_dispatch_pending
|
||||
#define wl_display_disconnect wl_call_tbl.wl_display_disconnect
|
||||
#define wl_display_cancel_read wl_call_tbl.wl_display_cancel_read
|
||||
#define wl_display_prepare_read wl_call_tbl.wl_display_prepare_read
|
||||
#define wl_display_read_events wl_call_tbl.wl_display_read_events
|
||||
#define wl_display_flush wl_call_tbl.wl_display_flush
|
||||
#define wl_display_get_fd wl_call_tbl.wl_display_get_fd
|
||||
#define wl_display_roundtrip wl_call_tbl.wl_display_roundtrip
|
||||
#define wl_proxy_add_listener wl_call_tbl.wl_proxy_add_listener
|
||||
#define wl_proxy_destroy wl_call_tbl.wl_proxy_destroy
|
||||
#define wl_log_set_handler_client wl_call_tbl.wl_log_set_handler_client
|
||||
#define wl_proxy_marshal_flags wl_call_tbl.wl_proxy_marshal_flags
|
||||
#define wl_display_connect wl_call_tbl.wl_display_connect
|
||||
#define wl_proxy_get_version wl_call_tbl.wl_proxy_get_version
|
||||
#define wl_display_connect_to_fd wl_call_tbl.wl_display_connect_to_fd
|
||||
|
||||
#define xkb_state_unref wl_call_tbl.xkb_state_unref
|
||||
#define xkb_context_new wl_call_tbl.xkb_context_new
|
||||
#define xkb_context_unref wl_call_tbl.xkb_context_unref
|
||||
#define xkb_state_new wl_call_tbl.xkb_state_new
|
||||
#define xkb_keymap_new_from_string wl_call_tbl.xkb_keymap_new_from_string
|
||||
#define xkb_keymap_unref wl_call_tbl.xkb_keymap_unref
|
||||
#define xkb_keymap_num_levels_for_key wl_call_tbl.xkb_keymap_num_levels_for_key
|
||||
#define xkb_keymap_key_get_syms_by_level wl_call_tbl.xkb_keymap_key_get_syms_by_level
|
||||
#define xkb_state_key_get_layout wl_call_tbl.xkb_state_key_get_layout
|
||||
|
||||
#define cairo_set_line_width wl_call_tbl.cairo_set_line_width
|
||||
#define cairo_scale wl_call_tbl.cairo_scale
|
||||
#define cairo_create wl_call_tbl.cairo_create
|
||||
#define cairo_move_to wl_call_tbl.cairo_move_to
|
||||
#define cairo_rectangle wl_call_tbl.cairo_rectangle
|
||||
#define cairo_new_path wl_call_tbl.cairo_new_path
|
||||
#define cairo_set_line_cap wl_call_tbl.cairo_set_line_cap
|
||||
#define cairo_set_antialias wl_call_tbl.cairo_set_antialias
|
||||
#define cairo_set_source_rgba wl_call_tbl.cairo_set_source_rgba
|
||||
#define cairo_set_source_rgb wl_call_tbl.cairo_set_source_rgb
|
||||
#define cairo_reset_clip wl_call_tbl.cairo_reset_clip
|
||||
#define cairo_image_surface_get_data wl_call_tbl.cairo_image_surface_get_data
|
||||
#define cairo_line_to wl_call_tbl.cairo_line_to
|
||||
#define cairo_surface_destroy wl_call_tbl.cairo_surface_destroy
|
||||
#define cairo_image_surface_create_for_data wl_call_tbl.cairo_image_surface_create_for_data
|
||||
#define cairo_image_surface_create wl_call_tbl.cairo_image_surface_create
|
||||
#define cairo_destroy wl_call_tbl.cairo_destroy
|
||||
#define cairo_get_source wl_call_tbl.cairo_get_source
|
||||
#define cairo_close_path wl_call_tbl.cairo_close_path
|
||||
#define cairo_paint wl_call_tbl.cairo_paint
|
||||
#define cairo_surface_flush wl_call_tbl.cairo_surface_flush
|
||||
#define cairo_clip wl_call_tbl.cairo_clip
|
||||
#define cairo_surface_mark_dirty wl_call_tbl.cairo_surface_mark_dirty
|
||||
#define cairo_stroke wl_call_tbl.cairo_stroke
|
||||
#define cairo_set_source_surface wl_call_tbl.cairo_set_source_surface
|
||||
#define cairo_fill wl_call_tbl.cairo_fill
|
||||
#define cairo_set_operator wl_call_tbl.cairo_set_operator
|
||||
#define cairo_pattern_set_filter wl_call_tbl.cairo_pattern_set_filter
|
||||
|
||||
#ifndef WL_PROTOCOLS_DEFINED
|
||||
#define WL_PROTOCOLS_DEFINED
|
||||
#include "Wayland/wayland-core-protocol.h"
|
||||
#include "Wayland/xdg-shell-client-protocol.h"
|
||||
#include "Wayland/viewporter-client-protocol.h"
|
||||
#include "Wayland/xdg-decoration-client-protocol.h"
|
||||
#include "Wayland/cursor-shape-client-protocol.h"
|
||||
#include "Wayland/primary-selection-client-protocol.h"
|
||||
#include "Wayland/pointer-constraints-client-protocol.h"
|
||||
#include "Wayland/relative-pointer-client-protocol.h"
|
||||
#include "Wayland/xdg-toplevel-icon-client-protocol.h"
|
||||
#endif
|
||||
|
||||
struct _MwLLWayland;
|
||||
|
||||
typedef struct wayland_protocol {
|
||||
void* listener;
|
||||
void* context;
|
||||
} wayland_protocol_t;
|
||||
|
||||
typedef wayland_protocol_t*(wl_setup_func)(MwU32, struct _MwLLWayland*);
|
||||
typedef void(wl_destroy_func)(struct _MwLLWayland* wayland, wayland_protocol_t* data);
|
||||
|
||||
typedef struct wayland_protocol_callback_table {
|
||||
wl_setup_func* setup;
|
||||
wl_destroy_func* destroy;
|
||||
} wayland_protocol_callback_table_t;
|
||||
|
||||
struct _MwLLWaylandTopLevel {
|
||||
struct xdg_surface* xdg_surface;
|
||||
|
|
@ -327,12 +41,13 @@ struct _MwLLWaylandTopLevel {
|
|||
struct xdg_toplevel_listener xdg_toplevel_listener;
|
||||
struct xdg_surface_listener xdg_surface_listener;
|
||||
|
||||
struct xkb_context* xkb_context;
|
||||
struct xkb_keymap* xkb_keymap;
|
||||
struct xkb_state* xkb_state;
|
||||
|
||||
MwBool compositor_created;
|
||||
MwBool xdg_wm_base_created;
|
||||
MwBool xdg_surface_created;
|
||||
|
||||
struct wl_subsurface* ssurface;
|
||||
struct wl_subcompositor* scompositor;
|
||||
};
|
||||
|
||||
struct _MwLLWaylandSublevel {
|
||||
|
|
@ -340,59 +55,9 @@ struct _MwLLWaylandSublevel {
|
|||
struct wl_subcompositor* subcompositor;
|
||||
|
||||
MwLL parent;
|
||||
|
||||
struct xdg_surface* xdg_surface;
|
||||
MwLL topmost_parent; /* The parent at the top of all the other parents. Usually a toplevel. */
|
||||
};
|
||||
|
||||
struct _MwLLWaylandPopup {
|
||||
struct xdg_surface* xdg_surface;
|
||||
struct xdg_popup* xdg_popup;
|
||||
struct xdg_positioner* xdg_positioner;
|
||||
struct xdg_surface_listener xdg_surface_listener;
|
||||
struct xdg_wm_base* xdg_wm_base;
|
||||
MwLL topmost_parent;
|
||||
};
|
||||
|
||||
/* Shared set of anything needed for a shm buffer. */
|
||||
struct _MwLLWaylandShmBuffer {
|
||||
struct wl_shm* shm;
|
||||
struct wl_shm_pool* shm_pool;
|
||||
struct wl_buffer* shm_buffer;
|
||||
struct wl_shm_pool* shm_pool_back;
|
||||
struct wl_buffer* shm_buffer_back;
|
||||
struct wl_surface* surface;
|
||||
struct wl_output* output;
|
||||
|
||||
MwU8* buf;
|
||||
MwU8* buf_back;
|
||||
MwU64 buf_size;
|
||||
int fd;
|
||||
int fd_back;
|
||||
MwBool setup;
|
||||
};
|
||||
|
||||
enum _MwLLWaylandType {
|
||||
MWLL_WAYLAND_UNKNOWN = 0,
|
||||
MWLL_WAYLAND_TOPLEVEL,
|
||||
MWLL_WAYLAND_SUBLEVEL,
|
||||
MWLL_WAYLAND_POPUP,
|
||||
};
|
||||
|
||||
typedef struct wl_clipboard_device_context {
|
||||
struct {
|
||||
struct wl_data_device* wl;
|
||||
struct zwp_primary_selection_device_v1* zwp;
|
||||
} device;
|
||||
struct {
|
||||
struct wl_data_offer* wl;
|
||||
struct zwp_primary_selection_offer_v1* zwp;
|
||||
} offer;
|
||||
|
||||
MwLL ll;
|
||||
struct wl_seat* seat;
|
||||
MwU32 capabilities;
|
||||
} wl_clipboard_device_context_t;
|
||||
|
||||
struct _MwLLWayland {
|
||||
struct _MwLLCommon common;
|
||||
|
||||
|
|
@ -401,129 +66,47 @@ struct _MwLLWayland {
|
|||
struct _MwLLWaylandTopLevel* toplevel;
|
||||
/* Pointer for data that's only loaded if the widget is a sublevel */
|
||||
struct _MwLLWaylandSublevel* sublevel;
|
||||
/* Pointer for data that's only loaded if the widget is a popup */
|
||||
struct _MwLLWaylandPopup* popup;
|
||||
};
|
||||
|
||||
enum _MwLLWaylandType type;
|
||||
enum _MwLLWaylandType type_to_be;
|
||||
|
||||
MwBool detatching;
|
||||
MwPoint detach_point;
|
||||
|
||||
MwBool did_initial_resize;
|
||||
enum {
|
||||
MWLL_WAYLAND_TOPLEVEL = 0,
|
||||
MWLL_WAYLAND_SUBLEVEL, /* Sublevels are surfaces that have the toplevel as a parent. Some parts of the code also call them subwidgets. */
|
||||
} type;
|
||||
|
||||
/* Map of Wayland interfaces to their relevant setup functions. */
|
||||
struct {
|
||||
char key[255];
|
||||
wayland_protocol_callback_table_t* value;
|
||||
const char* key;
|
||||
wl_setup_func* value;
|
||||
}* wl_protocol_setup_map;
|
||||
|
||||
/* Map of Wayland interfaces to any information we keep about them once we've registered them. */
|
||||
struct {
|
||||
char key[255];
|
||||
const char* key;
|
||||
wayland_protocol_t* value;
|
||||
}* wl_protocol_map;
|
||||
|
||||
MwBool has_decorations;
|
||||
char title[255];
|
||||
|
||||
struct xkb_context* xkb_context;
|
||||
struct xkb_keymap* xkb_keymap;
|
||||
struct xkb_state* xkb_state;
|
||||
|
||||
struct wl_display* display;
|
||||
struct wl_registry* registry;
|
||||
struct wl_compositor* compositor;
|
||||
struct wl_surface* surface;
|
||||
struct wl_registry_listener registry_listener;
|
||||
struct wl_region* o_region;
|
||||
struct wl_region* region;
|
||||
struct wl_output* output;
|
||||
|
||||
struct wp_viewport* vp;
|
||||
|
||||
MwBool do_lock_pointer;
|
||||
struct zwp_pointer_constraints_v1* pointer_constraints;
|
||||
struct zwp_relative_pointer_manager_v1* relative_pointer_manager;
|
||||
struct zwp_relative_pointer_v1* relative_pointer;
|
||||
struct zwp_locked_pointer_v1* locked_pointer;
|
||||
MwBool pointer_constrained;
|
||||
|
||||
#ifdef USE_DBUS
|
||||
MwLLDBusContext dbus;
|
||||
#endif
|
||||
|
||||
MwBool dark_theme_detection;
|
||||
MwU32 dark_theme;
|
||||
|
||||
/* clipboard related stuff.
|
||||
* Note that unlike most interfaces, we don't keep zwp_primary_selection stuff in a wayland_protocol_t because we use wl_data_device as a fallback and want to have it share memory space.*/
|
||||
|
||||
struct {
|
||||
struct wl_data_device_manager* wl;
|
||||
struct zwp_primary_selection_device_manager_v1* zwp;
|
||||
} clipboard_manager;
|
||||
union {
|
||||
struct wl_data_source* wl;
|
||||
struct zwp_primary_selection_source_v1* zwp;
|
||||
} clipboard_source;
|
||||
char* clipboard_buffer;
|
||||
MwBool supports_zwp;
|
||||
|
||||
uint32_t clipboard_serial;
|
||||
wl_clipboard_device_context_t** clipboard_devices_wl;
|
||||
wl_clipboard_device_context_t** clipboard_devices_zwp;
|
||||
|
||||
struct wl_pointer* pointer;
|
||||
MwU32 pointer_serial;
|
||||
struct wl_seat* pointer_seat;
|
||||
|
||||
struct wl_keyboard* keyboard;
|
||||
MwU32 keyboard_serial;
|
||||
|
||||
MwU64 events_pending;
|
||||
|
||||
MwU32 mod_state;
|
||||
/*struct wl_event_queue* event_queue;*/
|
||||
|
||||
MwLL* sublevels; /* stb_ds managed array of any sublevels */
|
||||
MwBool configured; /* Whether or not xdg_toplevel_configure has run once */
|
||||
|
||||
MwBool held_down;
|
||||
|
||||
MwI32 x, y;
|
||||
MwI32 ox, oy;
|
||||
MwU32 ww, wh; /* Window position */
|
||||
MwU32 x, y, ww, wh; /* Window position */
|
||||
MwPoint cur_mouse_pos; /* Currently known mouse position */
|
||||
|
||||
MwU32 mw, mh; /* Monitor width and height as advertised by wl_output.mode */
|
||||
struct wl_shm* shm;
|
||||
struct wl_shm_pool* shm_pool;
|
||||
struct wl_buffer* shm_buffer;
|
||||
void* mapped_shm_buf;
|
||||
MwU64 mapped_shm_buf_size;
|
||||
int shm_fd;
|
||||
|
||||
MwLL parent;
|
||||
|
||||
MwBool force_render;
|
||||
MwBool did_event_loop_early;
|
||||
|
||||
MwBool dispatching_resize;
|
||||
|
||||
struct _MwLLWaylandShmBuffer framebuffer;
|
||||
struct _MwLLWaylandShmBuffer backbuffer;
|
||||
struct _MwLLWaylandShmBuffer cursor;
|
||||
struct _MwLLWaylandShmBuffer* icon;
|
||||
|
||||
/*
|
||||
Events mutex. Any time a keyboard/mouse event happens, we try to lock this for 100 milliseconds, then give up if we can't do it. This is used in conjunction with some code in the MwLLDestroyImpl to make sure that destroy is NEVER interferes with an ongoing event.
|
||||
|
||||
IOI_XD: This sounds like a hilariously rare edge case, so it's almost funnier that this happened with 100% certainty for me and I spent day(s) trying to figure out what was happening. */
|
||||
pthread_mutex_t eventsMutex;
|
||||
|
||||
uint32_t last_time;
|
||||
|
||||
MwBool moving;
|
||||
|
||||
cairo_surface_t* front_cs;
|
||||
cairo_surface_t* back_cs;
|
||||
cairo_t* front_cairo;
|
||||
cairo_t* back_cairo;
|
||||
/* The cairo to actually use for draw operations. Typically is front_cairo, but MwLLBeginDraw can change this to the back_cairo so it can be used to draw window decorations. */
|
||||
cairo_t* selected_cairo;
|
||||
cairo_surface_t* cs;
|
||||
cairo_t* cairo;
|
||||
};
|
||||
|
||||
struct _MwLLWaylandColor {
|
||||
|
|
|
|||
|
|
@ -29,18 +29,9 @@ struct _MwLLX11 {
|
|||
GC gc;
|
||||
Colormap colormap;
|
||||
Atom wm_delete;
|
||||
Atom wm_protocols;
|
||||
Atom utf8_string;
|
||||
Atom compound_text;
|
||||
Atom text;
|
||||
Atom clipboard;
|
||||
Atom selection;
|
||||
XIM xim;
|
||||
XIC xic;
|
||||
|
||||
long clipboard_time;
|
||||
int clipboard_pending; /* 1 if UTF8_STRING, 2 if COMPOUNd_TEXT, 3 if TEXT, 4 if STRING, otherwise 0 */
|
||||
|
||||
int top;
|
||||
int toplevel;
|
||||
int grabbed;
|
||||
|
|
@ -57,12 +48,6 @@ struct _MwLLX11 {
|
|||
unsigned long blue_mask;
|
||||
unsigned long blue_max;
|
||||
unsigned long blue_shift;
|
||||
|
||||
#ifdef USE_DBUS
|
||||
MwLLDBusContext dbus;
|
||||
#endif
|
||||
|
||||
MwBool dark_theme_detection;
|
||||
};
|
||||
|
||||
struct _MwLLX11Color {
|
||||
|
|
|
|||
|
|
@ -37,63 +37,27 @@
|
|||
#define GET_WHEEL_DELTA_WPARAM(x) ((short)HIWORD(x))
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(CLASSIC_MAC_OS)
|
||||
#include <unistd.h>
|
||||
#include <MacTypes.h>
|
||||
#include <CFBundle.h>
|
||||
#include <CodeFragments.h>
|
||||
#include <Timer.h>
|
||||
#include <MacWindows.h>
|
||||
#include <TextEdit.h>
|
||||
#include <Dialogs.h>
|
||||
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifdef __unix__
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <mach/clock.h>
|
||||
#include <mach/mach.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_DBUS
|
||||
#include <dbus/dbus.h>
|
||||
#include <signal.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265
|
||||
#endif
|
||||
|
||||
/* Windows */
|
||||
#if defined(_MILSKO) && defined(_WIN32)
|
||||
#define MWDECL extern __declspec(dllexport)
|
||||
#elif defined(_WIN32)
|
||||
#define MWDECL extern __declspec(dllimport)
|
||||
/* GCC/Clang */
|
||||
/* First check if we have __has_attribute and can check for the existence of visibility */
|
||||
#elif defined(__has_attribute)
|
||||
#if __has_attribute(visibility)
|
||||
#define MWDECL extern __attribute__((visibility("default")))
|
||||
#else
|
||||
#define MWDECL extern
|
||||
#endif
|
||||
/* It might be that we're on an old version of GCC (like the one Apple ships with older versions of Mac OS).
|
||||
* If we're on gcc 3 or above, assume it's there
|
||||
*/
|
||||
#elif __GNUC__ >= 3
|
||||
#define MWDECL extern __attribute__((visibility("default")))
|
||||
#else
|
||||
/* all else fails */
|
||||
#define MWDECL extern
|
||||
#endif
|
||||
|
||||
#define MwInline static __inline
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <Mw/Core.h>
|
||||
#include <Mw/Default.h>
|
||||
#include <Mw/Font.h>
|
||||
#include <Mw/Error.h>
|
||||
#include <Mw/Constants.h>
|
||||
#include <Mw/Unicode.h>
|
||||
#include <Mw/String.h>
|
||||
|
|
|
|||
|
|
@ -42,26 +42,6 @@ MWDECL unsigned char MwBoldTTFData[];
|
|||
*/
|
||||
MWDECL unsigned int MwBoldTTFDataSize;
|
||||
|
||||
/*!
|
||||
* @brief Default monospace TTF font data
|
||||
*/
|
||||
MWDECL unsigned char MwMonospaceTTFData[];
|
||||
|
||||
/*!
|
||||
* @brief Default monospace TTF font size
|
||||
*/
|
||||
MWDECL unsigned int MwMonospaceTTFDataSize;
|
||||
|
||||
/*!
|
||||
* @brief Default bold monospace TTF font data
|
||||
*/
|
||||
MWDECL unsigned char MwBoldMonospaceTTFData[];
|
||||
|
||||
/*!
|
||||
* @brief Default bold monospace TTF font size
|
||||
*/
|
||||
MWDECL unsigned int MwBoldMonospaceTTFDataSize;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -41,21 +41,6 @@ MWDECL void MwStringSize(char* out, MwOffset size);
|
|||
*/
|
||||
MWDECL void MwStringTime(char* out, time_t t);
|
||||
|
||||
/*!
|
||||
* @brief Prints up to n characters into a bufferMwStringPrintIntoBuffer.
|
||||
* @note On compilers that support C99, this uses vsnprintf to safely print into a buffer; on compilers that don't, vsprintf is used.
|
||||
* @param out Buffer
|
||||
* @param size Max size
|
||||
*/
|
||||
MWDECL void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...);
|
||||
|
||||
/*!
|
||||
* @brief Check if the given key is UTF8
|
||||
* @param key Input
|
||||
* @return whether its utf8
|
||||
*/
|
||||
MWDECL MwBool MwStringIsKeyUTF8(MwU32 key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,14 +35,6 @@
|
|||
#define MwNratio "Iratio"
|
||||
#define MwNfixedSize "IfixedSize"
|
||||
#define MwNmargin "Imargin"
|
||||
#define MwNbitmapFont "IbitmapFont"
|
||||
#define MwNsevenSegment "IsevenSegment"
|
||||
#define MwNlength "Ilength"
|
||||
#define MwNforceInverted "IforceInverted"
|
||||
#define MwNroundness "Iroundness"
|
||||
#define MwNisRounded "IisRounded"
|
||||
#define MwNdarkTheme "IdarkTheme"
|
||||
#define MwNuseMonospace "IuseMonospace"
|
||||
|
||||
#define MwNtitle "Stitle"
|
||||
#define MwNtext "Stext"
|
||||
|
|
@ -57,20 +49,15 @@
|
|||
#define MwNfont "Vfont"
|
||||
#define MwNboldFont "VboldFont"
|
||||
#define MwNbackgroundPixmap "VbackgroundPixmap"
|
||||
#define MwNmonospaceFont "VmonospaceFont"
|
||||
#define MwNboldMonospaceFont "VboldMonospaceFont"
|
||||
|
||||
#define MwNactivateHandler "Cactivate" /* NULL */
|
||||
#define MwNlistBoxActivateHandler "ClistBoxActivate" /* int* */
|
||||
#define MwNtreeViewActivateHandler "CtreeViewActivate" /* void* */
|
||||
#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox)/void* (MwTreeView) */
|
||||
#define MwNresizeHandler "Cresize" /* NULL */
|
||||
#define MwNtickHandler "Ctick" /* NULL */
|
||||
#define MwNmenuHandler "Cmenu" /* MwMenu */
|
||||
#define MwNmouseDownHandler "CmouseDown" /* MwMouse* */
|
||||
#define MwNmouseDownHandler "CmouseDown" /* MwLLMouse* */
|
||||
#define MwNmouseUpHandler "CmouseUp" /* same as MwNmouseDownHandler */
|
||||
#define MwNmouseMoveHandler "CmouseMove" /* MwPoint* */
|
||||
#define MwNchangedHandler "Cchanged" /* NULL */
|
||||
#define MwNcomboBoxChangedHandler "CcomboBoxChanged" /* int* */
|
||||
#define MwNchangedHandler "Cchanged" /* NULL/int* (MwComboBox) */
|
||||
#define MwNkeyHandler "Ckey" /* int* (MwLLKeyEnum or character code) */
|
||||
#define MwNkeyReleaseHandler "CkeyRelease" /* same as MwNkeyHandler */
|
||||
#define MwNcloseHandler "Cclose" /* NULL */
|
||||
|
|
@ -80,7 +67,5 @@
|
|||
#define MwNdirectoryChosenHandler "CdirectoryChosen" /* char* */
|
||||
#define MwNcolorChosenHandler "CcolorChosen" /* MwRGB* */
|
||||
#define MwNdrawHandler "Cdraw" /* NULL */
|
||||
#define MwNclipboardHandler "Cclipboard" /* char* */
|
||||
#define MwNdarkThemeHandler "CdarkTheme" /* int* */
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,15 +20,10 @@ typedef struct _MwViewport* MwViewport;
|
|||
typedef struct _MwListBox* MwListBox;
|
||||
typedef struct _MwComboBox* MwComboBox;
|
||||
typedef struct _MwTreeView* MwTreeView;
|
||||
typedef struct _MwScrollBar* MwScrollBar;
|
||||
typedef struct _MwLabel* MwLabel;
|
||||
typedef struct _MwLabelSegment MwLabelSegment;
|
||||
typedef struct _MwListBoxEntry MwListBoxEntry;
|
||||
typedef struct _MwTreeViewEntry MwTreeViewEntry;
|
||||
typedef struct _MwDirectoryEntry MwDirectoryEntry;
|
||||
typedef struct _MwListBoxPacket MwListBoxPacket;
|
||||
typedef struct _MwBox* MwBox;
|
||||
typedef struct _MwMouse MwMouse;
|
||||
#ifdef _MILSKO
|
||||
typedef struct _MwWidget* MwWidget;
|
||||
#else
|
||||
|
|
@ -41,7 +36,6 @@ typedef void (*MwHandlerChildrenProp)(MwWidget handle, MwWidget child, const cha
|
|||
typedef void (*MwHandlerKey)(MwWidget handle, int key);
|
||||
typedef void (*MwHandlerMouse)(MwWidget handle, void* ptr);
|
||||
typedef void (*MwHandlerExecute)(MwWidget handle, const char* name, void* out, va_list args);
|
||||
typedef void (*MwHandlerClipboardReceived)(MwWidget handle, const char* data);
|
||||
|
||||
typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
||||
typedef void (*MwErrorHandler)(int code, const char* message, void* user_data);
|
||||
|
|
@ -77,6 +71,7 @@ struct _MwVoidKeyValue {
|
|||
struct _MwWidget {
|
||||
char* name;
|
||||
MwLLColor bgcolor;
|
||||
int dark_theme;
|
||||
|
||||
MwLL lowlevel;
|
||||
MwWidget parent;
|
||||
|
|
@ -102,16 +97,6 @@ struct _MwWidget {
|
|||
MwWidget* tick_list;
|
||||
|
||||
int destroyed;
|
||||
|
||||
void* root_font;
|
||||
void* root_boldfont;
|
||||
void* root_monofont;
|
||||
void* root_boldmonofont;
|
||||
|
||||
int top_step;
|
||||
MwWidget* draw_queue;
|
||||
|
||||
int berserk;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
@ -120,7 +105,6 @@ struct _MwMenu {
|
|||
int keep;
|
||||
MwWidget wsub;
|
||||
MwMenu* sub;
|
||||
void* opaque;
|
||||
};
|
||||
|
||||
struct _MwEntry {
|
||||
|
|
@ -180,21 +164,6 @@ struct _MwTreeView {
|
|||
MwPoint pressed;
|
||||
};
|
||||
|
||||
struct _MwScrollBar {
|
||||
MwPoint point;
|
||||
int drag;
|
||||
int pos;
|
||||
};
|
||||
|
||||
struct _MwLabel {
|
||||
MwLabelSegment* segment;
|
||||
};
|
||||
|
||||
struct _MwLabelSegment {
|
||||
int key;
|
||||
unsigned char value;
|
||||
};
|
||||
|
||||
struct _MwDirectoryEntry {
|
||||
char* name;
|
||||
int type;
|
||||
|
|
@ -207,15 +176,6 @@ struct _MwListBoxPacket {
|
|||
char*** names;
|
||||
};
|
||||
|
||||
struct _MwBox {
|
||||
int layout;
|
||||
};
|
||||
|
||||
struct _MwMouse {
|
||||
MwPoint point;
|
||||
int button;
|
||||
};
|
||||
|
||||
struct _MwClass {
|
||||
MwHandlerWithStatus create;
|
||||
MwHandler destroy;
|
||||
|
|
@ -232,11 +192,11 @@ struct _MwClass {
|
|||
MwHandler resize;
|
||||
MwHandler children_update;
|
||||
MwHandlerChildrenProp children_prop_change;
|
||||
MwHandlerClipboardReceived clipboard;
|
||||
void* reserved1;
|
||||
void* reserved2;
|
||||
void* reserved3;
|
||||
void* reserved4;
|
||||
void* reserved5;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -17,17 +17,6 @@ extern "C" {
|
|||
*/
|
||||
MWDECL MwClass MwLabelClass;
|
||||
|
||||
/*!
|
||||
* @brief Sets the custom data for seven segment
|
||||
* @param handle Widget
|
||||
* @param index Index
|
||||
* @param data Data, `GFEDCBA` as 7-bit value
|
||||
* @note See https://en.wikipedia.org/wiki/File:7_Segment_Display_with_Labeled_Segments.svg for what alphabets mean here
|
||||
* */
|
||||
MwInline void MwLabelSetSevenSegment(MwWidget handle, int index, int data) {
|
||||
MwVaWidgetExecute(handle, "mwLabelSetSevenSegment", NULL, index, data);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,29 +5,20 @@
|
|||
#ifndef __MW_WIDGET_OPENGL_H__
|
||||
#define __MW_WIDGET_OPENGL_H__
|
||||
|
||||
#include <Mw/Core.h>
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
#include <Mw/Core.h>
|
||||
|
||||
#if !defined(MW_OPENGL_NO_INCLUDE) && !defined(__gl_h_)
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#elif defined(__APPLE__)
|
||||
#else
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#ifndef GLAPIENTRY
|
||||
#define GLAPIENTRY APIENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -18,25 +18,8 @@ extern "C" {
|
|||
*/
|
||||
MWDECL MwClass MwSubMenuClass;
|
||||
|
||||
/*!
|
||||
* @brief Makes submenu appear
|
||||
* @param handle Handle
|
||||
* @param menu Menu
|
||||
* @param point Point
|
||||
* @param diff_calc Toggles different way to calculate positiion
|
||||
*/
|
||||
MwInline void MwSubMenuAppear(MwWidget handle, MwMenu menu, MwPoint* point, int diff_calc) {
|
||||
MwVaWidgetExecute(handle, "mwSubMenuAppear", NULL, menu, point, diff_calc);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Calculates the size of submenu
|
||||
* @param handle Handle
|
||||
* @param menu Menu
|
||||
* @param rect Size
|
||||
*/
|
||||
MwInline void MwSubMenuGetSize(MwWidget handle, MwMenu menu, MwRect* rect) {
|
||||
MwVaWidgetExecute(handle, "mwSubMenuGetSize", NULL, menu, rect);
|
||||
MwInline void MwSubMenuAppear(MwWidget handle, MwMenu menu, MwPoint* point) {
|
||||
MwVaWidgetExecute(handle, "mwSubMenuAppear", NULL, menu, point);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -11,18 +11,17 @@
|
|||
#ifndef __MW_WIDGET_VULKAN_H__
|
||||
#define __MW_WIDGET_VULKAN_H__
|
||||
|
||||
#if defined(MW_VULKAN) && !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
|
||||
#if !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
|
||||
#error Vulkan is unsupported on the requested platform.
|
||||
#endif
|
||||
|
||||
#if !defined(MW_VULKAN_NO_INCLUDE)
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
#endif
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
#include <Mw/Core.h>
|
||||
#include <Mw/Error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -48,19 +47,19 @@ MWDECL void MwVulkanEnableLayer(const char* ext_name);
|
|||
/*!
|
||||
* @brief Configuration options that can be passed to setup Vulkan before a widget is created.
|
||||
*/
|
||||
typedef struct _MwVulkanConfig {
|
||||
typedef struct MwVulkanConfig_T {
|
||||
/*!
|
||||
* @brief Vulkan API version (default: VK_API_VERSION_1_0)
|
||||
*/
|
||||
MwU32 api_version;
|
||||
uint32_t api_version;
|
||||
/*!
|
||||
* @brief Vulkan version (default: VK_VERSION_1_0)
|
||||
*/
|
||||
MwU32 vk_version;
|
||||
uint32_t vk_version;
|
||||
/*!
|
||||
* @brief Whether or not to enable validation layers (default: false)
|
||||
*/
|
||||
int validation_layers;
|
||||
VkBool32 validation_layers;
|
||||
} MwVulkanConfig;
|
||||
|
||||
/*!
|
||||
|
|
@ -68,61 +67,61 @@ typedef struct _MwVulkanConfig {
|
|||
* @warning This must be called before MwCreateWidget.
|
||||
* @warning The configuration provided will be used for future initializations of the Vulkan widget (unless it's changed)
|
||||
*/
|
||||
MWDECL void MwVulkanConfigure(MwVulkanConfig* cfg);
|
||||
MWDECL void MwVulkanConfigure(MwVulkanConfig cfg);
|
||||
|
||||
/*!
|
||||
* @brief Field that can be gotten from Vulkan.
|
||||
*/
|
||||
enum MwVULKANFIELD {
|
||||
typedef enum MwVulkanField_T {
|
||||
/*!
|
||||
* @brief The address of the vulkan widget's vkGetInstanceProcAddr function (PFN_vkGetInstanceProcAddr)
|
||||
*/
|
||||
MwVULKANFIELD_GETINSTANCEPROCADDR = 0,
|
||||
MwVulkanField_GetInstanceProcAddr = 0,
|
||||
/*!
|
||||
* @brief The address of the vulkan widget's instance (VkInstance)
|
||||
*/
|
||||
MwVULKANFIELD_INSTANCE,
|
||||
MwVulkanField_Instance,
|
||||
/*!
|
||||
* @brief The address of the vulkan widget's surface (VkSurfaceKHR)
|
||||
*/
|
||||
MwVULKANFIELD_SURFACE,
|
||||
MwVulkanField_Surface,
|
||||
/*!
|
||||
* @brief The address of the vulkan widget's physical device (VkPhysicalDevice)
|
||||
*/
|
||||
MwVULKANFIELD_PHYSICALDEVICE,
|
||||
MwVulkanField_PhysicalDevice,
|
||||
/*!
|
||||
* @brief The address of the vulkan widget's logical device (VkDevice)
|
||||
*/
|
||||
MwVULKANFIELD_LOGICALDEVICE,
|
||||
MwVulkanField_LogicalDevice,
|
||||
/*!
|
||||
* @brief The address of the index that the vulkan widget uses for the graphics queue (uint32_t *)
|
||||
*/
|
||||
MwVULKANFIELD_GRAPHICSQUEUEINDEX,
|
||||
MwVulkanField_GraphicsQueueIndex,
|
||||
/*!
|
||||
* @brief The address of the index that the vulkan widget uses for the present queue (uint32_t *)
|
||||
*/
|
||||
MwVULKANFIELD_PRESENTQUEUEINDEX,
|
||||
MwVULKANFIELD_GRAPHICSQUEUE,
|
||||
MwVulkanField_PresentQueueIndex,
|
||||
MwVulkanField_GraphicsQueue,
|
||||
/*!
|
||||
* @brief The address of the vulkan widget's graphics queue (VkQueue)
|
||||
*/
|
||||
MwVULKANFIELD_PRESENTQUEUE,
|
||||
};
|
||||
MwVulkanField_PresentQueue,
|
||||
} MwVulkanField;
|
||||
|
||||
/*!
|
||||
* @brief Function for getting a field from within Vulkan.
|
||||
* @note Consult the documentation for MwVULKANFIELD to know what type is expected for output.
|
||||
* @warning Consult the documentation for MwVulkanField to know what type is expected for out.
|
||||
*/
|
||||
MwInline void* MwVulkanGetField(MwWidget handle, int field, int* err) {
|
||||
MwInline void* MwVulkanGetField(MwWidget handle, MwVulkanField field, MwErrorEnum* out) {
|
||||
void* field_out;
|
||||
MwVaWidgetExecute(handle, "mwVulkanGetField", &field_out, field, err);
|
||||
MwVaWidgetExecute(handle, "mwVulkanGetField", &field_out, field, out);
|
||||
return field_out;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Return whether Vulkan is installed on the target platform.
|
||||
*/
|
||||
MWDECL int MwVulkanSupported(void);
|
||||
MWDECL VkBool32 MwVulkanSupported(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
236
milsko.xml
236
milsko.xml
|
|
@ -38,18 +38,19 @@
|
|||
<short name="green" unsigned="yes" />
|
||||
<short name="blue" unsigned="yes" />
|
||||
</struct>
|
||||
<struct name="MwMouse">
|
||||
<struct defname="MwPoint" name="point" />
|
||||
<integer name="button" />
|
||||
</struct>
|
||||
<struct name="MwVulkanConfig">
|
||||
<integer name="api_version" unsigned="yes" />
|
||||
<integer name="vk_version" unsigned="yes" />
|
||||
<integer name="validation_layers" />
|
||||
</struct>
|
||||
</structs>
|
||||
<!--
|
||||
All widgets have properties that are common="yes".
|
||||
All widgets have:
|
||||
- MwNbackground
|
||||
- MwNforeground
|
||||
- MwNx
|
||||
- MwNy
|
||||
- MwNwidth
|
||||
- MwNheight
|
||||
- MwNborderWidth
|
||||
- MwNbackgroundPixmap
|
||||
- MwNratio
|
||||
- MwNfixedSize
|
||||
|
||||
Integer properties must be prefixed with I.
|
||||
String properties must be prefixed with S.
|
||||
|
|
@ -57,10 +58,10 @@
|
|||
Other properties must be prefixed with V.
|
||||
-->
|
||||
<properties>
|
||||
<integer name="x" common="yes" />
|
||||
<integer name="y" common="yes" />
|
||||
<integer name="width" common="yes" />
|
||||
<integer name="height" common="yes" />
|
||||
<integer name="x" />
|
||||
<integer name="y" />
|
||||
<integer name="width" />
|
||||
<integer name="height" />
|
||||
<integer name="orientation" />
|
||||
<integer name="minValue" />
|
||||
<integer name="maxValue" />
|
||||
|
|
@ -75,93 +76,46 @@
|
|||
<integer name="hasHeading" />
|
||||
<integer name="hasBorder" />
|
||||
<integer name="inverted" />
|
||||
<integer name="modernLook" common="yes" />
|
||||
<integer name="modernLook" />
|
||||
<integer name="waitMS" />
|
||||
<integer name="hideInput" />
|
||||
<integer name="singleClickSelectable" />
|
||||
<integer name="flat" />
|
||||
<integer name="showArrows" />
|
||||
<integer name="padding" />
|
||||
<integer name="borderWidth" common="yes" />
|
||||
<integer name="ratio" common="yes" />
|
||||
<integer name="fixedSize" common="yes" />
|
||||
<integer name="borderWidth" />
|
||||
<integer name="ratio" />
|
||||
<integer name="fixedSize" />
|
||||
<integer name="margin" />
|
||||
<integer name="bitmapFont" common="yes" />
|
||||
<integer name="sevenSegment" />
|
||||
<integer name="length" />
|
||||
<integer name="forceInverted" common="yes" />
|
||||
<integer name="isRounded" common="yes" />
|
||||
<integer name="darkTheme" common="yes" />
|
||||
<integer name="useMonospace" common="yes" />
|
||||
|
||||
<!-- waitMS is a special property, only applies to toplevel widget -->
|
||||
<integer name="waitMS" common="yes" />
|
||||
|
||||
<string name="title" />
|
||||
<string name="text" />
|
||||
<string name="background" common="yes" />
|
||||
<string name="subBackground" common="yes" />
|
||||
<string name="foreground" common="yes" />
|
||||
<string name="subForeground" common="yes" />
|
||||
<string name="background" />
|
||||
<string name="foreground" />
|
||||
|
||||
<pixmap name="pixmap" />
|
||||
<pixmap name="iconPixmap" />
|
||||
<struct defname="MwSizeHints" pointer="yes" name="sizeHints" />
|
||||
<pointer name="font" />
|
||||
<pointer name="boldFont" />
|
||||
<pixmap name="backgroundPixmap" common="yes" />
|
||||
<pointer name="monospaceFont" />
|
||||
<pointer name="boldMonospaceFont" />
|
||||
|
||||
<handler name="activate" />
|
||||
<handler name="listBoxActivate">
|
||||
<integer pointer="yes" />
|
||||
</handler>
|
||||
<handler name="treeViewActivate">
|
||||
<pointer />
|
||||
</handler>
|
||||
<handler name="resize" />
|
||||
<handler name="tick" />
|
||||
<handler name="menu">
|
||||
<pointer />
|
||||
</handler>
|
||||
<handler name="mouseDown">
|
||||
<struct defname="MwMouse" pointer="yes" />
|
||||
</handler>
|
||||
<handler name="mouseUp">
|
||||
<struct defname="MwMouse" pointer="yes" />
|
||||
</handler>
|
||||
<handler name="mouseMove">
|
||||
<struct defname="MwPoint" pointer="yes" />
|
||||
</handler>
|
||||
<handler name="menu" />
|
||||
<handler name="mouseDown" />
|
||||
<handler name="mouseUp" />
|
||||
<handler name="mouseMove" />
|
||||
<handler name="changed" />
|
||||
<handler name="comboBoxChanged">
|
||||
<integer pointer="yes" />
|
||||
</handler>
|
||||
<handler name="key">
|
||||
<integer pointer="yes" />
|
||||
</handler>
|
||||
<handler name="keyRelease">
|
||||
<integer pointer="yes" />
|
||||
</handler>
|
||||
<handler name="key" />
|
||||
<handler name="keyRelease" />
|
||||
<handler name="close" />
|
||||
<handler name="focusIn" />
|
||||
<handler name="focusOut" />
|
||||
<handler name="fileChosen">
|
||||
<string />
|
||||
</handler>
|
||||
<handler name="directoryChosen">
|
||||
<string />
|
||||
</handler>
|
||||
<handler name="colorChosen">
|
||||
<struct defname="MwRGB" pointer="yes" />
|
||||
</handler>
|
||||
<handler name="fileChosen" />
|
||||
<handler name="directoryChosen" />
|
||||
<handler name="colorChosen" />
|
||||
<handler name="draw" />
|
||||
<handler name="clipboard">
|
||||
<string />
|
||||
</handler>
|
||||
<handler name="darkTheme">
|
||||
<integer pointer="yes" />
|
||||
</handler>
|
||||
</properties>
|
||||
<enumerations>
|
||||
<enumeration name="MwDIRECTION">
|
||||
|
|
@ -188,32 +142,6 @@
|
|||
<integer name="MwMB_ICONERROR" />
|
||||
<integer name="MwMB_ICONCLOCK" />
|
||||
</enumeration>
|
||||
<enumeration name="MwCOORDINATE">
|
||||
<integer name="MwCOORDINATE_GLOBAL">0</integer>
|
||||
<integer name="MwCOORDINATE_LOCAL" />
|
||||
</enumeration>
|
||||
<enumeration name="MwCLIPBOARD">
|
||||
<integer name="MwCLIPBOARD_MAIN">0</integer>
|
||||
<integer name="MwCLIPBOARD_PRIMARY" />
|
||||
</enumeration>
|
||||
<enumeration name="MwMOUSE">
|
||||
<integer name="MwMOUSE_LEFT">1</integer>
|
||||
<integer name="MwMOUSE_MIDDLE" />
|
||||
<integer name="MwMOUSE_RIGHT" />
|
||||
<integer name="MwMOUSE_WHEELUP" />
|
||||
<integer name="MwMOUSE_WHEELDOWN" />
|
||||
</enumeration>
|
||||
<enumeration name="MwVULKANFIELD">
|
||||
<integer name="MwVULKANFIELD_GETINSTANCEPROCADDR">0</integer>
|
||||
<integer name="MwVULKANFIELD_INSTANCE" />
|
||||
<integer name="MwVULKANFIELD_SURFACE" />
|
||||
<integer name="MwVULKANFIELD_PHYSICALDEVICE" />
|
||||
<integer name="MwVULKANFIELD_LOGICALDEVICE" />
|
||||
<integer name="MwVULKANFIELD_GRAPHICSQUEUEINDEX" />
|
||||
<integer name="MwVULKANFIELD_PRESENTQUEUEINDEX" />
|
||||
<integer name="MwVULKANFIELD_GRAPHICSQUEUE" />
|
||||
<integer name="MwVULKANFIELD_PRESENTQUEUE" />
|
||||
</enumeration>
|
||||
</enumerations>
|
||||
<constants>
|
||||
<integer name="MwDEFAULT">0x0fffffff</integer>
|
||||
|
|
@ -418,7 +346,7 @@
|
|||
<widget name="handle" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="MwSetDarkTheme">
|
||||
<function name="MwToggleDarkTheme">
|
||||
<arguments>
|
||||
<widget name="handle" />
|
||||
<integer name="toggle" />
|
||||
|
|
@ -467,18 +395,14 @@
|
|||
<struct defname="MwRect" pointer="yes" name="rect" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="MwGetClipboard">
|
||||
<arguments>
|
||||
<widget name="handle" />
|
||||
<integer enumname="MwClipboardType" name="clipboard_type" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="MwSetClipboard">
|
||||
<arguments>
|
||||
<widget name="handle" />
|
||||
<string name="text" />
|
||||
<integer enumname="MwClipboardType" name="clipboard_type" />
|
||||
</arguments>
|
||||
</functions>
|
||||
</header>
|
||||
<header name="Error">
|
||||
<functions>
|
||||
<function name="MwGetLastError">
|
||||
<return>
|
||||
<string />
|
||||
</return>
|
||||
</function>
|
||||
</functions>
|
||||
</header>
|
||||
|
|
@ -562,31 +486,13 @@
|
|||
</function>
|
||||
</functions>
|
||||
</header>
|
||||
|
||||
<!-- They are not alphabetically sorted for reasons -->
|
||||
<header name="Widget/Vulkan.h">
|
||||
<functions>
|
||||
<function name="MwVulkanConfigure">
|
||||
<return>
|
||||
<pointer />
|
||||
</return>
|
||||
<arguments>
|
||||
<struct defname="MwVulkanConfig" name="cfg" pointer="yes" />
|
||||
</arguments>
|
||||
</function>
|
||||
</functions>
|
||||
</header>
|
||||
</headers>
|
||||
|
||||
<!-- Widget functions are prefixed with mw<widget name> -->
|
||||
<widgets>
|
||||
<widget name="Box">
|
||||
<properties>
|
||||
<property name="orientation" />
|
||||
<property name="margin" />
|
||||
<property name="padding" />
|
||||
<property name="hasBorder" />
|
||||
<property name="inverted" />
|
||||
</properties>
|
||||
</widget>
|
||||
<widget name="Button">
|
||||
|
|
@ -620,7 +526,6 @@
|
|||
<property name="pixmap" />
|
||||
<property name="hasBorder" />
|
||||
<property name="inverted" />
|
||||
<property name="fillArea" />
|
||||
</properties>
|
||||
</widget>
|
||||
<widget name="Label">
|
||||
|
|
@ -628,18 +533,7 @@
|
|||
<property name="text" />
|
||||
<property name="alignment" />
|
||||
<property name="bold" />
|
||||
<property name="sevenSegment" />
|
||||
<property name="length" />
|
||||
<property name="leftPadding" />
|
||||
</properties>
|
||||
<functions>
|
||||
<function name="SetSevenSegment">
|
||||
<arguments>
|
||||
<integer name="index" />
|
||||
<integer name="data" />
|
||||
</arguments>
|
||||
</function>
|
||||
</functions>
|
||||
</widget>
|
||||
<widget name="ListBox">
|
||||
<properties>
|
||||
|
|
@ -694,6 +588,20 @@
|
|||
<property name="text" />
|
||||
</properties>
|
||||
</widget>
|
||||
<widget name="OpenGL">
|
||||
<functions>
|
||||
<function name="MakeCurrent" />
|
||||
<function name="GetProcAddress">
|
||||
<return>
|
||||
<pointer />
|
||||
</return>
|
||||
<arguments>
|
||||
<string name="name" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="SwapBuffer" />
|
||||
</functions>
|
||||
</widget>
|
||||
<widget name="ScrollBar">
|
||||
<properties>
|
||||
<property name="showArrows" />
|
||||
|
|
@ -713,9 +621,6 @@
|
|||
</functions>
|
||||
</widget>
|
||||
<widget name="SubMenu">
|
||||
<properties>
|
||||
<property name="leftPadding" />
|
||||
</properties>
|
||||
<functions>
|
||||
<function name="Appear">
|
||||
<arguments>
|
||||
|
|
@ -784,48 +689,15 @@
|
|||
</properties>
|
||||
<functions>
|
||||
<function name="Add">
|
||||
<arguments>
|
||||
<pointer name="parent" />
|
||||
<pixmap name="pixmap" />
|
||||
<string name="item" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="Delete">
|
||||
<arguments>
|
||||
<pointer name="item" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="Reset" />
|
||||
</functions>
|
||||
</widget>
|
||||
|
||||
<!-- They are not alphabetically sorted for reasons -->
|
||||
<widget name="OpenGL">
|
||||
<functions>
|
||||
<function name="MakeCurrent" />
|
||||
<function name="GetProcAddress">
|
||||
<return>
|
||||
<pointer />
|
||||
</return>
|
||||
<arguments>
|
||||
<string name="name" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="SwapBuffer" />
|
||||
</functions>
|
||||
</widget>
|
||||
<widget name="Vulkan">
|
||||
<functions>
|
||||
<function name="GetField">
|
||||
<return>
|
||||
<pointer />
|
||||
</return>
|
||||
<arguments>
|
||||
<integer enumname="MwVulkanField" name="field" />
|
||||
<integer pointer="yes" name="output" />
|
||||
</arguments>
|
||||
</function>
|
||||
</functions>
|
||||
</widget>
|
||||
</widgets>
|
||||
</milsko>
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
use_backend("classicmacos");
|
||||
|
||||
print(
|
||||
"Compiling for Classic Mac OS via ./configure currently outputs a broken executable and it only supports PowerPC. Help is wanted. In the mean time, use CMake."
|
||||
);
|
||||
|
||||
$cc = $ENV{RETRO68_TOOLCHAIN_PATH} . "/bin/powerpc-apple-macos-gcc";
|
||||
$ar = $ENV{RETRO68_TOOLCHAIN_PATH} . "/bin/powerpc-apple-macos-ar";
|
||||
add_cflags("-DCLASSIC_MAC_OS");
|
||||
add_cflags("-DSTBI_NO_THREAD_LOCALS");
|
||||
|
||||
1;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
$library_suffix = ".dylib";
|
||||
set_shared_flag("-dynamiclib");
|
||||
|
||||
use_backend("cocoa");
|
||||
|
||||
add_cflags("-DSTBI_NO_THREAD_LOCALS");
|
||||
add_ldflags("-framework Cocoa -lobjc");
|
||||
|
||||
1;
|
||||
|
|
@ -1,14 +1,8 @@
|
|||
my @enabled_backends = ();
|
||||
|
||||
if (param_get("wayland")) {
|
||||
push(@enabled_backends, "wayland");
|
||||
if (param_get("experimental-wayland")) {
|
||||
use_backend("wayland", "x11");
|
||||
}
|
||||
if (param_get("x11")) {
|
||||
push(@enabled_backends, "x11");
|
||||
else {
|
||||
use_backend("x11");
|
||||
}
|
||||
|
||||
add_cflags("-DUSE_DBUS");
|
||||
|
||||
use_backend(@enabled_backends);
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
add_incdir2("-I/usr/X11R7/include -I/usr/pkg/include");
|
||||
add_incdir("-I/usr/X11R7/include -I/usr/pkg/include");
|
||||
add_libdir(
|
||||
"-L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib");
|
||||
use_backend("x11");
|
||||
add_libs("-lpthread");
|
||||
|
||||
add_cflags("-DUSE_DBUS");
|
||||
|
||||
1;
|
||||
|
|
|
|||
90
pl/rules.pl
90
pl/rules.pl
|
|
@ -1,24 +1,20 @@
|
|||
new_object("src/*.c");
|
||||
|
||||
my $gl_libs = "";
|
||||
if (param_get("tiny")) {
|
||||
add_cflags("-Oz");
|
||||
if (defined($ENV{CC}) && grep(/^clang$/, $ENV{CC})) {
|
||||
add_libs("-flto=thin");
|
||||
add_cflags("-flto=thin");
|
||||
}
|
||||
}
|
||||
|
||||
if (param_get("classic-theme")) {
|
||||
add_cflags("-DUSE_CLASSIC_THEME");
|
||||
}
|
||||
if (grep(/^x11$/, @backends)) {
|
||||
add_cflags("-DUSE_X11");
|
||||
new_object("src/backend/x11.c");
|
||||
add_libs("-lX11");
|
||||
|
||||
$gl_libs = "-lGL -lGLU";
|
||||
|
||||
if (param_get("xrender")) {
|
||||
add_cflags("-DUSE_XRENDER");
|
||||
add_libs("-lXrender");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -30,83 +26,34 @@ if (grep(/^gdi$/, @backends)) {
|
|||
$gl_libs = "-lopengl32 -lglu32";
|
||||
}
|
||||
|
||||
if (grep(/^classicmacos$/, @backends)) {
|
||||
|
||||
#add_cflags("-DCLASSIC_MAC_OS");
|
||||
new_object("src/backend/classicmacos.c");
|
||||
|
||||
$gl_libs = "";
|
||||
}
|
||||
|
||||
if (grep(/^wayland$/, @backends)) {
|
||||
add_cflags("-DUSE_WAYLAND");
|
||||
new_object("src/backend/wayland.c");
|
||||
add_cflags(`pkg-config --cflags cairo wayland-client xkbcommon`);
|
||||
add_libs(`pkg-config --libs cairo wayland-client xkbcommon`);
|
||||
|
||||
if (param_get("opengl")) {
|
||||
add_cflags("-DWAYLAND_LOAD_OPENGL");
|
||||
}
|
||||
|
||||
scan_wayland_protocol_core();
|
||||
scan_wayland_protocol("stable", "xdg-shell", "");
|
||||
scan_wayland_protocol("stable", "viewporter", "");
|
||||
scan_wayland_protocol("stable", "tablet", "-v2");
|
||||
scan_wayland_protocol("staging", "xdg-toplevel-icon", "-v1");
|
||||
scan_wayland_protocol("staging", "cursor-shape", "-v1");
|
||||
scan_wayland_protocol("unstable", "xdg-decoration", "-unstable-v1");
|
||||
scan_wayland_protocol("unstable", "primary-selection", "-unstable-v1");
|
||||
scan_wayland_protocol("unstable", "pointer-constraints", "-unstable-v1");
|
||||
scan_wayland_protocol("unstable", "relative-pointer", "-unstable-v1");
|
||||
|
||||
$gl_libs = "-lGL -lGLU";
|
||||
}
|
||||
|
||||
if (grep(/( |^)-DUSE_DBUS( |$)/, $cflags)) {
|
||||
add_cflags(`pkg-config --cflags dbus-1`);
|
||||
}
|
||||
|
||||
if (grep(/^cocoa$/, @backends) || param_get("gnustep")) {
|
||||
add_cflags("-DUSE_COCOA");
|
||||
new_object("src/backend/cocoa.m");
|
||||
|
||||
if (param_get("gnustep")) {
|
||||
add_incdir("-I" . `gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS`);
|
||||
add_libdir("-L" . `gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARIES`);
|
||||
add_cflags("-fobjc-runtime=gnustep-2.0 -fblocks");
|
||||
add_ldflags("-lobjc -lgnustep-base -lm -lgnustep-gui");
|
||||
}
|
||||
|
||||
if (param_get("opengl")) {
|
||||
new_object("src/widget/opengl_cocoa.m");
|
||||
}
|
||||
|
||||
# tim cook my man literally everybody and their mother who knows what opengl is knows its deprecated on macos and i'm not having you spam the console with this
|
||||
add_cflags("-DGL_SILENCE_DEPRECATION");
|
||||
|
||||
$gl_libs = "-framework OpenGL";
|
||||
$gl_libs = "-lEGL -lwayland-egl lGL -lGLU";
|
||||
}
|
||||
|
||||
if (param_get("stb-image")) {
|
||||
add_cflags("-DUSE_STB_IMAGE");
|
||||
if (param_get("tiny")) {
|
||||
add_cflags("-DSTB_IMAGE_STATIC");
|
||||
add_cflags("-DSTB_IMAGE_IMPLEMENTATION");
|
||||
}
|
||||
}
|
||||
else {
|
||||
new_object("external/libjpeg/src/*.c");
|
||||
new_object("external/libpng/src/*.c");
|
||||
add_incdir("-Iexternal/libjpeg/include -Iexternal/libpng/include");
|
||||
}
|
||||
if (param_get("stb-truetype")) {
|
||||
add_cflags("-DUSE_STB_TRUETYPE");
|
||||
}
|
||||
|
||||
add_incdir("-Iexternal/libz/include");
|
||||
|
||||
if (param_get("freetype2")) {
|
||||
add_cflags("-DUSE_FREETYPE2");
|
||||
if (!$cross) {
|
||||
if ($cross) {
|
||||
add_libs("-lfreetype");
|
||||
}
|
||||
else {
|
||||
add_cflags(`pkg-config --cflags freetype2`);
|
||||
add_libs(`pkg-config --libs freetype2`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,9 +62,8 @@ if (param_get("vulkan") && param_get("vulkan-string-helper")) {
|
|||
}
|
||||
|
||||
new_object("src/icon/*.c");
|
||||
new_object("src/font/*.c");
|
||||
new_object("src/cursor/*.c");
|
||||
new_object("src/text/*.c");
|
||||
new_object("src/text/font/*.c");
|
||||
|
||||
new_object("src/widget/box.c");
|
||||
new_object("src/widget/button.c");
|
||||
|
|
@ -139,14 +85,11 @@ new_object("src/widget/treeview.c");
|
|||
new_object("src/widget/viewport.c");
|
||||
new_object("src/widget/window.c");
|
||||
|
||||
new_object("src/widget/opengl.c");
|
||||
new_object("src/widget/vulkan.c");
|
||||
|
||||
if (param_get("opengl")) {
|
||||
add_cflags("-DMW_OPENGL");
|
||||
new_object("src/widget/opengl.c");
|
||||
}
|
||||
if (param_get("vulkan")) {
|
||||
add_cflags("-DMW_VULKAN");
|
||||
new_object("src/widget/vulkan.c");
|
||||
}
|
||||
|
||||
new_object("src/dialog/*.c");
|
||||
|
|
@ -154,7 +97,6 @@ new_object("src/dialog/*.c");
|
|||
new_object("src/abstract/*.c");
|
||||
|
||||
new_object("external/*.c");
|
||||
new_object("external/libz/src/*.c");
|
||||
|
||||
new_example("examples/basic/example");
|
||||
new_example("examples/basic/rotate");
|
||||
|
|
@ -170,10 +112,6 @@ new_example("examples/basic/colorpicker");
|
|||
new_example("examples/basic/combobox");
|
||||
new_example("examples/basic/treeview");
|
||||
new_example("examples/basic/box");
|
||||
new_example("examples/basic/clipboard");
|
||||
new_example("examples/basic/sevensegment");
|
||||
new_example("examples/basic/calculator");
|
||||
new_example("examples/basic/periodic");
|
||||
|
||||
if (param_get("opengl")) {
|
||||
new_example("examples/gldemos/boing", $gl_libs);
|
||||
|
|
|
|||
41
pl/utils.pl
41
pl/utils.pl
|
|
@ -5,13 +5,6 @@ sub add_incdir {
|
|||
$incdir = "${incdir} ${input}";
|
||||
}
|
||||
|
||||
sub add_incdir2 {
|
||||
my $input = $_[0];
|
||||
$input =~ s/\r?\n/ /g;
|
||||
|
||||
$incdir2 = "${incdir2} ${input}";
|
||||
}
|
||||
|
||||
sub add_cflags {
|
||||
my $input = $_[0];
|
||||
$input =~ s/\r?\n/ /g;
|
||||
|
|
@ -47,14 +40,10 @@ sub new_example {
|
|||
push(@examples_targets, "${_[0]}${executable_suffix}");
|
||||
}
|
||||
|
||||
sub set_shared_flag {
|
||||
@shared = $_[0];
|
||||
}
|
||||
|
||||
sub new_object {
|
||||
my @l = glob($_[0]);
|
||||
foreach my $e (@l) {
|
||||
$e =~ s/\.(c|m)$/$object_suffix/;
|
||||
$e =~ s/\.c$/$object_suffix/;
|
||||
push(@library_targets, $e);
|
||||
}
|
||||
}
|
||||
|
|
@ -65,34 +54,6 @@ sub use_backend {
|
|||
}
|
||||
}
|
||||
|
||||
sub scan_wayland_protocol_core {
|
||||
my $proto_c = "src/backend/wayland-core-protocol.c";
|
||||
|
||||
if (
|
||||
system(
|
||||
"wayland-scanner private-code /usr/share/wayland/wayland.xml ${proto_c}"
|
||||
) != 0
|
||||
)
|
||||
{
|
||||
print(
|
||||
"^ Error on getting private code for /usr/share/wayland/wayland.xml\n"
|
||||
);
|
||||
}
|
||||
else {
|
||||
new_object($proto_c);
|
||||
}
|
||||
if (
|
||||
system(
|
||||
"wayland-scanner client-header /usr/share/wayland/wayland.xml include/Mw/LowLevel/Wayland/wayland-core-protocol.h"
|
||||
)
|
||||
)
|
||||
{
|
||||
print(
|
||||
"^ Error on getting client header for /usr/share/wayland/wayland.xml\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub scan_wayland_protocol {
|
||||
my $tier = $_[0];
|
||||
my $proto = $_[1];
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -4,11 +4,7 @@
|
|||
typedef struct dir {
|
||||
HANDLE hFind;
|
||||
WIN32_FIND_DATA ffd;
|
||||
int next;
|
||||
} dir_t;
|
||||
#elif defined(CLASSIC_MAC_OS)
|
||||
typedef struct dir {
|
||||
int dummy;
|
||||
int first;
|
||||
} dir_t;
|
||||
#else
|
||||
typedef struct dir {
|
||||
|
|
@ -22,21 +18,14 @@ void* MwDirectoryOpen(const char* path) {
|
|||
#ifdef _WIN32
|
||||
char* p = malloc(strlen(path) + 2 + 1);
|
||||
strcpy(p, path);
|
||||
if(strchr(path, '/') != NULL) {
|
||||
strcat(p, "/");
|
||||
} else {
|
||||
strcat(p, "\\");
|
||||
}
|
||||
strcat(p, "*");
|
||||
strcat(p, "/*");
|
||||
if((dir->hFind = FindFirstFile(p, &dir->ffd)) == INVALID_HANDLE_VALUE) {
|
||||
free(p);
|
||||
free(dir);
|
||||
return NULL;
|
||||
}
|
||||
free(p);
|
||||
dir->next = 1;
|
||||
#elif defined(CLASSIC_MAC_OS)
|
||||
/* todo */
|
||||
dir->first = 1;
|
||||
#else
|
||||
if((dir->dir = opendir(path)) == NULL) {
|
||||
free(dir);
|
||||
|
|
@ -53,8 +42,6 @@ void MwDirectoryClose(void* handle) {
|
|||
dir_t* dir = handle;
|
||||
#ifdef _WIN32
|
||||
FindClose(dir->hFind);
|
||||
#elif defined(CLASSIC_MAC_OS)
|
||||
/* todo */
|
||||
#else
|
||||
closedir(dir->dir);
|
||||
free(dir->base);
|
||||
|
|
@ -67,10 +54,14 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
|
|||
MwDirectoryEntry* entry = malloc(sizeof(*entry));
|
||||
#ifdef _WIN32
|
||||
ULARGE_INTEGER* l;
|
||||
|
||||
if(!dir->next) return NULL;
|
||||
|
||||
if(dir->first) {
|
||||
dir->first = 0;
|
||||
} else if(FindNextFile(dir->hFind, &dir->ffd) == 0) {
|
||||
free(entry);
|
||||
return NULL;
|
||||
}
|
||||
entry->name = MwStringDuplicate(dir->ffd.cFileName);
|
||||
|
||||
if(dir->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
entry->type = MwDIRECTORY_DIRECTORY;
|
||||
} else {
|
||||
|
|
@ -86,10 +77,6 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
|
|||
l = (ULARGE_INTEGER*)&dir->ffd.ftLastWriteTime;
|
||||
|
||||
entry->mtime = l->QuadPart / 10000000 - 11644473600;
|
||||
|
||||
dir->next = FindNextFile(dir->hFind, &dir->ffd);
|
||||
#elif defined(CLASSIC_MAC_OS)
|
||||
/* todo */
|
||||
#else
|
||||
struct dirent* d;
|
||||
struct stat s;
|
||||
|
|
@ -133,8 +120,6 @@ char* MwDirectoryCurrent(void) {
|
|||
GetCurrentDirectory(len, out);
|
||||
|
||||
return out;
|
||||
#elif CLASSIC_MAC_OS
|
||||
return "";
|
||||
#else
|
||||
return getcwd(NULL, 0);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -12,43 +12,7 @@ void* MwDynamicSymbol(void* handle, const char* symbol) {
|
|||
void MwDynamicClose(void* handle) {
|
||||
FreeLibrary(handle);
|
||||
}
|
||||
#elif defined(CLASSIC_MAC_OS)
|
||||
void* MwDynamicOpen(const char* path) {
|
||||
// CFragConnectionID connID;
|
||||
// Ptr* addr;
|
||||
// unsigned char err[255];
|
||||
|
||||
// if(GetSharedLibrary((ConstStr63Param)path, kPowerPCCFragArch, kPrivateCFragCopy,
|
||||
// &connID, addr, err)) {
|
||||
// printf("Error getting %s: %s\n", path, err);
|
||||
// return NULL;
|
||||
// };
|
||||
// return connID;
|
||||
printf("MwDynamicOpen not implemented yet.\n");
|
||||
getchar();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* MwDynamicSymbol(void* handle, const char* symbol) {
|
||||
// CFragConnectionID connID = (CFragConnectionID)handle;
|
||||
// Ptr* symAddr;
|
||||
// CFragSymbolClass* symClass;
|
||||
// OSErr err;
|
||||
// if((err = FindSymbol(connID, (ConstStr63Param)symbol, symAddr, symClass))) {
|
||||
// printf("Error getting %s: %d\n", symbol, err);
|
||||
// return NULL;
|
||||
// };
|
||||
// return symAddr;
|
||||
printf("MwDynamicSymbol not implemented yet.\n");
|
||||
getchar();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void MwDynamicClose(void* handle) {
|
||||
// CFragConnectionID connID = (CFragConnectionID)handle;
|
||||
// CloseConnection(&connID);
|
||||
}
|
||||
#elif defined(__unix__) || defined(__APPLE__)
|
||||
#elif defined(__unix__)
|
||||
void* MwDynamicOpen(const char* path) {
|
||||
return dlopen(path, RTLD_LOCAL | RTLD_LAZY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,53 +8,6 @@ long MwTimeGetTick(void) {
|
|||
void MwTimeSleep(int ms) {
|
||||
Sleep(ms);
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
long MwTimeGetTick(void) {
|
||||
struct timespec ts;
|
||||
long n = 0;
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
clock_get_time(cclock, &mts);
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
|
||||
n += ts.tv_nsec / 1000 / 1000;
|
||||
n += ts.tv_sec * 1000;
|
||||
|
||||
return n;
|
||||
}
|
||||
void MwTimeSleep(int ms) {
|
||||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = ms / 1000;
|
||||
ts.tv_nsec = (ms % 1000) * 1000 * 1000;
|
||||
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
#elif defined(CLASSIC_MAC_OS)
|
||||
// static TMTask tm;
|
||||
// static int timer;
|
||||
// void timerUpdateFunc(void) {
|
||||
// timer += 1;
|
||||
// PrimeTime((QElemPtr)&tm, 1);
|
||||
// };
|
||||
|
||||
long MwTimeGetTick(void) {
|
||||
UnsignedWide h;
|
||||
Microseconds(&h);
|
||||
return h.lo;
|
||||
}
|
||||
void MwTimeSleep(int ms) {
|
||||
// tm.tmAddr = NewTimerProc(timerUpdateFunc);
|
||||
// tm.tmWakeUp = 0;
|
||||
// tm.tmReserved = 0;
|
||||
|
||||
// InsTime((QElemPtr)&tm);
|
||||
// PrimeTime((QElemPtr)&tm, 1);
|
||||
|
||||
// DisposeTimerUPP(tm.tmAddr);
|
||||
}
|
||||
#elif defined(__unix__)
|
||||
long MwTimeGetTick(void) {
|
||||
struct timespec ts;
|
||||
|
|
@ -72,7 +25,7 @@ void MwTimeSleep(int ms) {
|
|||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = ms / 1000;
|
||||
ts.tv_nsec = (ms % 1000) * 1000000;
|
||||
ts.tv_nsec = (ms % 1000) * 1000 * 1000;
|
||||
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@
|
|||
\
|
||||
MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \
|
||||
MwLLGetScreenSize = MwLLGetScreenSizeImpl; \
|
||||
\
|
||||
MwLLSetDarkTheme = MwLLSetDarkThemeImpl; \
|
||||
\
|
||||
return 0; \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,357 +0,0 @@
|
|||
#include <Mw/Milsko.h>
|
||||
#include <Threads.h>
|
||||
#include <QuickDraw.h>
|
||||
|
||||
#include "../../external/stb_ds.h"
|
||||
|
||||
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||
MwLL r;
|
||||
r = malloc(sizeof(*r));
|
||||
memset(r, 0, sizeof(*r));
|
||||
MwLLCreateCommon(r);
|
||||
|
||||
r->cmacos.parent = parent;
|
||||
|
||||
if(x == MwDEFAULT) {
|
||||
x = (qd.screenBits.bounds.right / 2) - (width / 2);
|
||||
}
|
||||
if(y == MwDEFAULT) {
|
||||
y = (qd.screenBits.bounds.bottom / 2) - (height / 2);
|
||||
}
|
||||
|
||||
/* todo: how do we set parent windows? If we can't, what is our equivalant to MacOS's NSViews, Wayland's subsurfaces, etc.? */
|
||||
SetRect(&r->cmacos.winRect, x, y, width, height);
|
||||
r->cmacos.window = newcwindow(nil, &r->cmacos.winRect, "", true,
|
||||
documentProc, (WindowPtr)(-1), true, 0);
|
||||
SetPort(r->cmacos.window);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void MwLLDestroyImpl(MwLL handle) {
|
||||
MwLLDestroyCommon(handle);
|
||||
|
||||
free(handle);
|
||||
}
|
||||
|
||||
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||
}
|
||||
|
||||
static void MwLLEndDrawImpl(MwLL handle) {
|
||||
}
|
||||
|
||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||
int i;
|
||||
PolyHandle p;
|
||||
RGBColor col;
|
||||
|
||||
SetPort(handle->cmacos.window);
|
||||
BeginUpdate(handle->cmacos.window);
|
||||
|
||||
p = OpenPoly();
|
||||
col.red = color->common.red * 0x101;
|
||||
col.green = color->common.green * 0x101;
|
||||
col.blue = color->common.blue * 0x101;
|
||||
|
||||
RGBForeColor(&col);
|
||||
PenMode(patCopy);
|
||||
|
||||
for(i = 0; i < points_count; i++) {
|
||||
if(i == 0) {
|
||||
MoveTo(points[i].x, points[i].y);
|
||||
} else {
|
||||
LineTo(points[i].x, points[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
ClosePoly();
|
||||
FillCPoly(p, &qd.ltGray);
|
||||
KillPoly(p);
|
||||
|
||||
EndUpdate(handle->cmacos.window);
|
||||
}
|
||||
|
||||
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
||||
RGBColor col;
|
||||
SetPort(handle->cmacos.window);
|
||||
|
||||
col.red = color->common.red;
|
||||
col.green = color->common.green;
|
||||
col.blue = color->common.blue;
|
||||
|
||||
RGBForeColor(&col);
|
||||
|
||||
PenMode(patCopy);
|
||||
|
||||
MoveTo(points[0].x, points[0].y);
|
||||
LineTo(points[1].x, points[1].y);
|
||||
}
|
||||
|
||||
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
||||
MwLLColor c = malloc(sizeof(*c));
|
||||
MwLLColorUpdate(handle, c, r, g, b);
|
||||
return c;
|
||||
}
|
||||
|
||||
static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
|
||||
c->common.red = r;
|
||||
c->common.green = g;
|
||||
c->common.blue = b;
|
||||
}
|
||||
|
||||
static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
|
||||
Rect bounds;
|
||||
GetWindowBounds(handle->cmacos.window, kWindowContentRgn, &bounds);
|
||||
*x = bounds.left;
|
||||
*y = bounds.top;
|
||||
*w = bounds.right;
|
||||
*h = bounds.bottom;
|
||||
}
|
||||
|
||||
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
||||
MoveWindow(handle->cmacos.window, x, y, MwTRUE);
|
||||
}
|
||||
|
||||
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
||||
SizeWindow(handle->cmacos.window, w, h, MwTRUE);
|
||||
}
|
||||
|
||||
static void MwLLFreeColorImpl(MwLLColor color) {
|
||||
free(color);
|
||||
}
|
||||
|
||||
static int MwLLPendingImpl(MwLL handle) {
|
||||
YieldToAnyThread();
|
||||
return EventAvail(everyEvent, &handle->cmacos.event);
|
||||
}
|
||||
|
||||
static void MwLLNextEventImpl(MwLL handle) {
|
||||
EventRecord event;
|
||||
GetNextEvent(everyEvent, &event);
|
||||
|
||||
switch(event.what) {
|
||||
case updateEvt: {
|
||||
}
|
||||
// MwLLDispatch(handle, draw, NULL);
|
||||
break;
|
||||
case osEvt:
|
||||
break;
|
||||
case mouseUp: {
|
||||
// MwLLMouse m;
|
||||
// m.button = MwLLMouseLeft;
|
||||
// if(___curWindow->mouseButtonCallback != NULL) {
|
||||
// int mods = MacModifiersToGLFWModifiers(event.modifiers);
|
||||
|
||||
// if(___curWindow->keyStateMap[MK_LCTRL] == 1) {
|
||||
// ___curWindow->mouseButtonCallback(
|
||||
// ___curWindow, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE, mods);
|
||||
// } else {
|
||||
// ___curWindow->mouseButtonCallback(
|
||||
// ___curWindow, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, mods);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
case mouseDown: {
|
||||
// // start with callback stuff
|
||||
// if(___curWindow->mouseButtonCallback != NULL) {
|
||||
// int mods = MacModifiersToGLFWModifiers(event.modifiers);
|
||||
|
||||
// if(___curWindow->keyStateMap[MK_LCTRL] == 1) {
|
||||
// ___curWindow->mouseButtonCallback(
|
||||
// ___curWindow, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
|
||||
// } else {
|
||||
// ___curWindow->mouseButtonCallback(
|
||||
// ___curWindow, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
|
||||
// }
|
||||
// }
|
||||
|
||||
// then do system stuff
|
||||
switch(FindWindow(event.where, &handle->cmacos.window)) {
|
||||
case inDrag:
|
||||
DragWindow(handle->cmacos.window, event.where, &qd.screenBits.bounds);
|
||||
// if(___curWindow->windowPosCallback != NULL) {
|
||||
// ___curWindow->windowPosCallback(___curWindow, event.where.h,
|
||||
// event.where.v);
|
||||
// }
|
||||
break;
|
||||
case inGrow: {
|
||||
long growResult =
|
||||
GrowWindow(handle->cmacos.window, event.where, &qd.screenBits.bounds);
|
||||
|
||||
int width = growResult & 0xFFFF;
|
||||
int height = growResult >> 16;
|
||||
|
||||
SizeWindow(handle->cmacos.window, growResult & 0xFFFF, growResult >> 16, true);
|
||||
|
||||
Rect rect;
|
||||
GetWindowBounds(handle->cmacos.window, kWindowStructureRgn, &rect);
|
||||
rect.right = width;
|
||||
rect.bottom = height;
|
||||
SetWindowBounds(handle->cmacos.window, kWindowStructureRgn, &rect);
|
||||
|
||||
// ___curWindow->width = width;
|
||||
// ___curWindow->height = height;
|
||||
|
||||
// if(___curWindow->windowSizeCallback != NULL) {
|
||||
// ___curWindow->windowSizeCallback(___curWindow, width, height);
|
||||
// }
|
||||
// if(___curWindow->windowSetFramebufferSizeCallback != NULL) {
|
||||
// ___curWindow->windowSetFramebufferSizeCallback(___curWindow,
|
||||
// width, height);
|
||||
// }
|
||||
} break;
|
||||
|
||||
case inGoAway: {
|
||||
if(TrackGoAway(handle->cmacos.window, event.where)) {
|
||||
MwLLDispatch(handle, close, NULL);
|
||||
// if(___curWindow->windowCloseCallback != NULL) {
|
||||
// ___curWindow->windowCloseCallback(___curWindow);
|
||||
// }
|
||||
// ___curWindow->shouldClose = true;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
case autoKey:
|
||||
case keyDown:
|
||||
case keyUp: {
|
||||
// // key char stuff
|
||||
// unsigned char ch = (event.message & charCodeMask);
|
||||
// if(*___curWindow->charCallback != NULL) {
|
||||
// ___curWindow->charCallback(___curWindow, ch);
|
||||
// }
|
||||
|
||||
// // key state map
|
||||
// unsigned char key = (event.message & keyCodeMask) >> 8;
|
||||
// ___curWindow->keyStateMap[key] = 0;
|
||||
// if(event.what == keyDown || event.what == autoKey) {
|
||||
// ___curWindow->keyStateMap[key] &= 1;
|
||||
// }
|
||||
|
||||
// if(*___curWindow->keyCallback != NULL) {
|
||||
// int key = MacKeyToGLFWKey(event.message);
|
||||
// int scancode = (event.message & adbAddrMask) >> 16;
|
||||
|
||||
// int mods = MacModifiersToGLFWModifiers(event.modifiers);
|
||||
|
||||
// int action;
|
||||
// if(event.what == keyUp) {
|
||||
// action = GLFW_RELEASE;
|
||||
// } else {
|
||||
// action = GLFW_PRESS;
|
||||
// }
|
||||
// ___curWindow->keyCallback(___curWindow, key, scancode, action,
|
||||
// mods);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
FlushEvents(everyEvent, -1);
|
||||
YieldToAnyThread();
|
||||
}
|
||||
|
||||
static void MwLLSetTitleImpl(MwLL handle, const char* title) {
|
||||
setwtitle(handle->cmacos.window, title);
|
||||
}
|
||||
|
||||
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
|
||||
MwLLPixmap r = malloc(sizeof(*r));
|
||||
|
||||
r->common.raw = malloc(4 * width * height);
|
||||
memcpy(r->common.raw, data, 4 * width * height);
|
||||
|
||||
MwLLPixmapUpdate(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
|
||||
}
|
||||
|
||||
static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
|
||||
}
|
||||
|
||||
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
||||
}
|
||||
|
||||
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
|
||||
}
|
||||
|
||||
static void MwLLForceRenderImpl(MwLL handle) {
|
||||
}
|
||||
|
||||
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
|
||||
}
|
||||
|
||||
static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
|
||||
}
|
||||
|
||||
static void MwLLShowImpl(MwLL handle, int show) {
|
||||
if(show)
|
||||
ShowWindow(handle->cmacos.window);
|
||||
else
|
||||
HideWindow(handle->cmacos.window);
|
||||
}
|
||||
|
||||
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
|
||||
}
|
||||
|
||||
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
|
||||
}
|
||||
|
||||
static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
|
||||
}
|
||||
|
||||
static void MwLLFocusImpl(MwLL handle) {
|
||||
HiliteWindow(handle->cmacos.window, MwTRUE);
|
||||
}
|
||||
|
||||
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
||||
}
|
||||
|
||||
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
|
||||
/* TODO */
|
||||
|
||||
(void)handle;
|
||||
(void)text;
|
||||
}
|
||||
|
||||
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
|
||||
}
|
||||
|
||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||
}
|
||||
|
||||
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
|
||||
}
|
||||
|
||||
static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
|
||||
}
|
||||
|
||||
static void MwLLBeginStateChangeImpl(MwLL handle) {
|
||||
MwLLShow(handle, 0);
|
||||
}
|
||||
|
||||
static void MwLLEndStateChangeImpl(MwLL handle) {
|
||||
MwLLShow(handle, 1);
|
||||
}
|
||||
|
||||
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) {
|
||||
(void)handle;
|
||||
(void)toggle;
|
||||
}
|
||||
|
||||
static int MwLLClassicMacOSCallInitImpl(void) {
|
||||
InitGraf(&qd.thePort);
|
||||
InitFonts();
|
||||
FlushEvents(everyEvent, 0);
|
||||
InitWindows();
|
||||
InitMenus();
|
||||
TEInit();
|
||||
InitDialogs(0L);
|
||||
InitCursor();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "call.c"
|
||||
CALL(ClassicMacOS);
|
||||
1115
src/backend/cocoa.m
1115
src/backend/cocoa.m
File diff suppressed because it is too large
Load diff
|
|
@ -8,40 +8,6 @@ typedef struct userdata {
|
|||
int max_set;
|
||||
} userdata_t;
|
||||
|
||||
static struct symtbl {
|
||||
void* lib_dwmapi;
|
||||
|
||||
HRESULT(WINAPI* DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
|
||||
} wsymtbl;
|
||||
|
||||
#define DwmSetWindowAttribute wsymtbl.DwmSetWindowAttribute
|
||||
|
||||
static void detect_darktheme(MwLL handle) {
|
||||
DWORD dw;
|
||||
DWORD sz = sizeof(dw);
|
||||
int err, t;
|
||||
HKEY hkey;
|
||||
DWORD type;
|
||||
|
||||
err = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_QUERY_VALUE, &hkey);
|
||||
if(err != ERROR_SUCCESS) return;
|
||||
|
||||
err = RegQueryValueEx(hkey, "AppsUseLightTheme", NULL, &type, (PBYTE)&dw, &sz);
|
||||
RegCloseKey(hkey);
|
||||
if(err != ERROR_SUCCESS || type != REG_DWORD) {
|
||||
return;
|
||||
}
|
||||
|
||||
t = dw ? 0 : 1;
|
||||
|
||||
if(t && DwmSetWindowAttribute != NULL) {
|
||||
LPARAM style = GetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE);
|
||||
if(!(style & WS_CHILD)) MwLLSetDarkTheme(handle, 1);
|
||||
}
|
||||
|
||||
MwLLDispatch(handle, dark_theme, &t);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||
userdata_t* u = (userdata_t*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||
|
||||
|
|
@ -79,44 +45,44 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
|||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
} else if(msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
|
||||
MwMouse p;
|
||||
MwLLMouse p;
|
||||
p.point.x = LOWORD(lp);
|
||||
p.point.y = HIWORD(lp);
|
||||
if(msg == WM_LBUTTONDOWN) {
|
||||
p.button = MwMOUSE_LEFT;
|
||||
p.button = MwLLMouseLeft;
|
||||
} else if(msg == WM_MBUTTONDOWN) {
|
||||
p.button = MwMOUSE_MIDDLE;
|
||||
p.button = MwLLMouseMiddle;
|
||||
} else if(msg == WM_RBUTTONDOWN) {
|
||||
p.button = MwMOUSE_RIGHT;
|
||||
p.button = MwLLMouseRight;
|
||||
}
|
||||
|
||||
SetCapture(hWnd);
|
||||
SetFocus(hWnd);
|
||||
MwLLDispatch(u->ll, down, &p);
|
||||
} else if(msg == WM_LBUTTONUP || msg == WM_MBUTTONUP || msg == WM_RBUTTONUP) {
|
||||
MwMouse p;
|
||||
MwLLMouse p;
|
||||
p.point.x = LOWORD(lp);
|
||||
p.point.y = HIWORD(lp);
|
||||
if(msg == WM_LBUTTONUP) {
|
||||
p.button = MwMOUSE_LEFT;
|
||||
p.button = MwLLMouseLeft;
|
||||
} else if(msg == WM_MBUTTONUP) {
|
||||
p.button = MwMOUSE_MIDDLE;
|
||||
p.button = MwLLMouseMiddle;
|
||||
} else if(msg == WM_RBUTTONUP) {
|
||||
p.button = MwMOUSE_RIGHT;
|
||||
p.button = MwLLMouseRight;
|
||||
}
|
||||
|
||||
SetCapture(NULL);
|
||||
MwLLDispatch(u->ll, up, &p);
|
||||
} else if(msg == WM_MOUSEWHEEL) {
|
||||
int d = GET_WHEEL_DELTA_WPARAM(wp);
|
||||
MwMouse p;
|
||||
MwLLMouse p;
|
||||
p.point.x = LOWORD(lp);
|
||||
p.point.y = HIWORD(lp);
|
||||
|
||||
if(d > 0) {
|
||||
p.button = MwMOUSE_WHEELUP;
|
||||
p.button = MwLLMouseWheelUp;
|
||||
} else if(d < 0) {
|
||||
p.button = MwMOUSE_WHEELDOWN;
|
||||
p.button = MwLLMouseWheelDown;
|
||||
}
|
||||
|
||||
MwLLDispatch(u->ll, down, &p);
|
||||
|
|
@ -239,13 +205,6 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
|||
} else if(msg == WM_USER) {
|
||||
InvalidateRect(hWnd, NULL, FALSE);
|
||||
UpdateWindow(hWnd);
|
||||
} else if(msg == WM_WININICHANGE) {
|
||||
char* s = (char*)lp;
|
||||
LPARAM style = GetWindowLongPtr(hWnd, GWL_STYLE);
|
||||
|
||||
if(!(style & WS_CHILD)) {
|
||||
if(s != NULL && strcmp(s, "ImmersiveColorSet") == 0) detect_darktheme(u->ll);
|
||||
}
|
||||
} else {
|
||||
return DefWindowProc(hWnd, msg, wp, lp);
|
||||
}
|
||||
|
|
@ -278,8 +237,6 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||
r->common.copy_buffer = 1;
|
||||
r->common.type = MwLLBackendGDI;
|
||||
|
||||
r->gdi.get_clipboard = 0;
|
||||
if(parent == NULL) r->gdi.get_darktheme = 1;
|
||||
r->gdi.force_render = 0;
|
||||
r->gdi.grabbed = 0;
|
||||
r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL);
|
||||
|
|
@ -426,7 +383,6 @@ static int MwLLPendingImpl(MwLL handle) {
|
|||
|
||||
(void)handle;
|
||||
|
||||
if(handle->gdi.get_clipboard || handle->gdi.get_darktheme) return 1;
|
||||
return PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
|
@ -435,29 +391,6 @@ static void MwLLNextEventImpl(MwLL handle) {
|
|||
|
||||
(void)handle;
|
||||
|
||||
if(handle->gdi.get_clipboard) {
|
||||
HGLOBAL hg;
|
||||
if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) {
|
||||
char* txt = malloc(GlobalSize(hg));
|
||||
char* clp = GlobalLock(hg);
|
||||
|
||||
strcpy(txt, clp);
|
||||
|
||||
GlobalUnlock(hg);
|
||||
CloseClipboard();
|
||||
|
||||
MwLLDispatch(handle, clipboard, txt);
|
||||
|
||||
free(txt);
|
||||
}
|
||||
|
||||
handle->gdi.get_clipboard = 0;
|
||||
}
|
||||
if(handle->gdi.get_darktheme) {
|
||||
detect_darktheme(handle);
|
||||
|
||||
handle->gdi.get_darktheme = 0;
|
||||
}
|
||||
while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) {
|
||||
GetMessage(&msg, handle->gdi.hWnd, 0, 0);
|
||||
TranslateMessage(&msg);
|
||||
|
|
@ -602,8 +535,8 @@ HCURSOR MwLLGDICreateCursor(MwCursor* image, MwCursor* mask) {
|
|||
int y, x, ys, xs;
|
||||
|
||||
xs = -mask->x + image->x;
|
||||
ys = mask->height + mask->y;
|
||||
ys = image->height + image->y - ys;
|
||||
ys = MwCursorDataHeight + mask->y;
|
||||
ys = MwCursorDataHeight + image->y - ys;
|
||||
|
||||
memset(dmask, 0xff, (MwCursorDataHeight / 8) * MwCursorDataHeight);
|
||||
memset(dimage, 0, (MwCursorDataHeight / 8) * MwCursorDataHeight);
|
||||
|
|
@ -634,7 +567,7 @@ HCURSOR MwLLGDICreateCursor(MwCursor* image, MwCursor* mask) {
|
|||
}
|
||||
}
|
||||
|
||||
cursor = CreateCursor(GetModuleHandle(NULL), xs - image->x, ys + (MwCursorDataHeight + image->y), MwCursorDataHeight, MwCursorDataHeight, dmask, dimage);
|
||||
cursor = CreateCursor(GetModuleHandle(NULL), xs, ys, MwCursorDataHeight, MwCursorDataHeight, dmask, dimage);
|
||||
|
||||
free(dimage);
|
||||
free(dmask);
|
||||
|
|
@ -676,8 +609,6 @@ static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
|
|||
rc2.bottom -= rc2.top;
|
||||
|
||||
SetWindowPos(handle->gdi.hWnd, HWND_TOPMOST, rc.left, rc.top, rc2.right == 0 ? 1 : rc2.right, rc2.bottom == 0 ? 1 : rc2.bottom, SWP_FRAMECHANGED | SWP_NOACTIVATE);
|
||||
|
||||
handle->gdi.get_darktheme = 1;
|
||||
}
|
||||
|
||||
static void MwLLShowImpl(MwLL handle, int show) {
|
||||
|
|
@ -748,9 +679,8 @@ static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
|||
}
|
||||
}
|
||||
|
||||
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
|
||||
static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
|
||||
HGLOBAL hg;
|
||||
(void)clipboard_type;
|
||||
if(OpenClipboard(handle->gdi.hWnd) != 0) {
|
||||
char* lock;
|
||||
|
||||
|
|
@ -767,9 +697,21 @@ static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_ty
|
|||
}
|
||||
}
|
||||
|
||||
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
|
||||
(void)clipboard_type;
|
||||
handle->gdi.get_clipboard = 1; /* nishi: we do this to make clipboard api work similar to other backends */
|
||||
static char* MwLLGetClipboardImpl(MwLL handle) {
|
||||
HGLOBAL hg;
|
||||
char* r = NULL;
|
||||
if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) {
|
||||
char* lock;
|
||||
|
||||
r = malloc(GlobalSize(hg));
|
||||
|
||||
lock = GlobalLock(hg);
|
||||
strcpy(r, lock);
|
||||
GlobalUnlock(hg);
|
||||
|
||||
CloseClipboard();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||
|
|
@ -819,19 +761,7 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
|
|||
(void)handle;
|
||||
}
|
||||
|
||||
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) {
|
||||
BOOL v = toggle ? TRUE : FALSE;
|
||||
|
||||
DwmSetWindowAttribute(handle->gdi.hWnd, 20, &v, sizeof(v));
|
||||
}
|
||||
|
||||
static int MwLLGDICallInitImpl(void) {
|
||||
memset(&wsymtbl, 0, sizeof(wsymtbl));
|
||||
|
||||
wsymtbl.lib_dwmapi = MwDynamicOpen("dwmapi.dll");
|
||||
|
||||
if(wsymtbl.lib_dwmapi != NULL) DwmSetWindowAttribute = MwDynamicSymbol(wsymtbl.lib_dwmapi, "DwmSetWindowAttribute");
|
||||
|
||||
/* TODO: check properly */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -2,190 +2,6 @@
|
|||
|
||||
#include "../../external/stb_ds.h"
|
||||
|
||||
#define ClipboardTimeout 100
|
||||
|
||||
static struct symtbl {
|
||||
void* lib_xlib;
|
||||
void* lib_xrender;
|
||||
MwBool has_xrender;
|
||||
|
||||
#ifdef USE_DBUS
|
||||
MwLLDBusFuncTable dbus;
|
||||
MwBool has_dbus;
|
||||
#endif
|
||||
|
||||
int (*XClearWindow)(Display* display, Window w);
|
||||
XImage* (*XCreateImage)(Display*, Visual*, unsigned int, int, int, char*, unsigned int, unsigned int, int, int);
|
||||
Display* (*XOpenDisplay)(_Xconst char*);
|
||||
char* (*XKeysymToString)(KeySym);
|
||||
Atom (*XInternAtom)(Display*, _Xconst char*, Bool);
|
||||
Cursor (*XCreatePixmapCursor)(Display*, Pixmap, Pixmap, XColor*, XColor*, unsigned int, unsigned int);
|
||||
GC (*XCreateGC)(Display*, Drawable, unsigned long, XGCValues*);
|
||||
Pixmap (*XCreatePixmap)(Display*, Drawable, unsigned int, unsigned int, unsigned int);
|
||||
Window (*XCreateSimpleWindow)(Display*, Window, int, int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned long);
|
||||
VisualID (*XVisualIDFromVisual)(Visual*);
|
||||
Window (*XRootWindow)(Display*, int);
|
||||
Status (*XSetWMProtocols)(Display*, Window, Atom*, int);
|
||||
int (*XSetTransientForHint)(Display*, Window, Window);
|
||||
Status (*XAllocColor)(Display*, Colormap, XColor*);
|
||||
int (*XChangeProperty)(Display*, Window, Atom, Atom, int, int, _Xconst unsigned char*, int);
|
||||
int (*XChangeWindowAttributes)(Display*, Window, unsigned long, XSetWindowAttributes*);
|
||||
Bool (*XCheckTypedWindowEvent)(Display*, Window, int, XEvent*);
|
||||
Bool (*XCheckWindowEvent)(Display*, Window, long, XEvent*);
|
||||
int (*XCloseDisplay)(Display*);
|
||||
int (*XConfigureWindow)(Display*, Window, unsigned int, XWindowChanges*);
|
||||
int (*XConvertSelection)(Display*, Atom, Atom, Atom, Window, Time);
|
||||
int (*XCopyArea)(Display*, Drawable, Drawable, GC, int, int, unsigned int, unsigned int, int, int);
|
||||
int (*XDefaultScreen)(Display*);
|
||||
int (*XDefineCursor)(Display*, Window, Cursor);
|
||||
int (*XDeleteProperty)(Display*, Window, Atom);
|
||||
int (*XDestroyWindow)(Display*, Window);
|
||||
int (*XDrawLine)(Display*, Drawable, GC, int, int, int, int);
|
||||
int (*XFillPolygon)(Display*, Drawable, GC, XPoint*, int, int, int);
|
||||
int (*XFree)(void*);
|
||||
int (*XFreeCursor)(Display*, Cursor);
|
||||
int (*XFreeGC)(Display*, GC);
|
||||
int (*XFreePixmap)(Display*, Pixmap);
|
||||
Status (*XGetGeometry)(Display*, Drawable, Window*, int*, int*, unsigned int*, unsigned int*, unsigned int*, unsigned int*);
|
||||
int (*XGetWindowProperty)(Display*, Window, Atom, long, long, Bool, Atom, Atom*, int*, unsigned long*, unsigned long*, unsigned char**);
|
||||
Status (*XGetWindowAttributes)(Display*, Window, XWindowAttributes*);
|
||||
int (*XMapWindow)(Display*, Window);
|
||||
int (*XNextEvent)(Display*, XEvent*);
|
||||
int (*XPending)(Display*);
|
||||
int (*XPutBackEvent)(Display*, XEvent*);
|
||||
int (*XPutImage)(Display*, Drawable, GC, XImage*, int, int, int, int, unsigned int, unsigned int);
|
||||
Bool (*XQueryPointer)(Display*, Window, Window*, Window*, int*, int*, int*, int*, unsigned int*);
|
||||
Status (*XQueryTree)(Display*, Window, Window*, Window*, Window**, unsigned int*);
|
||||
int (*XReparentWindow)(Display*, Window, Window, int, int);
|
||||
int (*XSelectInput)(Display*, Window, long);
|
||||
Status (*XSendEvent)(Display*, Window, Bool, long, XEvent*);
|
||||
int (*XSetClipMask)(Display*, GC, Pixmap);
|
||||
int (*XSetClipOrigin)(Display*, GC, int, int);
|
||||
int (*XSetForeground)(Display*, GC, unsigned long);
|
||||
int (*XSetGraphicsExposures)(Display*, GC, Bool);
|
||||
int (*XSetInputFocus)(Display*, Window, int, Time);
|
||||
int (*XSetWindowBackgroundPixmap)(Display*, Window, Pixmap);
|
||||
int (*XSync)(Display*, Bool);
|
||||
Bool (*XTranslateCoordinates)(Display*, Window, Window, int, int, int*, int*, Window*);
|
||||
int (*XUnmapWindow)(Display*, Window);
|
||||
int (*XWarpPointer)(Display*, Window, Window, int, int, unsigned int, unsigned int, int, int);
|
||||
char* (*XSetLocaleModifiers)(const char*);
|
||||
XIM (*XOpenIM)(Display*, struct _XrmHashBucketRec*, char*, char*);
|
||||
Status (*XCloseIM)(XIM);
|
||||
XIC (*XCreateIC)(XIM, ...);
|
||||
void (*XDestroyIC)(XIC);
|
||||
void (*XSetICFocus)(XIC);
|
||||
|
||||
XSizeHints* (*XAllocSizeHints)(void);
|
||||
XVisualInfo* (*XGetVisualInfo)(Display*, long, XVisualInfo*, int*);
|
||||
Status (*XGetWMNormalHints)(Display*, Window, XSizeHints*, long*);
|
||||
Status (*XGetWMSizeHints)(Display*, Window, XSizeHints*, long*, Atom);
|
||||
int (*XLookupString)(XKeyEvent*, char*, int, KeySym*, XComposeStatus*);
|
||||
int (*XSetStandardProperties)(Display*, Window, _Xconst char*, _Xconst char*, Pixmap, char**, int, XSizeHints*);
|
||||
void (*XSetWMNormalHints)(Display*, Window, XSizeHints*);
|
||||
void (*XSetWMSizeHints)(Display*, Window, XSizeHints*, Atom);
|
||||
|
||||
#if USE_XRENDER
|
||||
Bool (*XRenderQueryExtension)(Display* dpy, int* event_basep, int* error_basep);
|
||||
|
||||
XRenderPictFormat* (*XRenderFindStandardFormat)(Display* dpy, int format);
|
||||
|
||||
Picture (*XRenderCreatePicture)(Display* dpy, Drawable drawable,
|
||||
_Xconst XRenderPictFormat* format,
|
||||
unsigned long valuemask,
|
||||
_Xconst XRenderPictureAttributes* attributes);
|
||||
|
||||
void (*XRenderFreePicture)(Display* dpy, Picture picture);
|
||||
|
||||
void (*XRenderSetPictureTransform)(Display* dpy, Picture picture,
|
||||
XTransform* transform);
|
||||
|
||||
void (*XRenderComposite)(Display* dpy, int op, Picture src, Picture mask,
|
||||
Picture dst, int src_x, int src_y, int mask_x, int mask_y,
|
||||
int dst_x, int dst_y, unsigned int width,
|
||||
unsigned int height);
|
||||
#endif
|
||||
} xsymtbl;
|
||||
|
||||
#define XClearWindow xsymtbl.XClearWindow
|
||||
#define XCreateIC xsymtbl.XCreateIC
|
||||
#define XFree xsymtbl.XFree
|
||||
#define XFreeCursor xsymtbl.XFreeCursor
|
||||
#define XConfigureWindow xsymtbl.XConfigureWindow
|
||||
#define XCheckTypedWindowEvent xsymtbl.XCheckTypedWindowEvent
|
||||
#define XGetWMNormalHints xsymtbl.XGetWMNormalHints
|
||||
#define XLookupString xsymtbl.XLookupString
|
||||
#define XCreateImage xsymtbl.XCreateImage
|
||||
#define XSetClipMask xsymtbl.XSetClipMask
|
||||
#define XConvertSelection xsymtbl.XConvertSelection
|
||||
#define XGetWindowProperty xsymtbl.XGetWindowProperty
|
||||
#define XSetWMNormalHints xsymtbl.XSetWMNormalHints
|
||||
#define XTranslateCoordinates xsymtbl.XTranslateCoordinates
|
||||
#define XCreateSimpleWindow xsymtbl.XCreateSimpleWindow
|
||||
#define XGetWMSizeHints xsymtbl.XGetWMSizeHints
|
||||
#define XRootWindow xsymtbl.XRootWindow
|
||||
#define XOpenDisplay xsymtbl.XOpenDisplay
|
||||
#define XCopyArea xsymtbl.XCopyArea
|
||||
#define XDeleteProperty xsymtbl.XDeleteProperty
|
||||
#define XDrawLine xsymtbl.XDrawLine
|
||||
#define XSetGraphicsExposures xsymtbl.XSetGraphicsExposures
|
||||
#define XDestroyWindow xsymtbl.XDestroyWindow
|
||||
#define XCloseDisplay xsymtbl.XCloseDisplay
|
||||
#define XSetForeground xsymtbl.XSetForeground
|
||||
#define XGetGeometry xsymtbl.XGetGeometry
|
||||
#define XUnmapWindow xsymtbl.XUnmapWindow
|
||||
#define XSetTransientForHint xsymtbl.XSetTransientForHint
|
||||
#define XSetWMSizeHints xsymtbl.XSetWMSizeHints
|
||||
#define XCreatePixmapCursor xsymtbl.XCreatePixmapCursor
|
||||
#define XFreeGC xsymtbl.XFreeGC
|
||||
#define XNextEvent xsymtbl.XNextEvent
|
||||
#define XSetWMProtocols xsymtbl.XSetWMProtocols
|
||||
#define XDefaultScreen xsymtbl.XDefaultScreen
|
||||
#define XKeysymToString xsymtbl.XKeysymToString
|
||||
#define XMapWindow xsymtbl.XMapWindow
|
||||
#define XPutBackEvent xsymtbl.XPutBackEvent
|
||||
#define XCreateGC xsymtbl.XCreateGC
|
||||
#define XSelectInput xsymtbl.XSelectInput
|
||||
#define XSetInputFocus xsymtbl.XSetInputFocus
|
||||
#define XDestroyIC xsymtbl.XDestroyIC
|
||||
#define XSync xsymtbl.XSync
|
||||
#define XSendEvent xsymtbl.XSendEvent
|
||||
#define XSetICFocus xsymtbl.XSetICFocus
|
||||
#define XWarpPointer xsymtbl.XWarpPointer
|
||||
#define XPutImage xsymtbl.XPutImage
|
||||
#define XFillPolygon xsymtbl.XFillPolygon
|
||||
#define XOpenIM xsymtbl.XOpenIM
|
||||
#define XDefineCursor xsymtbl.XDefineCursor
|
||||
#define XSetWindowBackgroundPixmap xsymtbl.XSetWindowBackgroundPixmap
|
||||
#define XAllocColor xsymtbl.XAllocColor
|
||||
#define XInternAtom xsymtbl.XInternAtom
|
||||
#define XQueryPointer xsymtbl.XQueryPointer
|
||||
#define XGetVisualInfo xsymtbl.XGetVisualInfo
|
||||
#define XVisualIDFromVisual xsymtbl.XVisualIDFromVisual
|
||||
#define XSetLocaleModifiers xsymtbl.XSetLocaleModifiers
|
||||
#define XGetWindowAttributes xsymtbl.XGetWindowAttributes
|
||||
#define XSetStandardProperties xsymtbl.XSetStandardProperties
|
||||
#define XChangeProperty xsymtbl.XChangeProperty
|
||||
#define XAllocSizeHints xsymtbl.XAllocSizeHints
|
||||
#define XCheckWindowEvent xsymtbl.XCheckWindowEvent
|
||||
#define XFreePixmap xsymtbl.XFreePixmap
|
||||
#define XReparentWindow xsymtbl.XReparentWindow
|
||||
#define XCreatePixmap xsymtbl.XCreatePixmap
|
||||
#define XSetClipOrigin xsymtbl.XSetClipOrigin
|
||||
#define XCloseIM xsymtbl.XCloseIM
|
||||
#define XQueryTree xsymtbl.XQueryTree
|
||||
#define XPending xsymtbl.XPending
|
||||
#define XChangeWindowAttributes xsymtbl.XChangeWindowAttributes
|
||||
|
||||
#if USE_XRENDER
|
||||
#define XRenderFindStandardFormat xsymtbl.XRenderFindStandardFormat
|
||||
#define XRenderCreatePicture xsymtbl.XRenderCreatePicture
|
||||
#define XRenderFreePicture xsymtbl.XRenderFreePicture
|
||||
#define XRenderComposite xsymtbl.XRenderComposite
|
||||
#define XRenderQueryExtension xsymtbl.XRenderQueryExtension
|
||||
#define XRenderSetPictureTransform xsymtbl.XRenderSetPictureTransform
|
||||
#endif
|
||||
|
||||
typedef struct mwm_hints {
|
||||
unsigned long flags;
|
||||
unsigned long functions;
|
||||
|
|
@ -193,10 +9,10 @@ typedef struct mwm_hints {
|
|||
long input_mode;
|
||||
unsigned long status;
|
||||
} mwm_hints_t;
|
||||
|
||||
enum mwm_hints_enum {
|
||||
MWM_HINTS_FUNCTIONS = (1L << 0),
|
||||
MWM_HINTS_DECORATIONS = (1L << 1),
|
||||
|
||||
MWM_FUNC_ALL = (1L << 0),
|
||||
MWM_FUNC_RESIZE = (1L << 1),
|
||||
MWM_FUNC_MOVE = (1L << 2),
|
||||
|
|
@ -313,18 +129,6 @@ static XVisualInfo* get_visual_info(Display* display) {
|
|||
return XGetVisualInfo(display, VisualIDMask, &xvi, &n);
|
||||
}
|
||||
|
||||
#ifdef USE_DBUS
|
||||
static void detect_dark_theme(MwLL handle) {
|
||||
MwU32 value = 0;
|
||||
MwU32 dark_theme = 0;
|
||||
MwLLDBusPortalGet(&xsymtbl.dbus, &handle->x11.dbus, "org.freedesktop.portal.Settings", "org.freedesktop.appearance", "color-scheme", &value);
|
||||
|
||||
dark_theme = (value == 1) ? 1 : 0;
|
||||
|
||||
MwLLDispatch(handle, dark_theme, &dark_theme);
|
||||
}
|
||||
#endif
|
||||
|
||||
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||
MwLL r;
|
||||
Window p;
|
||||
|
|
@ -355,7 +159,6 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||
r->x11.toplevel = 0;
|
||||
}
|
||||
r->x11.window = XCreateSimpleWindow(r->x11.display, p, px, py, width, height, 0, 0, WhitePixel(r->x11.display, DefaultScreen(r->x11.display)));
|
||||
|
||||
sh.flags = PWinGravity;
|
||||
sh.win_gravity = StaticGravity;
|
||||
XSetWMNormalHints(r->x11.display, r->x11.window, &sh);
|
||||
|
|
@ -384,7 +187,6 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||
|
||||
XFree(xvi);
|
||||
|
||||
#ifdef DO_XIM
|
||||
XSetLocaleModifiers("");
|
||||
if((r->x11.xim = XOpenIM(r->x11.display, 0, 0, 0)) == NULL) {
|
||||
XSetLocaleModifiers("@im=none");
|
||||
|
|
@ -397,7 +199,6 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||
XNFocusWindow, r->x11.window,
|
||||
NULL);
|
||||
XSetICFocus(r->x11.xic);
|
||||
#endif
|
||||
|
||||
r->common.copy_buffer = 1;
|
||||
r->common.type = MwLLBackendX11;
|
||||
|
|
@ -410,17 +211,8 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||
|
||||
r->x11.colormap = DefaultColormap(r->x11.display, XDefaultScreen(r->x11.display));
|
||||
r->x11.wm_delete = XInternAtom(r->x11.display, "WM_DELETE_WINDOW", False);
|
||||
r->x11.wm_protocols = XInternAtom(r->x11.display, "WM_PROTOCOLS", False);
|
||||
XSetWMProtocols(r->x11.display, r->x11.window, &r->x11.wm_delete, 1);
|
||||
|
||||
r->x11.utf8_string = XInternAtom(r->x11.display, "UTF8_STRING", False);
|
||||
r->x11.compound_text = XInternAtom(r->x11.display, "COMPOUND_TEXT", False);
|
||||
r->x11.text = XInternAtom(r->x11.display, "TEXT", False);
|
||||
r->x11.clipboard = XInternAtom(r->x11.display, "CLIPBOARD", False);
|
||||
r->x11.selection = XInternAtom(r->x11.display, "_MILSKO_SELECTION_", False);
|
||||
|
||||
r->x11.clipboard_pending = 0;
|
||||
|
||||
r->x11.gc = XCreateGC(r->x11.display, r->x11.window, 0, NULL);
|
||||
|
||||
create_pixmap(r);
|
||||
|
|
@ -446,24 +238,14 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_DBUS
|
||||
memset(&r->x11.dbus, 0, sizeof(r->x11.dbus));
|
||||
if(!parent && xsymtbl.has_dbus) {
|
||||
xsymtbl.has_dbus = MwLLDBusNewContext(&xsymtbl.dbus, &r->x11.dbus);
|
||||
r->x11.dark_theme_detection = MwTRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void MwLLDestroyImpl(MwLL handle) {
|
||||
MwLLDestroyCommon(handle);
|
||||
|
||||
#ifdef DO_XIM
|
||||
if(handle->x11.xic) XDestroyIC(handle->x11.xic);
|
||||
if(handle->x11.xim) XCloseIM(handle->x11.xim);
|
||||
#endif
|
||||
|
||||
destroy_pixmap(handle);
|
||||
XFreeGC(handle->x11.display, handle->x11.gc);
|
||||
|
|
@ -474,12 +256,6 @@ static void MwLLDestroyImpl(MwLL handle) {
|
|||
|
||||
if(handle->x11.toplevel) XCloseDisplay(handle->x11.display);
|
||||
|
||||
#ifdef USE_DBUS
|
||||
if(!xsymtbl.has_dbus) {
|
||||
MwLLDBusFreeContext(&xsymtbl.dbus, &handle->x11.dbus);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(handle);
|
||||
}
|
||||
|
||||
|
|
@ -489,8 +265,6 @@ static void MwLLBeginDrawImpl(MwLL handle) {
|
|||
|
||||
static void MwLLEndDrawImpl(MwLL handle) {
|
||||
(void)handle;
|
||||
|
||||
XClearWindow(handle->x11.display, handle->x11.window);
|
||||
}
|
||||
|
||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||
|
|
@ -637,22 +411,7 @@ static void MwLLFreeColorImpl(MwLLColor color) {
|
|||
|
||||
static int MwLLPendingImpl(MwLL handle) {
|
||||
XEvent ev;
|
||||
|
||||
if(handle->x11.dark_theme_detection) {
|
||||
handle->x11.dark_theme_detection = MwFALSE;
|
||||
#ifdef USE_DBUS
|
||||
if(xsymtbl.has_dbus) {
|
||||
detect_dark_theme(handle);
|
||||
MwLLDispatch(handle, draw, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(handle->x11.clipboard_pending && (MwTimeGetTick() - handle->x11.clipboard_time) >= ClipboardTimeout) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, ClientMessage, &ev) || XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, SelectionNotify, &ev) || XCheckWindowEvent(handle->x11.display, handle->x11.window, mask, &ev)) {
|
||||
if(XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, ClientMessage, &ev) || XCheckWindowEvent(handle->x11.display, handle->x11.window, mask, &ev)) {
|
||||
XPutBackEvent(handle->x11.display, &ev);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -661,71 +420,44 @@ static int MwLLPendingImpl(MwLL handle) {
|
|||
|
||||
static void MwLLNextEventImpl(MwLL handle) {
|
||||
XEvent ev;
|
||||
|
||||
if(handle->x11.clipboard_pending && (MwTimeGetTick() - handle->x11.clipboard_time) >= ClipboardTimeout) {
|
||||
Atom a = handle->x11.selection;
|
||||
|
||||
handle->x11.clipboard_pending++;
|
||||
handle->x11.clipboard_time = MwTimeGetTick();
|
||||
|
||||
switch(handle->x11.clipboard_pending) {
|
||||
case 2:
|
||||
a = handle->x11.compound_text;
|
||||
break;
|
||||
case 3:
|
||||
a = handle->x11.text;
|
||||
break;
|
||||
case 4:
|
||||
a = XA_STRING;
|
||||
break;
|
||||
case 5:
|
||||
handle->x11.clipboard_pending = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if(a != handle->x11.selection) {
|
||||
XConvertSelection(handle->x11.display, handle->x11.clipboard, a, handle->x11.selection, handle->x11.window, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
while(XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, ClientMessage, &ev) || XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, SelectionNotify, &ev) || XCheckWindowEvent(handle->x11.display, handle->x11.window, mask, &ev)) {
|
||||
while(XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, ClientMessage, &ev) || XCheckWindowEvent(handle->x11.display, handle->x11.window, mask, &ev)) {
|
||||
int render = 0;
|
||||
if(ev.type == Expose) {
|
||||
handle->x11.force_render = 0;
|
||||
render = 1;
|
||||
} else if(ev.type == ButtonPress) {
|
||||
MwMouse p;
|
||||
MwLLMouse p;
|
||||
p.point.x = ev.xbutton.x;
|
||||
p.point.y = ev.xbutton.y;
|
||||
if(ev.xbutton.button == Button1) {
|
||||
p.button = MwMOUSE_LEFT;
|
||||
p.button = MwLLMouseLeft;
|
||||
} else if(ev.xbutton.button == Button2) {
|
||||
p.button = MwMOUSE_MIDDLE;
|
||||
p.button = MwLLMouseMiddle;
|
||||
} else if(ev.xbutton.button == Button3) {
|
||||
p.button = MwMOUSE_RIGHT;
|
||||
p.button = MwLLMouseRight;
|
||||
} else if(ev.xbutton.button == Button4) {
|
||||
p.button = MwMOUSE_WHEELUP;
|
||||
p.button = MwLLMouseWheelUp;
|
||||
} else if(ev.xbutton.button == Button5) {
|
||||
p.button = MwMOUSE_WHEELDOWN;
|
||||
p.button = MwLLMouseWheelDown;
|
||||
}
|
||||
|
||||
XSetInputFocus(handle->x11.display, handle->x11.window, RevertToNone, CurrentTime);
|
||||
|
||||
MwLLDispatch(handle, down, &p);
|
||||
} else if(ev.type == ButtonRelease) {
|
||||
MwMouse p;
|
||||
MwLLMouse p;
|
||||
p.point.x = ev.xbutton.x;
|
||||
p.point.y = ev.xbutton.y;
|
||||
if(ev.xbutton.button == Button1) {
|
||||
p.button = MwMOUSE_LEFT;
|
||||
p.button = MwLLMouseLeft;
|
||||
} else if(ev.xbutton.button == Button2) {
|
||||
p.button = MwMOUSE_MIDDLE;
|
||||
p.button = MwLLMouseMiddle;
|
||||
} else if(ev.xbutton.button == Button3) {
|
||||
p.button = MwMOUSE_RIGHT;
|
||||
p.button = MwLLMouseRight;
|
||||
} else if(ev.xbutton.button == Button4) {
|
||||
p.button = MwMOUSE_WHEELUP;
|
||||
p.button = MwLLMouseWheelUp;
|
||||
} else if(ev.xbutton.button == Button5) {
|
||||
p.button = MwMOUSE_WHEELDOWN;
|
||||
p.button = MwLLMouseWheelDown;
|
||||
}
|
||||
|
||||
MwLLDispatch(handle, up, &p);
|
||||
|
|
@ -739,7 +471,7 @@ static void MwLLNextEventImpl(MwLL handle) {
|
|||
handle->x11.width = ev.xconfigure.width;
|
||||
handle->x11.height = ev.xconfigure.height;
|
||||
} else if(ev.type == ClientMessage) {
|
||||
if(ev.xclient.message_type == handle->x11.wm_protocols && ev.xclient.data.l[0] == (long)handle->x11.wm_delete) {
|
||||
if(ev.xclient.data.l[0] == (long)handle->x11.wm_delete) {
|
||||
MwLLDispatch(handle, close, NULL);
|
||||
}
|
||||
} else if(ev.type == FocusIn) {
|
||||
|
|
@ -780,7 +512,8 @@ static void MwLLNextEventImpl(MwLL handle) {
|
|||
strcpy(str, s);
|
||||
}
|
||||
|
||||
if(MwStringIsKeyUTF8(sym)) {
|
||||
/* HACK: this is bad, you can guess why */
|
||||
if(strlen(str) == 1) {
|
||||
char s = str[0];
|
||||
|
||||
if(ev.xkey.state & (ShiftMask | LockMask) && !(ev.xkey.state & (ControlMask | Mod1Mask))) {
|
||||
|
|
@ -826,49 +559,6 @@ static void MwLLNextEventImpl(MwLL handle) {
|
|||
MwLLDispatch(handle, key_released, &n);
|
||||
}
|
||||
}
|
||||
} else if(ev.type == SelectionNotify) {
|
||||
handle->x11.clipboard_pending = 0;
|
||||
|
||||
if(ev.xselection.property != None) {
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long nitems, after, size;
|
||||
unsigned char* pdat;
|
||||
int ret = XGetWindowProperty(handle->x11.display, handle->x11.window, handle->x11.selection, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &pdat);
|
||||
|
||||
if(pdat != NULL) XFree(pdat);
|
||||
|
||||
size = after;
|
||||
|
||||
if(ret == Success && type != None && format == 8) {
|
||||
char* buf = malloc(size + 1);
|
||||
int offset;
|
||||
|
||||
for(offset = 0; after > 0; offset += nitems) {
|
||||
ret = XGetWindowProperty(handle->x11.display, handle->x11.window, handle->x11.selection, offset / 4, after / 4 + 1, False, AnyPropertyType, &type, &format, &nitems, &after, &pdat);
|
||||
|
||||
if(ret != Success) {
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy(buf + offset, pdat, nitems);
|
||||
|
||||
XFree(pdat);
|
||||
}
|
||||
|
||||
if(buf != NULL) {
|
||||
buf[size] = 0;
|
||||
|
||||
MwLLDispatch(handle, clipboard, buf);
|
||||
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
XDeleteProperty(handle->x11.display, handle->x11.window, handle->x11.selection);
|
||||
}
|
||||
}
|
||||
if(render) {
|
||||
int x, y;
|
||||
|
|
@ -908,9 +598,7 @@ static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int wid
|
|||
r->x11.handle = handle;
|
||||
|
||||
#ifdef USE_XRENDER
|
||||
if(xsymtbl.has_xrender) {
|
||||
r->x11.use_xrender = XRenderQueryExtension(handle->x11.display, &evbase, &erbase) ? 1 : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
r->x11.image = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), r->x11.depth, ZPixmap, 0, NULL, width, height, 32, 0);
|
||||
|
|
@ -961,7 +649,7 @@ static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
|
|||
}
|
||||
|
||||
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
||||
if(rect->width <= 0 || rect->height <= 0 || pixmap->common.width <= 0 || pixmap->common.height <= 0) return;
|
||||
if(rect->width == 0 || rect->height == 0 || pixmap->common.width == 0 || pixmap->common.height == 0) return;
|
||||
#ifdef USE_XRENDER
|
||||
if(pixmap->x11.image != NULL && pixmap->x11.use_xrender) {
|
||||
Pixmap px = XCreatePixmap(handle->x11.display, handle->x11.window, pixmap->common.width, pixmap->common.height, pixmap->x11.depth);
|
||||
|
|
@ -1119,8 +807,8 @@ Cursor MwLLX11CreateCursor(Display* display, MwCursor* image, MwCursor* mask) {
|
|||
XColor cfg, cbg;
|
||||
|
||||
xs = -mask->x + image->x;
|
||||
ys = mask->height + mask->y;
|
||||
ys = image->height + image->y - ys;
|
||||
ys = MwCursorDataHeight + mask->y;
|
||||
ys = MwCursorDataHeight + image->y - ys;
|
||||
|
||||
memset(cimage->data, 0, cimage->bytes_per_line * cimage->height);
|
||||
memset(cmask->data, 0, cmask->bytes_per_line * cmask->height);
|
||||
|
|
@ -1157,7 +845,7 @@ Cursor MwLLX11CreateCursor(Display* display, MwCursor* image, MwCursor* mask) {
|
|||
XPutImage(display, pimage, imagegc, cimage, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
||||
XPutImage(display, pmask, maskgc, cmask, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
||||
|
||||
cur = XCreatePixmapCursor(display, pimage, pmask, &cfg, &cbg, xs - image->x, ys + (MwCursorDataHeight + image->y));
|
||||
cur = XCreatePixmapCursor(display, pimage, pmask, &cfg, &cbg, xs, ys);
|
||||
|
||||
XFreePixmap(display, pimage);
|
||||
XFreePixmap(display, pmask);
|
||||
|
|
@ -1261,23 +949,52 @@ static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
|||
}
|
||||
}
|
||||
|
||||
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
|
||||
static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
|
||||
/* TODO */
|
||||
|
||||
(void)handle;
|
||||
(void)text;
|
||||
(void)clipboard_type;
|
||||
}
|
||||
|
||||
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
|
||||
(void)clipboard_type;
|
||||
static char* MwLLGetClipboardImpl(MwLL handle) {
|
||||
Atom clip, target, prop;
|
||||
XEvent ev;
|
||||
XEvent* queue = NULL;
|
||||
char* r = NULL;
|
||||
|
||||
if(handle->x11.clipboard_pending) return;
|
||||
clip = XInternAtom(handle->x11.display, "CLIPBOARD", 0);
|
||||
target = XA_STRING;
|
||||
prop = XInternAtom(handle->x11.display, "XSEL_DATA", 0);
|
||||
|
||||
XConvertSelection(handle->x11.display, handle->x11.clipboard, handle->x11.utf8_string, handle->x11.selection, handle->x11.window, CurrentTime);
|
||||
XConvertSelection(handle->x11.display, clip, target, prop, handle->x11.window, CurrentTime);
|
||||
|
||||
handle->x11.clipboard_pending = 1;
|
||||
handle->x11.clipboard_time = MwTimeGetTick();
|
||||
while(1) {
|
||||
XNextEvent(handle->x11.display, &ev);
|
||||
if(ev.type == SelectionNotify) {
|
||||
if(ev.xselection.selection == clip && ev.xselection.property != 0) {
|
||||
Atom t;
|
||||
unsigned long size, N;
|
||||
char* data;
|
||||
int format;
|
||||
|
||||
XGetWindowProperty(ev.xselection.display, ev.xselection.requestor, ev.xselection.property, 0, (~0L), 0, AnyPropertyType, &t, &format, &size, &N, (unsigned char**)&data);
|
||||
if(t == target) {
|
||||
r = MwStringDuplicate(data);
|
||||
XFree(data);
|
||||
}
|
||||
XDeleteProperty(ev.xselection.display, ev.xselection.requestor, ev.xselection.property);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while(arrlen(queue) > 0) {
|
||||
XPutBackEvent(handle->x11.display, &queue[0]);
|
||||
arrdel(queue, 0);
|
||||
}
|
||||
arrfree(queue);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||
|
|
@ -1319,128 +1036,7 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
|
|||
MwLLShow(handle, 1);
|
||||
}
|
||||
|
||||
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) {
|
||||
(void)handle;
|
||||
(void)toggle;
|
||||
}
|
||||
|
||||
static int MwLLX11CallInitImpl(void) {
|
||||
MwBool loadX11 = MwFALSE;
|
||||
if(getenv("MILSKO_BACKEND")) {
|
||||
loadX11 |=
|
||||
(strcmp(getenv("MILSKO_BACKEND"), "x11") == 0);
|
||||
} else if(getenv("DISPLAY")) {
|
||||
loadX11 |= (getenv("DISPLAY") != NULL);
|
||||
}
|
||||
|
||||
if(!loadX11) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
xsymtbl.lib_xlib = MwDynamicOpen("libX11.dylib");
|
||||
#else
|
||||
xsymtbl.lib_xlib = MwDynamicOpen("libX11.so");
|
||||
#endif
|
||||
if(!xsymtbl.lib_xlib) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
xsymtbl.has_xrender = MwFALSE;
|
||||
#if USE_XRENDER
|
||||
xsymtbl.lib_xrender = MwDynamicOpen("libXrender.so");
|
||||
if(xsymtbl.lib_xrender) {
|
||||
xsymtbl.has_xrender = MwTRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define X11_FUNC_LOAD(x) x = MwDynamicSymbol(xsymtbl.lib_xlib, #x)
|
||||
|
||||
X11_FUNC_LOAD(XClearWindow);
|
||||
X11_FUNC_LOAD(XCreateImage);
|
||||
X11_FUNC_LOAD(XOpenDisplay);
|
||||
X11_FUNC_LOAD(XKeysymToString);
|
||||
X11_FUNC_LOAD(XInternAtom);
|
||||
X11_FUNC_LOAD(XCreatePixmapCursor);
|
||||
X11_FUNC_LOAD(XCreateGC);
|
||||
X11_FUNC_LOAD(XCreatePixmap);
|
||||
X11_FUNC_LOAD(XCreateSimpleWindow);
|
||||
X11_FUNC_LOAD(XVisualIDFromVisual);
|
||||
X11_FUNC_LOAD(XRootWindow);
|
||||
X11_FUNC_LOAD(XSetWMProtocols);
|
||||
X11_FUNC_LOAD(XSetTransientForHint);
|
||||
X11_FUNC_LOAD(XAllocColor);
|
||||
X11_FUNC_LOAD(XChangeProperty);
|
||||
X11_FUNC_LOAD(XChangeWindowAttributes);
|
||||
X11_FUNC_LOAD(XCheckTypedWindowEvent);
|
||||
X11_FUNC_LOAD(XCheckWindowEvent);
|
||||
X11_FUNC_LOAD(XCloseDisplay);
|
||||
X11_FUNC_LOAD(XConfigureWindow);
|
||||
X11_FUNC_LOAD(XConvertSelection);
|
||||
X11_FUNC_LOAD(XCopyArea);
|
||||
X11_FUNC_LOAD(XDefaultScreen);
|
||||
X11_FUNC_LOAD(XDefineCursor);
|
||||
X11_FUNC_LOAD(XDeleteProperty);
|
||||
X11_FUNC_LOAD(XDestroyWindow);
|
||||
X11_FUNC_LOAD(XDrawLine);
|
||||
X11_FUNC_LOAD(XFillPolygon);
|
||||
X11_FUNC_LOAD(XFree);
|
||||
X11_FUNC_LOAD(XFreeCursor);
|
||||
X11_FUNC_LOAD(XFreeGC);
|
||||
X11_FUNC_LOAD(XFreePixmap);
|
||||
X11_FUNC_LOAD(XGetGeometry);
|
||||
X11_FUNC_LOAD(XGetWindowProperty);
|
||||
X11_FUNC_LOAD(XGetWindowAttributes);
|
||||
X11_FUNC_LOAD(XMapWindow);
|
||||
X11_FUNC_LOAD(XNextEvent);
|
||||
X11_FUNC_LOAD(XPending);
|
||||
X11_FUNC_LOAD(XPutBackEvent);
|
||||
X11_FUNC_LOAD(XPutImage);
|
||||
X11_FUNC_LOAD(XQueryPointer);
|
||||
X11_FUNC_LOAD(XQueryTree);
|
||||
X11_FUNC_LOAD(XReparentWindow);
|
||||
X11_FUNC_LOAD(XSelectInput);
|
||||
X11_FUNC_LOAD(XSendEvent);
|
||||
X11_FUNC_LOAD(XSetClipMask);
|
||||
X11_FUNC_LOAD(XSetClipOrigin);
|
||||
X11_FUNC_LOAD(XSetForeground);
|
||||
X11_FUNC_LOAD(XSetGraphicsExposures);
|
||||
X11_FUNC_LOAD(XSetInputFocus);
|
||||
X11_FUNC_LOAD(XSetWindowBackgroundPixmap);
|
||||
X11_FUNC_LOAD(XSync);
|
||||
X11_FUNC_LOAD(XTranslateCoordinates);
|
||||
X11_FUNC_LOAD(XUnmapWindow);
|
||||
X11_FUNC_LOAD(XWarpPointer);
|
||||
X11_FUNC_LOAD(XSetLocaleModifiers);
|
||||
X11_FUNC_LOAD(XOpenIM);
|
||||
X11_FUNC_LOAD(XCloseIM);
|
||||
X11_FUNC_LOAD(XCreateIC);
|
||||
X11_FUNC_LOAD(XDestroyIC);
|
||||
X11_FUNC_LOAD(XSetICFocus);
|
||||
|
||||
X11_FUNC_LOAD(XAllocSizeHints);
|
||||
X11_FUNC_LOAD(XGetVisualInfo);
|
||||
X11_FUNC_LOAD(XGetWMNormalHints);
|
||||
X11_FUNC_LOAD(XGetWMSizeHints);
|
||||
X11_FUNC_LOAD(XLookupString);
|
||||
X11_FUNC_LOAD(XSetStandardProperties);
|
||||
X11_FUNC_LOAD(XSetWMNormalHints);
|
||||
X11_FUNC_LOAD(XSetWMSizeHints);
|
||||
|
||||
#if USE_XRENDER
|
||||
#define XRENDER_FUNC_LOAD(x) x = MwDynamicSymbol(xsymtbl.lib_xrender, #x);
|
||||
|
||||
XRENDER_FUNC_LOAD(XRenderQueryExtension)
|
||||
XRENDER_FUNC_LOAD(XRenderFindStandardFormat)
|
||||
XRENDER_FUNC_LOAD(XRenderCreatePicture)
|
||||
XRENDER_FUNC_LOAD(XRenderFreePicture)
|
||||
XRENDER_FUNC_LOAD(XRenderSetPictureTransform)
|
||||
XRENDER_FUNC_LOAD(XRenderComposite)
|
||||
#endif
|
||||
|
||||
#ifdef USE_DBUS
|
||||
xsymtbl.has_dbus = MwLLDBusFuncSetup(&xsymtbl.dbus);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
367
src/core.c
367
src/core.c
|
|
@ -2,73 +2,37 @@
|
|||
|
||||
#include "../external/stb_ds.h"
|
||||
|
||||
#ifdef USE_COCOA
|
||||
#define PERIODIC
|
||||
#endif
|
||||
|
||||
#define DRAW(handle) \
|
||||
{ \
|
||||
MwLLBeginDraw(handle->lowlevel); \
|
||||
\
|
||||
handle->bgcolor = NULL; \
|
||||
MwDispatch(handle, draw); \
|
||||
if(handle->draw_inject != NULL) handle->draw_inject(handle); \
|
||||
MwDispatchUserHandler(handle, MwNdrawHandler, NULL); \
|
||||
\
|
||||
MwLLEndDraw(handle->lowlevel); \
|
||||
}
|
||||
|
||||
static void lldrawhandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->common.user;
|
||||
#ifdef PERIODIC
|
||||
MwWidget top;
|
||||
#endif
|
||||
|
||||
(void)data;
|
||||
MwLLBeginDraw(handle);
|
||||
|
||||
#ifdef PERIODIC
|
||||
top = h;
|
||||
while(top != NULL) {
|
||||
if(top->top_step) {
|
||||
break;
|
||||
}
|
||||
h->bgcolor = NULL;
|
||||
MwDispatch(h, draw);
|
||||
if(h->draw_inject != NULL) h->draw_inject(h);
|
||||
MwDispatchUserHandler(h, MwNdrawHandler, NULL);
|
||||
|
||||
top = top->parent;
|
||||
}
|
||||
|
||||
if(top == NULL) {
|
||||
DRAW(h); /* fallback */
|
||||
} else {
|
||||
int i;
|
||||
|
||||
for(i = 0; i < arrlen(top->draw_queue); i++) {
|
||||
if(top->draw_queue[i] == h) break;
|
||||
}
|
||||
if(i == arrlen(top->draw_queue)) arrput(top->draw_queue, h);
|
||||
}
|
||||
#else
|
||||
DRAW(h);
|
||||
#endif
|
||||
MwLLEndDraw(handle);
|
||||
}
|
||||
|
||||
static void lluphandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->common.user;
|
||||
MwMouse* p = data;
|
||||
MwLLMouse* p = data;
|
||||
|
||||
if(p->button == MwMOUSE_LEFT) h->pressed = 0;
|
||||
if(p->button == MwLLMouseLeft) h->pressed = 0;
|
||||
h->mouse_point.x = p->point.x;
|
||||
h->mouse_point.y = p->point.y;
|
||||
|
||||
if(p->button == MwMOUSE_LEFT) MwDispatch(h, click);
|
||||
if(p->button == MwLLMouseLeft) MwDispatch(h, click);
|
||||
MwDispatch3(h, mouse_up, data);
|
||||
MwDispatchUserHandler(h, MwNmouseUpHandler, data);
|
||||
}
|
||||
|
||||
static void lldownhandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->common.user;
|
||||
MwMouse* p = data;
|
||||
|
||||
if(p->button == MwMOUSE_LEFT) h->pressed = 1;
|
||||
MwLLMouse* p = data;
|
||||
if(p->button == MwLLMouseLeft) h->pressed = 1;
|
||||
h->mouse_point.x = p->point.x;
|
||||
h->mouse_point.y = p->point.y;
|
||||
|
||||
|
|
@ -85,7 +49,6 @@ static void llresizehandler(MwLL handle, void* data) {
|
|||
MwDispatchUserHandler(h, MwNresizeHandler, NULL);
|
||||
for(i = 0; i < arrlen(h->children); i++) {
|
||||
MwDispatch(h->children[i], parent_resize);
|
||||
MwDispatch(h->children[i], draw);
|
||||
}
|
||||
MwDispatch(h, resize);
|
||||
}
|
||||
|
|
@ -144,39 +107,6 @@ static void llfocusouthandler(MwLL handle, void* data) {
|
|||
MwDispatchUserHandler(h, MwNfocusOutHandler, data);
|
||||
}
|
||||
|
||||
static void llclipboardhandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->common.user;
|
||||
|
||||
MwDispatch3(h, clipboard, data);
|
||||
MwDispatchUserHandler(h, MwNclipboardHandler, data);
|
||||
}
|
||||
|
||||
/* if both of them are true
|
||||
* 1. widget class is not NULL
|
||||
* 2. parent is NULL
|
||||
* or parent's widget class is NULL
|
||||
*
|
||||
* most likely this widget is first *visible* widget
|
||||
*
|
||||
* this macro is not used anywhere else - we could expose it if we have to
|
||||
*
|
||||
* (nishi)
|
||||
*/
|
||||
#define IsFirstVisible(handle) ((handle)->widget_class != NULL && ((handle)->parent == NULL || (handle)->parent->widget_class == NULL))
|
||||
|
||||
static void lldarkthemehandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->common.user;
|
||||
int* ptr = data;
|
||||
|
||||
if(IsFirstVisible(h)) {
|
||||
MwVaApply(h,
|
||||
MwNdarkTheme, *ptr,
|
||||
NULL);
|
||||
|
||||
MwDispatchUserHandler(h, MwNdarkThemeHandler, data);
|
||||
}
|
||||
}
|
||||
|
||||
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||
MwWidget h = malloc(sizeof(*h));
|
||||
|
||||
|
|
@ -184,7 +114,6 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||
|
||||
h->parent = parent;
|
||||
h->children = NULL;
|
||||
|
||||
if(widget_class != NULL) {
|
||||
if((h->lowlevel = MwLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height)) == NULL) {
|
||||
free(h->name);
|
||||
|
|
@ -202,18 +131,11 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||
h->draw_inject = NULL;
|
||||
h->tick_list = NULL;
|
||||
h->destroyed = 0;
|
||||
h->dark_theme = 0;
|
||||
h->bgcolor = NULL;
|
||||
h->berserk = 0;
|
||||
|
||||
h->top_step = 0;
|
||||
h->draw_queue = NULL;
|
||||
|
||||
if(parent == NULL) arrput(h->tick_list, h);
|
||||
|
||||
#ifdef PERIODIC
|
||||
if(parent == NULL) h->top_step = 1;
|
||||
#endif
|
||||
|
||||
if(h->lowlevel != NULL) {
|
||||
h->lowlevel->common.user = h;
|
||||
h->lowlevel->common.handler->draw = lldrawhandler;
|
||||
|
|
@ -226,8 +148,6 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||
h->lowlevel->common.handler->key_released = llkeyrelhandler;
|
||||
h->lowlevel->common.handler->focus_in = llfocusinhandler;
|
||||
h->lowlevel->common.handler->focus_out = llfocusouthandler;
|
||||
h->lowlevel->common.handler->clipboard = llclipboardhandler;
|
||||
h->lowlevel->common.handler->dark_theme = lldarkthemehandler;
|
||||
}
|
||||
|
||||
if(parent != NULL) arrput(parent->children, h);
|
||||
|
|
@ -257,19 +177,6 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
|||
MwAddTickList(h);
|
||||
}
|
||||
|
||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||
if(IsFirstVisible(h)) {
|
||||
h->root_font = MwFontLoad(MwTTFData, MwTTFDataSize);
|
||||
h->root_boldfont = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize);
|
||||
h->root_monofont = MwFontLoad(MwMonospaceTTFData, MwMonospaceTTFDataSize);
|
||||
h->root_boldmonofont = MwFontLoad(MwBoldMonospaceTTFData, MwBoldMonospaceTTFDataSize);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
h->root_font = NULL;
|
||||
h->root_boldfont = NULL;
|
||||
}
|
||||
|
||||
if(h->parent != NULL) MwDispatch(h->parent, children_update);
|
||||
|
||||
return h;
|
||||
|
|
@ -298,22 +205,6 @@ MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget p
|
|||
static void MwFreeWidget(MwWidget handle) {
|
||||
int i;
|
||||
MwWidget root = handle;
|
||||
MwWidget w;
|
||||
|
||||
w = handle;
|
||||
while(w != NULL) {
|
||||
if(w->top_step) break;
|
||||
w = w->parent;
|
||||
}
|
||||
|
||||
if(w != NULL) {
|
||||
for(i = 0; i < arrlen(w->draw_queue); i++) {
|
||||
if(w->draw_queue[i] == handle) {
|
||||
arrdel(w->draw_queue, i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handle->destroyed = 0;
|
||||
MwDispatch(handle, destroy);
|
||||
|
|
@ -350,11 +241,6 @@ static void MwFreeWidget(MwWidget handle) {
|
|||
arrfree(handle->destroy_queue);
|
||||
arrfree(handle->tick_list);
|
||||
|
||||
arrfree(handle->draw_queue);
|
||||
|
||||
if(handle->root_font != NULL) MwFontFree(handle->root_font);
|
||||
if(handle->root_boldfont != NULL) MwFontFree(handle->root_boldfont);
|
||||
|
||||
free(handle);
|
||||
}
|
||||
|
||||
|
|
@ -375,8 +261,6 @@ void MwDestroyWidget(MwWidget handle) {
|
|||
if(i == arrlen(handle->parent->destroy_queue)) {
|
||||
arrput(handle->parent->destroy_queue, handle);
|
||||
}
|
||||
|
||||
MwDispatch(handle->parent, children_update);
|
||||
}
|
||||
destroy_children(handle);
|
||||
handle->destroyed = 1;
|
||||
|
|
@ -413,22 +297,6 @@ static void clean_destroy_queue(MwWidget handle) {
|
|||
arrfree(handle->destroy_queue);
|
||||
}
|
||||
|
||||
static void MwAfterStep(MwWidget handle) {
|
||||
#ifdef PERIODIC
|
||||
if(handle->top_step) {
|
||||
int i;
|
||||
|
||||
for(i = 0; i < arrlen(handle->draw_queue); i++) {
|
||||
DRAW(handle->draw_queue[i]);
|
||||
}
|
||||
|
||||
arrfree(handle->draw_queue);
|
||||
}
|
||||
#else
|
||||
(void)handle;
|
||||
#endif
|
||||
}
|
||||
|
||||
int MwStep(MwWidget handle) {
|
||||
int i;
|
||||
MwWidget* widgets = NULL;
|
||||
|
|
@ -442,13 +310,11 @@ int MwStep(MwWidget handle) {
|
|||
|
||||
handle->prop_event = 0;
|
||||
|
||||
while(handle->lowlevel != NULL && MwLLPending(handle->lowlevel))
|
||||
if(handle->lowlevel != NULL && MwLLPending(handle->lowlevel))
|
||||
MwLLNextEvent(handle->lowlevel);
|
||||
|
||||
handle->prop_event = 1;
|
||||
|
||||
if(handle->top_step) MwAfterStep(handle);
|
||||
|
||||
clean_destroy_queue(handle);
|
||||
if(handle->parent == NULL && handle->destroyed) {
|
||||
MwFreeWidget(handle);
|
||||
|
|
@ -462,7 +328,7 @@ int MwPending(MwWidget handle) {
|
|||
for(i = 0; i < arrlen(handle->children); i++) {
|
||||
if(MwPending(handle->children[i])) return 1;
|
||||
}
|
||||
return (arrlen(handle->destroy_queue) > 0) || (handle->widget_class == NULL ? 0 : MwLLPending(handle->lowlevel));
|
||||
return (arrlen(handle->destroy_queue) > 0 ? 1 : 0) || (handle->widget_class == NULL ? 0 : MwLLPending(handle->lowlevel));
|
||||
}
|
||||
|
||||
void MwLoop(MwWidget handle) {
|
||||
|
|
@ -488,7 +354,7 @@ void MwLoop(MwWidget handle) {
|
|||
more = over % (wait / 2);
|
||||
t = (tick + wait - more) - (t2 = MwTimeGetTick());
|
||||
if(t > 0) {
|
||||
if(!handle->berserk) MwTimeSleep(t);
|
||||
MwTimeSleep(t);
|
||||
tick = MwTimeGetTick();
|
||||
over -= more;
|
||||
} else {
|
||||
|
|
@ -498,14 +364,6 @@ void MwLoop(MwWidget handle) {
|
|||
}
|
||||
}
|
||||
|
||||
static void force_render_all(MwWidget handle) {
|
||||
int i;
|
||||
for(i = 0; i < arrlen(handle->children); i++) {
|
||||
force_render_all(handle->children[i]);
|
||||
}
|
||||
if(handle->lowlevel != NULL) MwForceRender(handle);
|
||||
}
|
||||
|
||||
void MwSetInteger(MwWidget handle, const char* key, int n) {
|
||||
int xy;
|
||||
int wh = 0;
|
||||
|
|
@ -527,20 +385,6 @@ void MwSetInteger(MwWidget handle, const char* key, int n) {
|
|||
MwDispatch3(handle, prop_change, key);
|
||||
if(handle->parent != NULL) MwDispatch4(handle->parent, children_prop_change, handle, key);
|
||||
}
|
||||
if(strcmp(key, MwNforceInverted) == 0) {
|
||||
MwForceRender(handle);
|
||||
}
|
||||
if(strcmp(key, MwNmodernLook) == 0 || strcmp(key, MwNdarkTheme) == 0 || strcmp(key, MwNbitmapFont) == 0) {
|
||||
force_render_all(handle);
|
||||
}
|
||||
|
||||
if(strcmp(key, MwNdarkTheme) == 0) {
|
||||
MwWidget h = handle;
|
||||
|
||||
while(h->parent != NULL && h->parent->widget_class != NULL) h = h->parent;
|
||||
|
||||
MwLLSetDarkTheme(h->lowlevel, n);
|
||||
}
|
||||
}
|
||||
|
||||
void MwSetText(MwWidget handle, const char* key, const char* value) {
|
||||
|
|
@ -584,15 +428,6 @@ void MwSetVoid(MwWidget handle, const char* key, void* value) {
|
|||
}
|
||||
}
|
||||
|
||||
static int inherit_integer(MwWidget handle, const char* key, int default_v) {
|
||||
int v;
|
||||
|
||||
if(handle->parent != NULL && (v = MwGetInteger(handle->parent, key)) != MwDEFAULT) {
|
||||
return v;
|
||||
}
|
||||
return default_v;
|
||||
}
|
||||
|
||||
int MwGetInteger(MwWidget handle, const char* key) {
|
||||
if(strcmp(key, MwNx) == 0 || strcmp(key, MwNy) == 0 || strcmp(key, MwNwidth) == 0 || strcmp(key, MwNheight) == 0) {
|
||||
int x, y;
|
||||
|
|
@ -606,20 +441,6 @@ int MwGetInteger(MwWidget handle, const char* key) {
|
|||
if(strcmp(key, MwNheight) == 0) return h;
|
||||
return MwDEFAULT;
|
||||
} else {
|
||||
if(shgeti(handle->integer, key) == -1) {
|
||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||
if(strcmp(key, MwNbitmapFont) == 0) return inherit_integer(handle, key, 0);
|
||||
#else
|
||||
if(strcmp(key, MwNbitmapFont) == 0) return inherit_integer(handle, key, 1);
|
||||
#endif
|
||||
#ifdef USE_CLASSIC_THEME
|
||||
if(strcmp(key, MwNmodernLook) == 0) return inherit_integer(handle, key, 0);
|
||||
#else
|
||||
if(strcmp(key, MwNmodernLook) == 0) return inherit_integer(handle, key, 1);
|
||||
#endif
|
||||
if(strcmp(key, MwNdarkTheme) == 0) return inherit_integer(handle, key, 0);
|
||||
if(strcmp(key, MwNuseMonospace) == 0) return inherit_integer(handle, key, 0);
|
||||
}
|
||||
return shget(handle->integer, key);
|
||||
}
|
||||
}
|
||||
|
|
@ -633,7 +454,7 @@ const char* MwGetText(MwWidget handle, const char* key) {
|
|||
h = h->parent;
|
||||
}
|
||||
if(v == NULL) {
|
||||
if(MwGetInteger(handle, MwNdarkTheme)) {
|
||||
if(handle->dark_theme) {
|
||||
if(strcmp(key, MwNbackground) == 0) return MwDefaultDarkBackground;
|
||||
if(strcmp(key, MwNforeground) == 0) return MwDefaultDarkForeground;
|
||||
if(strcmp(key, MwNsubBackground) == 0) return MwDefaultDarkSubBackground;
|
||||
|
|
@ -651,47 +472,8 @@ const char* MwGetText(MwWidget handle, const char* key) {
|
|||
return shget(handle->text, key);
|
||||
}
|
||||
|
||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||
static void* inherit_void(MwWidget handle, const char* key) {
|
||||
void* v;
|
||||
|
||||
if(handle->parent != NULL && (v = MwGetVoid(handle->parent, key)) != NULL) {
|
||||
return v;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
void* MwGetVoid(MwWidget handle, const char* key) {
|
||||
void* v = shget(handle->data, key);
|
||||
|
||||
if(v != NULL) return v;
|
||||
|
||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||
if(strcmp(key, MwNfont) == 0 || strcmp(key, MwNboldFont) == 0 || strcmp(key, MwNmonospaceFont) == 0 || strcmp(key, MwNboldMonospaceFont) == 0) {
|
||||
v = inherit_void(handle, key);
|
||||
|
||||
if(v == NULL) {
|
||||
MwWidget w = handle;
|
||||
|
||||
while(w != NULL && v == NULL) {
|
||||
if(strcmp(key, MwNfont) == 0) {
|
||||
v = w->root_font;
|
||||
} else if(strcmp(key, MwNboldFont) == 0) {
|
||||
v = w->root_boldfont;
|
||||
} else if(strcmp(key, MwNmonospaceFont) == 0) {
|
||||
v = w->root_monofont;
|
||||
} else if(strcmp(key, MwNboldMonospaceFont) == 0) {
|
||||
v = w->root_boldmonofont;
|
||||
}
|
||||
|
||||
w = w->parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return v;
|
||||
return shget(handle->data, key);
|
||||
}
|
||||
|
||||
void MwVaApply(MwWidget handle, ...) {
|
||||
|
|
@ -759,8 +541,61 @@ void MwVaListApply(MwWidget handle, va_list va) {
|
|||
}
|
||||
}
|
||||
|
||||
static void inherit_integer(MwWidget handle, const char* key, int default_value) {
|
||||
int n;
|
||||
MwWidget h = handle;
|
||||
while(h != NULL) {
|
||||
if((n = MwGetInteger(h, key)) != MwDEFAULT) {
|
||||
MwSetInteger(handle, key, n);
|
||||
return;
|
||||
}
|
||||
h = h->parent;
|
||||
}
|
||||
MwSetInteger(handle, key, default_value);
|
||||
}
|
||||
|
||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||
static void set_font(MwWidget handle) {
|
||||
void* f;
|
||||
MwWidget h = handle;
|
||||
while(h != NULL) {
|
||||
if((f = MwGetVoid(h, MwNfont)) != NULL) {
|
||||
MwSetVoid(handle, MwNfont, f);
|
||||
return;
|
||||
}
|
||||
h = h->parent;
|
||||
}
|
||||
f = MwFontLoad(MwTTFData, MwTTFDataSize);
|
||||
MwSetVoid(handle, MwNfont, f);
|
||||
}
|
||||
|
||||
static void set_boldfont(MwWidget handle) {
|
||||
void* f;
|
||||
MwWidget h = handle;
|
||||
while(h != NULL) {
|
||||
if((f = MwGetVoid(h, MwNboldFont)) != NULL) {
|
||||
MwSetVoid(handle, MwNboldFont, f);
|
||||
return;
|
||||
}
|
||||
h = h->parent;
|
||||
}
|
||||
f = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize);
|
||||
MwSetVoid(handle, MwNboldFont, f);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MwSetDefault(MwWidget handle) {
|
||||
if(handle->lowlevel != NULL) MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
||||
|
||||
#ifdef USE_CLASSIC_THEME
|
||||
inherit_integer(handle, MwNmodernLook, 0);
|
||||
#else
|
||||
inherit_integer(handle, MwNmodernLook, 1);
|
||||
#endif
|
||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||
set_font(handle);
|
||||
set_boldfont(handle);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MwHideCursor(MwWidget handle) {
|
||||
|
|
@ -814,7 +649,7 @@ void MwDispatchError(int code, const char* message) {
|
|||
} else {
|
||||
#ifdef _WIN32
|
||||
char buffer[1024];
|
||||
MwStringPrintIntoBuffer(buffer, 1024, "Error: %s\r\nCode : %d\r\n\r\nMilsko is exiting.", message, code);
|
||||
sprintf(buffer, "Error: %s\r\nCode : %d\r\n\r\nMilsko is exiting.", message, code);
|
||||
MessageBox(NULL, buffer, "Error", MB_ICONERROR | MB_OK);
|
||||
#else
|
||||
fprintf(stderr, "Error: %s\nCode : %d\n\nMilsko is exiting.", message, code);
|
||||
|
|
@ -853,10 +688,21 @@ void MwGrabPointer(MwWidget handle, int toggle) {
|
|||
MwLLGrabPointer(handle->lowlevel, toggle);
|
||||
}
|
||||
|
||||
void MwSetDarkTheme(MwWidget handle, int toggle) {
|
||||
MwVaApply(handle,
|
||||
MwNdarkTheme, toggle,
|
||||
NULL);
|
||||
static void force_render_all(MwWidget handle) {
|
||||
int i;
|
||||
for(i = 0; i < arrlen(handle->children); i++) {
|
||||
force_render_all(handle->children[i]);
|
||||
}
|
||||
MwForceRender(handle);
|
||||
}
|
||||
|
||||
void MwToggleDarkTheme(MwWidget handle, int toggle) {
|
||||
int old = handle->dark_theme;
|
||||
if(old != toggle) {
|
||||
handle->dark_theme = toggle;
|
||||
|
||||
force_render_all(handle);
|
||||
}
|
||||
}
|
||||
|
||||
MwWidget MwGetParent(MwWidget handle) {
|
||||
|
|
@ -869,46 +715,19 @@ int MwLibraryInit(void) {
|
|||
#ifdef USE_WAYLAND
|
||||
MwLLWaylandCallInit,
|
||||
#endif
|
||||
/* x11 has higher priority then cocoa until it works */
|
||||
#ifdef USE_X11
|
||||
MwLLX11CallInit,
|
||||
#endif
|
||||
#ifdef USE_COCOA
|
||||
MwLLCocoaCallInit,
|
||||
#endif
|
||||
#ifdef USE_GDI
|
||||
MwLLGDICallInit,
|
||||
#endif
|
||||
#ifdef CLASSIC_MAC_OS
|
||||
MwLLClassicMacOSCallInit,
|
||||
#endif
|
||||
NULL};
|
||||
int i;
|
||||
|
||||
MwFLSetup();
|
||||
|
||||
for(i = 0; calls[i] != NULL; i++) {
|
||||
if(calls[i]() == 0) return 0;
|
||||
}
|
||||
|
||||
printf("[WARNING] No suitable GUI backend found! Enabled:"
|
||||
#ifdef USE_COCOA
|
||||
" Cocoa"
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
" Wayland"
|
||||
#endif
|
||||
#ifdef USE_X11
|
||||
" X11"
|
||||
#endif
|
||||
#ifdef USE_GDI
|
||||
" GDI"
|
||||
#endif
|
||||
#ifdef CLASSIC_MAC_OS
|
||||
" ClassicMacOS"
|
||||
#endif
|
||||
"\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -933,8 +752,6 @@ void MwReparent(MwWidget handle, MwWidget new_parent) {
|
|||
arrput(new_parent->children, handle);
|
||||
|
||||
MwDispatch(handle->parent, children_update);
|
||||
|
||||
MwForceRender(handle);
|
||||
}
|
||||
|
||||
MwClass MwGetClass(MwWidget handle) {
|
||||
|
|
@ -964,15 +781,3 @@ void MwGetCursorCoord(MwWidget handle, MwPoint* point) {
|
|||
void MwGetScreenSize(MwWidget handle, MwRect* rect) {
|
||||
MwLLGetScreenSize(handle->lowlevel, rect);
|
||||
}
|
||||
|
||||
int MwGetCoordinateType(MwWidget handle) {
|
||||
if(handle->parent == NULL || handle->parent->lowlevel == NULL) {
|
||||
return handle->lowlevel->common.coordinate_type;
|
||||
} else {
|
||||
return MwCOORDINATE_LOCAL;
|
||||
}
|
||||
}
|
||||
|
||||
void MwGetClipboard(MwWidget handle, int clipboard_type) {
|
||||
MwLLGetClipboard(handle->lowlevel, clipboard_type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ const char* MwDefaultDarkForeground = "#ddd";
|
|||
const char* MwDefaultDarkSubBackground = "#333";
|
||||
const char* MwDefaultDarkSubForeground = "#ddd";
|
||||
|
||||
const int MwDefaultShadow = -32;
|
||||
|
||||
int MwDefaultBorderWidth(MwWidget handle) {
|
||||
int bw = MwGetInteger(handle, MwNborderWidth);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#define WIN_SIZE 464
|
||||
#define PICKER_SIZE 364
|
||||
#define PICKER_SIZE 360
|
||||
#define IMG_POS_X(w) ((w - PICKER_SIZE) / 2)
|
||||
#define IMG_POS_Y(h) ((h - PICKER_SIZE) / 2)
|
||||
#define SCROLL_BAR_WIDTH 16
|
||||
|
|
@ -104,16 +104,11 @@ static void color_picker_image_update(color_picker_t* picker) {
|
|||
int _y = y - (PICKER_SIZE / 2);
|
||||
double dist = sqrt(_x * _x + _y * _y);
|
||||
|
||||
if(dist >= 182.) {
|
||||
if(dist >= 180.) {
|
||||
picker->color_picker_image_data[i] = 0;
|
||||
picker->color_picker_image_data[i + 1] = 0;
|
||||
picker->color_picker_image_data[i + 2] = 0;
|
||||
picker->color_picker_image_data[i + 3] = 0;
|
||||
} else if(dist >= 180.) {
|
||||
picker->color_picker_image_data[i] = dist;
|
||||
picker->color_picker_image_data[i + 1] = dist;
|
||||
picker->color_picker_image_data[i + 2] = dist;
|
||||
picker->color_picker_image_data[i + 3] = 255;
|
||||
} else {
|
||||
MwHSV hsv_v;
|
||||
MwRGB color;
|
||||
|
|
@ -160,7 +155,7 @@ static void color_picker_image_update(color_picker_t* picker) {
|
|||
|
||||
static void color_picker_click(MwWidget handle, void* user, void* call) {
|
||||
color_picker_t* picker = user;
|
||||
MwMouse* mouse = call;
|
||||
MwLLMouse* mouse = call;
|
||||
char hexColor[8];
|
||||
int i;
|
||||
char fgColor[8];
|
||||
|
|
@ -178,13 +173,13 @@ static void color_picker_click(MwWidget handle, void* user, void* call) {
|
|||
picker->chosen_color.green = picker->color_picker_image_data[i + 1];
|
||||
picker->chosen_color.blue = picker->color_picker_image_data[i + 2];
|
||||
|
||||
MwStringPrintIntoBuffer(hexColor, 8, "#%02X%02X%02X", picker->chosen_color.red & 0xff, picker->chosen_color.green & 0xff, picker->chosen_color.blue & 0xff);
|
||||
sprintf(hexColor, "#%02X%02X%02X", picker->chosen_color.red & 0xff, picker->chosen_color.green & 0xff, picker->chosen_color.blue & 0xff);
|
||||
|
||||
fr = picker->chosen_color.red > 128 ? 0 : 255;
|
||||
fg = picker->chosen_color.green > 128 ? 0 : 255;
|
||||
fb = picker->chosen_color.blue > 128 ? 0 : 255;
|
||||
|
||||
MwStringPrintIntoBuffer(fgColor, 8, "#%02X%02X%02X", fr, fg, fb);
|
||||
sprintf(fgColor, "#%02X%02X%02X", fr, fg, fb);
|
||||
MwSetText(picker->color_display_text, MwNforeground, fgColor);
|
||||
|
||||
MwSetText(picker->color_display_text, MwNbackground, hexColor);
|
||||
|
|
@ -252,7 +247,7 @@ static void color_display_text_change(MwWidget handle, void* user,
|
|||
fg = color->common.green > 128 ? 0 : 255;
|
||||
fb = color->common.blue > 128 ? 0 : 255;
|
||||
|
||||
MwStringPrintIntoBuffer(fgColor, 9, "#%02X%02X%02X", fr, fg, fb);
|
||||
sprintf(fgColor, "#%02X%02X%02X", fr, fg, fb);
|
||||
MwSetText(picker->color_display_text, MwNforeground, fgColor);
|
||||
|
||||
MwSetText(picker->color_display_text, MwNbackground, hexColor);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static void destroy(MwWidget handle) {
|
|||
MwDestroyWidget(handle);
|
||||
}
|
||||
|
||||
static void filecancel(MwWidget handle, void* user, void* call) {
|
||||
static void cancel(MwWidget handle, void* user, void* call) {
|
||||
(void)user;
|
||||
(void)call;
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ static void nav_activate(MwWidget handle, void* user, void* call) {
|
|||
(void)user;
|
||||
|
||||
if(strcmp(e, "Home") == 0) {
|
||||
#if defined(_WIN32) || defined(CLASSIC_MAC_OS)
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
struct passwd* p = getpwuid(getuid());
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ static void layout(MwWidget handle) {
|
|||
MwNleftPadding, 16,
|
||||
NULL);
|
||||
MwListBoxInsert(fc->nav, -1, p);
|
||||
MwAddUserHandler(fc->nav, MwNlistBoxActivateHandler, nav_activate, NULL);
|
||||
MwAddUserHandler(fc->nav, MwNactivateHandler, nav_activate, NULL);
|
||||
|
||||
MwListBoxDestroyPacket(p);
|
||||
} else {
|
||||
|
|
@ -242,7 +242,7 @@ static void layout(MwWidget handle) {
|
|||
MwNhasHeading, 1,
|
||||
MwNleftPadding, 16,
|
||||
NULL);
|
||||
MwAddUserHandler(fc->files, MwNlistBoxActivateHandler, files_activate, NULL);
|
||||
MwAddUserHandler(fc->files, MwNactivateHandler, files_activate, NULL);
|
||||
} else {
|
||||
MwVaApply(fc->files,
|
||||
MwNx, wx,
|
||||
|
|
@ -383,7 +383,7 @@ static void layout(MwWidget handle) {
|
|||
MwNtext, "Cancel",
|
||||
NULL);
|
||||
|
||||
MwAddUserHandler(fc->cancel, MwNactivateHandler, filecancel, NULL);
|
||||
MwAddUserHandler(fc->cancel, MwNactivateHandler, cancel, NULL);
|
||||
} else {
|
||||
MwVaApply(fc->cancel,
|
||||
MwNx, wx,
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
|
|||
left = 8 + 48 + 8;
|
||||
}
|
||||
|
||||
th = MwTextHeight(handle, NULL, text);
|
||||
th = MwTextHeight(handle, text);
|
||||
(void)MwVaCreateWidget(MwLabelClass, "label", window, left, (h - th) / 2, w - left - 8, th,
|
||||
MwNtext, text,
|
||||
MwNalignment, MwALIGNMENT_BEGINNING,
|
||||
|
|
|
|||
127
src/draw.c
127
src/draw.c
|
|
@ -1,7 +1,6 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#ifdef NO_IMAGE
|
||||
#elif defined(USE_STB_IMAGE)
|
||||
#ifdef USE_STB_IMAGE
|
||||
#include "../external/stb_image.h"
|
||||
#else
|
||||
#include <png.h>
|
||||
|
|
@ -13,7 +12,7 @@
|
|||
|
||||
static int get_color_diff(MwWidget handle) {
|
||||
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||
return 40;
|
||||
return 46;
|
||||
} else {
|
||||
return 80;
|
||||
}
|
||||
|
|
@ -29,7 +28,7 @@ static int hex(const char* txt, int len) {
|
|||
n = c - 'a' + 10;
|
||||
} else if('A' <= c && c <= 'F') {
|
||||
n = c - 'A' + 10;
|
||||
} else if('0' <= c && c <= 'g') {
|
||||
} else if('0' <= c && c <= '9') {
|
||||
n = c - '0';
|
||||
}
|
||||
r = r << 4;
|
||||
|
|
@ -107,21 +106,11 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
|
|||
int y;
|
||||
double darken = 0.;
|
||||
int ColorDiff = get_color_diff(handle);
|
||||
double darkenStep = (ColorDiff / 2.) / rect->height;
|
||||
double darkenStep = (ColorDiff / 4.) / rect->height;
|
||||
unsigned long sz = 1 * rect->height * 4;
|
||||
unsigned char* data = malloc(sz);
|
||||
MwRect r = *rect;
|
||||
if(rect->width <= 0 || rect->height <= 0) {
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
memset(data, 0, sz);
|
||||
|
||||
r.x += 1;
|
||||
r.y += 1;
|
||||
r.width -= 2;
|
||||
r.height -= 2;
|
||||
|
||||
for(y = 0; y < rect->height; y++) {
|
||||
MwLLColor col = MwLightenColor(handle, color, -darken, -darken, -darken);
|
||||
int idx = y * 4;
|
||||
|
|
@ -134,16 +123,13 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
|
|||
}
|
||||
|
||||
pixmap = MwLLCreatePixmap(handle->lowlevel, data, 1, rect->height);
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, pixmap);
|
||||
MwLLDrawPixmap(handle->lowlevel, rect, pixmap);
|
||||
MwLLDestroyPixmap(pixmap);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||
int inv;
|
||||
|
||||
if((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv) invert = 1;
|
||||
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0);
|
||||
} else {
|
||||
|
|
@ -165,18 +151,7 @@ void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
|||
void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
||||
MwLLColor col;
|
||||
|
||||
if(rect->width <= 0 || rect->height <= 0) return;
|
||||
|
||||
if(border) {
|
||||
if(!handle->lowlevel->common.supports_transparency) {
|
||||
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
|
||||
|
||||
if(c != NULL) {
|
||||
MwDrawRect(handle, rect, c);
|
||||
MwLLFreeColor(c);
|
||||
}
|
||||
}
|
||||
|
||||
MwDrawFrame(handle, rect, color, invert);
|
||||
}
|
||||
col = invert ? MwLightenColor(handle, color, -8, -8, -8) : color;
|
||||
|
|
@ -191,7 +166,7 @@ void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert
|
|||
void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||
MwPoint p[6];
|
||||
int border = MwDefaultBorderWidth(handle);
|
||||
int ColorDiff = get_color_diff(handle) + (MwGetInteger(handle, MwNmodernLook) ? 48 : 0);
|
||||
int ColorDiff = get_color_diff(handle);
|
||||
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
||||
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
||||
MwLLColor col = invert ? MwLightenColor(handle, color, -8, -8, -8) : color;
|
||||
|
|
@ -255,11 +230,12 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
|||
MwLLFreeColor(darker);
|
||||
}
|
||||
|
||||
static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
||||
MwPoint p[7];
|
||||
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
||||
MwPoint p[6];
|
||||
int ColorDiff = get_color_diff(handle);
|
||||
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff);
|
||||
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, ColorDiff - diff, ColorDiff - diff, ColorDiff - diff);
|
||||
|
||||
p[0].x = rect->x;
|
||||
p[0].y = rect->y;
|
||||
|
||||
|
|
@ -268,6 +244,7 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color,
|
|||
|
||||
p[2].x = rect->x + rect->width - border;
|
||||
p[2].y = rect->y + border;
|
||||
|
||||
p[3].x = rect->x + border;
|
||||
p[3].y = rect->y + border;
|
||||
|
||||
|
|
@ -276,6 +253,7 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color,
|
|||
|
||||
p[5].x = rect->x;
|
||||
p[5].y = rect->y + rect->height;
|
||||
|
||||
MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter);
|
||||
|
||||
p[0].x = rect->x + rect->width;
|
||||
|
|
@ -295,6 +273,7 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color,
|
|||
|
||||
p[5].x = rect->x + rect->width;
|
||||
p[5].y = rect->y + rect->height;
|
||||
|
||||
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||
|
||||
MwLLFreeColor(lighter);
|
||||
|
|
@ -306,81 +285,6 @@ static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color,
|
|||
rect->height -= border * 2;
|
||||
}
|
||||
|
||||
static void frame_border_complex(MwWidget handle, MwRect* rect, MwLLColor lighter, MwLLColor darker, int invert, int border, int diff, int same) {
|
||||
MwPoint p[7];
|
||||
|
||||
(void)diff;
|
||||
(void)same;
|
||||
|
||||
p[0].x = rect->x;
|
||||
p[0].y = rect->y;
|
||||
|
||||
p[1].x = rect->x + rect->width;
|
||||
p[1].y = rect->y;
|
||||
|
||||
p[2].x = rect->x + rect->width - border;
|
||||
p[2].y = rect->y + border;
|
||||
p[3].x = rect->x + border;
|
||||
p[3].y = rect->y + border;
|
||||
|
||||
p[4].x = rect->x + border;
|
||||
p[4].y = rect->y + rect->height - border;
|
||||
|
||||
p[5].x = rect->x;
|
||||
p[5].y = rect->y + rect->height;
|
||||
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||
|
||||
p[0].x = rect->x + rect->width;
|
||||
p[0].y = rect->y;
|
||||
|
||||
p[1].x = rect->x + rect->width - border;
|
||||
p[1].y = rect->y + border;
|
||||
|
||||
p[2].x = rect->x + rect->width - border;
|
||||
p[2].y = rect->y + rect->height - border;
|
||||
|
||||
p[3].x = rect->x + border;
|
||||
p[3].y = rect->y + rect->height - border;
|
||||
|
||||
p[4].x = rect->x;
|
||||
p[4].y = rect->y + rect->height;
|
||||
|
||||
p[5].x = rect->x + rect->width;
|
||||
p[5].y = rect->y + rect->height;
|
||||
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||
}
|
||||
|
||||
static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
||||
int ColorDiff = get_color_diff(handle);
|
||||
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff);
|
||||
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff);
|
||||
MwRect r = *rect;
|
||||
|
||||
frame_border_complex(handle, rect, lighter, darker, invert, border, diff, same);
|
||||
|
||||
r.x += 1;
|
||||
r.y += 1;
|
||||
r.width -= 2;
|
||||
r.height -= 2;
|
||||
frame_border_complex(handle, &r, lighter, darker, !invert, border, diff, same);
|
||||
|
||||
MwLLFreeColor(lighter);
|
||||
MwLLFreeColor(darker);
|
||||
|
||||
rect->x += border;
|
||||
rect->y += border;
|
||||
rect->width -= border * 2;
|
||||
rect->height -= border * 2;
|
||||
}
|
||||
|
||||
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
||||
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||
MwDrawFrameEx_complex(handle, rect, color, invert, border, diff, same);
|
||||
} else {
|
||||
MwDrawFrameEx_simple(handle, rect, color, invert, border, diff, same);
|
||||
}
|
||||
}
|
||||
|
||||
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
|
||||
MwPoint p1[4], p2[4], p3[4], p4[3];
|
||||
const int border = MwGetInteger(handle, MwNmodernLook) ? 2 : MwDefaultBorderWidth(handle);
|
||||
|
|
@ -598,8 +502,7 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert,
|
|||
MwLLFreeColor(darker);
|
||||
}
|
||||
|
||||
#if defined(NO_IMAGE)
|
||||
#elif !defined(USE_STB_IMAGE)
|
||||
#ifndef USE_STB_IMAGE
|
||||
static void PNGCAPI user_error(png_structp png, const char* str) {
|
||||
(void)str;
|
||||
|
||||
|
|
@ -714,9 +617,7 @@ static unsigned char* load_jpeg(FILE* f, int* w, int* h) {
|
|||
#endif
|
||||
|
||||
static unsigned char* load_image(const char* path, int* w, int* h) {
|
||||
#if defined(NO_IMAGE)
|
||||
return NULL;
|
||||
#elif defined(USE_STB_IMAGE)
|
||||
#ifdef USE_STB_IMAGE
|
||||
int ch;
|
||||
|
||||
return stbi_load(path, w, h, &ch, 4);
|
||||
|
|
|
|||
23
src/error.c
Normal file
23
src/error.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include <Mw/Milsko.h>
|
||||
#include "error_internal.h"
|
||||
|
||||
#define MAX_ERROR_LEN 512
|
||||
|
||||
/* buffer for holding the error. +1 to ensure there's always a null terminator. */
|
||||
char error[MAX_ERROR_LEN + 1] = {0};
|
||||
|
||||
const char* MwGetLastError(void) {
|
||||
return error;
|
||||
}
|
||||
|
||||
void setLastError(const char* fmt, ...) {
|
||||
va_list va;
|
||||
char out[MAX_ERROR_LEN];
|
||||
memset(out, 0, MAX_ERROR_LEN);
|
||||
|
||||
va_start(va, fmt);
|
||||
vsprintf(out, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
memcpy(error, out, MAX_ERROR_LEN);
|
||||
}
|
||||
15
src/error_internal.h
Normal file
15
src/error_internal.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef __MW_ERROR_INTERNAL_H__
|
||||
#define __MW_ERROR_INTERNAL_H__
|
||||
|
||||
/**
|
||||
* This is not to be documented or exposed publically.
|
||||
* This contains an internal function for setting the error,
|
||||
* something the user shouldn't want to do and thus we don't want them to.
|
||||
* (hence also, its placement in the src directory)
|
||||
*/
|
||||
|
||||
#include <Mw/Error.h>
|
||||
|
||||
void setLastError(const char* fmt, ...);
|
||||
|
||||
#endif
|
||||
0
src/text/font/boldfont.c → src/font/boldfont.c
generated
0
src/text/font/boldfont.c → src/font/boldfont.c
generated
4
src/text/font/boldmonottf.c → src/font/boldttf.c
generated
4
src/text/font/boldmonottf.c → src/font/boldttf.c
generated
|
|
@ -1,7 +1,7 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||
unsigned char MwBoldMonospaceTTFData[] = {
|
||||
unsigned char MwBoldTTFData[] = {
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x04, 0x00, 0x10,
|
||||
0x46, 0x46, 0x54, 0x4d, 0xac, 0x0d, 0xe4, 0x44, 0x00, 0x00, 0x8d, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x4f, 0x53, 0x2f, 0x32, 0xa4, 0xe6, 0xab, 0x72,
|
||||
|
|
@ -3018,5 +3018,5 @@ unsigned char MwBoldMonospaceTTFData[] = {
|
|||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x16, 0xe7, 0x6b,
|
||||
0x00, 0x00, 0x00, 0x00, 0xe1, 0xa9, 0xde, 0x3f, 0x00, 0x00, 0x00, 0x00,
|
||||
0xe5, 0x4d, 0x1e, 0x99};
|
||||
unsigned int MwBoldMonospaceTTFDataSize = 36184;
|
||||
unsigned int MwBoldTTFDataSize = 36184;
|
||||
#endif
|
||||
0
src/text/font/font.c → src/font/font.c
generated
0
src/text/font/font.c → src/font/font.c
generated
4
src/text/font/monottf.c → src/font/ttf.c
generated
4
src/text/font/monottf.c → src/font/ttf.c
generated
|
|
@ -1,7 +1,7 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||
unsigned char MwMonospaceTTFData[] = {
|
||||
unsigned char MwTTFData[] = {
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x04, 0x00, 0x10,
|
||||
0x46, 0x46, 0x54, 0x4d, 0xac, 0x0d, 0xe4, 0x23, 0x00, 0x00, 0x8d, 0x3c,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x4f, 0x53, 0x2f, 0x32, 0xa3, 0xba, 0xa8, 0x6a,
|
||||
|
|
@ -3018,5 +3018,5 @@ unsigned char MwMonospaceTTFData[] = {
|
|||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x16, 0xe7, 0x6b,
|
||||
0x00, 0x00, 0x00, 0x00, 0xe1, 0xa9, 0xde, 0x41, 0x00, 0x00, 0x00, 0x00,
|
||||
0xe5, 0x4d, 0x1e, 0x76};
|
||||
unsigned int MwMonospaceTTFDataSize = 36184;
|
||||
unsigned int MwTTFDataSize = 36184;
|
||||
#endif
|
||||
316
src/lowlevel.c
316
src/lowlevel.c
|
|
@ -1,305 +1,61 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
MwLL (*MwLLCreate)(MwLL parent, int x, int y, int width, int height) = NULL;
|
||||
void (*MwLLDestroy)(MwLL handle) = NULL;
|
||||
MwLL (*MwLLCreate)(MwLL parent, int x, int y, int width, int height);
|
||||
void (*MwLLDestroy)(MwLL handle);
|
||||
|
||||
void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color) = NULL;
|
||||
void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color) = NULL;
|
||||
void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
|
||||
void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color);
|
||||
|
||||
void (*MwLLBeginDraw)(MwLL handle) = NULL;
|
||||
void (*MwLLEndDraw)(MwLL handle) = NULL;
|
||||
void (*MwLLBeginDraw)(MwLL handle);
|
||||
void (*MwLLEndDraw)(MwLL handle);
|
||||
|
||||
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b) = NULL;
|
||||
void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b) = NULL;
|
||||
void (*MwLLFreeColor)(MwLLColor color) = NULL;
|
||||
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);
|
||||
void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
|
||||
void (*MwLLFreeColor)(MwLLColor color);
|
||||
|
||||
void (*MwLLGetXYWH)(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) = NULL;
|
||||
void (*MwLLSetXY)(MwLL handle, int x, int y) = NULL;
|
||||
void (*MwLLSetWH)(MwLL handle, int w, int h) = NULL;
|
||||
void (*MwLLGetXYWH)(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
||||
void (*MwLLSetXY)(MwLL handle, int x, int y);
|
||||
void (*MwLLSetWH)(MwLL handle, int w, int h);
|
||||
|
||||
void (*MwLLSetTitle)(MwLL handle, const char* title) = NULL;
|
||||
void (*MwLLSetTitle)(MwLL handle, const char* title);
|
||||
|
||||
int (*MwLLPending)(MwLL handle) = NULL;
|
||||
void (*MwLLNextEvent)(MwLL handle) = NULL;
|
||||
int (*MwLLPending)(MwLL handle);
|
||||
void (*MwLLNextEvent)(MwLL handle);
|
||||
|
||||
MwLLPixmap (*MwLLCreatePixmap)(MwLL handle, unsigned char* data, int width, int height) = NULL;
|
||||
void (*MwLLPixmapUpdate)(MwLLPixmap pixmap) = NULL;
|
||||
void (*MwLLDestroyPixmap)(MwLLPixmap pixmap) = NULL;
|
||||
void (*MwLLDrawPixmap)(MwLL handle, MwRect* rect, MwLLPixmap pixmap) = NULL;
|
||||
void (*MwLLSetIcon)(MwLL handle, MwLLPixmap pixmap) = NULL;
|
||||
MwLLPixmap (*MwLLCreatePixmap)(MwLL handle, unsigned char* data, int width, int height);
|
||||
void (*MwLLPixmapUpdate)(MwLLPixmap pixmap);
|
||||
void (*MwLLDestroyPixmap)(MwLLPixmap pixmap);
|
||||
void (*MwLLDrawPixmap)(MwLL handle, MwRect* rect, MwLLPixmap pixmap);
|
||||
void (*MwLLSetIcon)(MwLL handle, MwLLPixmap pixmap);
|
||||
|
||||
void (*MwLLForceRender)(MwLL handle) = NULL;
|
||||
void (*MwLLForceRender)(MwLL handle);
|
||||
|
||||
void (*MwLLSetCursor)(MwLL handle, MwCursor* image, MwCursor* mask) = NULL;
|
||||
void (*MwLLDetach)(MwLL handle, MwPoint* point) = NULL;
|
||||
void (*MwLLShow)(MwLL handle, int show) = NULL;
|
||||
void (*MwLLSetCursor)(MwLL handle, MwCursor* image, MwCursor* mask);
|
||||
void (*MwLLDetach)(MwLL handle, MwPoint* point);
|
||||
void (*MwLLShow)(MwLL handle, int show);
|
||||
|
||||
void (*MwLLSetSizeHints)(MwLL handle, int minx, int miny, int maxx, int maxy) = NULL;
|
||||
void (*MwLLMakeBorderless)(MwLL handle, int toggle) = NULL;
|
||||
void (*MwLLMakeToolWindow)(MwLL handle) = NULL;
|
||||
void (*MwLLMakePopup)(MwLL handle, MwLL parent) = NULL;
|
||||
void (*MwLLSetSizeHints)(MwLL handle, int minx, int miny, int maxx, int maxy);
|
||||
void (*MwLLMakeBorderless)(MwLL handle, int toggle);
|
||||
void (*MwLLMakeToolWindow)(MwLL handle);
|
||||
void (*MwLLMakePopup)(MwLL handle, MwLL parent);
|
||||
|
||||
void (*MwLLBeginStateChange)(MwLL handle) = NULL;
|
||||
void (*MwLLEndStateChange)(MwLL handle) = NULL;
|
||||
void (*MwLLBeginStateChange)(MwLL handle);
|
||||
void (*MwLLEndStateChange)(MwLL handle);
|
||||
|
||||
void (*MwLLFocus)(MwLL handle) = NULL;
|
||||
void (*MwLLGrabPointer)(MwLL handle, int toggle) = NULL;
|
||||
void (*MwLLFocus)(MwLL handle);
|
||||
void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
||||
|
||||
void (*MwLLSetClipboard)(MwLL handle, const char* text, int clipboard_type) = NULL;
|
||||
void (*MwLLGetClipboard)(MwLL, int clipboard_type) = NULL;
|
||||
void (*MwLLSetClipboard)(MwLL handle, const char* text);
|
||||
char* (*MwLLGetClipboard)(MwLL handle);
|
||||
|
||||
void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point) = NULL;
|
||||
void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect) = NULL;
|
||||
|
||||
void (*MwLLSetDarkTheme)(MwLL handle, int toggle) = NULL;
|
||||
void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
||||
void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
||||
|
||||
void MwLLCreateCommon(MwLL handle) {
|
||||
handle->common.handler = malloc(sizeof(*handle->common.handler));
|
||||
memset(handle->common.handler, 0, sizeof(*handle->common.handler));
|
||||
|
||||
handle->common.supports_transparency = 0;
|
||||
}
|
||||
|
||||
void MwLLDestroyCommon(MwLL handle) {
|
||||
free(handle->common.handler);
|
||||
}
|
||||
|
||||
#ifdef USE_DBUS
|
||||
MwBool MwLLDBusFuncSetup(MwLLDBusFuncTable* tbl) {
|
||||
tbl->lib = MwDynamicOpen("libdbus-1.so");
|
||||
if(!tbl->lib) {
|
||||
fprintf(stderr, "[WARNING] dbus library (libdbus-1.so) not found, will not be able to check for any XDG settings.\n");
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
#define DBUS_FUNC(x) \
|
||||
tbl->x = MwDynamicSymbol(tbl->lib, #x); \
|
||||
if(!tbl->x) { \
|
||||
fprintf(stderr, "[WARNING] dbus function %s not found, will not be able to check for any XDG settings.\n", #x); \
|
||||
dlclose(tbl->lib); \
|
||||
return MwFALSE; \
|
||||
}
|
||||
|
||||
DBUS_FUNC(dbus_error_init);
|
||||
DBUS_FUNC(dbus_bus_get);
|
||||
DBUS_FUNC(dbus_bus_add_match);
|
||||
DBUS_FUNC(dbus_error_is_set);
|
||||
DBUS_FUNC(dbus_error_free);
|
||||
DBUS_FUNC(dbus_message_new_method_call);
|
||||
DBUS_FUNC(dbus_message_is_signal);
|
||||
DBUS_FUNC(dbus_message_iter_init_append);
|
||||
DBUS_FUNC(dbus_message_iter_append_basic);
|
||||
DBUS_FUNC(dbus_connection_flush);
|
||||
DBUS_FUNC(dbus_connection_pop_message);
|
||||
DBUS_FUNC(dbus_connection_read_write);
|
||||
DBUS_FUNC(dbus_connection_send_with_reply_and_block);
|
||||
DBUS_FUNC(dbus_message_unref);
|
||||
DBUS_FUNC(dbus_message_iter_init);
|
||||
DBUS_FUNC(dbus_message_iter_get_arg_type);
|
||||
DBUS_FUNC(dbus_message_iter_recurse);
|
||||
DBUS_FUNC(dbus_message_iter_next);
|
||||
DBUS_FUNC(dbus_connection_unref);
|
||||
DBUS_FUNC(dbus_message_iter_get_basic);
|
||||
|
||||
return MwTRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_DBUS
|
||||
MwBool MwLLDBusNewContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx) {
|
||||
if(!tbl->lib) {
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
tbl->dbus_error_init(&ctx->dbus_err);
|
||||
|
||||
ctx->dbus_conn = tbl->dbus_bus_get(DBUS_BUS_SESSION, &ctx->dbus_err);
|
||||
if(tbl->dbus_error_is_set(&ctx->dbus_err)) {
|
||||
fprintf(stderr, "[WARNING] Could not initialize dbus: Connection error: %s\n", ctx->dbus_err.message);
|
||||
tbl->dbus_error_free(&ctx->dbus_err);
|
||||
return MwFALSE;
|
||||
}
|
||||
if(!ctx->dbus_conn) {
|
||||
fprintf(stderr, "[WARNING] Could not initialize dbus: Failed to connect to session bus\n");
|
||||
return MwFALSE;
|
||||
}
|
||||
return MwTRUE;
|
||||
};
|
||||
|
||||
MWDECL MwBool MwLLDBusPortalGet(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal, const char* namespace, const char* key, void* out) {
|
||||
DBusMessageIter dbus_args, dbus_variant, dbus_inner_variant;
|
||||
char arg_type;
|
||||
if(!ctx->dbus_conn) {
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
ctx->dbus_msg = tbl->dbus_message_new_method_call(
|
||||
"org.freedesktop.portal.Desktop",
|
||||
"/org/freedesktop/portal/desktop",
|
||||
portal,
|
||||
"Read");
|
||||
if(!ctx->dbus_msg) {
|
||||
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Failed to create message\n", namespace, key);
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
tbl->dbus_message_iter_init_append(ctx->dbus_msg, &dbus_args);
|
||||
tbl->dbus_message_iter_append_basic(&dbus_args, 's', &namespace);
|
||||
tbl->dbus_message_iter_append_basic(&dbus_args, 's', &key);
|
||||
|
||||
ctx->dbus_reply = tbl->dbus_connection_send_with_reply_and_block(ctx->dbus_conn, ctx->dbus_msg, 100, &ctx->dbus_err);
|
||||
|
||||
if(tbl->dbus_error_is_set(&ctx->dbus_err)) {
|
||||
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Send error: %s\n", namespace, key, ctx->dbus_err.message);
|
||||
tbl->dbus_error_free(&ctx->dbus_err);
|
||||
return MwFALSE;
|
||||
}
|
||||
if(!ctx->dbus_reply) {
|
||||
fprintf(stderr, "[WARNING] Couldn't get %s::%s: No reply received\n", namespace, key);
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
if(!tbl->dbus_message_iter_init(ctx->dbus_reply, &dbus_args)) {
|
||||
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Reply has no arguments\n", namespace, key);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
if((arg_type = tbl->dbus_message_iter_get_arg_type(&dbus_args)) != 'v') {
|
||||
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Expected outer variant, got: %c\n", namespace, key, arg_type);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
tbl->dbus_message_iter_recurse(&dbus_args, &dbus_variant);
|
||||
|
||||
/* Some portals wrap the value in a second variant */
|
||||
arg_type = tbl->dbus_message_iter_get_arg_type(&dbus_variant);
|
||||
if(arg_type == 'v') {
|
||||
tbl->dbus_message_iter_recurse(&dbus_variant, &dbus_inner_variant);
|
||||
if((arg_type = tbl->dbus_message_iter_get_arg_type(&dbus_inner_variant)) != 'u') {
|
||||
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Expected 'u' (uint32) for 'value', got: %c\n", portal, arg_type);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
tbl->dbus_message_iter_get_basic(&dbus_inner_variant, out);
|
||||
} else if (arg_type == 'u') {
|
||||
tbl->dbus_message_iter_get_basic(&dbus_variant, out);
|
||||
} else {
|
||||
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Expected variant or string, got: %c\n", namespace, key, arg_type);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
tbl->dbus_message_unref(ctx->dbus_msg);
|
||||
|
||||
return MwTRUE;
|
||||
}
|
||||
|
||||
MWDECL MwBool MwLLDBusPortalWatch(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal) {
|
||||
char filter_string[2048];
|
||||
if(!ctx->dbus_conn) {
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
MwStringPrintIntoBuffer(filter_string, sizeof(filter_string), "type='%s',interface=%s", "signal", portal);
|
||||
|
||||
tbl->dbus_bus_add_match(ctx->dbus_conn, filter_string, &ctx->dbus_err);
|
||||
tbl->dbus_connection_flush(ctx->dbus_conn);
|
||||
|
||||
return MwTRUE;
|
||||
}
|
||||
|
||||
/* Technically this will swallow all other results, so this is not usable multiple times.
|
||||
TODO: Use a hashmap instead */
|
||||
MWDECL MwBool MwLLDBusPortalPoll(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, MwLL handle, const char* portal, const char* namespace, const char* key, MwLLDBusPortalPollListener listener) {
|
||||
DBusMessageIter args, msg_value, msg_value_inner;
|
||||
const char* msg_namespace;
|
||||
const char* msg_key;
|
||||
MwU32 msg_value_content;
|
||||
char arg_type;
|
||||
|
||||
if(!ctx->dbus_conn) {
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
tbl->dbus_connection_read_write(ctx->dbus_conn, 0);
|
||||
tbl->dbus_connection_read_write(ctx->dbus_conn, 0);
|
||||
ctx->dbus_reply = tbl->dbus_connection_pop_message(ctx->dbus_conn);
|
||||
|
||||
if(tbl->dbus_error_is_set(&ctx->dbus_err)) {
|
||||
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Poll error: %s\n", portal, ctx->dbus_err.message);
|
||||
tbl->dbus_error_free(&ctx->dbus_err);
|
||||
return MwFALSE;
|
||||
}
|
||||
if(!ctx->dbus_reply) {
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
/* check if the message is a signal from the correct interface and with the correct name */
|
||||
if(tbl->dbus_message_is_signal(ctx->dbus_reply, portal, "SettingChanged")) {
|
||||
/* read the parameters */
|
||||
if(!tbl->dbus_message_iter_init(ctx->dbus_reply, &args))
|
||||
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged has no arguments\n", portal);
|
||||
else {
|
||||
if((arg_type = tbl->dbus_message_iter_get_arg_type(&args)) != 's') {
|
||||
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Expected 's' (string) for 'namespace', got: %c\n", portal, arg_type);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
tbl->dbus_message_iter_get_basic(&args, &msg_namespace);
|
||||
|
||||
tbl->dbus_message_iter_next(&args);
|
||||
if((arg_type = tbl->dbus_message_iter_get_arg_type(&args)) != 's') {
|
||||
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Expected 's' (string) for 'key', got: %c\n", portal, arg_type);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
tbl->dbus_message_iter_get_basic(&args, &msg_key);
|
||||
|
||||
/* Check that key and namespace match */
|
||||
if(strcmp(msg_namespace, namespace) == 0 && strcmp(msg_key, key) == 0) {
|
||||
/* Assuming the value is a basic type */
|
||||
tbl->dbus_message_iter_next(&args);
|
||||
|
||||
if((arg_type = tbl->dbus_message_iter_get_arg_type(&args)) != 'v') {
|
||||
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Expected outer variant, got: %c\n", namespace, key, arg_type);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
tbl->dbus_message_iter_recurse(&args, &msg_value);
|
||||
|
||||
/* Some portals wrap the value in a second variant */
|
||||
arg_type = tbl->dbus_message_iter_get_arg_type(&msg_value);
|
||||
if(arg_type == 'v') {
|
||||
tbl->dbus_message_iter_recurse(&msg_value, &msg_value_inner);
|
||||
if((arg_type = tbl->dbus_message_iter_get_arg_type(&msg_value_inner)) != 'u') {
|
||||
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Expected 'u' (uint32) for 'value', got: %c\n", portal, arg_type);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
tbl->dbus_message_iter_get_basic(&msg_value_inner, &msg_value_content);
|
||||
} else if (arg_type == 'u') {
|
||||
tbl->dbus_message_iter_get_basic(&msg_value, &msg_value_content);
|
||||
} else {
|
||||
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Expected variant or string, got: %c\n", namespace, key, arg_type);
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwFALSE;
|
||||
}
|
||||
|
||||
listener(handle, msg_value_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* free the message */
|
||||
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
return MwTRUE;
|
||||
}
|
||||
|
||||
void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx) {
|
||||
if(!tbl->lib) {
|
||||
return;
|
||||
}
|
||||
if(ctx->dbus_reply) tbl->dbus_message_unref(ctx->dbus_reply);
|
||||
if(ctx->dbus_conn) tbl->dbus_connection_unref(ctx->dbus_conn);
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
77
src/string.c
77
src/string.c
|
|
@ -37,80 +37,3 @@ void MwStringTime(char* out, time_t t) {
|
|||
sprintf(out, "%s %2d %02d:%02d %d", months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, 1900 + tm->tm_year);
|
||||
}
|
||||
}
|
||||
void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
vsnprintf(out, size, fmt, va);
|
||||
#else
|
||||
vsprintf(out, fmt, va);
|
||||
#endif
|
||||
|
||||
va_end(va);
|
||||
};
|
||||
|
||||
MWDECL MwBool MwStringIsKeyUTF8(MwU32 key) {
|
||||
unsigned char bytes[4];
|
||||
int i;
|
||||
bytes[0] = (key & 0x000000FF);
|
||||
bytes[1] = (key & 0x0000FF00) >> 8;
|
||||
bytes[2] = (key & 0x00FF0000) >> 16;
|
||||
bytes[3] = (key & 0xFF000000) >> 24;
|
||||
|
||||
for(i = 0; i < sizeof(MwU32); i++) {
|
||||
if(( // ASCII
|
||||
// use bytes[0] <= 0x7F to allow ASCII control characters
|
||||
bytes[0] == 0x09 ||
|
||||
bytes[0] == 0x0A ||
|
||||
bytes[0] == 0x0D ||
|
||||
(0x20 <= bytes[0] && bytes[0] <= 0x7E))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(( // non-overlong 2-byte
|
||||
(0xC2 <= bytes[0] && bytes[0] <= 0xDF) &&
|
||||
(0x80 <= bytes[1] && bytes[1] <= 0xBF))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(( // excluding overlongs
|
||||
bytes[0] == 0xE0 &&
|
||||
(0xA0 <= bytes[1] && bytes[1] <= 0xBF) &&
|
||||
(0x80 <= bytes[2] && bytes[2] <= 0xBF)) ||
|
||||
( // straight 3-byte
|
||||
((0xE1 <= bytes[0] && bytes[0] <= 0xEC) ||
|
||||
bytes[0] == 0xEE ||
|
||||
bytes[0] == 0xEF) &&
|
||||
(0x80 <= bytes[1] && bytes[1] <= 0xBF) &&
|
||||
(0x80 <= bytes[2] && bytes[2] <= 0xBF)) ||
|
||||
( // excluding surrogates
|
||||
bytes[0] == 0xED &&
|
||||
(0x80 <= bytes[1] && bytes[1] <= 0x9F) &&
|
||||
(0x80 <= bytes[2] && bytes[2] <= 0xBF))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(( // planes 1-3
|
||||
bytes[0] == 0xF0 &&
|
||||
(0x90 <= bytes[1] && bytes[1] <= 0xBF) &&
|
||||
(0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
|
||||
(0x80 <= bytes[3] && bytes[3] <= 0xBF)) ||
|
||||
( // planes 4-15
|
||||
(0xF1 <= bytes[0] && bytes[0] <= 0xF3) &&
|
||||
(0x80 <= bytes[1] && bytes[1] <= 0xBF) &&
|
||||
(0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
|
||||
(0x80 <= bytes[3] && bytes[3] <= 0xBF)) ||
|
||||
( // plane 16
|
||||
bytes[0] == 0xF4 &&
|
||||
(0x80 <= bytes[1] && bytes[1] <= 0x8F) &&
|
||||
(0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
|
||||
(0x80 <= bytes[3] && bytes[3] <= 0xBF))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
384
src/text.c
Normal file
384
src/text.c
Normal file
|
|
@ -0,0 +1,384 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#if defined(USE_FREETYPE2)
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
typedef struct ttf {
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
void* data;
|
||||
} ttf_t;
|
||||
|
||||
#define TTF
|
||||
#elif defined(USE_STB_TRUETYPE)
|
||||
#include "../external/stb_truetype.h"
|
||||
|
||||
typedef struct ttf {
|
||||
stbtt_fontinfo font;
|
||||
void* data;
|
||||
float scale;
|
||||
int ascent;
|
||||
int descent;
|
||||
} ttf_t;
|
||||
|
||||
#define TTF
|
||||
#endif
|
||||
|
||||
#define FontWidth 7
|
||||
#define FontHeight 14
|
||||
|
||||
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
||||
int i = 0, x, y, sx, sy;
|
||||
int tw, th;
|
||||
unsigned char* px;
|
||||
MwRect r;
|
||||
MwLLPixmap p;
|
||||
|
||||
if(strlen(text) == 0) text = " ";
|
||||
tw = MwTextWidth(handle, text);
|
||||
th = MwTextHeight(handle, text);
|
||||
px = malloc(tw * th * 4);
|
||||
|
||||
memset(px, 0, tw * th * 4);
|
||||
|
||||
sx = 0;
|
||||
sy = 0;
|
||||
|
||||
while(text[i] != 0) {
|
||||
int out;
|
||||
i += MwUTF8ToUTF32(text + i, &out);
|
||||
|
||||
if(out > 0xff) {
|
||||
out = 0;
|
||||
}
|
||||
|
||||
if(out == '\n') {
|
||||
sx = 0;
|
||||
sy += FontHeight;
|
||||
} else {
|
||||
for(y = 0; y < FontHeight; y++) {
|
||||
for(x = 0; x < FontWidth; x++) {
|
||||
unsigned char* ppx = &px[((sy + y) * tw + sx + x) * 4];
|
||||
if((bold ? MwBoldFontData : MwFontData)[out].data[y] & (1 << ((FontWidth - 1) - x))) {
|
||||
ppx[0] = color->common.red;
|
||||
ppx[1] = color->common.green;
|
||||
ppx[2] = color->common.blue;
|
||||
ppx[3] = 255;
|
||||
} else {
|
||||
ppx[0] = 0;
|
||||
ppx[1] = 0;
|
||||
ppx[2] = 0;
|
||||
ppx[3] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
sx += FontWidth;
|
||||
}
|
||||
}
|
||||
|
||||
p = MwLoadRaw(handle, px, tw, th);
|
||||
r.x = point->x;
|
||||
r.y = point->y - th / 2;
|
||||
r.width = tw;
|
||||
r.height = th;
|
||||
|
||||
if(align == MwALIGNMENT_CENTER) {
|
||||
r.x -= tw / 2;
|
||||
} else if(align == MwALIGNMENT_END) {
|
||||
r.x -= tw;
|
||||
}
|
||||
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||
MwLLDestroyPixmap(p);
|
||||
free(px);
|
||||
}
|
||||
|
||||
#if defined(USE_STB_TRUETYPE)
|
||||
static int ttf_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
||||
ttf_t* ttf = MwGetVoid(handle, bold ? MwNboldFont : MwNfont);
|
||||
unsigned char* px;
|
||||
int tw, th;
|
||||
MwRect r;
|
||||
MwLLPixmap p;
|
||||
int ax, lsb;
|
||||
int x = 0, y = 0;
|
||||
if(ttf == NULL) return 1;
|
||||
|
||||
tw = MwTextWidth(handle, text);
|
||||
th = MwTextHeight(handle, text);
|
||||
px = malloc(tw * th * 4);
|
||||
|
||||
memset(px, 0, tw * th * 4);
|
||||
while(text[0] != 0) {
|
||||
int c;
|
||||
int x0, y0, x1, y1, cx, cy;
|
||||
int ow, oh;
|
||||
unsigned char* out;
|
||||
|
||||
text += MwUTF8ToUTF32(text, &c);
|
||||
if(c == '\n') {
|
||||
x = 0;
|
||||
y += (ttf->ascent - ttf->descent) * ttf->scale;
|
||||
continue;
|
||||
}
|
||||
|
||||
stbtt_GetCodepointHMetrics(&ttf->font, c, &ax, &lsb);
|
||||
|
||||
stbtt_GetCodepointBitmapBox(&ttf->font, c, ttf->scale, ttf->scale, &x0, &y0, &x1, &y1);
|
||||
ow = x1 - x0;
|
||||
oh = y1 - y0;
|
||||
out = malloc(ow * oh);
|
||||
stbtt_MakeCodepointBitmap(&ttf->font, out, ow, oh, ow, ttf->scale, ttf->scale, c);
|
||||
|
||||
for(cy = 0; cy < oh; cy++) {
|
||||
for(cx = 0; cx < ow; cx++) {
|
||||
int ox = x + (lsb * ttf->scale) + cx;
|
||||
int oy = y + (ttf->ascent * ttf->scale) + y0 + cy;
|
||||
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
||||
|
||||
opx[0] = color->common.red;
|
||||
opx[1] = color->common.green;
|
||||
opx[2] = color->common.blue;
|
||||
opx[3] = out[cy * ow + cx];
|
||||
}
|
||||
}
|
||||
|
||||
x += ax * ttf->scale;
|
||||
|
||||
free(out);
|
||||
}
|
||||
|
||||
p = MwLoadRaw(handle, px, tw, th);
|
||||
r.x = point->x;
|
||||
r.y = point->y - th / 2;
|
||||
r.width = tw;
|
||||
r.height = th;
|
||||
|
||||
if(align == MwALIGNMENT_CENTER) {
|
||||
r.x -= tw / 2;
|
||||
} else if(align == MwALIGNMENT_END) {
|
||||
r.x -= tw;
|
||||
}
|
||||
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||
MwLLDestroyPixmap(p);
|
||||
free(px);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ttf_MwTextWidth(MwWidget handle, const char* text) {
|
||||
ttf_t* ttf = MwGetVoid(handle, MwNfont);
|
||||
int ax, lsb;
|
||||
int tw = 0;
|
||||
if(ttf == NULL) return -1;
|
||||
|
||||
while(text[0] != 0) {
|
||||
int c;
|
||||
text += MwUTF8ToUTF32(text, &c);
|
||||
|
||||
stbtt_GetCodepointHMetrics(&ttf->font, c, &ax, &lsb);
|
||||
|
||||
tw += ax * ttf->scale;
|
||||
}
|
||||
|
||||
return tw;
|
||||
}
|
||||
|
||||
static int ttf_MwTextHeight(MwWidget handle, int count) {
|
||||
ttf_t* ttf = MwGetVoid(handle, MwNfont);
|
||||
if(ttf == NULL) return -1;
|
||||
|
||||
return (ttf->ascent - ttf->descent) * ttf->scale * count;
|
||||
}
|
||||
#elif defined(USE_FREETYPE2)
|
||||
static int ttf_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
||||
ttf_t* ttf = MwGetVoid(handle, bold ? MwNboldFont : MwNfont);
|
||||
int tw, th;
|
||||
unsigned char* px;
|
||||
MwLLPixmap p;
|
||||
MwRect r;
|
||||
int x = 0, y = 0;
|
||||
if(ttf == NULL) return 1;
|
||||
|
||||
tw = MwTextWidth(handle, text);
|
||||
th = MwTextHeight(handle, text);
|
||||
px = malloc(tw * th * 4);
|
||||
|
||||
memset(px, 0, tw * th * 4);
|
||||
while(text[0] != 0) {
|
||||
int c;
|
||||
FT_Bitmap* bmp;
|
||||
int cy, cx;
|
||||
int l = MwUTF8ToUTF32(text, &c);
|
||||
if(l <= 0) break;
|
||||
text += l;
|
||||
|
||||
if(c == '\n') {
|
||||
x = 0;
|
||||
y += ttf->face->height * 14 / ttf->face->units_per_EM;
|
||||
continue;
|
||||
}
|
||||
|
||||
FT_Load_Char(ttf->face, c, FT_LOAD_RENDER);
|
||||
bmp = &ttf->face->glyph->bitmap;
|
||||
|
||||
for(cy = 0; cy < bmp->rows; cy++) {
|
||||
for(cx = 0; cx < bmp->width; cx++) {
|
||||
int ox = x + cx + ttf->face->glyph->bitmap_left;
|
||||
int oy = y + (ttf->face->height * 14 / ttf->face->units_per_EM) - ttf->face->glyph->bitmap_top + cy + (ttf->face->descender * 14 / ttf->face->units_per_EM);
|
||||
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
||||
|
||||
opx[0] = color->common.red;
|
||||
opx[1] = color->common.green;
|
||||
opx[2] = color->common.blue;
|
||||
opx[3] = bmp->buffer[cy * bmp->pitch + cx];
|
||||
}
|
||||
}
|
||||
|
||||
x += ttf->face->glyph->metrics.horiAdvance / 64;
|
||||
}
|
||||
|
||||
p = MwLoadRaw(handle, px, tw, th);
|
||||
r.x = point->x;
|
||||
r.y = point->y - th / 2;
|
||||
r.width = tw;
|
||||
r.height = th;
|
||||
|
||||
if(align == MwALIGNMENT_CENTER) {
|
||||
r.x -= tw / 2;
|
||||
} else if(align == MwALIGNMENT_END) {
|
||||
r.x -= tw;
|
||||
}
|
||||
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||
MwLLDestroyPixmap(p);
|
||||
free(px);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ttf_MwTextWidth(MwWidget handle, const char* text) {
|
||||
ttf_t* ttf = MwGetVoid(handle, MwNfont);
|
||||
int tw = 0, mtw = 0;
|
||||
if(ttf == NULL) return -1;
|
||||
|
||||
while(text[0] != 0) {
|
||||
int c;
|
||||
int l = MwUTF8ToUTF32(text, &c);
|
||||
if(l <= 0) break;
|
||||
text += l;
|
||||
if(c == '\n') {
|
||||
tw = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
FT_Load_Char(ttf->face, c, FT_LOAD_RENDER);
|
||||
|
||||
tw += ttf->face->glyph->metrics.horiAdvance / 64;
|
||||
if(tw > mtw) mtw = tw;
|
||||
}
|
||||
|
||||
return mtw;
|
||||
}
|
||||
|
||||
static int ttf_MwTextHeight(MwWidget handle, int count) {
|
||||
ttf_t* ttf = MwGetVoid(handle, MwNfont);
|
||||
if(ttf == NULL) return -1;
|
||||
|
||||
return (ttf->face->height * 14 / ttf->face->units_per_EM) * count;
|
||||
}
|
||||
#endif
|
||||
|
||||
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
||||
if(strlen(text) == 0) return;
|
||||
#ifdef TTF
|
||||
if(ttf_MwDrawText(handle, point, text, bold, align, color))
|
||||
#endif
|
||||
bitmap_MwDrawText(handle, point, text, bold, align, color);
|
||||
}
|
||||
|
||||
int MwTextWidth(MwWidget handle, const char* text) {
|
||||
/* TODO: check newline */
|
||||
#ifdef TTF
|
||||
int st;
|
||||
|
||||
if((st = ttf_MwTextWidth(handle, text)) != -1) return st;
|
||||
#else
|
||||
(void)handle;
|
||||
|
||||
#endif
|
||||
return MwUTF8Length(text) * FontWidth;
|
||||
}
|
||||
|
||||
int MwTextHeight(MwWidget handle, const char* text) {
|
||||
int c = 1;
|
||||
int i = 0;
|
||||
#ifdef TTF
|
||||
int st;
|
||||
#endif
|
||||
|
||||
(void)handle;
|
||||
(void)text;
|
||||
|
||||
while(text[i] != 0) {
|
||||
int out;
|
||||
int l = MwUTF8ToUTF32(text + i, &out);
|
||||
if(l == 0) break;
|
||||
i += l;
|
||||
|
||||
if(out == '\n') c++;
|
||||
}
|
||||
#ifdef TTF
|
||||
if((st = ttf_MwTextHeight(handle, c)) != -1) return st;
|
||||
#endif
|
||||
return FontHeight * c;
|
||||
}
|
||||
|
||||
void* MwFontLoad(unsigned char* data, unsigned int size) {
|
||||
#if defined(USE_FREETYPE2)
|
||||
ttf_t* ttf = malloc(sizeof(*ttf));
|
||||
ttf->data = malloc(size);
|
||||
memcpy(ttf->data, data, size);
|
||||
FT_Init_FreeType(&ttf->library);
|
||||
FT_New_Memory_Face(ttf->library, ttf->data, size, 0, &ttf->face);
|
||||
|
||||
FT_Set_Pixel_Sizes(ttf->face, 0, 14);
|
||||
|
||||
return ttf;
|
||||
#elif defined(USE_STB_TRUETYPE)
|
||||
ttf_t* ttf = malloc(sizeof(*ttf));
|
||||
ttf->data = malloc(size);
|
||||
memcpy(ttf->data, data, size);
|
||||
stbtt_InitFont(&ttf->font, ttf->data, 0);
|
||||
|
||||
ttf->scale = stbtt_ScaleForPixelHeight(&ttf->font, 16);
|
||||
stbtt_GetFontVMetrics(&ttf->font, &ttf->ascent, &ttf->descent, 0);
|
||||
|
||||
return ttf;
|
||||
#else
|
||||
(void)data;
|
||||
(void)size;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void MwFontFree(void* handle) {
|
||||
#if defined(USE_FREETYPE2)
|
||||
ttf_t* ttf = handle;
|
||||
|
||||
FT_Done_Face(ttf->face);
|
||||
FT_Done_FreeType(ttf->library);
|
||||
|
||||
free(ttf->data);
|
||||
free(ttf);
|
||||
#elif defined(USE_STB_TRUETYPE)
|
||||
ttf_t* ttf = handle;
|
||||
|
||||
free(ttf->data);
|
||||
free(ttf);
|
||||
#else
|
||||
(void)handle;
|
||||
#endif
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
2945
src/text/font/ttf.c
2945
src/text/font/ttf.c
File diff suppressed because it is too large
Load diff
194
src/text/ft2.c
194
src/text/ft2.c
|
|
@ -1,194 +0,0 @@
|
|||
#ifdef USE_FREETYPE2
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
static struct ft_table {
|
||||
FT_Error (*FT_Init_FreeType)(FT_Library* alibrary);
|
||||
FT_Error (*FT_New_Memory_Face)(FT_Library library,
|
||||
const FT_Byte* file_base,
|
||||
FT_Long file_size,
|
||||
FT_Long face_index,
|
||||
FT_Face* aface);
|
||||
FT_Error (*FT_Set_Pixel_Sizes)(FT_Face face,
|
||||
FT_UInt pixel_width,
|
||||
FT_UInt pixel_height);
|
||||
FT_Error (*FT_Load_Char)(FT_Face face,
|
||||
FT_ULong char_code,
|
||||
FT_Int32 load_flags);
|
||||
FT_Error (*FT_Get_Kerning)(FT_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_UInt kern_mode,
|
||||
FT_Vector* akerning);
|
||||
FT_Error (*FT_Done_Face)(FT_Face face);
|
||||
FT_Error (*FT_Done_FreeType)(FT_Library library);
|
||||
|
||||
} ft_table;
|
||||
|
||||
struct _MwFLFont {
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
void* data;
|
||||
int px;
|
||||
};
|
||||
static int ft2_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color) {
|
||||
int tw, th;
|
||||
unsigned char* px;
|
||||
MwLLPixmap p;
|
||||
MwRect r;
|
||||
int x = 0, y = 0;
|
||||
|
||||
tw = MwTextWidth(handle, ttf, text);
|
||||
th = MwTextHeight(handle, ttf, text);
|
||||
px = malloc(tw * th * 4);
|
||||
|
||||
memset(px, 0, tw * th * 4);
|
||||
while(text[0] != 0) {
|
||||
FT_Bitmap* bmp;
|
||||
int cy, cx;
|
||||
int c, c2;
|
||||
int l = MwUTF8ToUTF32(text, &c);
|
||||
FT_Vector vec;
|
||||
const char* old_text;
|
||||
if(l <= 0) break;
|
||||
text += l;
|
||||
|
||||
if(c == '\n') {
|
||||
x = 0;
|
||||
y += ttf->face->height * ttf->px / ttf->face->units_per_EM;
|
||||
continue;
|
||||
}
|
||||
|
||||
ft_table.FT_Load_Char(ttf->face, c, FT_LOAD_RENDER);
|
||||
bmp = &ttf->face->glyph->bitmap;
|
||||
|
||||
for(cy = 0; cy < bmp->rows; cy++) {
|
||||
for(cx = 0; cx < bmp->width; cx++) {
|
||||
int ox = x + (ttf->face->glyph->metrics.horiBearingX / 64) + cx + ttf->face->glyph->bitmap_left;
|
||||
int oy = y + (ttf->face->height * ttf->px / ttf->face->units_per_EM) - ttf->face->glyph->bitmap_top + cy + (ttf->face->descender * ttf->px / ttf->face->units_per_EM);
|
||||
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
||||
opx[0] = color->common.red;
|
||||
opx[1] = color->common.green;
|
||||
opx[2] = color->common.blue;
|
||||
/* overflow check */
|
||||
if(opx[3] + bmp->buffer[cy * bmp->pitch + cx] < opx[3]) {
|
||||
opx[3] = 255;
|
||||
} else {
|
||||
opx[3] = bmp->buffer[cy * bmp->pitch + cx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x += (ttf->face->glyph->advance.x >> 6) + (ttf->face->glyph->metrics.horiBearingX >> 6);
|
||||
|
||||
old_text = text;
|
||||
text += MwUTF8ToUTF32(text, &c2);
|
||||
|
||||
if(c2 != '\n') {
|
||||
ft_table.FT_Get_Kerning(ttf->face, c, c2, FT_KERNING_DEFAULT, &vec);
|
||||
|
||||
x += vec.x >> 6;
|
||||
}
|
||||
|
||||
text = old_text;
|
||||
}
|
||||
|
||||
p = MwLoadRaw(handle, px, tw, th);
|
||||
r.x = point->x;
|
||||
r.y = point->y - th / 2;
|
||||
r.width = tw;
|
||||
r.height = th;
|
||||
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||
MwLLDestroyPixmap(p);
|
||||
free(px);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ft2_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||
int tw = 0, mtw = 0;
|
||||
|
||||
while(text[0] != 0) {
|
||||
int c, c2;
|
||||
FT_Vector vec;
|
||||
const char* old_text;
|
||||
|
||||
text += MwUTF8ToUTF32(text, &c);
|
||||
if(c == '\n') {
|
||||
tw = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
ft_table.FT_Load_Char(ttf->face, c, FT_LOAD_DEFAULT);
|
||||
|
||||
tw += (ttf->face->glyph->advance.x >> 6) + (ttf->face->glyph->metrics.horiBearingX >> 6);
|
||||
|
||||
old_text = text;
|
||||
text += MwUTF8ToUTF32(text, &c2);
|
||||
|
||||
if(c2 != '\n') {
|
||||
ft_table.FT_Get_Kerning(ttf->face, c, c2, FT_KERNING_DEFAULT, &vec);
|
||||
|
||||
tw += vec.x >> 6;
|
||||
}
|
||||
|
||||
text = old_text;
|
||||
if(tw > mtw) mtw = tw;
|
||||
}
|
||||
|
||||
return mtw + 1;
|
||||
}
|
||||
|
||||
static int ft2_MwTextHeight(MwFLFont ttf, int count) {
|
||||
return ceil((ttf->face->height * ttf->px / ttf->face->units_per_EM) * count);
|
||||
}
|
||||
|
||||
static void* ft2_MwFontLoad(unsigned char* data, unsigned int size, int px) {
|
||||
MwFLFont ttf = malloc(sizeof(*ttf));
|
||||
ttf->data = malloc(size);
|
||||
memcpy(ttf->data, data, size);
|
||||
ft_table.FT_Init_FreeType(&ttf->library);
|
||||
ft_table.FT_New_Memory_Face(ttf->library, ttf->data, size, 0, &ttf->face);
|
||||
|
||||
ttf->px = px;
|
||||
ft_table.FT_Set_Pixel_Sizes(ttf->face, 0, ttf->px);
|
||||
|
||||
return ttf;
|
||||
}
|
||||
|
||||
static void ft2_MwFontFree(void* handle) {
|
||||
MwFLFont ttf = handle;
|
||||
|
||||
ft_table.FT_Done_Face(ttf->face);
|
||||
ft_table.FT_Done_FreeType(ttf->library);
|
||||
|
||||
free(ttf->data);
|
||||
free(ttf);
|
||||
}
|
||||
|
||||
int MWFL_FT2Setup(void) {
|
||||
/* Try and load FreeType2. If it fails, return 1, signifying we default to stbtt. */
|
||||
void* ftlib;
|
||||
if(!(ftlib = MwDynamicOpen("libfreetype.so"))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
ft_table.FT_Init_FreeType = MwDynamicSymbol(ftlib, "FT_Init_FreeType");
|
||||
ft_table.FT_New_Memory_Face = MwDynamicSymbol(ftlib, "FT_New_Memory_Face");
|
||||
ft_table.FT_Set_Pixel_Sizes = MwDynamicSymbol(ftlib, "FT_Set_Pixel_Sizes");
|
||||
ft_table.FT_Load_Char = MwDynamicSymbol(ftlib, "FT_Load_Char");
|
||||
ft_table.FT_Get_Kerning = MwDynamicSymbol(ftlib, "FT_Get_Kerning");
|
||||
ft_table.FT_Done_Face = MwDynamicSymbol(ftlib, "FT_Done_Face");
|
||||
ft_table.FT_Done_FreeType = MwDynamicSymbol(ftlib, "FT_Done_FreeType");
|
||||
|
||||
MwFLDrawText = ft2_MwDrawText;
|
||||
MwFLTextWidth = ft2_MwTextWidth;
|
||||
MwFLTextHeight = ft2_MwTextHeight;
|
||||
MwFLFontLoad = ft2_MwFontLoad;
|
||||
MwFLFontFree = ft2_MwFontFree;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
163
src/text/stbtt.c
163
src/text/stbtt.c
|
|
@ -1,163 +0,0 @@
|
|||
#ifdef USE_STB_TRUETYPE
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
#include "../../external/stb_truetype.h"
|
||||
|
||||
struct _MwFLFont {
|
||||
stbtt_fontinfo font;
|
||||
void* data;
|
||||
float scale;
|
||||
int ascent;
|
||||
int descent;
|
||||
};
|
||||
|
||||
static int stbtt_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color) {
|
||||
unsigned char* px;
|
||||
int tw, th;
|
||||
MwRect r;
|
||||
MwLLPixmap p;
|
||||
int ax, lsb;
|
||||
int x = 0, y = 0;
|
||||
|
||||
tw = MwTextWidth(handle, ttf, text);
|
||||
th = MwTextHeight(handle, ttf, text);
|
||||
px = malloc(tw * th * 4);
|
||||
|
||||
memset(px, 0, tw * th * 4);
|
||||
while(text[0] != 0) {
|
||||
int c, c2;
|
||||
int x0, y0, x1, y1, cx, cy;
|
||||
int ow, oh;
|
||||
unsigned char* out;
|
||||
int kern;
|
||||
const char* old_text;
|
||||
|
||||
text += MwUTF8ToUTF32(text, &c);
|
||||
if(c == '\n') {
|
||||
x = 0;
|
||||
y += ceil((ttf->ascent - ttf->descent) * ttf->scale);
|
||||
continue;
|
||||
}
|
||||
|
||||
stbtt_GetCodepointHMetrics(&ttf->font, c, &ax, &lsb);
|
||||
|
||||
stbtt_GetCodepointBitmapBox(&ttf->font, c, ttf->scale, ttf->scale, &x0, &y0, &x1, &y1);
|
||||
ow = x1 - x0;
|
||||
oh = y1 - y0;
|
||||
out = malloc(ow * oh);
|
||||
stbtt_MakeCodepointBitmap(&ttf->font, out, ow, oh, ow, ttf->scale, ttf->scale, c);
|
||||
|
||||
for(cy = 0; cy < oh; cy++) {
|
||||
for(cx = 0; cx < ow; cx++) {
|
||||
int ox = x + ceil(lsb * ttf->scale) + cx;
|
||||
int oy = y + ceil(ttf->ascent * ttf->scale) + y0 + cy;
|
||||
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
||||
opx[0] = color->common.red;
|
||||
opx[1] = color->common.green;
|
||||
opx[2] = color->common.blue;
|
||||
/* overflow check */
|
||||
if(opx[3] + out[cy * ow + cx] < opx[3]) {
|
||||
opx[3] = 255;
|
||||
} else {
|
||||
opx[3] = out[cy * ow + cx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x += ceil(ax * ttf->scale);
|
||||
|
||||
old_text = text;
|
||||
text += MwUTF8ToUTF32(text, &c2);
|
||||
|
||||
if(c2 != '\n') {
|
||||
kern = stbtt_GetCodepointKernAdvance(&ttf->font, c, c2);
|
||||
|
||||
x += ceil(kern * ttf->scale);
|
||||
}
|
||||
|
||||
text = old_text;
|
||||
|
||||
free(out);
|
||||
}
|
||||
|
||||
p = MwLoadRaw(handle, px, tw, th);
|
||||
r.x = point->x;
|
||||
r.y = point->y - th / 2;
|
||||
r.width = tw;
|
||||
r.height = th;
|
||||
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||
MwLLDestroyPixmap(p);
|
||||
free(px);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stbtt_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||
int ax, lsb;
|
||||
int tw = 0, mtw = 0;
|
||||
|
||||
while(text[0] != 0) {
|
||||
int kern;
|
||||
int c, c2;
|
||||
const char* old_text;
|
||||
|
||||
text += MwUTF8ToUTF32(text, &c);
|
||||
if(c == '\n') {
|
||||
tw = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
stbtt_GetCodepointHMetrics(&ttf->font, c, &ax, &lsb);
|
||||
|
||||
tw += ceil(ax * ttf->scale);
|
||||
|
||||
old_text = text;
|
||||
text += MwUTF8ToUTF32(text, &c2);
|
||||
|
||||
if(c2 != '\n') {
|
||||
kern = stbtt_GetCodepointKernAdvance(&ttf->font, c, c2);
|
||||
|
||||
tw += ceil(kern * ttf->scale);
|
||||
}
|
||||
|
||||
text = old_text;
|
||||
if(tw > mtw) mtw = tw;
|
||||
}
|
||||
|
||||
return mtw + 1;
|
||||
}
|
||||
|
||||
static int stbtt_MwTextHeight(MwFLFont ttf, int count) {
|
||||
return ceil((ttf->ascent - ttf->descent) * ttf->scale * count);
|
||||
}
|
||||
|
||||
static void* stbtt_MwFontLoad(unsigned char* data, unsigned int size, int px) {
|
||||
MwFLFont ttf = malloc(sizeof(*ttf));
|
||||
ttf->data = malloc(size);
|
||||
memcpy(ttf->data, data, size);
|
||||
stbtt_InitFont(&ttf->font, ttf->data, 0);
|
||||
|
||||
ttf->scale = stbtt_ScaleForMappingEmToPixels(&ttf->font, px);
|
||||
stbtt_GetFontVMetrics(&ttf->font, &ttf->ascent, &ttf->descent, 0);
|
||||
|
||||
return ttf;
|
||||
}
|
||||
|
||||
static void stbtt_MwFontFree(void* handle) {
|
||||
MwFLFont ttf = handle;
|
||||
|
||||
free(ttf->data);
|
||||
free(ttf);
|
||||
}
|
||||
|
||||
int MwFL_STBTTSetup(void) {
|
||||
MwFLDrawText = stbtt_MwDrawText;
|
||||
MwFLTextWidth = stbtt_MwTextWidth;
|
||||
MwFLTextHeight = stbtt_MwTextHeight;
|
||||
MwFLFontLoad = stbtt_MwFontLoad;
|
||||
MwFLFontFree = stbtt_MwFontFree;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
204
src/text/text.c
204
src/text/text.c
|
|
@ -1,204 +0,0 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
int (*MwFLDrawText)(MwWidget handle, MwFLFont font, MwPoint* point, const char* text, MwLLColor color) = NULL;
|
||||
int (*MwFLTextWidth)(MwFLFont font, const char* text) = NULL;
|
||||
int (*MwFLTextHeight)(MwFLFont font, int count) = NULL;
|
||||
void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px) = NULL;
|
||||
void (*MwFLFontFree)(void* handle) = NULL;
|
||||
|
||||
#if defined(USE_FREETYPE2) || defined(USE_STB_TRUETYPE)
|
||||
#define TTF
|
||||
#endif
|
||||
|
||||
#define FontWidth 7
|
||||
#define FontHeight 14
|
||||
|
||||
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, MwLLColor color);
|
||||
|
||||
static int is_bold(MwWidget handle, MwFLFont ttf) {
|
||||
size_t u = (size_t)ttf;
|
||||
int s;
|
||||
|
||||
if(u & MwFLFlagBold) return 1;
|
||||
|
||||
s = MwGetInteger(handle, MwNbold);
|
||||
if(s == MwDEFAULT) return 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef TTF
|
||||
static int is_monospace(MwWidget handle, MwFLFont ttf) {
|
||||
size_t u = (size_t)ttf;
|
||||
int s;
|
||||
|
||||
if(u & MwFLFlagMonospace) return 1;
|
||||
|
||||
s = MwGetInteger(handle, MwNuseMonospace);
|
||||
if(s == MwDEFAULT) return 0;
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TTF
|
||||
|
||||
static MwFLFont assume_ttf(MwWidget handle, MwFLFont ttf) {
|
||||
if(MwGetInteger(handle, MwNbitmapFont)) return NULL;
|
||||
|
||||
if(is_monospace(handle, ttf)) return is_bold(handle, ttf) ? MwGetVoid(handle, MwNboldMonospaceFont) : MwGetVoid(handle, MwNmonospaceFont);
|
||||
return is_bold(handle, ttf) ? MwGetVoid(handle, MwNboldFont) : MwGetVoid(handle, MwNfont);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color) {
|
||||
MwPoint p = *point;
|
||||
|
||||
if(strlen(text) == 0) return;
|
||||
#ifdef TTF
|
||||
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||
#endif
|
||||
|
||||
if(align == MwALIGNMENT_CENTER) {
|
||||
p.x -= MwTextWidth(handle, ttf, text) / 2;
|
||||
} else if(align == MwALIGNMENT_END) {
|
||||
p.x -= MwTextWidth(handle, ttf, text);
|
||||
}
|
||||
|
||||
#ifdef TTF
|
||||
if(MwFLDrawText)
|
||||
if(MwGetInteger(handle, MwNbitmapFont) || ttf == NULL || MwFLDrawText(handle, ttf, &p, text, color))
|
||||
#endif
|
||||
bitmap_MwDrawText(handle, &p, text, is_bold(handle, ttf), color);
|
||||
}
|
||||
|
||||
int MwTextWidth(MwWidget handle, MwFLFont ttf, const char* text) {
|
||||
/* TODO: check newline */
|
||||
#ifdef TTF
|
||||
int st;
|
||||
|
||||
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||
|
||||
if(MwFLTextWidth)
|
||||
if(!MwGetInteger(handle, MwNbitmapFont) && ttf != NULL && (st = MwFLTextWidth(ttf, text)) != -1) return st;
|
||||
#else
|
||||
(void)handle;
|
||||
(void)ttf;
|
||||
#endif
|
||||
return MwUTF8Length(text) * FontWidth;
|
||||
}
|
||||
|
||||
int MwTextHeight(MwWidget handle, MwFLFont ttf, const char* text) {
|
||||
int c = 1;
|
||||
int i = 0;
|
||||
#ifdef TTF
|
||||
int st;
|
||||
#endif
|
||||
|
||||
#ifdef TTF
|
||||
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||
#else
|
||||
(void)handle;
|
||||
(void)text;
|
||||
(void)ttf;
|
||||
#endif
|
||||
|
||||
while(text[i] != 0) {
|
||||
int out;
|
||||
int l = MwUTF8ToUTF32(text + i, &out);
|
||||
if(l == 0) break;
|
||||
i += l;
|
||||
|
||||
if(out == '\n') c++;
|
||||
}
|
||||
#ifdef TTF
|
||||
if(MwFLTextHeight)
|
||||
if(!MwGetInteger(handle, MwNbitmapFont) && ttf != NULL && (st = MwFLTextHeight(ttf, c)) != -1) return st;
|
||||
#endif
|
||||
return FontHeight * c;
|
||||
}
|
||||
|
||||
void* MwFontLoad(unsigned char* data, unsigned int size) {
|
||||
if(MwFLFontLoad)
|
||||
return MwFLFontLoad(data, size, 14);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void MwFontFree(void* handle) {
|
||||
if(MwFLFontFree) MwFLFontFree(handle);
|
||||
}
|
||||
|
||||
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, MwLLColor color) {
|
||||
int i = 0, x, y, sx, sy;
|
||||
int tw, th;
|
||||
unsigned char* px;
|
||||
MwRect r;
|
||||
MwLLPixmap p;
|
||||
|
||||
if(strlen(text) == 0) text = " ";
|
||||
tw = MwTextWidth(handle, NULL, text);
|
||||
th = MwTextHeight(handle, NULL, text);
|
||||
px = malloc(tw * th * 4);
|
||||
|
||||
memset(px, 0, tw * th * 4);
|
||||
|
||||
sx = 0;
|
||||
sy = 0;
|
||||
|
||||
while(text[i] != 0) {
|
||||
int out;
|
||||
i += MwUTF8ToUTF32(text + i, &out);
|
||||
|
||||
if(out > 0xff) {
|
||||
out = 0;
|
||||
}
|
||||
|
||||
if(out == '\n') {
|
||||
sx = 0;
|
||||
sy += FontHeight;
|
||||
} else {
|
||||
for(y = 0; y < FontHeight; y++) {
|
||||
for(x = 0; x < FontWidth; x++) {
|
||||
unsigned char* ppx = &px[((sy + y) * tw + sx + x) * 4];
|
||||
if((bold ? MwBoldFontData : MwFontData)[out].data[y] & (1 << ((FontWidth - 1) - x))) {
|
||||
ppx[0] = color->common.red;
|
||||
ppx[1] = color->common.green;
|
||||
ppx[2] = color->common.blue;
|
||||
ppx[3] = 255;
|
||||
} else {
|
||||
ppx[0] = 0;
|
||||
ppx[1] = 0;
|
||||
ppx[2] = 0;
|
||||
ppx[3] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
sx += FontWidth;
|
||||
}
|
||||
}
|
||||
|
||||
p = MwLoadRaw(handle, px, tw, th);
|
||||
r.x = point->x;
|
||||
r.y = point->y - th / 2;
|
||||
r.width = tw;
|
||||
r.height = th;
|
||||
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||
MwLLDestroyPixmap(p);
|
||||
free(px);
|
||||
}
|
||||
|
||||
typedef int (*call_t)(void);
|
||||
void MwFLSetup(void) {
|
||||
call_t calls[] = {
|
||||
#ifdef USE_FREETYPE2
|
||||
MWFL_FT2Setup,
|
||||
#endif
|
||||
#ifdef USE_STB_TRUETYPE
|
||||
MwFL_STBTTSetup,
|
||||
#endif
|
||||
NULL};
|
||||
int i;
|
||||
|
||||
for(i = 0; calls[i] != NULL; i++) {
|
||||
if(calls[i]() == 0) return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,28 +2,27 @@
|
|||
|
||||
#include "../../external/stb_ds.h"
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
MwBox b = malloc(sizeof(*b));
|
||||
memset(b, 0, sizeof(*b));
|
||||
|
||||
handle->internal = b;
|
||||
|
||||
static int create(MwWidget handle) {
|
||||
MwSetDefault(handle);
|
||||
|
||||
MwSetInteger(handle, MwNorientation, MwHORIZONTAL);
|
||||
MwSetInteger(handle, MwNmargin, 0);
|
||||
MwSetInteger(handle, MwNpadding, 0);
|
||||
MwSetInteger(handle, MwNhasBorder, 0);
|
||||
MwSetInteger(handle, MwNinverted, 1);
|
||||
|
||||
b->layout = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void destroy(MwWidget handle) {
|
||||
MwBox b = handle->internal;
|
||||
free(b);
|
||||
static void draw(MwWidget handle) {
|
||||
MwRect r;
|
||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||
|
||||
r.x = 0;
|
||||
r.y = 0;
|
||||
r.width = MwGetInteger(handle, MwNwidth);
|
||||
r.height = MwGetInteger(handle, MwNheight);
|
||||
MwDrawRect(handle, &r, base);
|
||||
|
||||
MwLLFreeColor(base);
|
||||
}
|
||||
|
||||
#define Margin ((i != (arrlen(handle->children) - 1)) ? MwGetInteger(handle, MwNmargin) : 0)
|
||||
|
|
@ -32,22 +31,19 @@ static void layout(MwWidget handle) {
|
|||
int i;
|
||||
int sum = 0;
|
||||
int horiz = MwGetInteger(handle, MwNorientation) == MwHORIZONTAL ? 1 : 0;
|
||||
int sz = MwGetInteger(handle, horiz ? MwNwidth : MwNheight) - (MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0)) * 2;
|
||||
int fsz = MwGetInteger(handle, horiz ? MwNheight : MwNwidth) - (MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0)) * 2;
|
||||
int sk = MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0);
|
||||
int sz = MwGetInteger(handle, horiz ? MwNwidth : MwNheight) - MwGetInteger(handle, MwNpadding) * 2;
|
||||
int fsz = MwGetInteger(handle, horiz ? MwNheight : MwNwidth) - MwGetInteger(handle, MwNpadding) * 2;
|
||||
int sk = MwGetInteger(handle, MwNpadding);
|
||||
|
||||
for(i = 0; i < arrlen(handle->children); i++) {
|
||||
int n = MwGetInteger(handle->children[i], MwNratio);
|
||||
int s = MwGetInteger(handle->children[i], MwNfixedSize);
|
||||
if(n == MwDEFAULT) n = 1;
|
||||
|
||||
if(handle->children[i]->destroyed) continue;
|
||||
|
||||
if(s != MwDEFAULT) {
|
||||
sz -= s + Margin;
|
||||
} else {
|
||||
sum += n;
|
||||
sz -= Margin;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,17 +53,16 @@ static void layout(MwWidget handle) {
|
|||
int wsz;
|
||||
if(n == MwDEFAULT) n = 1;
|
||||
|
||||
if(handle->children[i]->destroyed) continue;
|
||||
|
||||
if(s != MwDEFAULT) {
|
||||
wsz = s;
|
||||
} else {
|
||||
wsz = sz * n / sum;
|
||||
}
|
||||
wsz -= Margin;
|
||||
|
||||
MwVaApply(handle->children[i],
|
||||
horiz ? MwNx : MwNy, sk, /* this is what gets changed */
|
||||
horiz ? MwNy : MwNx, MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0), /* fixed between widgets */
|
||||
horiz ? MwNy : MwNx, MwGetInteger(handle, MwNpadding), /* fixed between widgets */
|
||||
horiz ? MwNwidth : MwNheight, wsz, /* this is what gets changed */
|
||||
horiz ? MwNheight : MwNwidth, fsz, /* fixed between widgets */
|
||||
NULL);
|
||||
|
|
@ -75,68 +70,27 @@ static void layout(MwWidget handle) {
|
|||
}
|
||||
}
|
||||
|
||||
static void draw(MwWidget handle) {
|
||||
MwRect r;
|
||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||
MwBox b = handle->internal;
|
||||
|
||||
r.x = 0;
|
||||
r.y = 0;
|
||||
r.width = MwGetInteger(handle, MwNwidth);
|
||||
r.height = MwGetInteger(handle, MwNheight);
|
||||
|
||||
if(MwGetInteger(handle, MwNhasBorder)) {
|
||||
MwDrawFrame(handle, &r, base, MwGetInteger(handle, MwNinverted));
|
||||
}
|
||||
|
||||
MwDrawRect(handle, &r, base);
|
||||
|
||||
MwLLFreeColor(base);
|
||||
|
||||
if(b->layout) {
|
||||
layout(handle);
|
||||
|
||||
b->layout = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void prop_change(MwWidget handle, const char* key) {
|
||||
if(strcmp(key, MwNorientation) == 0) {
|
||||
MwBox b = handle->internal;
|
||||
b->layout = 1;
|
||||
|
||||
MwForceRender(handle);
|
||||
}
|
||||
if(strcmp(key, MwNorientation) == 0) layout(handle);
|
||||
}
|
||||
|
||||
static void children_prop_change(MwWidget handle, MwWidget child, const char* key) {
|
||||
(void)child;
|
||||
|
||||
if(strcmp(key, MwNratio) == 0 || strcmp(key, MwNfixedSize) == 0) {
|
||||
MwBox b = handle->internal;
|
||||
b->layout = 1;
|
||||
|
||||
MwForceRender(handle);
|
||||
}
|
||||
if(strcmp(key, MwNratio) == 0 || strcmp(key, MwNfixedSize) == 0) layout(handle);
|
||||
}
|
||||
|
||||
static void resize(MwWidget handle) {
|
||||
MwBox b = handle->internal;
|
||||
b->layout = 1;
|
||||
|
||||
MwForceRender(handle);
|
||||
layout(handle);
|
||||
}
|
||||
|
||||
static void children_update(MwWidget handle) {
|
||||
MwBox b = handle->internal;
|
||||
b->layout = 1;
|
||||
|
||||
MwForceRender(handle);
|
||||
layout(handle);
|
||||
}
|
||||
|
||||
MwClassRec MwBoxClassRec = {
|
||||
wcreate, /* create */
|
||||
destroy, /* destroy */
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
|
|
@ -150,7 +104,7 @@ MwClassRec MwBoxClassRec = {
|
|||
resize, /* resize */
|
||||
children_update, /* children_update */
|
||||
children_prop_change, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#include "../../external/stb_ds.h"
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
static int create(MwWidget handle) {
|
||||
MwSetDefault(handle);
|
||||
|
||||
MwSetInteger(handle, MwNflat, 0);
|
||||
MwSetInteger(handle, MwNpadding, 0);
|
||||
MwSetInteger(handle, MwNfillArea, 1);
|
||||
MwSetInteger(handle, MwNroundness, 5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -21,7 +18,6 @@ static void draw(MwWidget handle) {
|
|||
const char* str = MwGetText(handle, MwNtext);
|
||||
MwLLPixmap px = MwGetVoid(handle, MwNpixmap);
|
||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||
int inv;
|
||||
|
||||
if(str == NULL) str = "";
|
||||
|
||||
|
|
@ -31,7 +27,7 @@ static void draw(MwWidget handle) {
|
|||
r.height = MwGetInteger(handle, MwNheight);
|
||||
|
||||
if(MwGetInteger(handle, MwNflat)) {
|
||||
if(handle->pressed || ((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv)) {
|
||||
if(handle->pressed) {
|
||||
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
||||
} else {
|
||||
MwDrawRect(handle, &r, base);
|
||||
|
|
@ -40,7 +36,7 @@ static void draw(MwWidget handle) {
|
|||
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
||||
}
|
||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||
if(MwGetInteger(handle, MwNflat) && !(handle->pressed || ((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv))) {
|
||||
if(MwGetInteger(handle, MwNflat) && !handle->pressed) {
|
||||
r.x += MwDefaultBorderWidth(handle);
|
||||
r.y += MwDefaultBorderWidth(handle);
|
||||
r.width -= MwDefaultBorderWidth(handle) * 2;
|
||||
|
|
@ -77,7 +73,7 @@ static void draw(MwWidget handle) {
|
|||
point.x = r.x + r.width / 2;
|
||||
point.y = r.x + r.height / 2;
|
||||
|
||||
MwDrawText(handle, NULL, &point, str, MwALIGNMENT_CENTER, text);
|
||||
MwDrawText(handle, &point, str, 0, MwALIGNMENT_CENTER, text);
|
||||
}
|
||||
|
||||
MwLLFreeColor(text);
|
||||
|
|
@ -93,7 +89,7 @@ static void prop_change(MwWidget handle, const char* key) {
|
|||
}
|
||||
|
||||
MwClassRec MwButtonClassRec = {
|
||||
wcreate, /* create */
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
draw, /* draw */
|
||||
click, /* click */
|
||||
|
|
@ -108,7 +104,7 @@ MwClassRec MwButtonClassRec = {
|
|||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
static int create(MwWidget handle) {
|
||||
MwSetDefault(handle);
|
||||
|
||||
MwSetInteger(handle, MwNchecked, 0);
|
||||
|
|
@ -38,7 +38,7 @@ static void prop_change(MwWidget handle, const char* key) {
|
|||
}
|
||||
|
||||
MwClassRec MwCheckBoxClassRec = {
|
||||
wcreate, /* create */
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
draw, /* draw */
|
||||
click, /* click */
|
||||
|
|
@ -53,7 +53,7 @@ MwClassRec MwCheckBoxClassRec = {
|
|||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "../../external/stb_ds.h"
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
static int create(MwWidget handle) {
|
||||
MwComboBox cb = malloc(sizeof(*cb));
|
||||
|
||||
cb->list = NULL;
|
||||
|
|
@ -51,7 +51,7 @@ static void draw(MwWidget handle) {
|
|||
p.x = MwDefaultBorderWidth(handle) * 2 + 4;
|
||||
p.y = MwGetInteger(handle, MwNheight) / 2;
|
||||
|
||||
MwDrawText(handle, NULL, &p, cb->list[MwGetInteger(handle, MwNvalue)], MwALIGNMENT_BEGINNING, text);
|
||||
MwDrawText(handle, &p, cb->list[MwGetInteger(handle, MwNvalue)], 0, MwALIGNMENT_BEGINNING, text);
|
||||
}
|
||||
|
||||
r = rc;
|
||||
|
|
@ -89,7 +89,7 @@ static void listbox_activate(MwWidget handle, void* user, void* client) {
|
|||
|
||||
MwForceRender(handle->parent);
|
||||
|
||||
MwDispatchUserHandler(handle->parent, MwNcomboBoxChangedHandler, client);
|
||||
MwDispatchUserHandler(handle->parent, MwNchangedHandler, client);
|
||||
|
||||
MwDestroyWidget(handle);
|
||||
}
|
||||
|
|
@ -115,11 +115,11 @@ static void click(MwWidget handle) {
|
|||
MwLLSetCursor(handle->lowlevel, &MwCursorArrow, &MwCursorArrowMask);
|
||||
|
||||
for(i = 0; i < arrlen(cb->list); i++) {
|
||||
int l = MwTextWidth(handle, NULL, cb->list[i]) + MwDefaultBorderWidth(handle) * 2;
|
||||
int l = MwTextWidth(handle, cb->list[i]) + MwDefaultBorderWidth(handle) * 2;
|
||||
if(l > width) width = l;
|
||||
}
|
||||
|
||||
cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, NULL, "M") * ent + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, NULL, "M") / 4,
|
||||
cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, "M") * ent + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M") / 4,
|
||||
MwNsingleClickSelectable, 1,
|
||||
NULL);
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
|
|||
}
|
||||
|
||||
MwClassRec MwComboBoxClassRec = {
|
||||
wcreate, /* create */
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
draw, /* draw */
|
||||
click, /* click */
|
||||
|
|
@ -204,7 +204,7 @@ MwClassRec MwComboBoxClassRec = {
|
|||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
static int create(MwWidget handle) {
|
||||
MwEntry t = malloc(sizeof(*t));
|
||||
|
||||
t->cursor = 0;
|
||||
|
|
@ -11,7 +11,6 @@ static int wcreate(MwWidget handle) {
|
|||
MwSetDefault(handle);
|
||||
|
||||
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
|
||||
MwSetInteger(handle, MwNroundness, 5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -27,7 +26,6 @@ static void draw(MwWidget handle) {
|
|||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||
const char* str = MwGetText(handle, MwNtext);
|
||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||
MwFLFont font = MwFLBuildFont(MwFLFlagMonospace);
|
||||
if(str == NULL) str = "";
|
||||
|
||||
r.x = 0;
|
||||
|
|
@ -38,8 +36,8 @@ static void draw(MwWidget handle) {
|
|||
MwDrawWidgetBack(handle, &r, base, 1, 1);
|
||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||
if(str != NULL) {
|
||||
int w = MwTextWidth(handle, font, "M");
|
||||
int h = MwTextHeight(handle, font, "M");
|
||||
int w = MwTextWidth(handle, "M");
|
||||
int h = MwTextHeight(handle, "M");
|
||||
MwPoint p;
|
||||
char* show;
|
||||
int len;
|
||||
|
|
@ -54,7 +52,6 @@ static void draw(MwWidget handle) {
|
|||
|
||||
len = (r.width - p.x * 2) / w;
|
||||
|
||||
if(len > 0) {
|
||||
show = malloc(len * 4 + 1);
|
||||
memset(show, 0, len * 4 + 1);
|
||||
|
||||
|
|
@ -66,13 +63,13 @@ static void draw(MwWidget handle) {
|
|||
for(i = 0; i < MwUTF8Length(str) - start; i++) show[i] = '*';
|
||||
}
|
||||
|
||||
MwDrawText(handle, font, &p, show, MwALIGNMENT_BEGINNING, text);
|
||||
MwDrawText(handle, &p, show, 0, MwALIGNMENT_BEGINNING, text);
|
||||
|
||||
textlen = (t->cursor - 1) % len + 1;
|
||||
for(i = 0; i < textlen; i++) show[i] = 'M';
|
||||
show[i] = 0;
|
||||
|
||||
currc.x = p.x + MwTextWidth(handle, font, show);
|
||||
currc.x = p.x + MwTextWidth(handle, show);
|
||||
currc.y = (r.height - h) / 2;
|
||||
currc.width = 1;
|
||||
currc.height = h;
|
||||
|
|
@ -80,7 +77,6 @@ static void draw(MwWidget handle) {
|
|||
|
||||
free(show);
|
||||
}
|
||||
}
|
||||
|
||||
MwLLFreeColor(text);
|
||||
MwLLFreeColor(base);
|
||||
|
|
@ -113,7 +109,20 @@ static void key(MwWidget handle, int code) {
|
|||
} else if(code == MwLLKeyEnter) {
|
||||
MwDispatchUserHandler(handle, MwNactivateHandler, NULL);
|
||||
} else if(code == (MwLLControlMask | 'v')) {
|
||||
MwLLGetClipboard(handle->lowlevel, MwCLIPBOARD_MAIN);
|
||||
char* c = MwLLGetClipboard(handle->lowlevel);
|
||||
if(c != NULL) {
|
||||
char* out = malloc(strlen(str) + strlen(c) + 1);
|
||||
|
||||
MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||
MwUTF8Copy(c, 0, out, t->cursor, MwUTF8Length(c));
|
||||
MwUTF8Copy(str, t->cursor, out, t->cursor + MwUTF8Length(c), MwUTF8Length(str) - t->cursor);
|
||||
|
||||
t->cursor += MwUTF8Length(c);
|
||||
|
||||
MwSetText(handle, MwNtext, out);
|
||||
free(out);
|
||||
free(c);
|
||||
}
|
||||
} else if(!(code & MwLLKeyMask)) {
|
||||
int incr = 0;
|
||||
out = malloc(strlen(str) + 5 + 1);
|
||||
|
|
@ -133,20 +142,6 @@ static void key(MwWidget handle, int code) {
|
|||
MwForceRender(handle);
|
||||
}
|
||||
|
||||
#if defined(USE_X11) || defined(USE_WAYLAND)
|
||||
static void mouse_up(MwWidget handle, void* ptr) {
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland || handle->lowlevel->common.type == MwLLBackendX11) {
|
||||
MwMouse* mouse = ptr;
|
||||
if(mouse->button == MwMOUSE_MIDDLE) {
|
||||
MwLLGetClipboard(handle->lowlevel, MwCLIPBOARD_PRIMARY);
|
||||
}
|
||||
}
|
||||
MwForceRender2(handle, NULL);
|
||||
}
|
||||
#else
|
||||
#define mouse_up MwForceRender2
|
||||
#endif
|
||||
|
||||
static void prop_change(MwWidget handle, const char* prop) {
|
||||
if(strcmp(prop, MwNtext) == 0 || strcmp(prop, MwNhideInput) == 0) MwForceRender(handle);
|
||||
|
||||
|
|
@ -162,38 +157,15 @@ static void prop_change(MwWidget handle, const char* prop) {
|
|||
}
|
||||
}
|
||||
|
||||
static void clipboard(MwWidget handle, const char* data) {
|
||||
MwEntry t = handle->internal;
|
||||
const char* str = MwGetText(handle, MwNtext);
|
||||
char* out;
|
||||
if(!str) {
|
||||
str = "";
|
||||
}
|
||||
out = malloc(strlen(str) + strlen(data) + 1);
|
||||
|
||||
if(str == NULL) str = "";
|
||||
|
||||
MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||
MwUTF8Copy(data, 0, out, t->cursor, MwUTF8Length(data));
|
||||
MwUTF8Copy(str, t->cursor, out, t->cursor + MwUTF8Length(data), MwUTF8Length(str) - t->cursor);
|
||||
|
||||
t->cursor += MwUTF8Length(data);
|
||||
|
||||
MwSetText(handle, MwNtext, out);
|
||||
free(out);
|
||||
|
||||
MwForceRender(handle);
|
||||
}
|
||||
|
||||
MwClassRec MwEntryClassRec = {
|
||||
wcreate, /* create */
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
prop_change, /* prop_change */
|
||||
NULL, /* mouse_move */
|
||||
mouse_up, /* mouse_up */
|
||||
MwForceRender2, /* mouse_up */
|
||||
MwForceRender2, /* mouse_down */
|
||||
key, /* key */
|
||||
NULL, /* execute */
|
||||
|
|
@ -201,7 +173,7 @@ MwClassRec MwEntryClassRec = {
|
|||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
clipboard, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
static int create(MwWidget handle) {
|
||||
MwSetDefault(handle);
|
||||
|
||||
MwSetInteger(handle, MwNhasBorder, 0);
|
||||
|
|
@ -46,7 +46,7 @@ static void prop_change(MwWidget handle, const char* key) {
|
|||
}
|
||||
|
||||
MwClassRec MwFrameClassRec = {
|
||||
wcreate, /* create */
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
|
|
@ -61,7 +61,7 @@ MwClassRec MwFrameClassRec = {
|
|||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
static int create(MwWidget handle) {
|
||||
MwSetDefault(handle);
|
||||
|
||||
MwSetInteger(handle, MwNhasBorder, 0);
|
||||
MwSetInteger(handle, MwNinverted, 1);
|
||||
MwSetInteger(handle, MwNfillArea, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -24,13 +23,6 @@ static void draw(MwWidget handle) {
|
|||
|
||||
MwDrawRect(handle, &r, base);
|
||||
if(px != NULL) {
|
||||
if(!MwGetInteger(handle, MwNfillArea)) {
|
||||
r.x = (r.width - px->common.width) / 2;
|
||||
r.y = (r.height - px->common.height) / 2;
|
||||
r.width = px->common.width;
|
||||
r.height = px->common.height;
|
||||
}
|
||||
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, px);
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +34,7 @@ static void prop_change(MwWidget handle, const char* key) {
|
|||
}
|
||||
|
||||
MwClassRec MwImageClassRec = {
|
||||
wcreate, /* create */
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
|
|
@ -57,7 +49,7 @@ MwClassRec MwImageClassRec = {
|
|||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -1,139 +1,21 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#include "../../external/stb_ds.h"
|
||||
|
||||
#define Spacing 1
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
MwLabel lab = malloc(sizeof(*lab));
|
||||
|
||||
lab->segment = NULL;
|
||||
handle->internal = lab;
|
||||
|
||||
static int create(MwWidget handle) {
|
||||
MwSetDefault(handle);
|
||||
MwSetInteger(handle, MwNalignment, MwALIGNMENT_CENTER);
|
||||
MwSetInteger(handle, MwNbold, 0);
|
||||
MwSetInteger(handle, MwNsevenSegment, 0);
|
||||
MwSetInteger(handle, MwNlength, 4);
|
||||
MwSetInteger(handle, MwNleftPadding, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void destroy(MwWidget handle) {
|
||||
MwLabel lab = handle->internal;
|
||||
|
||||
hmfree(lab->segment);
|
||||
|
||||
free(handle->internal);
|
||||
}
|
||||
|
||||
static void draw_v(MwWidget handle, unsigned char* raw, int x, int y, int stride, MwLLColor text) {
|
||||
int cy, cx, b;
|
||||
|
||||
int l_one = MwGetInteger(handle, MwNlength) - (MwGetInteger(handle, MwNlength) % 2);
|
||||
int s_one = (l_one * 3 / 4) - ((l_one * 3 / 4) % 2) + 1;
|
||||
|
||||
for(cy = y; cy < y + l_one; cy++) {
|
||||
for(cx = x; cx < x + s_one; cx++) {
|
||||
unsigned char* px = &raw[(cy * stride + cx) * 4];
|
||||
px[0] = text->common.red;
|
||||
px[1] = text->common.green;
|
||||
px[2] = text->common.blue;
|
||||
px[3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
b = y - (s_one - 1) / 2;
|
||||
for(cy = b; cy < b + (s_one - 1) / 2; cy++) {
|
||||
int w = (cy - b) * 2 + 1;
|
||||
int b2 = x + (s_one - w) / 2;
|
||||
for(cx = b2; cx < b2 + w; cx++) {
|
||||
unsigned char* px;
|
||||
|
||||
px = &raw[(cy * stride + cx) * 4];
|
||||
px[0] = text->common.red;
|
||||
px[1] = text->common.green;
|
||||
px[2] = text->common.blue;
|
||||
px[3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
b = y + l_one;
|
||||
for(cy = b; cy < b + (s_one - 1) / 2; cy++) {
|
||||
int w = ((s_one - 1) / 2 - 1 - (cy - b)) * 2 + 1;
|
||||
int b2 = x + (s_one - w) / 2;
|
||||
for(cx = b2; cx < b2 + w; cx++) {
|
||||
unsigned char* px;
|
||||
|
||||
px = &raw[(cy * stride + cx) * 4];
|
||||
px[0] = text->common.red;
|
||||
px[1] = text->common.green;
|
||||
px[2] = text->common.blue;
|
||||
px[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_h(MwWidget handle, unsigned char* raw, int x, int y, int stride, MwLLColor text) {
|
||||
int cy, cx, b;
|
||||
|
||||
int l_one = MwGetInteger(handle, MwNlength) - (MwGetInteger(handle, MwNlength) % 2);
|
||||
int s_one = (l_one * 3 / 4) - ((l_one * 3 / 4) % 2) + 1;
|
||||
|
||||
for(cx = x; cx < x + l_one; cx++) {
|
||||
for(cy = y; cy < y + s_one; cy++) {
|
||||
unsigned char* px = &raw[(cy * stride + cx) * 4];
|
||||
px[0] = text->common.red;
|
||||
px[1] = text->common.green;
|
||||
px[2] = text->common.blue;
|
||||
px[3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
b = x - (s_one - 1) / 2;
|
||||
for(cx = b; cx < b + (s_one - 1) / 2; cx++) {
|
||||
int w = (cx - b) * 2 + 1;
|
||||
int b2 = y + (s_one - w) / 2;
|
||||
for(cy = b2; cy < b2 + w; cy++) {
|
||||
unsigned char* px;
|
||||
|
||||
px = &raw[(cy * stride + cx) * 4];
|
||||
px[0] = text->common.red;
|
||||
px[1] = text->common.green;
|
||||
px[2] = text->common.blue;
|
||||
px[3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
b = x + l_one;
|
||||
for(cx = b; cx < b + (s_one - 1) / 2; cx++) {
|
||||
int w = ((s_one - 1) / 2 - 1 - (cx - b)) * 2 + 1;
|
||||
int b2 = y + (s_one - w) / 2;
|
||||
for(cy = b2; cy < b2 + w; cy++) {
|
||||
unsigned char* px;
|
||||
|
||||
px = &raw[(cy * stride + cx) * 4];
|
||||
px[0] = text->common.red;
|
||||
px[1] = text->common.green;
|
||||
px[2] = text->common.blue;
|
||||
px[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw(MwWidget handle) {
|
||||
MwRect r;
|
||||
MwPoint p;
|
||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||
MwLLColor shadow = MwLightenColor(handle, base, MwDefaultShadow, MwDefaultShadow, MwDefaultShadow);
|
||||
int align;
|
||||
const char* str = MwGetText(handle, MwNtext);
|
||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||
MwLabel lab = handle->internal;
|
||||
int l_one = MwGetInteger(handle, MwNlength) - (MwGetInteger(handle, MwNlength) % 2);
|
||||
int s_one = (l_one * 3 / 4) - ((l_one * 3 / 4) % 2) + 1;
|
||||
|
||||
if(str == NULL) str = "";
|
||||
|
||||
|
|
@ -146,222 +28,27 @@ static void draw(MwWidget handle) {
|
|||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||
|
||||
align = MwGetInteger(handle, MwNalignment);
|
||||
if(MwGetInteger(handle, MwNsevenSegment)) {
|
||||
MwLLPixmap px;
|
||||
unsigned char* raw;
|
||||
int w = 0, h = s_one * 3 + l_one * 2, i;
|
||||
int x = 0;
|
||||
|
||||
/* so - this mode cannot do unicode.
|
||||
* but you wouldn't show unicode on 7 segment anyways
|
||||
*/
|
||||
|
||||
/* L
|
||||
* S <--->
|
||||
*
|
||||
* S
|
||||
* ^
|
||||
* |
|
||||
* L |
|
||||
* |
|
||||
* v
|
||||
*/
|
||||
|
||||
for(i = 0; (hmgeti(lab->segment, i) != -1) || str[i] != 0; i++) {
|
||||
if(i > 0 && ((hmgeti(lab->segment, i) != -1) || str[i] != '.')) w += Spacing;
|
||||
if(hmgeti(lab->segment, i) != -1 || ('0' <= str[i] && str[i] <= '9') || ('A' <= str[i] && str[i] <= 'F') || ('a' <= str[i] && str[i] <= 'f')) {
|
||||
w += l_one + s_one * 2;
|
||||
} else if(str[i] == ':' || str[i] == ' ') {
|
||||
w += s_one;
|
||||
}
|
||||
}
|
||||
|
||||
w++;
|
||||
h++;
|
||||
|
||||
raw = malloc(w * h * 4);
|
||||
memset(raw, 0, w * h * 4);
|
||||
|
||||
for(i = 0; (hmgeti(lab->segment, i) != -1) || str[i] != 0; i++) {
|
||||
if((hmgeti(lab->segment, i) != -1) || ('0' <= str[i] && str[i] <= '9') || ('A' <= str[i] && str[i] <= 'F') || ('a' <= str[i] && str[i] <= 'f')) {
|
||||
int la = 0, lb = 0, lc = 0, ld = 0, le = 0, lf = 0, lg = 0;
|
||||
int j;
|
||||
|
||||
/* https://en.wikipedia.org/wiki/File:7_Segment_Display_with_Labeled_Segments.svg */
|
||||
|
||||
if(hmgeti(lab->segment, i) != -1) {
|
||||
unsigned char c = hmget(lab->segment, i);
|
||||
|
||||
if(c & (1 << 0)) la = 1;
|
||||
if(c & (1 << 1)) lb = 1;
|
||||
if(c & (1 << 2)) lc = 1;
|
||||
if(c & (1 << 3)) ld = 1;
|
||||
if(c & (1 << 4)) le = 1;
|
||||
if(c & (1 << 5)) lf = 1;
|
||||
if(c & (1 << 6)) lg = 1;
|
||||
} else {
|
||||
if(str[i] == '0') {
|
||||
la = lb = lc = ld = le = lf = 1;
|
||||
} else if(str[i] == '1') {
|
||||
lb = lc = 1;
|
||||
} else if(str[i] == '2') {
|
||||
la = lb = ld = le = lg = 1;
|
||||
} else if(str[i] == '3') {
|
||||
la = lb = lc = ld = lg = 1;
|
||||
} else if(str[i] == '4') {
|
||||
lb = lc = lf = lg = 1;
|
||||
} else if(str[i] == '5') {
|
||||
la = lc = ld = lf = lg = 1;
|
||||
} else if(str[i] == '6') {
|
||||
la = lc = ld = le = lf = lg = 1;
|
||||
} else if(str[i] == '7') {
|
||||
la = lb = lc = 1;
|
||||
} else if(str[i] == '8') {
|
||||
la = lb = lc = ld = le = lf = lg = 1;
|
||||
} else if(str[i] == '9') {
|
||||
la = lb = lc = ld = lf = lg = 1;
|
||||
} else if(str[i] == 'A' || str[i] == 'a') {
|
||||
la = lb = lc = le = lf = lg = 1;
|
||||
} else if(str[i] == 'B' || str[i] == 'b') {
|
||||
lc = ld = le = lf = lg = 1;
|
||||
} else if(str[i] == 'C' || str[i] == 'c') {
|
||||
ld = le = lg = 1;
|
||||
} else if(str[i] == 'D' || str[i] == 'd') {
|
||||
lb = lc = ld = le = lg = 1;
|
||||
} else if(str[i] == 'E' || str[i] == 'e') {
|
||||
la = ld = le = lf = lg = 1;
|
||||
} else if(str[i] == 'F' || str[i] == 'f') {
|
||||
la = le = lf = lg = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(j = 1; j >= 0; j--) {
|
||||
MwLLColor cl = j == 1 ? shadow : text;
|
||||
|
||||
if(la) draw_h(handle, raw, x + s_one + j, j, w, cl);
|
||||
if(lb) draw_v(handle, raw, x + s_one + l_one + j, s_one + j, w, cl);
|
||||
if(lc) draw_v(handle, raw, x + s_one + l_one + j, s_one * 2 + l_one + j, w, cl);
|
||||
if(ld) draw_h(handle, raw, x + s_one + j, s_one * 2 + l_one * 2 + j, w, cl);
|
||||
if(le) draw_v(handle, raw, x + j, s_one * 2 + l_one + j, w, cl);
|
||||
if(lf) draw_v(handle, raw, x + j, s_one + j, w, cl);
|
||||
if(lg) draw_h(handle, raw, x + s_one + j, s_one + l_one + j, w, cl);
|
||||
}
|
||||
|
||||
x += l_one + s_one * 2;
|
||||
} else if(str[i] == ':') {
|
||||
int cy, cx;
|
||||
int j;
|
||||
for(j = 1; j >= 0; j--) {
|
||||
MwLLColor cl = j == 1 ? shadow : text;
|
||||
for(cy = 1; cy < h - 1; cy++) {
|
||||
int h = s_one / 2;
|
||||
int c = (l_one - h) / 2 + s_one;
|
||||
|
||||
int c1 = (c <= cy && cy <= (c + h)) ? 1 : 0;
|
||||
int c2 = ((s_one + l_one + c) <= cy && cy <= (s_one + l_one + c + h)) ? 1 : 0;
|
||||
|
||||
if(c1 || c2) {
|
||||
for(cx = x; cx < x + s_one; cx++) {
|
||||
unsigned char* px = &raw[((cy + j) * w + (cx + j)) * 4];
|
||||
px[0] = cl->common.red;
|
||||
px[1] = cl->common.green;
|
||||
px[2] = cl->common.blue;
|
||||
px[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
x += s_one;
|
||||
} else if(str[i] == ' ') {
|
||||
x += s_one;
|
||||
} else if(str[i] == '.') {
|
||||
int cy, cx;
|
||||
int j;
|
||||
for(j = 1; j >= 0; j--) {
|
||||
MwLLColor cl = j == 1 ? shadow : text;
|
||||
for(cy = h - (s_one - 1) / 2 - 1; cy < h; cy++) {
|
||||
for(cx = x - Spacing - (s_one - 1) / 2 - 1; cx < (x - Spacing); cx++) {
|
||||
unsigned char* px = &raw[((cy + j) * w + (cx + j)) * 4];
|
||||
px[0] = cl->common.red;
|
||||
px[1] = cl->common.green;
|
||||
px[2] = cl->common.blue;
|
||||
px[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
x += Spacing;
|
||||
}
|
||||
|
||||
px = MwLoadRaw(handle, raw, w, h);
|
||||
|
||||
r.y = (r.height - h) / 2;
|
||||
r.height = h;
|
||||
if(align == MwALIGNMENT_CENTER) {
|
||||
r.x = (r.width - w) / 2;
|
||||
} else if(align == MwALIGNMENT_BEGINNING) {
|
||||
r.x = 0;
|
||||
} else if(align == MwALIGNMENT_END) {
|
||||
r.x = r.width - w;
|
||||
}
|
||||
r.width = w;
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, px);
|
||||
|
||||
MwLLDestroyPixmap(px);
|
||||
} else {
|
||||
r.width -= MwGetInteger(handle, MwNleftPadding);
|
||||
|
||||
if(align == MwALIGNMENT_CENTER) {
|
||||
p.x = r.width / 2;
|
||||
} else if(align == MwALIGNMENT_BEGINNING) {
|
||||
p.x = MwTextWidth(handle, NULL, str) / 2;
|
||||
p.x = MwTextWidth(handle, str) / 2;
|
||||
} else if(align == MwALIGNMENT_END) {
|
||||
p.x = r.width - MwTextWidth(handle, NULL, str) / 2;
|
||||
p.x = r.width - MwTextWidth(handle, str) / 2;
|
||||
}
|
||||
p.y = r.height / 2;
|
||||
MwDrawText(handle, &p, str, MwGetInteger(handle, MwNbold), MwALIGNMENT_CENTER, text);
|
||||
|
||||
p.x += MwGetInteger(handle, MwNleftPadding);
|
||||
|
||||
p.x += 1;
|
||||
p.y += 1;
|
||||
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_CENTER, shadow);
|
||||
|
||||
p.x -= 1;
|
||||
p.y -= 1;
|
||||
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_CENTER, text);
|
||||
}
|
||||
|
||||
MwLLFreeColor(shadow);
|
||||
MwLLFreeColor(text);
|
||||
MwLLFreeColor(base);
|
||||
}
|
||||
|
||||
static void prop_change(MwWidget handle, const char* key) {
|
||||
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNalignment) == 0 || strcmp(key, MwNsevenSegment) == 0 || strcmp(key, MwNlength) == 0 || strcmp(key, MwNleftPadding) == 0) MwForceRender(handle);
|
||||
}
|
||||
|
||||
static void mwLabelSetSevenSegmentImpl(MwWidget handle, int index, unsigned char data) {
|
||||
MwLabel lab = handle->internal;
|
||||
|
||||
hmput(lab->segment, index, data);
|
||||
}
|
||||
|
||||
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
|
||||
(void)out;
|
||||
|
||||
if(strcmp(name, "mwLabelSetSevenSegment") == 0) {
|
||||
int index = va_arg(va, int);
|
||||
int data = va_arg(va, int);
|
||||
|
||||
mwLabelSetSevenSegmentImpl(handle, index, data);
|
||||
}
|
||||
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNalignment) == 0) MwForceRender(handle);
|
||||
}
|
||||
|
||||
MwClassRec MwLabelClassRec = {
|
||||
wcreate, /* create */
|
||||
destroy, /* destroy */
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
|
|
@ -370,12 +57,12 @@ MwClassRec MwLabelClassRec = {
|
|||
NULL, /* mouse_up */
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL, /* execute */
|
||||
NULL, /* tick */
|
||||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
#define Padding 2
|
||||
|
||||
#define Font MwFLBuildFont(MwFLFlagMonospace)
|
||||
|
||||
MwListBoxPacket* MwListBoxCreatePacket(void) {
|
||||
MwListBoxPacket* packet = malloc(sizeof(*packet));
|
||||
memset(packet, 0, sizeof(*packet));
|
||||
|
|
@ -120,19 +118,19 @@ static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
|||
|
||||
static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
||||
MwListBox lb = handle->parent->internal;
|
||||
MwMouse* m = call;
|
||||
MwLLMouse* m = call;
|
||||
|
||||
(void)user;
|
||||
|
||||
if(m->button == MwMOUSE_LEFT) {
|
||||
if(m->button == MwLLMouseLeft) {
|
||||
int st = 0;
|
||||
int i;
|
||||
int y = MwDefaultBorderWidth(handle);
|
||||
int h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
st = get_first_entry(handle->parent, lb);
|
||||
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, Font, "M") + Padding) + 2; i++) {
|
||||
if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, Font, "M") + Padding)) {
|
||||
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, "M") + Padding) + 2; i++) {
|
||||
if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, "M") + Padding)) {
|
||||
unsigned long t;
|
||||
int old = MwGetInteger(handle->parent, MwNvalue);
|
||||
|
||||
|
|
@ -140,12 +138,12 @@ static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
|||
|
||||
if((((t = MwTimeGetTick()) - lb->click_time) < MwDoubleClickTimeout && old == st + i) || MwGetInteger(handle->parent, MwNsingleClickSelectable)) {
|
||||
int n = MwGetInteger(handle->parent, MwNvalue);
|
||||
MwDispatchUserHandler(handle->parent, MwNlistBoxActivateHandler, &n);
|
||||
MwDispatchUserHandler(handle->parent, MwNactivateHandler, &n);
|
||||
}
|
||||
|
||||
lb->click_time = t;
|
||||
}
|
||||
y += MwTextHeight(handle, Font, "M") + Padding;
|
||||
y += MwTextHeight(handle, "M") + Padding;
|
||||
}
|
||||
|
||||
MwForceRender(lb->frame);
|
||||
|
|
@ -155,11 +153,11 @@ static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
|||
|
||||
static void frame_mouse_up(MwWidget handle, void* user, void* call) {
|
||||
MwListBox lb = handle->parent->internal;
|
||||
MwMouse* m = call;
|
||||
MwLLMouse* m = call;
|
||||
|
||||
(void)user;
|
||||
|
||||
if(m->button == MwMOUSE_LEFT) {
|
||||
if(m->button == MwLLMouseLeft) {
|
||||
lb->pressed = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -177,11 +175,11 @@ static void frame_mouse_move(MwWidget handle, void* user, void* call) {
|
|||
int h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
st = get_first_entry(handle->parent, lb);
|
||||
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, Font, "M") + Padding) + 2; i++) {
|
||||
if(y <= p->y && p->y <= (y + MwTextHeight(handle, Font, "M") + Padding)) {
|
||||
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, "M") + Padding) + 2; i++) {
|
||||
if(y <= p->y && p->y <= (y + MwTextHeight(handle, "M") + Padding)) {
|
||||
MwSetInteger(handle->parent, MwNvalue, st + i);
|
||||
}
|
||||
y += MwTextHeight(handle, Font, "M") + Padding;
|
||||
y += MwTextHeight(handle, "M") + Padding;
|
||||
}
|
||||
|
||||
MwForceRender(lb->frame);
|
||||
|
|
@ -218,7 +216,7 @@ static void frame_draw(MwWidget handle) {
|
|||
st = get_first_entry(handle->parent, lb);
|
||||
|
||||
area = r.height - MwDefaultBorderWidth(handle) * 2;
|
||||
ent = area / (MwTextHeight(handle, Font, "M") + Padding) + 2;
|
||||
ent = area / (MwTextHeight(handle, "M") + Padding) + 2;
|
||||
|
||||
for(i = st; i < arrlen(lb->list) && i < st + ent; i++) {
|
||||
int selected = MwGetInteger(handle->parent, MwNvalue) == i ? 1 : 0;
|
||||
|
|
@ -229,20 +227,20 @@ static void frame_draw(MwWidget handle) {
|
|||
r2.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
||||
r2.y = p.y;
|
||||
r2.width = r.width - r2.x;
|
||||
r2.height = MwTextHeight(handle, Font, "M") + Padding;
|
||||
r2.height = MwTextHeight(handle, "M") + Padding;
|
||||
MwDrawRect(handle, &r2, text2);
|
||||
handle->bgcolor = text2;
|
||||
}
|
||||
if(lb->list[i].pixmap != NULL) {
|
||||
MwRect r2;
|
||||
int h = (lb->list[i].pixmap->common.height > (MwTextHeight(handle, Font, "M") + Padding)) ? (MwTextHeight(handle, Font, "M") + Padding) : lb->list[i].pixmap->common.height;
|
||||
int h = (lb->list[i].pixmap->common.height > (MwTextHeight(handle, "M") + Padding)) ? (MwTextHeight(handle, "M") + Padding) : lb->list[i].pixmap->common.height;
|
||||
r2.x = MwDefaultBorderWidth(handle);
|
||||
r2.y = p.y + (MwTextHeight(handle, Font, "M") + Padding - h) / 2;
|
||||
r2.y = p.y + (MwTextHeight(handle, "M") + Padding - h) / 2;
|
||||
r2.width = h * lb->list[i].pixmap->common.width / lb->list[i].pixmap->common.height;
|
||||
r2.height = h;
|
||||
MwLLDrawPixmap(handle->lowlevel, &r2, lb->list[i].pixmap);
|
||||
}
|
||||
p.y += (MwTextHeight(handle, Font, "M") + Padding) / 2;
|
||||
p.y += (MwTextHeight(handle, "M") + Padding) / 2;
|
||||
p.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
||||
for(j = 0; j < arrlen(lb->list[i].name); j++) {
|
||||
char* t = lb->list[i].name[j];
|
||||
|
|
@ -252,8 +250,8 @@ static void frame_draw(MwWidget handle) {
|
|||
if(t == NULL) t = "";
|
||||
|
||||
str = MwStringDuplicate(t);
|
||||
if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M")) {
|
||||
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M");
|
||||
if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, "M")) {
|
||||
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, "M");
|
||||
str[ind] = 0;
|
||||
if(ind > 3) memset(str + ind - 3, '.', 3);
|
||||
}
|
||||
|
|
@ -261,26 +259,26 @@ static void frame_draw(MwWidget handle) {
|
|||
if(j == (arrlen(lb->list[i].name) - 1)) p.x -= MwDefaultBorderWidth(handle);
|
||||
if(arrlen(lb->alignment) <= j || lb->alignment[j] == MwALIGNMENT_BEGINNING) {
|
||||
p.x += 4;
|
||||
MwDrawText(handle, Font, &p, str, MwALIGNMENT_BEGINNING, selected ? base2 : text2);
|
||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_BEGINNING, selected ? base2 : text2);
|
||||
p.x -= 4;
|
||||
p.x += get_col_width(lb, j);
|
||||
|
||||
} else if(lb->alignment[j] == MwALIGNMENT_CENTER) {
|
||||
p.x += (get_col_width(lb, j) - l) / 2;
|
||||
MwDrawText(handle, Font, &p, str, MwALIGNMENT_CENTER, selected ? base2 : text2);
|
||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_CENTER, selected ? base2 : text2);
|
||||
p.x += (get_col_width(lb, j) - l) / 2;
|
||||
p.x += l;
|
||||
} else if(lb->alignment[j] == MwALIGNMENT_END) {
|
||||
p.x += get_col_width(lb, j);
|
||||
p.x -= 4;
|
||||
MwDrawText(handle, Font, &p, str, MwALIGNMENT_END, selected ? base2 : text2);
|
||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_END, selected ? base2 : text2);
|
||||
p.x += 4;
|
||||
}
|
||||
free(str);
|
||||
|
||||
if(j == 0) p.x -= MwGetInteger(handle->parent, MwNleftPadding);
|
||||
}
|
||||
p.y += (MwTextHeight(handle, Font, "M") + Padding) / 2;
|
||||
p.y += (MwTextHeight(handle, "M") + Padding) / 2;
|
||||
handle->bgcolor = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +297,7 @@ static void resize(MwWidget handle) {
|
|||
int ih, y;
|
||||
int m = 0;
|
||||
|
||||
y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, NULL, "M") + MwDefaultBorderWidth(handle) * 2) : 0;
|
||||
y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, "M") + MwDefaultBorderWidth(handle) * 2) : 0;
|
||||
|
||||
if(lb->vscroll == NULL) {
|
||||
lb->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h, NULL);
|
||||
|
|
@ -318,7 +316,7 @@ static void resize(MwWidget handle) {
|
|||
|
||||
h -= y;
|
||||
|
||||
if(ih <= (h / (MwTextHeight(handle, Font, "M") + Padding))) {
|
||||
if(ih <= (h / (MwTextHeight(handle, "M") + Padding))) {
|
||||
MwLLShow(lb->vscroll->lowlevel, 0);
|
||||
} else {
|
||||
MwLLShow(lb->vscroll->lowlevel, 1);
|
||||
|
|
@ -342,12 +340,12 @@ static void resize(MwWidget handle) {
|
|||
h -= MwDefaultBorderWidth(handle) * 2;
|
||||
|
||||
MwVaApply(lb->vscroll,
|
||||
MwNareaShown, h / (MwTextHeight(handle, Font, "M") + Padding),
|
||||
MwNareaShown, h / (MwTextHeight(handle, "M") + Padding),
|
||||
MwNmaxValue, ih,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
static int create(MwWidget handle) {
|
||||
MwListBox lb = malloc(sizeof(*lb));
|
||||
memset(lb, 0, sizeof(*lb));
|
||||
|
||||
|
|
@ -402,7 +400,7 @@ static void draw(MwWidget handle) {
|
|||
r.x = x;
|
||||
r.y = 0;
|
||||
r.width = get_col_width(lb, i);
|
||||
r.height = MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, NULL, "M");
|
||||
r.height = MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M");
|
||||
MwDrawFrame(handle, &r, base, 0);
|
||||
|
||||
x += MwDefaultBorderWidth(handle);
|
||||
|
|
@ -410,15 +408,15 @@ static void draw(MwWidget handle) {
|
|||
if(arrlen(lb->alignment) <= i || lb->alignment[i] == MwALIGNMENT_BEGINNING) {
|
||||
p.x = 4 + x;
|
||||
p.y = r.y + r.height / 2;
|
||||
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_BEGINNING, text);
|
||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_BEGINNING, text);
|
||||
} else if(lb->alignment[i] == MwALIGNMENT_CENTER) {
|
||||
p.x = x + r.width / 2;
|
||||
p.y = r.y + r.height / 2;
|
||||
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_CENTER, text);
|
||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_CENTER, text);
|
||||
} else if(lb->alignment[i] == MwALIGNMENT_END) {
|
||||
p.x = x + r.width - 4;
|
||||
p.y = r.y + r.height / 2;
|
||||
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_END, text);
|
||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_END, text);
|
||||
}
|
||||
|
||||
x += r.width;
|
||||
|
|
@ -595,7 +593,7 @@ static void tick(MwWidget handle) {
|
|||
}
|
||||
|
||||
MwClassRec MwListBoxClassRec = {
|
||||
wcreate, /* create */
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
|
|
@ -610,7 +608,7 @@ MwClassRec MwListBoxClassRec = {
|
|||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ static void set_xywh(MwWidget handle) {
|
|||
int diff = MwDefaultBorderWidth(handle);
|
||||
diff = 0;
|
||||
|
||||
height = MwTextHeight(handle, NULL, "M") + 10;
|
||||
height = MwTextHeight(handle, "M") + 10;
|
||||
|
||||
MwVaApply(handle,
|
||||
MwNx, -diff,
|
||||
|
|
@ -18,7 +18,7 @@ static void set_xywh(MwWidget handle) {
|
|||
NULL);
|
||||
}
|
||||
|
||||
static int wcreate(MwWidget handle) {
|
||||
static int create(MwWidget handle) {
|
||||
MwMenu m = malloc(sizeof(*m));
|
||||
|
||||
m->name = NULL;
|
||||
|
|
@ -71,8 +71,8 @@ static void destroy(MwWidget handle) {
|
|||
#define BEGIN_MENU_LOOP \
|
||||
for(i = 0; i < arrlen(m->sub); i++) { \
|
||||
int incr = m->sub[i]->name[0] == '?' ? 1 : 0; \
|
||||
int tw = MwTextWidth(handle, NULL, m->sub[i]->name + incr); \
|
||||
int th = MwTextHeight(handle, NULL, m->sub[i]->name + incr); \
|
||||
int tw = MwTextWidth(handle, m->sub[i]->name + incr); \
|
||||
int th = MwTextHeight(handle, m->sub[i]->name + incr); \
|
||||
int in_area; \
|
||||
\
|
||||
if(incr) { \
|
||||
|
|
@ -104,7 +104,7 @@ static void draw(MwWidget handle) {
|
|||
MwDrawWidgetBack(handle, &r, base, 0, MwFALSE);
|
||||
}
|
||||
|
||||
MwDrawText(handle, MwFLBuildFont((m->sub[i]->wsub != NULL || (in_area && handle->pressed)) ? MwFLFlagBold : 0), &p, m->sub[i]->name + incr, MwALIGNMENT_BEGINNING, text);
|
||||
MwDrawText(handle, &p, m->sub[i]->name + incr, m->sub[i]->wsub != NULL || (in_area && handle->pressed) ? 1 : 0, MwALIGNMENT_BEGINNING, text);
|
||||
END_MENU_LOOP;
|
||||
|
||||
MwLLFreeColor(text);
|
||||
|
|
@ -118,7 +118,7 @@ static void parent_resize(MwWidget handle) {
|
|||
static void mouse_down(MwWidget handle, void* ptr) {
|
||||
MENU_LOOP_DECL;
|
||||
|
||||
if(((MwMouse*)ptr)->button != MwMOUSE_LEFT) return;
|
||||
if(((MwLLMouse*)ptr)->button != MwLLMouseLeft) return;
|
||||
|
||||
BEGIN_MENU_LOOP;
|
||||
if(in_area) {
|
||||
|
|
@ -129,7 +129,7 @@ static void mouse_down(MwWidget handle, void* ptr) {
|
|||
p2.y = p.y + th / 2 + 5;
|
||||
|
||||
m->sub[i]->wsub = MwCreateWidget(MwSubMenuClass, "submenu", handle, 0, 0, 0, 0);
|
||||
MwSubMenuAppear(m->sub[i]->wsub, m->sub[i], &p2, 0);
|
||||
MwSubMenuAppear(m->sub[i]->wsub, m->sub[i], &p2);
|
||||
} else if(m->sub[i]->wsub != NULL && m->sub[i]->keep) {
|
||||
MwDestroyWidget(m->sub[i]->wsub);
|
||||
m->sub[i]->wsub = NULL;
|
||||
|
|
@ -150,7 +150,7 @@ static void mouse_down(MwWidget handle, void* ptr) {
|
|||
static void mouse_up(MwWidget handle, void* ptr) {
|
||||
MENU_LOOP_DECL;
|
||||
|
||||
if(((MwMouse*)ptr)->button != MwMOUSE_LEFT) return;
|
||||
if(((MwLLMouse*)ptr)->button != MwLLMouseLeft) return;
|
||||
|
||||
BEGIN_MENU_LOOP;
|
||||
if(in_area && m->sub[i]->wsub != NULL) {
|
||||
|
|
@ -189,7 +189,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
|
|||
}
|
||||
|
||||
MwClassRec MwMenuClassRec = {
|
||||
wcreate, /* create */
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
|
|
@ -204,7 +204,7 @@ MwClassRec MwMenuClassRec = {
|
|||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue