Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve toolbar icons #734

Open
kjk opened this issue Mar 3, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@kjk
Copy link
Member

commented Mar 3, 2017

@blake-mealey continuing discussion from #731

The icon pack I used (https://material.io/icons/) looks much better with transparency, but obviously I had to modify them to work with the BMP format. I wasn't able to determine whether it is possible to switch to an image format which does support transparency. If you know that it is possible and could point me in the right direction, I'd be happy to implement that before submitting that PR.

Currently we use standard toolbar control. It only supports .bmp files but it does support transparency (pixels RGB(0xFF, 0, 0xFF) in the .bmp image are transparent in the toolbar).

My wishlist is to stop using windows toolbar control and instead paint the icons in code, preferably using a textual vector format, which would give us transparency and good looking dpi scaling for free.

We already have code in SvgPath.cpp to parse a subset of SVG path expression and draw it using GDI+, so it should be easy to extract relevant parts of the icon from .svg file and use in Sumatra.

@kjk kjk referenced this issue Mar 3, 2017

Closed

Theme Support #731

@blake-mealey

This comment has been minimized.

Copy link
Contributor

commented Mar 4, 2017

Would moving away from the windows toolbar control also involve this stuff? (https://code.msdn.microsoft.com/windowsapps/CppWindowsOwnerDrawnMenu-a9888b0c, https://msdn.microsoft.com/en-us/library/windows/desktop/ms647558(v=vs.85).aspx#_win32_Creating_Owner_Drawn_Menu_Items)

I don't have any prior experience with these libraries but I'd love implement a custom toolbar that would allow for more customization and better looking icons.

@kjk

This comment has been minimized.

Copy link
Member Author

commented Mar 5, 2017

As background, with CreateWindow* you can either create "raw" windows, where you have to provide your WndProc (a function that processes windows messages sent to a window). Then you draw into that window on WM_PAINT message.

Or you can create one of the custom controls, like menu control or toolbar control. Those are also windows but the os paints them, provides most of the low-level handling and eposes a nicer, high-level interface (where "nicer" being relative; it's less work that doing everything from scratch but the API to custom controls is not how we would write code today).

Some custom controls allow for certain levels of customization. The above articles describe how to modify the look of standard menu control (as complicated as it looks, it's much less work than re-implementing menus from scratch).

For toolbar control, I don't think it allows for enough paint customization so it has to be done from scratch. There are 2 possibilities.

  1. Write HWND-based control, similar in spirit and functionality to standard toolbar control. See LabelWithCloseWnd.[h|cpp] for a template of such style and an implementation of a simple control in this style.

  2. HWND-less implementation.

Instead of using a HWND (which has some limitations e.g. it's not easy to alpha-blend HWND onto its parent HWND), you can draw toolbar elements directly onto parent window.

For ebook view I've build src\mui to make it such style a bit easier. I'm pointing this only as a source of ideas, I think I overdid some things and might re-implement ebook view in a similar, but hopefully simpler system.

We already draw a bunch of custom stuff in Canvas.cpp and toolbar controls could be drawn directly in there (WM_PAINT of WndProcCanvasFixedPageUI).

Currently the structure of main window is:
HWND_frame
HWND_toolbar <-- current toolbar
HWND_canvas <-- where we draw the PDF document and some other stuff
(and a bunch of other HWND-based windows).

After the change it would be:
HWND_frame
HWND_canvas <- toolbar would be drawn directly into hwnd canvas

Solution 1. is probably easier as you would basically replace toolbar custom control (which is hwnd) with another hwnd-based window that just paints different things into that space, like use icons from .png image or draw them from vector data using SvgPath.cpp).

@kjk

This comment has been minimized.

Copy link
Member Author

commented Sep 27, 2017

Continuing toolbar discussion in relation to theming (from #898)

The improvements we want in toolbar:

What: allow customizing colors of the icon (background/outline) and scale icons better with dpi
How: instead of using toolbar control (which only allows bitmaps) do custom drawing using vector (i.e. scalable) shapes

What: modernize the icons
How: find a nice SVG icon set with free license (e.g. material design icons)

What: allow toolbar customizability (especially adding back/forward buttons as it's a frequent request) but in general we should be flexible enough to remove/re-arrange the icons
How: extend settings to allow defining toolbar

As far as icon drawing, I would steal what Chrome does. Supporting SVG natively is too much work. Chrome designed a much simpler, limited format for vector icons:

Code that parses that format:

For the icons we could use chrome icons or write svg -> simple format converter

So the order would be:

  • implement parser for .icon files
  • implement drawing of the icon into hdc/bitmap at a given resolution
  • re-implement toolbar using vector icons
@blake-mealey

This comment has been minimized.

Copy link
Contributor

commented Sep 27, 2017

So, to be clear, would this require a full new toolbar, or just rendering vector images into bitmaps and drawing them in the places the current bitmaps are drawn?

@kjk

This comment has been minimized.

Copy link
Member Author

commented Sep 27, 2017

Either way would work.

@az4726

This comment has been minimized.

Copy link

commented May 24, 2019

Hi there, I've been using this Sumatra for a while and thought I'd try creating the toolbar vector icons. Have a look and let me know what you think. Hopefully this issue can finally be closed.

I've also included an updated PDF file icon as the old one looks quite dated, and there are also a couple of new program icon vectors which you can have a look at.

Sumatra PDF Icons.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.