On 1 Feb 2013, at 21:54, Howard Rubin wrote:

> I'm adding a symbol to an Fl_Menu_Item on an Fl_Menu_Bar using 
> set_labeltype(). It's mostly working but when the menu is dropped down, 
> the symbol moves to the left by about 12 units. (BTW, this approach 
> solves the "Changing an Fl_Menu_Bar item colors" question)
> 
> Why does the symbol move and how can I keep it from moving?

I'm not entirely sure *why* it is happening, but it is pretty easy to see 
*what* is happening...

If you modify menu_label as follows...

void menu_label(const Fl_Label* o, int X, int Y, int W, int H, Fl_Align a) {
    fl_normal_label(o, X, Y, W, H, a);
    // ***** Why does this move when the menu item is selected? *****

    // W = 63; // apply the sledgehammer fix...
    int xx = X + W - 12;
    int yy = Y + (H / 2);

    printf("pos (%d, %d) (X %d Y %d W %d H %d)\n", xx, yy, X, Y, W, H);

    fl_circle(xx, yy, 5);
}

Then at run time (on this Mac, numbers on other hosts might conceivably differ?)

For the "not selected" menu:

pos (60, 12) (X 9 Y 0 W 63 H 25)

For the "selected" menu:

pos (45, 9) (X 6 Y 0 W 51 H 19)


Now... I am not sure what I'm seeing there, but I speculate that the changes to 
X and H reflect the change in the size of the selection rectangle or something, 
they seem to be about 3 (or 6) pixels off the size of the no-selection case? 3 
pixels seems about right for the "inset" of the selection from the edges...

The kicker is the change in the W value - and I don't know what is happening 
there at all...

However, that is the key - note the commented out "sledgehammer fix" in the 
code fragment. With that enabled it all "works" just fine.

So; not a solution, but might be a hint where to look (or how to hack around 
it!)



_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to