Skip to content

Commit

Permalink
Merge 266, fix includes
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Nov 12, 2024
1 parent 3490dab commit d1d2760
Show file tree
Hide file tree
Showing 47 changed files with 204 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LIBUI_COMMON := $(patsubst %.c,%.o,$(wildcard common/*.c))
LIBUI_COMMON := $(filter-out %OLD_table.o,$(LIBUI_COMMON))

CFLAGS := -I. -g
CFLAGS := -I. -Iinclude/ -g

all:
echo "see Makefile"
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This is a fork of libui-ng with some extras:
- [ ] uiImageButton
- [ ] OpenGLArea (405)

# Build system
Meson build system is preserved, but a make-based system is added for cross-compilation.
```
# Compile for MinGW from Linux
make TARGET=w libui_win64.a install
Expand All @@ -28,3 +30,7 @@ make TARGET=m libui.dylib
- [ ] X86_64 MacOS (.dylib, .app)
- [ ] ARM64 Linux
- [ ] ARM64 MacOS

Merged PRs:
- https://github.com/libui-ng/libui-ng/pull/266 / https://github.com/libui-ng/libui-ng/pull/256

2 changes: 1 addition & 1 deletion common/OLD_table.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 21 june 2016
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"

void *uiTableModelGiveInt(int i)
Expand Down
2 changes: 1 addition & 1 deletion common/areaevents.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 29 march 2014
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"

/*
Expand Down
2 changes: 1 addition & 1 deletion common/attribute.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 19 february 2018
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"
#include "attrstr.h"

Expand Down
2 changes: 1 addition & 1 deletion common/attrlist.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 16 december 2016
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"
#include "attrstr.h"

Expand Down
2 changes: 1 addition & 1 deletion common/attrstr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 3 december 2016
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"
#include "attrstr.h"

Expand Down
2 changes: 1 addition & 1 deletion common/control.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 26 may 2015
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"

void uiControlDestroy(uiControl *c)
Expand Down
2 changes: 1 addition & 1 deletion common/debug.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 13 may 2016
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"

void uiprivDoImplBug(const char *file, const char *line, const char *func, const char *format, ...)
Expand Down
2 changes: 1 addition & 1 deletion common/matrix.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 11 october 2015
#include <math.h>
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"

void uiDrawMatrixSetIdentity(uiDrawMatrix *m)
Expand Down
2 changes: 1 addition & 1 deletion common/opentype.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 25 february 2018
#include <stdlib.h>
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"
#include "attrstr.h"

Expand Down
2 changes: 1 addition & 1 deletion common/shouldquit.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 9 may 2015
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"

static int defaultOnShouldQuit(void *data)
Expand Down
2 changes: 1 addition & 1 deletion common/table.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"

void uiFreeTableSelection(uiTableSelection *s)
Expand Down
2 changes: 1 addition & 1 deletion common/tablemodel.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 23 june 2018
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"
#include "table.h"

Expand Down
2 changes: 1 addition & 1 deletion common/tablevalue.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 3 june 2018
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"
#include "table.h"

Expand Down
2 changes: 1 addition & 1 deletion common/userbugs.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 22 may 2016
#include "../ui.h"
#include <ui.h>
#include "uipriv.h"

void uiUserBugCannotSetParentOnToplevel(const char *type)
Expand Down
1 change: 1 addition & 0 deletions darwin/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ libui_sources += [
'darwin/table.m',
'darwin/tablecolumn.m',
'darwin/text.m',
'darwin/tooltip.m',
'darwin/undocumented.m',
'darwin/util.m',
'darwin/window.m',
Expand Down
12 changes: 12 additions & 0 deletions darwin/tooltip.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "uipriv_darwin.h"

// https://developer.apple.com/documentation/appkit/nsview/1483541-tooltip?language=objc

void uiControlSetTooltip(uiControl *c, const char *tooltip) {
NSView *view = (NSView *)uiControlHandle(c);
if (tooltip == NULL) {
view.toolTip = nil;
} else {
view.toolTip = uiprivToNSString(tooltip);
}
}
12 changes: 6 additions & 6 deletions extras/266.diff
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ index 00000000..04a6f1cc
+ view.toolTip = uiprivToNSString(tooltip);
+ }
+}
diff --git a/ui.h b/ui.h
diff --git a/include/ui.h b/include/ui.h
index cfb801e3..9a972d9b 100644
--- a/ui.h
+++ b/ui.h
--- a/include/ui.h
+++ b/include/ui.h
@@ -4008,6 +4008,18 @@ _UI_EXTERN void uiTableSetSelection(uiTable *t, uiTableSelection *sel);
*/
_UI_EXTERN void uiFreeTableSelection(uiTableSelection* s);
Expand All @@ -51,10 +51,10 @@ index cfb801e3..9a972d9b 100644
#ifdef __cplusplus
}
#endif
diff --git a/ui_windows.h b/ui_windows.h
diff --git a/include/ui_windows.h b/include/ui_windows.h
index 9e472451..7126f6f9 100644
--- a/ui_windows.h
+++ b/ui_windows.h
--- a/include/ui_windows.h
+++ b/include/ui_windows.h
@@ -20,6 +20,7 @@ struct uiWindowsControl {
// TODO this should be int on both os x and windows
BOOL enabled;
Expand Down
12 changes: 12 additions & 0 deletions include/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -4008,6 +4008,18 @@ _UI_EXTERN void uiTableSetSelection(uiTable *t, uiTableSelection *sel);
*/
_UI_EXTERN void uiFreeTableSelection(uiTableSelection* s);

/**
* Sets the control tooltip.
*
* @param c uiControl instance.
* @param tooltip Control tooltip.\n
* A valid, `NULL` terminated UTF-8 string.\n
* Data is copied internally. Ownership is not transferred.
* @note Setting `NULL` resets the tooltip to the default value.
* @memberof uiControl
*/
_UI_EXTERN void uiControlSetTooltip(uiControl *c, const char *tooltip);

#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 5 additions & 1 deletion include/ui_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct uiWindowsControl {
// TODO this should be int on both os x and windows
BOOL enabled;
BOOL visible;
void *tooltips;
void (*SyncEnableState)(uiWindowsControl *, int);
void (*SetParentHWND)(uiWindowsControl *, HWND);
void (*MinimumSize)(uiWindowsControl *, int *, int *);
Expand All @@ -42,6 +43,7 @@ _UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *);
#define uiWindowsControlDefaultDestroy(type) \
static void type ## Destroy(uiControl *c) \
{ \
uiprivDestroyTooltip(c); \
uiWindowsEnsureDestroyWindow(type(c)->hwnd); \
uiFreeControl(c); \
}
Expand Down Expand Up @@ -185,7 +187,9 @@ _UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *);
uiWindowsControl(var)->AssignControlIDZOrder = type ## AssignControlIDZOrder; \
uiWindowsControl(var)->ChildVisibilityChanged = type ## ChildVisibilityChanged; \
uiWindowsControl(var)->visible = 1; \
uiWindowsControl(var)->enabled = 1;
uiWindowsControl(var)->enabled = 1; \
uiWindowsControl(var)->tooltips = NULL;

