>>
> Can you provide a small standalone, compilable program showing what you're doing?
Here you go:
#include "FL/Fl.H"
#include "FL/Fl_Tree.H"
#include "FL/Fl_Double_Window.H"
#include "FL/Fl_Button.H"
namespace mrv
{
class PlaylistClip : public Fl_Button
{
public:
PlaylistClip( int X, int Y, int W, int H, const char* L = 0 ) :
Fl_Button( X, Y, W, H, L )
{
box( FL_ENGRAVED_BOX );
color( FL_BLUE );
selection_color( FL_YELLOW );
align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE |
FL_ALIGN_IMAGE_NEXT_TO_TEXT );
labelsize( 12 );
}
void draw()
{
if ( value() ) labelcolor( FL_BLACK );
else labelcolor( FL_WHITE );
Fl_Color col = value() ? selection_color() : color();
draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(), col);
draw_backdrop();
draw_label();
}
int handle( int e )
{
Fl_Button::handle( e );
return 0;
}
inline void drawAt( int X, int Y )
{
int xsave = x(), ysave = y();
// Temporarily move widget to mouse position
position(X,Y);
redraw();
// Draw widget at mouse position
draw(); // draw widget's group
// ..now move widget back to where it was
position(xsave,ysave);
redraw();
}
};
}
int main( const int argc, const char** argv )
{
using namespace mrv;
Fl_Double_Window win( 640, 480 );
win.begin();
Fl_Tree* tree = new Fl_Tree( 10, 10, 620, 400 );
tree->showroot(0);
tree->showcollapse(0);
tree->selectmode(FL_TREE_SELECT_SINGLE_DRAGGABLE);
tree->item_draw_mode(FL_TREE_ITEM_HEIGHT_FROM_WIDGET);
tree->item_reselect_mode( FL_TREE_SELECTABLE_ALWAYS );
tree->connectorstyle( FL_TREE_CONNECTOR_NONE );
tree->connectorwidth( 0 );
tree->widgetmarginleft( 0 );
tree->marginleft(0);
tree->margintop(0);
tree->marginbottom(0);
tree->openchild_marginbottom(0);
tree->labelmarginleft(0);
tree->linespacing(0);
tree->usericonmarginleft( 0 );
tree->labelmarginleft( 0 );
tree->linespacing(3);
tree->box( FL_FLAT_BOX );
tree->color( FL_RED );
tree->begin();
PlaylistClip* b = new PlaylistClip( 10, 10, tree->w(), 68 );
char buf[32];
size_t i = 0;
sprintf( buf, "%zu", i );
Fl_Tree_Item* item = tree->add( buf );
item->widget( b );
tree->end();
win.end();
win.show();
return Fl::run();
}
The tree background is red, the button widget is blue.
On my Mac, there’s a 5 pixel or so gap on the left of the button, which belongs to the tree.
—
Gonzalo Garramuno
ggar...@gmail.com