FLTK logo

Re: [fltk.general] Re: FLUID: how can I have SVG icons embedded in the code?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Re: FLUID: how can I have SVG icons embedded in the code? Ian MacArthur 01:22 Apr 19  
 
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
  }
}

Function {} {open
} {
  code {Fl_SVG_Image *svg2 = new Fl_SVG_Image(NULL, svg3, svg3_size);} {selected
  }
  code {svg_rsz *boxA = NULL;} {}
  Fl_Window main_win {open
    private xywh {882 285 249 221} type Double resizable
    code0 {boxA = new svg_rsz(svg2, 15, 15, 180, 180);} visible
  } {}
}


=======================


--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/ecc1164e-24e2-4aee-95a0-57eb869be396n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.