mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 22:04:26 +08:00
* Replace hand rolles symbol hashing with C++11 code * Update symbol drawing functions, add fl_remove_symbol() * Refactored some of fl_draw_symbol. * Using clang format for symbol code and test * Circumvent Doxygen bug https://github.com/doxygen/doxygen/issues/11190 Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Albrecht Schlosser <albrechts.fltk@online.de>
This commit is contained in:
+19
-3
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# clang-format control file for the FLTK project.
|
||||
#
|
||||
# Copyright 2017-2022 by Bill Spitzak and others.
|
||||
# Copyright 2017-2026 by Bill Spitzak and others.
|
||||
#
|
||||
# This library is free software. Distribution and use rights are outlined in
|
||||
# the file "COPYING" which should have been included with this file. If this
|
||||
@@ -112,7 +112,9 @@ SortIncludes: false
|
||||
# Multiple constructor initializers must be on consecutive lines.
|
||||
# Note: this is NOT (always) true in current FLTK code!
|
||||
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
# or: BeforeColon, BeforeComma, AfterColon, AfterComma
|
||||
# was: BreakConstructorInitializersBeforeComma: true
|
||||
|
||||
# Constructor initializers will be indented by 2 spaces.
|
||||
# LLVM default: 4
|
||||
@@ -125,6 +127,20 @@ ConstructorInitializerIndentWidth: 2
|
||||
# LLVM default: 4
|
||||
# ContinuationIndentWidth: 2
|
||||
|
||||
# If a control statement (if-clause, etc.) spans multiple lines, the opening
|
||||
# brace can get visibly lost and it is hard to see when the condition ends and
|
||||
# the statements start. MultiLine puts the brace on the next line in this case.
|
||||
#
|
||||
# AfterFunction: true would be a change in style and is up for debate.
|
||||
# I like it because it separates the declaration from the body. I wish there
|
||||
# was a MultiLine option here as well.
|
||||
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterControlStatement: MultiLine
|
||||
AfterFunction: true
|
||||
SplitEmptyFunction: false
|
||||
|
||||
# Most of FLTK's code uses 'void *p' as opposed to 'void* p'.
|
||||
# This is particularly useful in combined declarations like:
|
||||
# int var, var2, *pv, **pp;
|
||||
@@ -136,4 +152,4 @@ ConstructorInitializerIndentWidth: 2
|
||||
# in function parameter lists.
|
||||
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Right
|
||||
PointerAlignment: Left
|
||||
|
||||
+5
-3
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Portable drawing function header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2025 by Bill Spitzak and others.
|
||||
// Copyright 1998-2026 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@@ -1251,9 +1251,11 @@ FL_EXPORT void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Wi
|
||||
FL_EXPORT void fl_reset_spot(void);
|
||||
|
||||
|
||||
// XForms symbols:
|
||||
// Symbols (originally from XForms):
|
||||
FL_EXPORT int fl_draw_symbol(const char *label, int x, int y, int w, int h, Fl_Color);
|
||||
FL_EXPORT int fl_add_symbol(const char *name, void (*drawit)(Fl_Color), int scalable);
|
||||
FL_EXPORT int fl_add_symbol(const char *name, void (*drawit)(Fl_Color c), int scalable);
|
||||
FL_EXPORT int fl_add_symbol(const char *name, void (*draw_in_rect)(int x, int y, int w, int h, Fl_Color c), int scalable);
|
||||
FL_EXPORT int fl_remove_symbol(const char *name);
|
||||
/** @} */
|
||||
|
||||
#endif
|
||||
|
||||
+1
Submodule fluid/.claude/worktrees/naughty-blackburn-008169 added at d2ed9a50cc
+785
-375
File diff suppressed because it is too large
Load Diff
+84
-75
@@ -30,29 +30,38 @@ int N = 0;
|
||||
#define ROWS 6
|
||||
#define COLS 7
|
||||
|
||||
Fl_Double_Window *window;
|
||||
Fl_Value_Slider *orientation;
|
||||
Fl_Value_Slider *size;
|
||||
Fl_Double_Window* window;
|
||||
Fl_Value_Slider* orientation;
|
||||
Fl_Value_Slider* size;
|
||||
|
||||
void slider_cb(Fl_Widget *, void *) {
|
||||
void slider_cb(Fl_Widget*, void*)
|
||||
{
|
||||
static char buf[80];
|
||||
int val = (int)orientation->value();
|
||||
int sze = (int)size->value();
|
||||
for (int i = window->children(); i--; ) { // all window children
|
||||
Fl_Widget *wc = window->child(i);
|
||||
const char *l = (const char *)(wc->user_data());
|
||||
if ( l && *l == '@' ) { // all children with '@'
|
||||
l ++;
|
||||
if ( wc->box() == FL_NO_BOX ) { // ascii legend?
|
||||
if (val&&sze) snprintf(buf, sizeof(buf), "@@%+d%d%s", sze, val, l);
|
||||
else if (val) snprintf(buf, sizeof(buf), "@@%d%s", val, l);
|
||||
else if (sze) snprintf(buf, sizeof(buf), "@@%+d%s", sze, l);
|
||||
else snprintf(buf, sizeof(buf), "@@%s", l);
|
||||
} else { // box with symbol
|
||||
if (val&&sze) snprintf(buf, sizeof(buf), "@%+d%d%s", sze, val, l);
|
||||
else if (val) snprintf(buf, sizeof(buf), "@%d%s", val, l);
|
||||
else if (sze) snprintf(buf, sizeof(buf), "@%+d%s", sze, l);
|
||||
else snprintf(buf, sizeof(buf), "@%s", l);
|
||||
for (int i = window->children(); i--;) { // all window children
|
||||
Fl_Widget* wc = window->child(i);
|
||||
const char* l = (const char*)(wc->user_data());
|
||||
if (l && *l == '@') { // all children with '@'
|
||||
l++;
|
||||
if (wc->box() == FL_NO_BOX) { // ascii legend?
|
||||
if (val && sze)
|
||||
snprintf(buf, sizeof(buf), "@@%+d%d%s", sze, val, l);
|
||||
else if (val)
|
||||
snprintf(buf, sizeof(buf), "@@%d%s", val, l);
|
||||
else if (sze)
|
||||
snprintf(buf, sizeof(buf), "@@%+d%s", sze, l);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "@@%s", l);
|
||||
} else { // box with symbol
|
||||
if (val && sze)
|
||||
snprintf(buf, sizeof(buf), "@%+d%d%s", sze, val, l);
|
||||
else if (val)
|
||||
snprintf(buf, sizeof(buf), "@%d%s", val, l);
|
||||
else if (sze)
|
||||
snprintf(buf, sizeof(buf), "@%+d%s", sze, l);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "@%s", l);
|
||||
}
|
||||
wc->copy_label(buf);
|
||||
}
|
||||
@@ -60,80 +69,80 @@ void slider_cb(Fl_Widget *, void *) {
|
||||
window->redraw();
|
||||
}
|
||||
|
||||
void bt(const char *name) {
|
||||
int x = N%COLS;
|
||||
int y = N/COLS;
|
||||
void bt(const char* name)
|
||||
{
|
||||
int x = N % COLS;
|
||||
int y = N / COLS;
|
||||
char buf[255];
|
||||
N++;
|
||||
x = x*W+10;
|
||||
y = y*H+10;
|
||||
x = x * W + 10;
|
||||
y = y * H + 10;
|
||||
snprintf(buf, sizeof(buf), "@%s", name);
|
||||
Fl_Box *a = new Fl_Box(x,y,W-20,H-20);
|
||||
Fl_Box* a = new Fl_Box(x, y, W - 20, H - 20);
|
||||
a->box(FL_NO_BOX);
|
||||
a->copy_label(buf);
|
||||
a->align(FL_ALIGN_BOTTOM);
|
||||
a->labelsize(11);
|
||||
a->user_data((void *)name);
|
||||
Fl_Box *b = new Fl_Box(x,y,W-20,H-20);
|
||||
a->user_data((void*)name);
|
||||
Fl_Box* b = new Fl_Box(x, y, W - 20, H - 20);
|
||||
b->box(FL_UP_BOX);
|
||||
b->copy_label(name);
|
||||
b->labelcolor(FL_DARK3);
|
||||
b->user_data((void *)name);
|
||||
b->user_data((void*)name);
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
window = new Fl_Double_Window(COLS*W,ROWS*H+60);
|
||||
bt("@->");
|
||||
bt("@>");
|
||||
bt("@>>");
|
||||
bt("@>|");
|
||||
bt("@>[]");
|
||||
bt("@|>");
|
||||
bt("@<-");
|
||||
bt("@<");
|
||||
bt("@<<");
|
||||
bt("@|<");
|
||||
bt("@[]<");
|
||||
bt("@<|");
|
||||
bt("@<->");
|
||||
bt("@-->");
|
||||
bt("@+");
|
||||
bt("@->|");
|
||||
bt("@||");
|
||||
bt("@arrow");
|
||||
bt("@returnarrow");
|
||||
bt("@square");
|
||||
bt("@circle");
|
||||
bt("@line");
|
||||
bt("@menu");
|
||||
bt("@UpArrow");
|
||||
bt("@DnArrow");
|
||||
bt("@search");
|
||||
bt("@FLTK");
|
||||
bt("@filenew");
|
||||
bt("@fileopen");
|
||||
bt("@filesave");
|
||||
bt("@filesaveas");
|
||||
bt("@fileprint");
|
||||
bt("@refresh");
|
||||
bt("@reload");
|
||||
bt("@undo");
|
||||
bt("@redo");
|
||||
bt("@import");
|
||||
bt("@export");
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
window = new Fl_Double_Window(COLS * W, ROWS * H + 60);
|
||||
bt("@->");
|
||||
bt("@>");
|
||||
bt("@>>");
|
||||
bt("@>|");
|
||||
bt("@>[]");
|
||||
bt("@|>");
|
||||
bt("@<-");
|
||||
bt("@<");
|
||||
bt("@<<");
|
||||
bt("@|<");
|
||||
bt("@[]<");
|
||||
bt("@<|");
|
||||
bt("@<->");
|
||||
bt("@-->");
|
||||
bt("@+");
|
||||
bt("@->|");
|
||||
bt("@||");
|
||||
bt("@arrow");
|
||||
bt("@returnarrow");
|
||||
bt("@square");
|
||||
bt("@circle");
|
||||
bt("@line");
|
||||
bt("@menu");
|
||||
bt("@UpArrow");
|
||||
bt("@DnArrow");
|
||||
bt("@search");
|
||||
bt("@FLTK");
|
||||
bt("@filenew");
|
||||
bt("@fileopen");
|
||||
bt("@filesave");
|
||||
bt("@filesaveas");
|
||||
bt("@fileprint");
|
||||
bt("@refresh");
|
||||
bt("@reload");
|
||||
bt("@undo");
|
||||
bt("@redo");
|
||||
bt("@import");
|
||||
bt("@export");
|
||||
|
||||
orientation = new Fl_Value_Slider(
|
||||
(int)(window->w()*.05+.5), window->h()-40,
|
||||
(int)(window->w()*.42+.5), 16, "Orientation");
|
||||
orientation = new Fl_Value_Slider((int)(window->w() * .05 + .5), window->h() - 40,
|
||||
(int)(window->w() * .42 + .5), 16, "Orientation");
|
||||
orientation->type(FL_HORIZONTAL);
|
||||
orientation->range(0.0, 9.0);
|
||||
orientation->value(0.0);
|
||||
orientation->step(1);
|
||||
orientation->callback(slider_cb, 0);
|
||||
|
||||
size = new Fl_Value_Slider(
|
||||
(int)(window->w()*.53+.5), window->h()-40,
|
||||
(int)(window->w()*.42+.5), 16, "Size");
|
||||
size = new Fl_Value_Slider((int)(window->w() * .53 + .5), window->h() - 40,
|
||||
(int)(window->w() * .42 + .5), 16, "Size");
|
||||
size->type(FL_HORIZONTAL);
|
||||
size->range(-3.0, 9.0);
|
||||
size->value(0.0);
|
||||
@@ -141,6 +150,6 @@ bt("@export");
|
||||
size->callback(slider_cb, 0);
|
||||
|
||||
window->resizable(window);
|
||||
window->show(argc,argv);
|
||||
window->show(argc, argv);
|
||||
return Fl::run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user