Re: Re: FLUID: how can I have SVG icons embedded in the code?
Ian MacArthur
Apr 19, 2024
On Friday 19 April 2024 at 09:01:01 UTC+1 Ian MacArthur wrote:
On Thursday 18 April 2024 at 21:09:51 UTC+1
Gonzalo wrote:
Ian MacArthur schrieb am Donnerstag, 18. April
2024 um 13:52:14 UTC+2:
BUT: It doesn't rescale when I resize the widget. So I
guess I do still need a resize() method to handle that
still?
I tried it and it works, but on Windows, with a certain .svg I got:
D:\a\mrv2\mrv2\BUILD-Msys-amd64\Release\mrv2\src\mrv2-build\lib\mrvWidgets\mrViewer.cxx(1529): error C2026: string too big, trailing characters truncated
I am attaching the .svg that I think is the issue.
Hmm, just dropped that SVG file into my little fluid test, and it seems to work OK. Is it possibly a different image that is causing the issue?
(I got a grey image showing a white outline, with a drop-shadow, of a stylised hand wiping a cloth over the surface; which seems like a credible image for a "scrub" icon, so I assume that is working OK.)
So, as a possible workaround, I tried storing the SVG file in "compressed" form in fluid, as Matt had suggested. That certainly makes it small enough (down from approx. 20K text to approx. 7K) but I can't then seem to get Fl_SVG_Image to load it, so... One for Matt maybe? As I am out of ideas now:
Here's the adapted fluid file, test2.fl:
=========== test2.fl ============
# data file for the Fltk User Interface Designer (fluid) version 1.0400 header_name {.h} code_name {.cxx} decl {\#include <FL/Fl_SVG_Image.H>} {public global }
decl {\#include <FL/Fl_Box.H>} {public global }
data svg3 {private local filename {Scrub.svg} compressed }
class svg_rsz {open : {public Fl_Box} } { Function {svg_rsz(Fl_SVG_Image *svg2, int X, int Y, int W, int H, const char* L=0) : Fl_Box(X,Y,W,H,L)} { comment Constructor open } { code {svg = svg2; svg->resize(w(),h()); image(svg);} {} } Function {resize(int x, int y, int w, int h)} { comment {A resize method} open return_type void } { code {Fl_Box::resize(x,y,w,h); svg->resize(this->w(),this->h());} {} } decl {Fl_SVG_Image *svg;} {private local } }
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.