Skip to content

Commit

Permalink
More autodoc stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Mar 12, 2024
1 parent d2f071a commit c000a32
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 18 deletions.
4 changes: 4 additions & 0 deletions FL/Fl_Menu_Item.H
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ struct FL_EXPORT Fl_Menu_Item {
const Fl_Menu_Item* test_shortcut() const;
const Fl_Menu_Item* find_shortcut(int *ip=0, const bool require_alt = false) const;

Fl_Window *build_menu_window(const Fl_Menu_Item* m, int X, int Y, int W, int H,
const Fl_Menu_Item* picked, const Fl_Menu_Item* title,
int menubar = 0, int menubar_title = 0, int right_edge = 0);

/**
Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument.
The callback is called with the stored user_data() as its second argument.
Expand Down
2 changes: 1 addition & 1 deletion FL/Fl_Window.H
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private:
Fl_Window(const Fl_Window&);
Fl_Window& operator=(const Fl_Window&);

protected:
public:

/** Stores the last window that was made current. See current() const */
static Fl_Window *current_;
Expand Down
34 changes: 23 additions & 11 deletions FL/fl_snapshot.H
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Widget *w, int frame=2
// 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) {
FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Menu_Item *menu, Fl_Menu_Item *m1, Fl_Menu_Item *m2, int fh=20, int fv=20, 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;
int m1i = -1, m2i = -1;
Expand All @@ -163,6 +168,7 @@ FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Menu_Item *menu, Fl_Me
for (; m->text; m = m->next()) {
if (m == m1) m1i = n_visible;
if (m == m2) m2i = n_visible;
if (m > m2) break;
if (m->visible()) {
m->measure(img_w, item_h, hotkey_mod_w, hotkey_w, NULL);
n_visible++;
Expand All @@ -176,21 +182,27 @@ FL_EXPORT inline int fl_snapshot(const char *filename, Fl_Menu_Item *menu, Fl_Me
img_h = item_h * n_visible + 8;

// Generate the Image Surface
Fl_Image_Surface *srfc = new Fl_Image_Surface(img_w, max_y-min_y);
Fl_Image_Surface *srfc = new Fl_Image_Surface(img_w + 2*fh, max_y-min_y+2*fv);
Fl_Image_Surface::push_current(srfc);

// Draw the background
fl_rectf(0, 0, img_w, img_h, 0x1395bf00);
fl_draw_box(FL_UP_BOX, 0, -min_y, img_w, img_h, FL_BACKGROUND_COLOR);
fl_rectf(0, 0, img_w+2*fh, img_h+2*fv, 0x1395bf00);
// FIXME: the box position and height depends on menus that may exist above and below m1 and m2
fl_draw_box(FL_UP_BOX, fh, fv-min_y-Fl::box_dy(FL_UP_BOX), img_w, img_h, FL_BACKGROUND_COLOR);

Fl_Window *mw = menu->build_menu_window(menu, 10, 10, 100, 1024, NULL, NULL);
mw->draw();


// Draw the menu items
m = menu;
int yy = 4 - min_y;
for (; m->text; m = m->next()) {
if (!m->visible()) continue;
m->draw(4, yy+2, img_w-8, item_h-4, hotkey_w, 3, NULL);
yy += item_h;
}
// m = menu;
// int yy = min_y;
// for (; m->text; m = m->next()) {
// if (m->visible()) {
// m->draw(fh+4, fv+yy+2, img_w-8, item_h-4, hotkey_w, 4, NULL);
// yy += item_h;
// }
// }
Fl_Image_Surface::pop_current();
Fl_RGB_Image *img = srfc->image();

Expand Down
10 changes: 7 additions & 3 deletions fluid/fluid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2144,9 +2144,13 @@ 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, 10, 10, 20, 4.0);
// fl_snapshot("/Users/matt/test.png", Main_Menu+1, Main_Menu+3, NULL);
// fl_snapshot("/Users/matt/test.png", the_panel);
// fl_snapshot("/Users/matt/test.png", widget_x_input, widget_h_input, 70, 12, 10, 10, 20, 2.0);
// fl_snapshot("/Users/matt/test.png", Main_Menu+1, Main_Menu+1, Main_Menu+4, 10, 10, 20, 2.0);
Fl_Menu_Item *mi1 = (Fl_Menu_Item*)main_menubar->find_item("&Layout/&Align");
Fl_Menu_Item *mi2 = (Fl_Menu_Item*)main_menubar->find_item("&Layout/Presets");
fl_snapshot("/Users/matt/test.png", mi1, mi1, mi2, 10, 10, 20, 2.0);
// fl_snapshot("/Users/matt/test.png", New_Menu+1, New_Menu+1, New_Menu+4, 10, 10, 20, 2.0);

fl_open_uri("file:///Users/matt/test.png");
return 0;
Expand Down
29 changes: 26 additions & 3 deletions src/Fl_Menu.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, int shortcut_width, int fram
int x1 = x + w - sz - 2;
int y1 = y + (h-sz)/2 + 1;

// draw an arrow whose style dependends on the active scheme
// draw an arrow whose style dependents on the active scheme
fl_draw_arrow(Fl_Rect(x1, y1, sz, sz), FL_ARROW_SINGLE, FL_ORIENT_RIGHT, fl_color());

} else if (shortcut_) {
Expand All @@ -413,10 +413,26 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, int shortcut_width, int fram
}

if (flags & FL_MENU_DIVIDER) {
#if 0
// int BW = Fl::box_dx(box());
// int xx = BW;
// int W = w();
// int ww = W-2*BW-1;
// int yy = BW+1+n*itemheight+Fl::menu_linespacing()/2-2;
// int hh = itemheight - Fl::menu_linespacing();

fl_color(FL_DARK3);
fl_xyline(BW-1, yy+hh+(Fl::menu_linespacing()-2)/2, W-2*BW+2);
fl_color(FL_LIGHT3);
fl_xyline(BW-1, yy+hh+((Fl::menu_linespacing()-2)/2+1), W-2*BW+2);
#else
int dx1 = frame_width-1;// +x-frame_width;
int dx2 = w-2*frame_width+2; //
fl_color(FL_DARK3);
fl_xyline(frame_width-1, y+h+(Fl::menu_linespacing()-2)/2, w+2*frame_width-1);
fl_xyline(dx1, y+h+(Fl::menu_linespacing()-2)/2, dx2);
fl_color(FL_LIGHT3);
fl_xyline(frame_width-1, y+h+((Fl::menu_linespacing()-2)/2+1), w+2*frame_width-1);
fl_xyline(dx1, y+h+((Fl::menu_linespacing()-2)/2+1), dx2);
#endif
}
}

Expand Down Expand Up @@ -1132,6 +1148,13 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
return m;
}

Fl_Window *Fl_Menu_Item::build_menu_window(const Fl_Menu_Item* m, int X, int Y, int W, int H,
const Fl_Menu_Item* picked, const Fl_Menu_Item* title,
int menubar, int menubar_title, int right_edge)
{
return new menuwindow(m, X, Y, W, H, picked, title, menubar, menubar_title, right_edge);
}

/**
This method is called by widgets that want to display menus.
Expand Down

0 comments on commit c000a32

Please sign in to comment.