// TODO document
_UI_EXTERN uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr);

Expand Down
13 changes: 7 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ libui_rpath = ''
subdir('common')
if libui_OS == 'windows'
subdir('windows')
install_headers('ui_windows.h')
install_headers('include/ui_windows.h')
elif libui_OS == 'darwin'
subdir('darwin')
install_headers('ui_darwin.h')
install_headers('include/ui_darwin.h')
else
subdir('unix')
install_headers('ui_unix.h')
install_headers('include/ui_unix.h')
endif
libui_libui = library('ui', libui_sources,
dependencies: libui_deps,
Expand All @@ -167,8 +167,9 @@ libui_libui = library('ui', libui_sources,
c_args: ['-Dlibui_EXPORTS'],
cpp_args: ['-Dlibui_EXPORTS'],
objc_args: ['-Dlibui_EXPORTS'],
link_args: libui_libui_link_args)
install_headers('ui.h')
link_args: libui_libui_link_args,
include_directories : include_directories('include'))
install_headers('include/ui.h')

# TODO when the API is stable enough to be versioned, create a pkg-config file (https://mesonbuild.com/Pkgconfig-module.html) and a declare_dependency() section too

Expand All @@ -178,7 +179,7 @@ if libui_mode == 'static'
endif

# Export symbols for use of libui as a meson subproject
libui_dep = declare_dependency(include_directories: include_directories('.'),
libui_dep = declare_dependency(include_directories: include_directories('./include'),
link_with : libui_libui)

if get_option('tests')
Expand Down
1 change: 1 addition & 0 deletions unix/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ libui_sources += [
'unix/table.c',
'unix/tablemodel.c',
'unix/text.c',
'unix/tooltip.c',
'unix/util.c',
'unix/window.c',
]
Expand Down
9 changes: 9 additions & 0 deletions unix/tooltip.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "uipriv_unix.h"

void uiControlSetTooltip(uiControl *c, const char *tooltip) {
if (tooltip == NULL) {
gtk_widget_set_has_tooltip(GTK_WIDGET(uiControlHandle(c)), FALSE);
} else {
gtk_widget_set_tooltip_text(GTK_WIDGET(uiControlHandle(c)), tooltip);
}
}
4 changes: 2 additions & 2 deletions unix/uipriv_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include "../ui.h"
#include "../ui_unix.h"
#include <ui.h>
#include <ui_unix.h>
#include "../common/uipriv.h"

#define uiprivGTKXMargin 12
Expand Down
1 change: 1 addition & 0 deletions windows/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static void uiBoxDestroy(uiControl *c)
uiControlDestroy(bc.c);
}
delete b->controls;
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(b->hwnd);
uiFreeControl(uiControl(b));
}
Expand Down
1 change: 1 addition & 0 deletions windows/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static void uiButtonDestroy(uiControl *c)
uiButton *b = uiButton(c);

