Skip to content

Commit

Permalink
Merge branch 'master' into uiSliderSetRange
Browse files Browse the repository at this point in the history
  • Loading branch information
szanni committed Sep 19, 2018
2 parents c74d924 + 6891017 commit bdee1c3
Show file tree
Hide file tree
Showing 57 changed files with 6,412 additions and 214 deletions.
5 changes: 2 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ artifacts:
deploy:
provider: GitHub
artifact: libui, examples
# TODO https://www.appveyor.com/docs/deployment/github/
#auth_token:
#secure: "2l/602m6FkqAB9TTIAkPX3Erfwg9jVTlf/Inmf2dWcbOrJJzK/WrCUIgY3B4ngly"
auth_token:
secure: li92W7mFAC8HbAVeZN6Ugmo5H1GzKSjr6DXlMniLcCRspKmi2Nz1nlslSa+9sLfo
on:
appveyor_repo_tag: true # deploy on tag push only
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ after_success:

deploy:
provider: releases
#api_key:
#secure: TODO
api_key:
secure: "fmgC97mlXQY/ASWAL/GyTJfiJIo/hsVFf6bP3Zz8odv259PJUFGgnZ9kNIgJcFQ5961lXDFi7pBMMSetm1GZ2EBZxIXnUfe1kfIhw62ybJHIwB2+g2tc8A4zzfkWJVY4xVYpitOU3iMuu5Z8U2n+68RYWKpcxhbkVw5v8Zu2Rms="
file: build/out/*.tgz
file_glob: true
skip_cleanup: true
Expand Down
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ if(BUILD_SHARED_LIBS)
SOVERSION "${_VERSION}")
endif()
endif()
# TODO why is this not a default?!
set_property(TARGET libui PROPERTY
POSITION_INDEPENDENT_CODE True)

macro(_add_exec _name)
# TODOTODO re-add WIN32 when merging back
Expand All @@ -214,11 +217,9 @@ macro(_add_exec _name)
target_link_libraries(${_name} libui)
_target_link_options_private(${_name}
_COMMON_LDFLAGS)
# make shared-linked executables PIC too
if(BUILD_SHARED_LIBS)
set_property(TARGET ${_name} PROPERTY
POSITION_INDEPENDENT_CODE True)
endif()
# TODO does this propagate?
set_property(TARGET ${_name} PROPERTY
POSITION_INDEPENDENT_CODE True)
# TODO see above about INTERFACE
if(NOT BUILD_SHARED_LIBS)
target_link_libraries(${_name}
Expand Down
65 changes: 65 additions & 0 deletions OLD_uitable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 20 june 2016
// kept in a separate file for now

typedef struct uiImage uiImage;

// TODO use const void * for const correctness
_UI_EXTERN uiImage *uiNewImage(double width, double height);
_UI_EXTERN void uiFreeImage(uiImage *i);
_UI_EXTERN void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int pixelStride);

typedef struct uiTableModel uiTableModel;
typedef struct uiTableModelHandler uiTableModelHandler;

// TODO actually validate these
_UI_ENUM(uiTableModelColumnType) {
uiTableModelColumnString,
uiTableModelColumnImage,
uiTableModelColumnInt,
uiTableModelColumnColor,
};

// TODO validate ranges; validate types on each getter/setter call (? table columns only?)
struct uiTableModelHandler {
int (*NumColumns)(uiTableModelHandler *, uiTableModel *);
uiTableModelColumnType (*ColumnType)(uiTableModelHandler *, uiTableModel *, int);
int (*NumRows)(uiTableModelHandler *, uiTableModel *);
void *(*CellValue)(uiTableModelHandler *, uiTableModel *, int, int);
void (*SetCellValue)(uiTableModelHandler *, uiTableModel *, int, int, const void *);
};

_UI_EXTERN void *uiTableModelStrdup(const char *str);
// TODO rename the strdup one to this too
_UI_EXTERN void *uiTableModelGiveColor(double r, double g, double b, double a);
_UI_EXTERN void *uiTableModelGiveInt(int i);
// TODO TakeString
// TODO add const
_UI_EXTERN int uiTableModelTakeInt(void *v);

_UI_EXTERN uiTableModel *uiNewTableModel(uiTableModelHandler *mh);
_UI_EXTERN void uiFreeTableModel(uiTableModel *m);
_UI_EXTERN void uiTableModelRowInserted(uiTableModel *m, int newIndex);
_UI_EXTERN void uiTableModelRowChanged(uiTableModel *m, int index);
_UI_EXTERN void uiTableModelRowDeleted(uiTableModel *m, int oldIndex);
// TODO reordering/moving

typedef struct uiTableColumn uiTableColumn;

_UI_EXTERN void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand);
// TODO images shouldn't expand...
_UI_EXTERN void uiTableColumnAppendImagePart(uiTableColumn *c, int modelColumn, int expand);
_UI_EXTERN void uiTableColumnAppendButtonPart(uiTableColumn *c, int modelColumn, int expand);
// TODO should these have labels?
_UI_EXTERN void uiTableColumnAppendCheckboxPart(uiTableColumn *c, int modelColumn, int expand);
_UI_EXTERN void uiTableColumnAppendProgressBarPart(uiTableColumn *c, int modelColumn, int expand);
// TODO Editable?
_UI_EXTERN void uiTableColumnPartSetEditable(uiTableColumn *c, int part, int editable);
_UI_EXTERN void uiTableColumnPartSetTextColor(uiTableColumn *c, int part, int modelColumn);

typedef struct uiTable uiTable;
#define uiTable(this) ((uiTable *) (this))
_UI_EXTERN uiTableColumn *uiTableAppendColumn(uiTable *t, const char *name);
_UI_EXTERN uiTableColumn *uiTableAppendTextColumn(uiTable *t, const char *name, int modelColumn);
// TODO getter?
_UI_EXTERN void uiTableSetRowBackgroundColorModelColumn(uiTable *t, int modelColumn);
_UI_EXTERN uiTable *uiNewTable(uiTableModel *model);
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ It has come to my attention that I have not been particularly clear about how us

libui is currently **mid-alpha** software. Much of what is currently present runs stabily enough for the examples and perhaps some small programs to work, but the stability is still a work-in-progress, much of what is already there is not feature-complete, some of it will be buggy on certain platforms, and there's a lot of stuff missing. In short, here's a list of features that I would like to add to libui, but that aren't in yet:

- tables and trees (the former is currently WIP and may land in preliminary form soon)
- trees
- clipboard support, including drag and drop
- more and better dialogs
- printing
- accessibility for uiArea and custom controls
- document-based programs
- tighter OS integration (especially for document-based programs), to allow programs to fully feel native, rather than merely look and act native
- better support for standard dialogs and features (search bars, etc.)
- OpenGL support (this was already being worked on by someone else, but I don't know what happened to them...)
- OpenGL support

In addition, [here](https://github.com/andlabs/libui/issues?utf8=%E2%9C%93&q=master+in%3Atitle+is%3Aissue+is%3Aopen) is a list of issues generalizing existing problems.

Expand All @@ -30,6 +30,17 @@ But libui is not dead; I am working on it whenever I can, and I hope to get it t

*Note that today's entry (Eastern Time) may be updated later today.*

* **1 September 2018**
* **Alpha 4.1 is here.** This is an emergency fix to Alpha 4 to fix `uiImageAppend()` not working as documented. It now works properly, with one important difference you'll need to care about: **it now requires image data to be alpha-premultiplied**. In addition, `uiImage` also is implemented slightly more nicely now, and `ui.h` has minor documentation typo fixes.
* Alpha 4.1 also tries to make everything properly PIC-enabled.

* **10 August 2018**
* **Alpha 4 is finally here.** Everything from Alpha 3.5 and what's listed below is in this release; the two biggest changes are still the new text drawing API and new uiTable control. In between all that is a whole bunch of bugfixes, and hopefully more stability too. Thanks to everybody who helped contribute!
* Alpha 4 should hopefully also include automated binary releases via CI. Thanks to those who helped set that up!

* **8 August 2018**
* Finally introduced an API for loading images, `uiImage`, and a new control, `uiTable`, for displaying tabular data. These provide enough basic functionality for now, but will be improved over time. You can read the documentation for the new features as they are [here](https://github.com/andlabs/libui/blob/f47e1423cf95ad7b1001663f3381b5a819fc67b9/uitable.h). Thanks to everyone who helped get to this point, in particular @bcampbell for the initial Windows code, and to everyone else for their patience!

* **30 May 2018**
* Merged the previous Announcements and Updates section of this README into a single News section, and merged the respective archive files into a single NEWS.md file.

Expand Down
2 changes: 2 additions & 0 deletions _notes/dialogs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://github.com/kusti8/proton-native/issues/47#issuecomment-373068947
https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0
1 change: 1 addition & 0 deletions _notes/highDPI
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
High DPI Displays | Qt 5.5 http://doc.qt.io/qt-5/highdpi.html bottom of page(?)
15 changes: 15 additions & 0 deletions _notes/i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
https://msdn.microsoft.com/en-us/library/windows/desktop/dd319079(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/dd318103(v=vs.85).aspx
https://stackoverflow.com/questions/4663855/is-there-a-repository-for-localized-common-text-in-winforms
https://stackoverflow.com/questions/2502375/find-localized-windows-strings
https://docs.microsoft.com/en-us/windows-hardware/customize/mobile/mcsf/create-a-resource-only-dll-for-localized-strings
https://msdn.microsoft.com/en-us/library/windows/desktop/ee845043(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/cc194807.aspx
https://www.codeproject.com/Articles/10542/Easily-Load-and-Format-Strings-from-the-String-Tab
https://www.codeproject.com/Tips/431045/The-inner-working-of-FindResource-and-LoadString-W
https://mihai-nita.net/2007/05/03/how-to-localize-an-rc-file/
https://www.microsoft.com/en-us/language
https://www.microsoft.com/en-us/language/Terminology
https://www.microsoft.com/en-us/language/LicenseAgreement
https://www.microsoft.com/en-us/language/Translations
http://www.ttt.org/oscarstandards/tbx/
21 changes: 21 additions & 0 deletions _notes/windowsUWPGlass
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,24 @@ http://www.brandonfa.lk/win8/
https://github.com/gamozolabs/pdblister
https://github.com/wbenny/pdbex
https://github.com/wbenny/pdbex/releases

https://stackoverflow.com/questions/44000217/mimicking-acrylic-in-a-win32-app
https://github.com/riverar/sample-win32-acrylicblur
https://github.com/riverar/sample-win10-aeroglass
https://guerra24blog.wordpress.com/2017/12/20/windows-10-use-acrylic-in-win32-apps/
https://news.ycombinator.com/item?id=14432951
https://gist.github.com/ethanhs/0e157e4003812e99bf5bc7cb6f73459f ACCENTPOLICY
https://github.com/TranslucentTB/Tools
https://withinrafael.com/2015/07/08/adding-the-aero-glass-blur-to-your-windows-10-apps/
https://withinrafael.com/2018/02/01/adding-acrylic-blur-to-your-windows-10-apps-redstone-4-desktop-apps/

diversion: DwmEnableBlurBehindWindow {
https://docs.microsoft.com/en-us/windows/desktop/api/dwmapi/nf-dwmapi-dwmenableblurbehindwindow
https://docs.microsoft.com/en-us/windows/desktop/api/dwmapi/ns-dwmapi-_dwm_blurbehind
https://docs.microsoft.com/en-us/windows/desktop/api/dwmapi/nf-dwmapi-dwmenableblurbehindwindow
http://www.danielmoth.com/Blog/Vista-Glass-Answers-And-DwmEnableBlurBehindWindow.aspx
http://www.danielmoth.com/Blog/Glass-In-C-An-Alternative-Approach.aspx
http://www.danielmoth.com/Blog/Vista-Glass-In-C.aspx
http://www.danielmoth.com/Blog/Glass-In-C-An-Alternative-Approach.aspx
https://weblogs.asp.net/kennykerr/Windows-Vista-for-Developers-_1320_-Part-3-_1320_-The-Desktop-Window-Manager
}
3 changes: 2 additions & 1 deletion common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ list(APPEND _LIBUI_SOURCES
common/areaevents.c
common/control.c
common/debug.c
# common/drawtext.c
common/matrix.c
common/opentype.c
common/shouldquit.c
common/tablemodel.c
common/tablevalue.c
common/userbugs.c
common/utf.c
)
Expand Down
22 changes: 22 additions & 0 deletions common/OLD_table.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 21 june 2016
#include "../ui.h"
#include "uipriv.h"

void *uiTableModelGiveInt(int i)
{
return (void *) ((intptr_t) i);
}

int uiTableModelTakeInt(void *v)
{
return (int) ((intptr_t) v);
}

uiTableColumn *uiTableAppendTextColumn(uiTable *t, const char *name, int modelColumn)
{
uiTableColumn *tc;

tc = uiTableAppendColumn(t, name);
uiTableColumnAppendTextPart(tc, modelColumn, 1);
return tc;
}
10 changes: 5 additions & 5 deletions common/attrstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,20 @@ void uiAttributedStringDelete(uiAttributedString *s, size_t start, size_t end)

// update the conversion tables
// note the use of <= to include the null terminator
for (i = 0; i <= count; i++)
for (i = 0; i <= (s->len - end); i++)
s->u8tou16[start + i] -= count16;
for (i = 0; i <= count16; i++)
for (i = 0; i <= (s->u16len - end16); i++)
s->u16tou8[start16 + i] -= count;

// null-terminate the string
s->s[start + count] = 0;
s->u16[start16 + count16] = 0;
s->s[start + (s->len - end)] = 0;
s->u16[start16 + (s->u16len - end16)] = 0;

// fix up attributes
uiprivAttrListRemoveCharacters(s->attrs, start, end);

// and finally resize
resize(s, start + count, start16 + count16);
resize(s, s->len - count, s->u16len - count16);
}

void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttribute *a, size_t start, size_t end)
Expand Down
20 changes: 20 additions & 0 deletions common/table.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 23 june 2018

#ifdef __cplusplus
extern "C" {
#endif

// tablemodel.c
extern uiTableModelHandler *uiprivTableModelHandler(uiTableModel *m);
extern int uiprivTableModelNumColumns(uiTableModel *m);
extern uiTableValueType uiprivTableModelColumnType(uiTableModel *m, int column);
extern int uiprivTableModelNumRows(uiTableModel *m);
extern uiTableValue *uiprivTableModelCellValue(uiTableModel *m, int row, int column);
extern void uiprivTableModelSetCellValue(uiTableModel *m, int row, int column, const uiTableValue *value);
extern const uiTableTextColumnOptionalParams uiprivDefaultTextColumnOptionalParams;
extern int uiprivTableModelCellEditable(uiTableModel *m, int row, int column);
extern int uiprivTableModelColorIfProvided(uiTableModel *m, int row, int column, double *r, double *g, double *b, double *a);

#ifdef __cplusplus
}
#endif
79 changes: 79 additions & 0 deletions common/tablemodel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// 23 june 2018
#include "../ui.h"
#include "uipriv.h"
#include "table.h"

int uiprivTableModelNumColumns(uiTableModel *m)
{
uiTableModelHandler *mh;

mh = uiprivTableModelHandler(m);
return (*(mh->NumColumns))(mh, m);
}

uiTableValueType uiprivTableModelColumnType(uiTableModel *m, int column)
{
uiTableModelHandler *mh;

mh = uiprivTableModelHandler(m);
return (*(mh->ColumnType))(mh, m, column);
}

int uiprivTableModelNumRows(uiTableModel *m)
{
uiTableModelHandler *mh;

mh = uiprivTableModelHandler(m);
return (*(mh->NumRows))(mh, m);
}

uiTableValue *uiprivTableModelCellValue(uiTableModel *m, int row, int column)
{
uiTableModelHandler *mh;

mh = uiprivTableModelHandler(m);
return (*(mh->CellValue))(mh, m, row, column);
}

void uiprivTableModelSetCellValue(uiTableModel *m, int row, int column, const uiTableValue *value)
{
uiTableModelHandler *mh;

mh = uiprivTableModelHandler(m);
(*(mh->SetCellValue))(mh, m, row, column, value);
}

const uiTableTextColumnOptionalParams uiprivDefaultTextColumnOptionalParams = {
.ColorModelColumn = -1,
};

int uiprivTableModelCellEditable(uiTableModel *m, int row, int column)
{
uiTableValue *value;
int editable;

switch (column) {
case uiTableModelColumnNeverEditable:
return 0;
case uiTableModelColumnAlwaysEditable:
return 1;
}
value = uiprivTableModelCellValue(m, row, column);
editable = uiTableValueInt(value);
uiFreeTableValue(value);
return editable;
}

int uiprivTableModelColorIfProvided(uiTableModel *m, int row, int column, double *r, double *g, double *b, double *a)
{
uiTableValue *value;

if (column == -1)
return 0;
value = uiprivTableModelCellValue(m, row, column);
if (value == NULL)
return 0;
uiTableValueColor(value, r, g, b, a);
uiFreeTableValue(value);
return 1;
}
Loading

0 comments on commit bdee1c3

Please sign in to comment.