Commit d758cdf9 authored by Hanspeter Portner's avatar Hanspeter Portner

Merge commit 'fe5dbf40'

parents b4f55514 fe5dbf40
Pipeline #121714905 failed with stages
in 1 minute and 59 seconds
......@@ -2,6 +2,7 @@ stages:
- build
- deploy
# templates
.variables_template: &variables_definition
variables:
BASE_NAME: "d2tk"
......@@ -17,6 +18,7 @@ stages:
.build_template: &build_definition
<<: *common_definition
stage: build
script:
- meson --prefix="/" --libdir="lib" --cross-file "${CI_BUILD_NAME}" build
- sed -i -e '/framework/s/-Wl,-O1//g' -e '/framework/s/-Wl,--start-group//g' -e '/framework/s/-Wl,--end-group//g' build/build.ninja
......@@ -25,21 +27,26 @@ stages:
.test_template: &test_definition
<<: *common_definition
stage: build
script:
- meson --prefix="/" --libdir="lib" --cross-file "${CI_BUILD_NAME}" build
- sed -i -e '/framework/s/-Wl,-O1//g' -e '/framework/s/-Wl,--start-group//g' -e '/framework/s/-Wl,--end-group//g' build/build.ninja
- ninja -C build
- DESTDIR="${CI_PROJECT_DIR}/${BASE_NAME}-$(cat VERSION)/${CI_BUILD_NAME}" ninja -C build install
- ninja -C build test
- meson test -C build
.analyze_template: &analyze_definition
<<: *common_definition
stage: build
script:
- meson --prefix="/" --libdir="lib" --cross-file "${CI_BUILD_NAME}" build
- sed -i -e '/framework/s/-Wl,-O1//g' -e '/framework/s/-Wl,--start-group//g' -e '/framework/s/-Wl,--end-group//g' build/build.ninja
- ninja -C build
- DESTDIR="${CI_PROJECT_DIR}/${BASE_NAME}-$(cat VERSION)/${CI_BUILD_NAME}" ninja -C build install
- ninja -C build test
- meson test -C build
- meson test -C build --wrap=valgrind
- CC=clang CXX=clang++ meson --prefix="/" --libdir="lib" --cross-file "${CI_BUILD_NAME}" clang
- ninja -C clang
......@@ -50,22 +57,22 @@ stages:
- scan-build --status-bugs ninja -C scanbuild test
.universal_linux_template: &universal_linux_definition
image: ventosus/universal-linux-gnu
image: ventosus/universal-linux-gnu:buster
<<: *analyze_definition
.arm_linux_template: &arm_linux_definition
image: ventosus/arm-linux-gnueabihf
image: ventosus/arm-linux-gnueabihf:buster
<<: *test_definition
.universal_w64_template: &universal_w64_definition
image: ventosus/universal-w64-mingw32
<<: *build_definition
<<: *test_definition
.universal_apple_template: &universal_apple_definition
image: ventosus/universal-apple-darwin
<<: *build_definition
# building in docker
# targets
x86_64-linux-gnu:
before_script:
- apt-get install -y libglu1-mesa-dev libevdev-dev libvterm-dev
......@@ -106,7 +113,6 @@ pack:
- "${BASE_NAME}-$(cat VERSION)/"
pages:
<<: *variables_definition
stage: deploy
before_script:
- apt-get update -y
......
#!/bin/sh
fc-list | grep "$1"
......@@ -26,8 +26,6 @@
#include <utf8.h/utf8.h>
#include "config.h"
#ifdef __cplusplus
extern "C" {
#endif
......@@ -43,6 +41,7 @@ typedef struct _d2tk_flowmatrix_t d2tk_flowmatrix_t;
typedef struct _d2tk_flowmatrix_node_t d2tk_flowmatrix_node_t;
typedef struct _d2tk_flowmatrix_arc_t d2tk_flowmatrix_arc_t;
typedef struct _d2tk_pane_t d2tk_pane_t;
typedef struct _d2tk_pty_t d2tk_pty_t;
typedef struct _d2tk_base_t d2tk_base_t;
struct _d2tk_pos_t {
......@@ -155,9 +154,9 @@ typedef enum _d2tk_flag_t {
D2TK_FLAG_TABLE_REL = (1 << 9),
} d2tk_flag_t;
#define D2TK_ID_IDX(IDX) ((d2tk_id_t)__LINE__ << 16) | (IDX)
#define D2TK_ID_IDX(IDX) ( ((d2tk_id_t)__LINE__ << 16) | (IDX) )
#define D2TK_ID_FILE_IDX(IDX) \
((d2tk_id_t)d2tk_hash(__FILE__, -1) << 32) | D2TK_ID_IDX((IDX))
( ((d2tk_id_t)d2tk_hash(__FILE__, -1) << 32) | D2TK_ID_IDX((IDX)) )
#define D2TK_ID D2TK_ID_IDX(0)
#define D2TK_ID_FILE D2TK_ID_FILE_IDX(0)
......@@ -169,6 +168,7 @@ extern const size_t d2tk_flowmatrix_sz;
extern const size_t d2tk_flowmatrix_node_sz;
extern const size_t d2tk_flowmatrix_arc_sz;
extern const size_t d2tk_pane_sz;
extern const size_t d2tk_pty_sz;
D2TK_API d2tk_table_t *
d2tk_table_begin(const d2tk_rect_t *rect, unsigned N, unsigned M,
......@@ -415,6 +415,14 @@ d2tk_base_button(d2tk_base_t *base, d2tk_id_t id, const d2tk_rect_t *rect);
#define d2tk_base_button_is_changed(...) \
d2tk_state_is_changed(d2tk_base_button(__VA_ARGS__))
D2TK_API d2tk_state_t
d2tk_base_toggle_label_image(d2tk_base_t *base, d2tk_id_t id, ssize_t lbl_len,
const char *lbl, d2tk_align_t align, ssize_t path_len, const char *path,
const d2tk_rect_t *rect, bool *value);
#define d2tk_base_toggle_label_image_is_changed(...) \
d2tk_state_is_changed(d2tk_base_toggle_label_image(__VA_ARGS__))
D2TK_API d2tk_state_t
d2tk_base_toggle_label(d2tk_base_t *base, d2tk_id_t id, ssize_t lbl_len,
const char *lbl, d2tk_align_t align, const d2tk_rect_t *rect, bool *value);
......@@ -475,14 +483,38 @@ d2tk_base_link(d2tk_base_t *base, d2tk_id_t id, ssize_t lbl_len, const char *lbl
d2tk_state_is_changed(d2tk_base_link(__VA_ARGS__))
#if D2TK_PTY
typedef void (*d2tk_clone_t)(FILE *stderr, void *data);
D2TK_API d2tk_pty_t *
d2tk_pty_begin(d2tk_base_t *base, d2tk_id_t id, char **argv,
d2tk_coord_t height, const d2tk_rect_t *rect, bool reinit, d2tk_pty_t *pty);
D2TK_API bool
d2tk_pty_not_end(d2tk_pty_t *pty);
D2TK_API d2tk_pty_t *
d2tk_pty_next(d2tk_pty_t *pty);
D2TK_API d2tk_state_t
d2tk_base_pty(d2tk_base_t *base, d2tk_id_t id, d2tk_clone_t clone, void *data,
d2tk_coord_t height, const d2tk_rect_t *rect, bool reinit);
d2tk_pty_get_state(d2tk_pty_t *pty);
D2TK_API uint32_t
d2tk_pty_get_max_red(d2tk_pty_t *pty);
#define d2tk_base_pty_is_changed(...) \
d2tk_state_is_changed(d2tk_base_pty(__VA_ARGS__))
D2TK_API uint32_t
d2tk_pty_get_max_green(d2tk_pty_t *pty);
D2TK_API uint32_t
d2tk_pty_get_max_blue(d2tk_pty_t *pty);
#define D2TK_BASE_PTY(BASE, ID, ARGV, HEIGHT, RECT, REINIT, PTY) \
for(d2tk_pty_t *(PTY) = d2tk_pty_begin((BASE), (ID), (ARGV), (HEIGHT), \
(RECT), (REINIT), alloca(d2tk_pty_sz)); \
d2tk_pty_not_end((PTY)); \
(PTY) = d2tk_pty_next((PTY)))
#endif
#if D2TK_EVDEV
D2TK_API d2tk_state_t
d2tk_base_vkb(d2tk_base_t *base, d2tk_id_t id, const d2tk_rect_t *rect);
#endif
D2TK_API d2tk_state_t
......@@ -534,6 +566,20 @@ d2tk_base_dial_double(d2tk_base_t *base, d2tk_id_t id, const d2tk_rect_t *rect,
#define d2tk_base_dial_double_is_changed(...) \
d2tk_state_is_changed(d2tk_base_dial_double(__VA_ARGS__))
D2TK_API d2tk_state_t
d2tk_base_spinner_int32(d2tk_base_t *base, d2tk_id_t id, const d2tk_rect_t *rect,
int32_t min, int32_t *value, int32_t max);
#define d2tk_base_spinner_int32_is_changed(...) \
d2tk_state_is_changed(d2tk_base_spinner_int32(__VA_ARGS__))
D2TK_API d2tk_state_t
d2tk_base_bar_int32(d2tk_base_t *base, d2tk_id_t id, const d2tk_rect_t *rect,
int32_t min, int32_t *value, int32_t max);
#define d2tk_base_bar_int32_is_changed(...) \
d2tk_state_is_changed(d2tk_base_bar_int32(__VA_ARGS__))
D2TK_API d2tk_flowmatrix_t *
d2tk_flowmatrix_begin(d2tk_base_t *base, const d2tk_rect_t *rect, d2tk_id_t id,
d2tk_flowmatrix_t *flowmatrix);
......@@ -647,6 +693,12 @@ d2tk_base_set_butmask(d2tk_base_t *base, d2tk_butmask_t mask, bool down);
D2TK_API bool
d2tk_base_get_butmask(d2tk_base_t *base, d2tk_butmask_t mask, bool clear);
D2TK_API bool
d2tk_base_get_butmask_down(d2tk_base_t *base, d2tk_butmask_t mask);
D2TK_API bool
d2tk_base_get_butmask_up(d2tk_base_t *base, d2tk_butmask_t mask);
D2TK_API void
d2tk_base_set_mouse_pos(d2tk_base_t *base, d2tk_coord_t x, d2tk_coord_t y);
......@@ -672,6 +724,12 @@ d2tk_base_set_keymask(d2tk_base_t *base, d2tk_keymask_t mask, bool down);
D2TK_API bool
d2tk_base_get_keymask(d2tk_base_t *base, d2tk_keymask_t mask, bool clear);
D2TK_API bool
d2tk_base_get_keymask_down(d2tk_base_t *base, d2tk_keymask_t mask);
D2TK_API bool
d2tk_base_get_keymask_up(d2tk_base_t *base, d2tk_keymask_t mask);
D2TK_API void
d2tk_base_set_dimensions(d2tk_base_t *base, d2tk_coord_t w, d2tk_coord_t h);
......
#define D2TK_PTY @[email protected]
#define D2TK_EVDEV @[email protected]
#define D2TK_INPUT_1_15 @[email protected]
#define D2TK_FONTCONFIG @[email protected]
......@@ -21,6 +21,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "config.h"
#include <d2tk/d2tk.h>
#ifdef __cplusplus
......
......@@ -33,6 +33,7 @@ typedef void (*foreach_t)(const char *path, const char *d_name);
struct _app_t {
d2tk_fbdev_t *fbdev;
bool show_cursor;
};
static sig_atomic_t done = false;
......@@ -52,11 +53,14 @@ _expose(void *data, d2tk_coord_t w, d2tk_coord_t h)
d2tk_example_run(base, w, h);
d2tk_coord_t x = 0;
d2tk_coord_t y = 0;
if(app->show_cursor)
{
d2tk_coord_t x = 0;
d2tk_coord_t y = 0;
d2tk_base_get_mouse_pos(base, &x, &y);
d2tk_base_cursor(base, &D2TK_RECT(x, y, 24, 24));
d2tk_base_get_mouse_pos(base, &x, &y);
d2tk_base_cursor(base, &D2TK_RECT(x, y, 24, 24));
}
return EXIT_SUCCESS;
}
......@@ -153,7 +157,7 @@ main(int argc, char **argv)
static char fb_device [PATH_MAX] = AUTO;
int c;
while( (c = getopt(argc, argv, "f:")) != -1)
while( (c = getopt(argc, argv, "f:c")) != -1)
{
switch(c)
{
......@@ -161,11 +165,16 @@ main(int argc, char **argv)
{
strncpy(fb_device, optarg, PATH_MAX-1);
} break;
case 'c':
{
app.show_cursor = true;
} break;
default:
{
fprintf(stderr, "Usage: %s\n"
" -f fb_device (auto)\n\n",
" -f fb_device (auto)\n"
" -c show cursor\n\n",
argv[0]);
} return EXIT_FAILURE;
}
......
This diff is collapsed.
linenoise_example
*.dSYM
history.txt
Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
linenoise_example: linenoise.h linenoise.c
linenoise_example: linenoise.c example.c
$(CC) -Wall -W -Os -g -o linenoise_example linenoise.c example.c
clean:
rm -f linenoise_example
This diff is collapsed.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "linenoise.h"
void completion(const char *buf, linenoiseCompletions *lc) {
if (buf[0] == 'h') {
linenoiseAddCompletion(lc,"hello");
linenoiseAddCompletion(lc,"hello there");
}
}
char *hints(const char *buf, int *color, int *bold) {
if (!strcasecmp(buf,"hello")) {
*color = 35;
*bold = 0;
return " World";
}
return NULL;
}
int main(int argc, char **argv) {
char *line;
char *prgname = argv[0];
/* Parse options, with --multiline we enable multi line editing. */
while(argc > 1) {
argc--;
argv++;
if (!strcmp(*argv,"--multiline")) {
linenoiseSetMultiLine(1);
printf("Multi-line mode enabled.\n");
} else if (!strcmp(*argv,"--keycodes")) {
linenoisePrintKeyCodes();
exit(0);
} else {
fprintf(stderr, "Usage: %s [--multiline] [--keycodes]\n", prgname);
exit(1);
}
}
/* Set the completion callback. This will be called every time the
* user uses the <tab> key. */
linenoiseSetCompletionCallback(completion);
linenoiseSetHintsCallback(hints);
/* Load history from file. The history file is just a plain text file
* where entries are separated by newlines. */
linenoiseHistoryLoad("history.txt"); /* Load the history at startup */
/* Now this is the main loop of the typical linenoise-based application.
* The call to linenoise() will block as long as the user types something
* and presses enter.
*
* The typed string is returned as a malloc() allocated string by
* linenoise, so the user needs to free() it. */
while((line = linenoise("hello> ")) != NULL) {
/* Do something with the string. */
if (line[0] != '\0' && line[0] != '/') {
printf("echo: '%s'\n", line);
linenoiseHistoryAdd(line); /* Add to the history. */
linenoiseHistorySave("history.txt"); /* Save the history on disk. */
} else if (!strncmp(line,"/historylen",11)) {
/* The "/historylen" command will change the history len. */
int len = atoi(line+11);
linenoiseHistorySetMaxLen(len);
} else if (line[0] == '/') {
printf("Unreconized command: %s\n", line);
}
free(line);
}
return 0;
}
This diff is collapsed.
/* linenoise.h -- VERSION 1.0
*
* Guerrilla line editing library against the idea that a line editing lib
* needs to be 20,000 lines of C code.
*
* See linenoise.c for more information.
*
* ------------------------------------------------------------------------
*
* Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
* Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __LINENOISE_H
#define __LINENOISE_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct linenoiseCompletions {
size_t len;
char **cvec;
} linenoiseCompletions;
typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
typedef char*(linenoiseHintsCallback)(const char *, int *color, int *bold);
typedef void(linenoiseFreeHintsCallback)(void *);
void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
void linenoiseSetHintsCallback(linenoiseHintsCallback *);
void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);
void linenoiseAddCompletion(linenoiseCompletions *, const char *);
char *linenoise(const char *prompt);
void linenoiseFree(void *ptr);
int linenoiseHistoryAdd(const char *line);
int linenoiseHistorySetMaxLen(int len);
int linenoiseHistorySave(const char *filename);
int linenoiseHistoryLoad(const char *filename);
void linenoiseClearScreen(void);
void linenoiseSetMultiLine(int ml);
void linenoisePrintKeyCodes(void);
#ifdef __cplusplus
}
#endif
#endif /* __LINENOISE_H */
This diff is collapsed.
option('build-debug', type : 'boolean', value : false)
option('build-debug-overlay',
type : 'boolean',
value : false,
yield : true)
option('build-examples',
type : 'boolean',
value : false,
yield : true)
option('build-tests',
type : 'boolean',
value : true,
yield : true)
option('use-backend-cairo',
type : 'feature',
value : 'disabled',
yield : true)
option('use-backend-nanovg',
type : 'feature',
value : 'disabled',
yield : true)
option('use-frontend-fbdev',
type : 'feature',
value : 'disabled',
yield : true)
option('use-frontend-pugl',
type : 'feature',
value : 'disabled',
yield : true)
option('use-vterm',
type : 'feature',
value : 'disabled',
yield : true)
option('use-evdev',
type : 'feature',
value : 'disabled',
yield : true)
option('use-fontconfig',
type : 'feature',
value : 'disabled',
yield : true)
......@@ -576,13 +576,12 @@ d2tk_cairo_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
if(!*sprite)
{
char *ft_path = NULL;
assert(asprintf(&ft_path, "%s%s", backend->bundle_path, body->face) != -1);
assert(ft_path);
char ft_path [1024];
d2tk_core_get_font_path(core, backend->bundle_path, body->face,
sizeof(ft_path), ft_path);
FT_Face ft_face = NULL;
FT_New_Face(backend->library, ft_path, 0, &ft_face);
free(ft_path);
assert(ft_face);
cairo_font_face_t *face = cairo_ft_font_face_create_for_ft_face(ft_face, 0);
......@@ -610,7 +609,6 @@ d2tk_cairo_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
cairo_text_extents_t extents;
cairo_text_extents(ctx, body->text, &extents);
int32_t x = -extents.x_bearing;
int32_t y = -extents.y_bearing;
if(body->align & D2TK_ALIGN_LEFT)
{
......@@ -627,19 +625,21 @@ d2tk_cairo_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
x -= extents.width;
}
cairo_font_extents_t font_extents;
cairo_font_extents(ctx, &font_extents);
double y = 0;
if(body->align & D2TK_ALIGN_TOP)
{
y += body->y;
y += body->y + font_extents.ascent;
}
else if(body->align & D2TK_ALIGN_MIDDLE)
{
y += body->y + body->h / 2;
y -= extents.height / 2;
y += body->y + body->h / 2 + font_extents.descent;
}
else if(body->align & D2TK_ALIGN_BOTTOM)
{
y += body->y + body->h;
y -= extents.height;
}
cairo_move_to(ctx, x + xo, y + yo);
......
......@@ -657,12 +657,11 @@ d2tk_nanovg_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
if(!*sprite)
{
char *ft_path = NULL;
assert(asprintf(&ft_path, "%s%s", backend->bundle_path, body->face) != -1);
assert(ft_path);
char ft_path [1024];
d2tk_core_get_font_path(core, backend->bundle_path, body->face,
sizeof(ft_path), ft_path);
const int face = nvgCreateFont(ctx, body->face, ft_path);
free(ft_path);
assert(face != -1);
*sprite = (uintptr_t)face;
......
......@@ -128,6 +128,12 @@ _d2tk_base_get_atom(d2tk_base_t *base, d2tk_id_t id, d2tk_atom_type_t type,
{
len = d2tk_atom_body_pty_sz;
} break;
#endif
#if D2TK_EVDEV
case D2TK_ATOM_VKB:
{
len = d2tk_atom_body_vkb_sz;
} break;
#endif
case D2TK_ATOM_FLOW_NODE:
// fall-through
......@@ -467,6 +473,15 @@ d2tk_base_is_active_hot(d2tk_base_t *base, d2tk_id_t id,
bool newfocus = curfocus;
const bool lastfocus = _d2tk_flip_equal_old(&base->focusitem, id);
// test for mouse up
if( is_active
&& !d2tk_base_get_butmask(base, D2TK_BUTMASK_LEFT, false) )
{
_d2tk_flip_clear(&base->activeitem);
is_active = false;
state |= D2TK_STATE_UP;
}
// handle forward focus
if(curfocus)
{
......@@ -505,11 +520,19 @@ d2tk_base_is_active_hot(d2tk_base_t *base, d2tk_id_t id,
}
}
if(d2tk_base_get_keymask(base, D2TK_KEYMASK_ENTER, false))
if(d2tk_base_get_keymask_up(base, D2TK_KEYMASK_ENTER))
{
is_active = false;
}
else if(d2tk_base_get_keymask_down(base, D2TK_KEYMASK_ENTER))
{
is_active = true;
state |= D2TK_STATE_ENTER;
}
else if(d2tk_base_get_keymask(base, D2TK_KEYMASK_ENTER, false))
{
is_active = true;
}
}
else if(!base->focused)
{
......@@ -518,15 +541,6 @@ d2tk_base_is_active_hot(d2tk_base_t *base, d2tk_id_t id,
base->focused = true; // set focused flag
}
// test for mouse up
if( is_active
&& !d2tk_base_get_butmask(base, D2TK_BUTMASK_LEFT, false) )
{
_d2tk_flip_clear(&base->activeitem);
is_active = false;
state |= D2TK_STATE_UP;
}
// test for mouse over
if(d2tk_base_is_hit(base, rect))
{
......@@ -644,11 +658,13 @@ d2tk_base_is_active_hot(d2tk_base_t *base, d2tk_id_t id,
#define light_orange 0xffcf00ff
#define dark_orange 0xcf9f00ff
#define FONT_SANS_BOLD "FiraSans:bold"
D2TK_API const d2tk_style_t *
d2tk_base_get_default_style()
{
static const d2tk_style_t style = {
.font_face = "FiraSans-Bold.ttf",
.font_face = FONT_SANS_BOLD,
.border_width = 1,
.padding = 1,
.rounding = 4,
......@@ -797,6 +813,9 @@ d2tk_base_post(d2tk_base_t *base)
base->focused = false;
}
base->mouse.mask_prev = base->mouse.mask;
base->keys.mask_prev = base->keys.mask;
_d2tk_base_clear_chars(base);
d2tk_core_post(base->core);
......@@ -918,6 +937,29 @@ d2tk_base_get_butmask(d2tk_base_t *base, d2tk_butmask_t mask, bool clear)
}
D2TK_API bool
d2tk_base_get_butmask_prev(d2tk_base_t *base, d2tk_butmask_t mask)
{
const bool old_state = (base->mouse.mask_prev & mask) == mask;
return old_state;
}
D2TK_API bool
d2tk_base_get_butmask_down(d2tk_base_t *base, d2tk_butmask_t mask)
{
return !d2tk_base_get_butmask_prev(base, mask)
&& d2tk_base_get_butmask(base, mask, false);
}
D2TK_API bool
d2tk_base_get_butmask_up(d2tk_base_t *base, d2tk_butmask_t mask)
{
return d2tk_base_get_butmask_prev(base, mask)
&& !d2tk_base_get_butmask(base, mask, false);
}
D2TK_API bool
d2tk_base_set_modmask(d2tk_base_t *base, d2tk_modmask_t mask, bool down)
{
......@@ -980,6 +1022,28 @@ d2tk_base_get_keymask(d2tk_base_t *base, d2tk_keymask_t mask, bool clear)
}
D2TK_API bool
d2tk_base_get_keymask_prev(d2tk_base_t *base, d2tk_keymask_t mask)
{