Skip to content

Commit

Permalink
A bit more docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Aug 4, 2023
1 parent f7de488 commit d2f071a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
43 changes: 21 additions & 22 deletions FL/fl_snapshot.H
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Widget screenshot header-only file for the Fast Light Tool Kit (FLTK).
// Widget snapshot header-only file for the Fast Light Tool Kit (FLTK).
//
// Copyright 2023 by Bill Spitzak and others.
//
Expand All @@ -15,8 +15,8 @@
//

/**
\file fl_screenshot.H
\brief header-only file to make screen shots of UI elements for documentation
\file fl_snapshot.H
\brief header-only file to take snapshots of UI elements for documentation purposes
*/

#ifndef fl_screenshot_H
Expand All @@ -31,28 +31,29 @@
@{
*/

//FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget *w, int frame=0, int alphaframe=0, double scale=1.0)
//FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget **w, int frame=0, int alphaframe=0, double scale=1.0)
//FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget *w, int frame=0, double scale=1.0) {

static inline int fl_min(int a, int b) { return a < b ? a : b; }
static inline int fl_max(int a, int b) { return a > b ? a : b; }

/**
Take a snapshot of a given widget and save it as a png image.
If a frame size is set, the area surrunding the widget is also drawn.
If a scale is set, the snapshot is scaled in scaled in size before it is saved.
If a frame size is set, the area surrounding the widget is also drawn.
If a scale is set, the snapshot is scaled in size before it is saved.
\param[in] filename the snapshot will be written in png format to this file
\param[in] w draw this widget
\param[in] frame draw a half transparent frame around the snapshot, defaults to 0
\param[in] scale scale the snapshot in size before saving it
\note if a widget has an outside label, we must snap that as well
\note we must allow snapping of menu items
\todo w is a list of widgets here!
\todo if a widget has an outside label, we must snap that as well
\todo how does scaling work for hires displays?
\todo put reoccuring parameters, alpha blend, frame sizes, etc. into global variables
*/

//FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget *w, int frame=0, int alphaframe=0, double scale=1.0)
//FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget **w, int frame=0, int alphaframe=0, double scale=1.0)
//FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget *w, int frame=0, double scale=1.0) {

static inline int fl_min(int a, int b) { return a < b ? a : b; }
static inline int fl_max(int a, int b) { return a > b ? a : b; }

FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget **w, int fx, int fy, int fr, int fb, int alpha=10, double scale=1.0) {
int i, j, c, min_x, min_y, max_x, max_y, bb_w, bb_h, img_w, img_h;

Expand Down Expand Up @@ -135,19 +136,21 @@ FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget **w, int fx, in
return ret;
}

// todo: document me
FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget *w1, Fl_Widget *w2, int fx=4, int fy=4, int fr=4, int fb=4, int alpha=8, double scale=1.0) {
Fl_Widget *ww[3] = { w1, w2, NULL };
return fl_snapshot(filename, ww, fx, fy, fr, fb, alpha, scale);
}

// todo: document me
FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget *w, int frame=20, int alpha=10, double scale=1.0) {
Fl_Widget *ww[2] = { w, NULL };
return fl_snapshot(filename, ww, frame, frame, frame, frame, alpha, scale);
}




// todo: verify me
// todo: calculate only the bounding box of the item range
// todo: document me
FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Menu_Item *menu, Fl_Menu_Item *m1, Fl_Menu_Item *m2, int fh=0, int fv=10, int alpha=10, double scale=1.0) {
int i, j, c, min_x, min_y, max_x, max_y, bb_w, bb_h, img_w = 0, img_h, item_h = 0, n_visible = 0;
int hotkey_w = 0, hotkey_mod_w = 0;
Expand Down Expand Up @@ -240,10 +243,6 @@ FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Menu_Item *menu, Fl_Me
}






/** @} */

#endif
2 changes: 1 addition & 1 deletion fluid/fluid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ int main(int argc,char **argv) {
the_panel = make_widget_panel();
// fl_snapshot("/Users/matt/test.png", widget_browser, 20);
// fl_snapshot("/Users/matt/test.png", wCallback);
fl_snapshot("/Users/matt/test.png", widget_x_input, widget_h_input, 70, 12, 4, 4, 8, 1.0);
fl_snapshot("/Users/matt/test.png", widget_x_input, widget_h_input, 70, 12, 10, 10, 20, 4.0);
// fl_snapshot("/Users/matt/test.png", Main_Menu+1, Main_Menu+3, NULL);

fl_open_uri("file:///Users/matt/test.png");
Expand Down

0 comments on commit d2f071a

Please sign in to comment.