1

We want to display an image to the left of the toolbars of our Eclipse RCP application, like this:

Eclipse RCP application with an imagem to the left of the toolbars

Our app has a setting that allows the user to change the size of the toolbars:

Eclipse RCP application with different toolbar size

We tried the following approaches:

  1. Create a model fragment and add a new Trim Contribution with a Tool Control. This Tool Control has the image. The problem here is that the Tool Control is always aligned on the right side of the trim.

  2. Via plugin.xml, use the org.eclipse.ui.menus extension, add a new menuContribution > toolbar > control, and then add a widget on it. This widget has the image. The problem here is that the widget has a fixed height. It's always with the height of a small toolbar.

  3. Create a custom TrimBarRenderer and create a Composite inside the main trim Composite. This inner Composite has the image. The problem here is that when the user changes the toolbar style, this widget is placed on the right. We managed to position it correctly, but it's an ugly solution.

  4. Create a custom TrimBarRenderer, adjust its layout's left margin to add some space and add a paintListener to its Composite. The paintListener draws the image on the space created by the extra margin. This is the best solution so far, albeit too cumbersome.

It seems the first or second approaches are the best ones, but we couldn't find how to deal with the positioning or sizing.

Which is the correct way to do this?

asked Jan 11, 2024 at 12:28

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.