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

feat: user defined colors #623

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

python357-1
Copy link
Collaborator

@python357-1 python357-1 commented Dec 2, 2024

This PR implements user-defined tag colors (discussed on the roadmap and would close #264)

@python357-1 python357-1 marked this pull request as draft December 2, 2024 09:06
@python357-1
Copy link
Collaborator Author

python357-1 commented Dec 2, 2024

Initial ideas for user-defined colors

This implementation would add a new table for user defined colors and pre-populate it with the default colors. This would allow for the colors to be ID based, as mentioned on the roadmap, and allow them to have custom names and hex values. The roadmap also mentions having the base colors be non-removable, which is what the following trigger does (currently in db.py):

CREATE TRIGGER delete_color BEFORE DELETE ON user_defined_colors
WHEN OLD.user_defined = FALSE
BEGIN
    SELECT RAISE(ABORT, 'Cannot delete program-defined colors');
END;

User-defined colors can still have their names and hex values updated to whatever the user wants, but they cannot be removed from the database - any attempts to do so will result in a SQL error.

@python357-1
Copy link
Collaborator Author

@CyanVoxel Do these user-defined colors need support for all the ColorTypes like in the current palette.py? ex:

TagColor.DEFAULT: {
        ColorType.PRIMARY: "#1e1e1e",
        ColorType.TEXT: ColorType.LIGHT_ACCENT,
        ColorType.BORDER: "#333333",
        ColorType.LIGHT_ACCENT: "#FFFFFF",
        ColorType.DARK_ACCENT: "#222222",
    },

@CyanVoxel
Copy link
Member

@CyanVoxel Do these user-defined colors need support for all the ColorTypes like in the current palette.py? ex:

TagColor.DEFAULT: {
        ColorType.PRIMARY: "#1e1e1e",
        ColorType.TEXT: ColorType.LIGHT_ACCENT,
        ColorType.BORDER: "#333333",
        ColorType.LIGHT_ACCENT: "#FFFFFF",
        ColorType.DARK_ACCENT: "#222222",
    },

Thank you for asking! The plan is to get rid of this system, and have all colors (built-in + user) be based off of a single hex value per color. From there, we can extrapolate any accent colors and detect whether it needs dark or light text programmatically. That function would likely need a lot of back-and-forth tweaking so I wouldn't worry about nailing it, just having something that works decently enough in its place.

@python357-1
Copy link
Collaborator Author

Were you thinking this function would just take a ColorType and a hex value/Color?

@CyanVoxel CyanVoxel added Type: Enhancement New feature or request Type: QoL A quality of life (QoL) enhancement or suggestion Type: UI/UX User interface and/or user experience TagStudio: Library Relating to the TagStudio library system Priority: High An important issue requiring attention TagStudio: Tags Relating to the TagStudio tag system labels Dec 3, 2024
@CyanVoxel CyanVoxel added this to the Alpha v9.5 (Post-SQL) milestone Dec 3, 2024
Copy link
Collaborator Author

@python357-1 python357-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CyanVoxel i made some comments for stuff i wanted your input on

if color.name == color_name.upper().replace(" ", "_"):
return color
return TagColor.DEFAULT
#class TSStandardColors(enum.IntEnum):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you said you aren't a fan of enums, but I think it would be good to have an enum that just has the IDs of colors in the default tagstudio color pack (whatever we will call it).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll concede to this ;)

@@ -91,6 +91,51 @@ def get_default_tags() -> tuple[Tag, ...]:
return archive_tag, favorite_tag


def get_default_colors(namespace: ColorNamespace) -> list[Color]:
colors: list[Color] = [
#TODO: reduce this to limited tagstudio standard color set
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you have settled on a final list of colors you do want in the default pack, but the sooner I can have that the better

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I'll get that fleshed out for you

from src.core.palette import ColorType

def get_hex_color(color: Color, color_type: ColorType) -> str:
#TODO: everything
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is obviously just a placeholder, I don't even know if this will be the final location for it, but for right now anything you want to do with the color function can be done here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the Color object will take care of the color ID + namespace identification, I think this should take care of it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High An important issue requiring attention TagStudio: Library Relating to the TagStudio library system TagStudio: Tags Relating to the TagStudio tag system Type: Enhancement New feature or request Type: QoL A quality of life (QoL) enhancement or suggestion Type: UI/UX User interface and/or user experience
Projects
Status: 🚧 In progress
Development

Successfully merging this pull request may close these issues.

[Feature Request] Hex/RGB Color Values for Tags
2 participants