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

PyRevit icons on the ribbon are barely visible when Revit 2024 dark theme enabled #1834

Closed
shtirlitsDva opened this issue Jun 2, 2023 · 19 comments
Assignees
Labels
Bundles Issues related to the pyRevit bundles [subsystem] New Feature New feature request [class->Implemented #{number}: {title}] Prioritize The issue is planned to be resolved in the next version

Comments

@shtirlitsDva
Copy link

Describe the bug
PyRevit icons on the ribbon are barely visible when Revit 2024 dark theme is enabled

To Reproduce
Steps to reproduce the behavior:
Install Revit 2024
Install PyRevit (I installed 9266f6a develop)

Expected behavior
I expect the icons to be visible in Dark mode.

Screenshots
image

Desktop (please complete the following information):

  • OS: Win 11 22H2
  • pyRevit Version 9266f6a Develop version
  • pyRevit Environment:

´´´
==> Registered Clones (full git repos)
==> Registered Clones (deployed from archive/image)
master | Deploy: "basepublic" | Branch: "master" | Version: "4.8.13.23144+1030-wip" | Path: "C:\Users\MichailGolubjev\AppData\Roaming\pyRevit-Master"
==> Attachments
master | Product: "Autodesk Revit 2024" | Engine: IPY277 (277) | Path: "C:\Users\MichailGolubjev\AppData\Roaming\pyRevit-Master"
==> Installed Extensions
DRIEXT | Type: Unknown | Repo: "" | Installed: "X:\AutoCAD DRI - Revit\pyRevitExtensions\DRIEXT.extension"
==> Default Extension Search Path
C:\Users\MichailGolubjev\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
X:\AutoCAD DRI - Revit\pyRevitExtensions
==> Extension Sources - Default
https://github.com/eirannejad/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
==> Installed Revits
Autodesk Revit 2024 | Version: 24.0.5.432 | Build: 20230411_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2024"
==> Running Revit Instances
Error: Objektreferencen er ikke indstillet til en forekomst af et objekt.
Run with "--debug" option to see debug messages
´´´

@jmcouffin
Copy link
Contributor

@shtirlitsDva do you have a proposal to fix this?

@shtirlitsDva
Copy link
Author

I am sorry, no.

@jmcouffin
Copy link
Contributor

I tried to recolor the icons for that specific purpose with this script.
The output is decent.
image

We would need to discuss it with @eirannejad if there is a better way than recoloring all the icons:

from PIL import Image, ImageDraw
import os

def grey_icons(input_path, output_path):
    image = Image.open(input_path).convert("RGBA")
    if input_path.endswith("icon.png"):
        new_image = Image.new("RGBA", image.size, (0, 0, 0, 0))
        draw = ImageDraw.Draw(new_image)
        greying_color = (243,243,243)
        for x in range(image.width):
            for y in range(image.height):
                r, g, b, a = image.getpixel((x, y))
                if a > 0:
                    draw.point((x, y), fill=greying_color + (a,))
        new_image.save(output_path)
    else:
        image.save(output_path)


def add_stroke(input_path, output_path, stroke_width=1):
    image = Image.open(input_path).convert("RGBA")
    new_image = Image.new("RGBA", image.size, (0, 0, 0, 0))
    draw = ImageDraw.Draw(new_image)
    colored_pixels = image.convert("L").point(lambda x: 0 if x == 0 else 255, mode="1")
    new_image.paste(image, (0, 0), mask=image)
    for x in range(image.width):
        for y in range(image.height):
            if colored_pixels.getpixel((x, y)):
                for dx in range(-stroke_width, stroke_width + 1):
                    for dy in range(-stroke_width, stroke_width + 1):
                        if dx == 0 and dy == 0:
                            continue
                        nx, ny = x + dx, y + dy
                        if nx < 0 or ny < 0 or nx >= image.width or ny >= image.height or not colored_pixels.getpixel((nx, ny)):
                            draw.point((x, y), fill=(0, 0, 0))
    final_image = Image.alpha_composite(image, new_image)
    final_image.save(output_path)

input_directory = "C:\pyRevit\latest\latest\extensions\pyRevitTools.extension\pyRevit.tab"
output_directory = "C:\pyRevit\latest\latest\extensions\pyRevitTools.extension\pyRevit.tab"
stroke_width = 1


for root, dirs, files in os.walk(input_directory):
    for filename in files:
        if filename.endswith(".png"):
            input_path = os.path.join(root, filename)
            relative_path = os.path.relpath(input_path, input_directory)
            output_path = os.path.join(output_directory, relative_path)
            os.makedirs(os.path.dirname(output_path), exist_ok=True)
            grey_icons(input_path, output_path)
            add_stroke(output_path, output_path, stroke_width)

@jmcouffin jmcouffin added Prioritize The issue is planned to be resolved in the next version 2024 labels Jun 9, 2023
@dosymep
Copy link
Member

dosymep commented Jun 13, 2023

@jmcouffin,
I've created new icons to bundles.
Will pyrevit maybe use that names?
image

@jmcouffin
Copy link
Contributor

@dosymep can you elaborate on the usage of dark vs fatal, regular and warning?
There is no process implemented to match 2024 theme behaviour. How would you approach it?

@dosymep
Copy link
Member

dosymep commented Jun 13, 2023

icon - default for light theme
icon.dark - for dark theme
icon.warning and icon.fatal - for my custom notifications
but I use old version pyRevit 4.8.8, my custom GUI supports themes

@jmcouffin
Copy link
Contributor

use case missing is on and off toggle in dark theme

@dosymep
Copy link
Member

dosymep commented Jun 13, 2023

I think need to use suffix dark for dark theme.
If you create images "on.png and off.png", you need to add dark suffix "on.dark.png and off.dark.png"

@jmcouffin jmcouffin added New Feature New feature request [class->Implemented #{number}: {title}] Bundles Issues related to the pyRevit bundles [subsystem] labels Jun 13, 2023
@LTusche
Copy link
Contributor

LTusche commented Jul 17, 2023

A very generic way to do this, could be to invert the brightness while preserving the hue. Should also work for icons.

Similar to how these guys are doing it:
https://forum.image.sc/t/invert-rgb-image-without-changing-colors/33571

Actually looks good even for more complex icons:
image
Done by inverting the image and displacing the hue by 180 degrees.

@sweco-begertjanvdb
Copy link
Contributor

sweco-begertjanvdb commented Aug 10, 2023

I think it makes sense to do both.
Use the .dark.png file if it is provided, otherwise , try a best guess by inverting the colors.

This ofcourse wouldn't fix issues with icons that work just fine in dark and light mode. But then you could argue that the easy fix for that is to just provide icon.dark.png as an exact copy of icon.png

@jmcouffin
Copy link
Contributor

@dosymep do you have the implementation for .dark somewhere already coded?

@dosymep
Copy link
Member

dosymep commented Aug 10, 2023

@jmcouffin, I am using this icon only in notifications

Code:

image

Light:

image

Dark:

image

@dosymep
Copy link
Member

dosymep commented Aug 10, 2023

@GertjanVDBVK, invert colors great idea, but I think bad to performance, cold start pyrevit will be so terrible

@dosymep dosymep mentioned this issue Aug 19, 2023
@jmcouffin
Copy link
Contributor

jmcouffin commented Aug 21, 2023

Fixed by @dosymep by #1897 🍾 🙏 🎉
image

  • All icons got duplicated and converter to icon.dark.png with white color
  • a utility script has been added under /extras/dark_mode/convert_icon_to_dark_mode.py to help batch convert icons for your own extensions

How do I get this change?

Requires a Reload whenever you switch theme

@tjxme
Copy link

tjxme commented Apr 15, 2024

Fixed by @dosymep by #1897 🍾 🙏 🎉 image

  • All icons got duplicated and converter to icon.dark.png with white color
  • a utility script has been added under /extras/dark_mode/convert_icon_to_dark_mode.py to help batch convert icons for your own extensions

How do I get this change?

Requires a Reload whenever you switch theme

sorry i dont find them under %appdata%/pyrevit folder. im using the non-admin version, what is the typical path??

@jmcouffin
Copy link
Contributor

Fixed by @dosymep by #1897 🍾 🙏 🎉 image

  • All icons got duplicated and converter to icon.dark.png with white color
  • a utility script has been added under /extras/dark_mode/convert_icon_to_dark_mode.py to help batch convert icons for your own extensions

How do I get this change?

Requires a Reload whenever you switch theme

sorry i dont find them under %appdata%/pyrevit folder. im using the non-admin version, what is the typical path??

Please open a new issue and follow the issue guidelines

@tjxme
Copy link

tjxme commented Apr 15, 2024

Fixed by @dosymep by #1897 🍾 🙏 🎉 image

  • All icons got duplicated and converter to icon.dark.png with white color
  • a utility script has been added under /extras/dark_mode/convert_icon_to_dark_mode.py to help batch convert icons for your own extensions

How do I get this change?

Requires a Reload whenever you switch theme

sorry i dont find them under %appdata%/pyrevit folder. im using the non-admin version, what is the typical path??

Please open a new issue and follow the issue guidelines

my bad, apologize again. found them under our issue
https://github.com/eirannejad/pyRevit/blob/develop/extras/dark_mode/convert_icon_to_dark_mode.py

@Denver-22
Copy link

https://github.com/eirannejad/pyRevit/blob/develop/extras/dark_mode/convert_icon_to_dark_mode.py
I think there is a mistake on line 38. Alpha channel should be the 4th argument?
output.putpixel((x, y), (pixel[3], color[0], color[1], color[2]))
Is that correct?
output.putpixel((x, y), (color[0], color[1], color[2], pixel[3]))

@jmcouffin
Copy link
Contributor

convert_icon_to_dark_mode.py

You are right, thanks
dc86688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bundles Issues related to the pyRevit bundles [subsystem] New Feature New feature request [class->Implemented #{number}: {title}] Prioritize The issue is planned to be resolved in the next version
Projects
None yet
Development

No branches or pull requests

8 participants