uiWindowsUnregisterWM_COMMANDHandler(b->hwnd);
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(b->hwnd);
uiFreeControl(uiControl(b));
}
Expand Down
3 changes: 2 additions & 1 deletion windows/checkbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ static void uiCheckboxDestroy(uiControl *cc)
uiCheckbox *c = uiCheckbox(cc);

uiWindowsUnregisterWM_COMMANDHandler(c->hwnd);
uiprivDestroyTooltip(cc);
uiWindowsEnsureDestroyWindow(c->hwnd);
uiFreeControl(uiControl(c));
uiFreeControl(cc);
}

uiWindowsControlAllDefaultsExceptDestroy(uiCheckbox)
Expand Down
1 change: 1 addition & 0 deletions windows/colorbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static void uiColorButtonDestroy(uiControl *c)

uiWindowsUnregisterWM_COMMANDHandler(b->hwnd);
uiWindowsUnregisterWM_NOTIFYHandler(b->hwnd);
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(b->hwnd);
uiFreeControl(uiControl(b));
}
Expand Down
3 changes: 2 additions & 1 deletion windows/combobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ void uiComboboxDestroy(uiControl *cc)
uiCombobox *c = uiCombobox(cc);

uiWindowsUnregisterWM_COMMANDHandler(c->hwnd);
uiprivDestroyTooltip(cc);
uiWindowsEnsureDestroyWindow(c->hwnd);
uiFreeControl(uiControl(c));
uiFreeControl(cc);
}

uiWindowsControlAllDefaultsExceptDestroy(uiCombobox)
Expand Down
1 change: 1 addition & 0 deletions windows/datetimepicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static void uiDateTimePickerDestroy(uiControl *c)

uiWindowsUnregisterReceiveWM_WININICHANGE(d->hwnd);
uiWindowsUnregisterWM_NOTIFYHandler(d->hwnd);
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(d->hwnd);
uiFreeControl(uiControl(d));
}
Expand Down
3 changes: 2 additions & 1 deletion windows/editablecombo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ void uiEditableComboboxDestroy(uiControl *cc)
uiEditableCombobox *c = uiEditableCombobox(cc);

uiWindowsUnregisterWM_COMMANDHandler(c->hwnd);
uiprivDestroyTooltip(cc);
uiWindowsEnsureDestroyWindow(c->hwnd);
uiFreeControl(uiControl(c));
uiFreeControl(cc);
}

uiWindowsControlAllDefaultsExceptDestroy(uiEditableCombobox)
Expand Down
1 change: 1 addition & 0 deletions windows/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static void uiEntryDestroy(uiControl *c)
uiEntry *e = uiEntry(c);

uiWindowsUnregisterWM_COMMANDHandler(e->hwnd);
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(e->hwnd);
uiFreeControl(uiControl(e));
}
Expand Down
1 change: 1 addition & 0 deletions windows/fontbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ static void uiFontButtonDestroy(uiControl *c)

uiWindowsUnregisterWM_COMMANDHandler(b->hwnd);
uiprivDestroyFontDialogParams(&(b->params));
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(b->hwnd);
uiFreeControl(uiControl(b));
}
Expand Down
1 change: 1 addition & 0 deletions windows/form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ static void uiFormDestroy(uiControl *c)
uiWindowsEnsureDestroyWindow(fc.label);
}
delete f->controls;
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(f->hwnd);
uiFreeControl(uiControl(f));
}
Expand Down
1 change: 1 addition & 0 deletions windows/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ static void uiGridDestroy(uiControl *c)
}
delete g->indexof;
delete g->children;
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(g->hwnd);
uiFreeControl(uiControl(g));
}
Expand Down
1 change: 1 addition & 0 deletions windows/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static void uiGroupDestroy(uiControl *c)
uiControlSetParent(g->child, NULL);
uiControlDestroy(g->child);
}
uiprivDestroyTooltip(c);
uiWindowsEnsureDestroyWindow(g->hwnd);
uiFreeControl(uiControl(g));
}
Expand Down
1 change: 1 addition & 0 deletions windows/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ libui_sources += [
'windows/tablemetrics.cpp',
'windows/tabpage.cpp',
'windows/text.cpp',
'windows/tooltip.cpp',
'windows/utf16.cpp',
'windows/utilwin.cpp',
'windows/window.cpp',
Expand Down
Loading

0 comments on commit d1d2760

Please sign in to comment.