4 Commits
Author SHA1 Message Date
admin c764cc82da Merge pull request #79 from Alpaq92/version-0.7.1
Version 0.7.1
2026-10-20 11:27:55 +02:00
admin f44c48854e Merge pull request #78 from Alpaq92/chart-tips
Showcase anticlam's trend chart, with a tooltip on each hour
2026-10-20 11:27:41 +02:00
adminandClaude Opus 5.5 2b61f37f15 Version 0.7.1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 10:58:25 +02:00
adminandClaude Opus 5.5 d551aebcf0 Showcase anticlam's trend chart, with a tooltip on each hour
reaktor_tip(app, rect, text) is a tooltip over a rectangle the caller drew,
in the .tooltip style, and makes it a hot rectangle so hover redraws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 10:58:09 +02:00
6 changed files with 80 additions and 2 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(reaktor VERSION 0.7.0 LANGUAGES C CXX)
project(reaktor VERSION 0.7.1 LANGUAGES C CXX)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(_reaktor_top ON)
+1
View File
@@ -129,6 +129,7 @@ struct App {
int want_cursor, cur_shown;
const char *tip;
char tip_text[256];
char render_mode[32];
int vsync_on, aa_mode, redraw_always;
+14
View File
@@ -383,6 +383,20 @@ decl_tip_at(const char *tip, struct nk_rect r, int cursor)
g_frame_app->tip = tip;
}
void
reaktor_tip(App *app, struct nk_rect r, const char *text)
{
struct nk_context *ctx = app ? app->ctx : NULL;
if (!text || !ctx || !ctx->current) return;
reaktor_hot_follow(app, r, 0);
if (nk_input_is_mouse_hovering_rect(&ctx->input, r) &&
nk_input_is_mouse_hovering_rect(&ctx->input, ctx->current->layout->clip)) {
SDL_strlcpy(app->tip_text, text, sizeof app->tip_text);
app->tip = app->tip_text;
}
}
void
reaktor_tip_draw(App *app, struct nk_context *ctx, struct nk_command_buffer *cv)
{
+2 -1
View File
@@ -73,7 +73,7 @@ errors, so an internal function cannot slip back in.
| `reaktor_lang_pref(app)` | The language `--lang` asked for, or `NULL` |
| `reaktor_set_borderless(app, on)`, `reaktor_borderless(app)` | Switch the main window's frame off for a titlebar of your own, drawn with `.window.hit_test` |
| `reaktor_set_visible(app, on)` | Show or hide that App's window; with `.window.hidden`, the main window waits for it |
| `reaktor_version()` | Reaktor's version, such as `"0.7.0"` |
| `reaktor_version()` | Reaktor's version, such as `"0.7.1"` |
The `set` calls are for the main thread, take effect at the next frame, and do
nothing when nothing changes.
@@ -820,6 +820,7 @@ out by hand inside a declared page. [`include/reaktor/ui.h`](../include/reaktor/
| `reaktor_style_frame`, `reaktor_style_frame_pop` | Counts of style pushes, popped together |
| `reaktor_fill_round`, `reaktor_edge_round` | Rounded fills and borders, smooth on the software renderer |
| `reaktor_hot`, `reaktor_hot_top`, `reaktor_hot_follow` | A rectangle that redraws on hover ([the frame loop](#the-frame-loop)), with a `REAKTOR_CURSOR_*` over it: default, pointer, text, or a horizontal or vertical resize |
| `reaktor_tip(app, rect, text)` | A tooltip over a rectangle you drew yourself, such as a bar of a chart; the text is copied, and the rectangle redraws as the pointer crosses it |
| `reaktor_button_label`, `reaktor_button_icon`, `reaktor_button_accent`, `reaktor_field_text`, `reaktor_slider_bar`, `reaktor_progress_bar`, `reaktor_chevron_at` | Styled controls inside hand-laid rows |
| `reaktor_menu_item`, `reaktor_menu_style_push`, `_pop`, `reaktor_menu_height`, `reaktor_menu_edge`, `reaktor_popup_rounding` | Menus and popups |
| `reaktor_note`, `_push`, `_pop`, `_here`, `_keys`, `_value`, `_bounds`, `reaktor_focus_activated` | The accessibility tree, and keyboard presses |
+1
View File
@@ -62,6 +62,7 @@ struct reaktor_color reaktor_on(struct reaktor_color bg);
void reaktor_hot(App *app, struct reaktor_rect r, int cursor, int repaint);
void reaktor_hot_top(App *app, struct reaktor_rect r, int cursor, int repaint);
void reaktor_hot_follow(App *app, struct reaktor_rect r, int cursor);
void reaktor_tip(App *app, struct reaktor_rect r, const char *text);
int reaktor_button_label(App *app, struct reaktor_context *ctx,
const char *label);
+61
View File
@@ -10,6 +10,64 @@ static const char *const g_grid[7][3] = {
{ "Aileron", "CC0", "the typeface" }
};
/* Example figures: scans and threats per hour over a day. */
static const int g_scans[24] = { 0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 0, 0,
9, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2 };
static const int g_threats[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static void
section_trend(App *app, struct reaktor_context *ctx)
{
struct reaktor_color scan_c = reaktor_token("--links", reaktor_rgb(0, 118, 209));
struct reaktor_color threat_c = reaktor_rgb(229, 72, 77);
struct reaktor_color axis = reaktor_token("--text-muted", reaktor_rgb(112, 119, 127));
struct reaktor_command_buffer *cv;
struct reaktor_rect b;
char tip[64];
int i, max = 1;
float slot, bw;
reaktor_layout_row_dynamic(ctx, 18.0f, 4);
reaktor_label_colored(ctx, "Scans", REAKTOR_TEXT_LEFT, scan_c);
reaktor_label_colored(ctx, "Threats", REAKTOR_TEXT_LEFT, threat_c);
reaktor_spacer(ctx);
reaktor_spacer(ctx);
reaktor_layout_row_dynamic(ctx, 150.0f, 1);
b = reaktor_widget_bounds(ctx);
reaktor_spacer(ctx);
cv = reaktor_window_get_canvas(ctx);
reaktor_fill_rect(cv, reaktor_rect(b.x, b.y + b.h - 1.0f, b.w, 1.0f), 0.0f, axis);
for (i = 0; i < 24; i++) {
if (g_scans[i] > max) max = g_scans[i];
if (g_threats[i] > max) max = g_threats[i];
}
slot = b.w / 24.0f;
bw = slot * 0.35f;
if (bw > 14.0f) bw = 14.0f;
for (i = 0; i < 24; i++) {
float x = b.x + slot * (float)i + (slot - 2.0f * bw - 2.0f) * 0.5f;
float hs = (b.h - 6.0f) * (float)g_scans[i] / (float)max;
float ht = (b.h - 6.0f) * (float)g_threats[i] / (float)max;
if (hs > 0.0f)
reaktor_fill_round(app, cv, reaktor_rect(x, b.y + b.h - 1.0f - hs, bw, hs), 2.0f,
scan_c);
if (ht > 0.0f)
reaktor_fill_round(app, cv,
reaktor_rect(x + bw + 2.0f, b.y + b.h - 1.0f - ht, bw, ht),
2.0f, threat_c);
if (!g_scans[i] && !g_threats[i]) continue;
SDL_snprintf(tip, sizeof tip, "%02d:00 %d scan%s, %d threat%s", i,
g_scans[i], g_scans[i] == 1 ? "" : "s",
g_threats[i], g_threats[i] == 1 ? "" : "s");
reaktor_tip(app, reaktor_rect(b.x + slot * (float)i, b.y, slot, b.h), tip);
}
reaktor_layout_row_dynamic(ctx, 18.0f, 1);
reaktor_label_colored(ctx, "Per hour, oldest on the left", REAKTOR_TEXT_LEFT, axis);
}
static const char *
grid_cell(int row, int column, void *user)
{
@@ -225,6 +283,9 @@ page_display(App *app, struct reaktor_context *ctx, showcase_state *s)
reaktor_layout_row_dynamic(ctx, 70.0f, 1);
reaktor_plot(ctx, REAKTOR_CHART_LINES, s->series, SC_SERIES_N, 0);
api(app, ctx, "reaktor_fill_round / reaktor_tip(app, rect, text)");
section_trend(app, ctx);
section(app, ctx, "Progress and rules",
"A fixed progress bar reports; reaktor_rule_horizontal is the "
"separator every page on this tab is divided by, and takes its "