UI: Add Optional Flags for Tooltip Image Fields #119437

Merged
Harley Acheson merged 5 commits from Harley/blender:TooltipImageFlags into main 2024-03-18 22:17:59 +01:00
Member

Add more flexibility to tooltip images by adding the ability to specify
if (one of two) checkerboards are added, border, premultiplied
blending, or recoloring.


The current tooltip images work okay in our current usages, but we need more flexibility to do things like this or that.

Why do we have two checkerboards? We have one that we use in most places which has colors that are set by the theme. But within the theme editor itself we use a checkerboard with fixed colors to always give consistent results. The former would be used for image thumbnails while the latter would be needed for previews of colors.

What is "recoloring"? When drawing images the shader has an option to shift the colors based on a passed color. An example of use is with font previews, which are always saved as white images on a transparent background. This would not be visible with light themes to we recolor with the text color so they appear dark there.

Add more flexibility to tooltip images by adding the ability to specify if (one of two) checkerboards are added, border, premultiplied blending, or recoloring. --- The current tooltip images work okay in our current usages, but we need more flexibility to do things like [this](https://projects.blender.org/blender/blender/pulls/117815) or [that](https://projects.blender.org/blender/blender/pulls/118945). Why do we have two checkerboards? We have one that we use in most places which has colors that are set by the theme. But within the theme editor itself we use a checkerboard with fixed colors to always give consistent results. The former would be used for image thumbnails while the latter would be needed for previews of colors. What is "recoloring"? When drawing images the shader has an option to shift the colors based on a passed color. An example of use is with font previews, which are always saved as white images on a transparent background. This would not be visible with light themes to we recolor with the text color so they appear dark there.
Harley Acheson added 1 commit 2024-03-13 19:31:34 +01:00
93d62db382 UI: Add Optional Flags for Tooltip Image Fields
Add more flexibility to tooltip images by adding a flag to the field to
specify if (one of two) checkerboards are added, border, premultiplied
blending, or recoloring.
Harley Acheson added this to the User Interface project 2024-03-13 19:32:02 +01:00
Harley Acheson requested review from Hans Goudey 2024-03-13 19:32:08 +01:00
Hans Goudey reviewed 2024-03-13 19:40:23 +01:00
Hans Goudey left a comment
Member

I like the way this is headed, but I think it could be a little friendlier/more flexible with a struct for parameters instead. For example, UI_TIP_FLAG_IMAGE_CHECKER and UI_TIP_FLAG_IMAGE_CHECKER_FIXED are mutually exclusive, but that can't be represented by a flag.

What about a struct, something loosely like this?

struct uiTooltipImageParams {
  bool fixed = false;
  bool border = false;
  bool premultiplied = false;
  bool text_color = false;
};

For now it's just booleans I guess, but it could also contain other things, even the size and the image pointer itself I guess.

I like the way this is headed, but I think it could be a little friendlier/more flexible with a struct for parameters instead. For example, `UI_TIP_FLAG_IMAGE_CHECKER` and `UI_TIP_FLAG_IMAGE_CHECKER_FIXED` are mutually exclusive, but that can't be represented by a flag. What about a struct, something loosely like this? ``` struct uiTooltipImageParams { bool fixed = false; bool border = false; bool premultiplied = false; bool text_color = false; }; ``` For now it's just booleans I guess, but it could also contain other things, even the size and the image pointer itself I guess.
Harley Acheson added 1 commit 2024-03-13 21:29:22 +01:00
Author
Member

@HooglyBoogly

What do you think of this? It certainly reads a lot nicer.

@HooglyBoogly What do you think of this? It certainly reads a lot nicer.
Hans Goudey requested changes 2024-03-14 14:36:13 +01:00
Dismissed
Hans Goudey left a comment
Member

Looks great!

Looks great!
@ -1722,6 +1722,22 @@ enum uiTooltipColorID {
UI_TIP_LC_MAX
};
enum uiTooltipImageBackground {
Member

How about this :)

enum class uiTooltipImageBackground {
  None = 0,
  Themed = 1,
  Fixed = 2,
};
How about this :) ``` enum class uiTooltipImageBackground { None = 0, Themed = 1, Fixed = 2, }; ```
Harley marked this conversation as resolved
@ -92,3 +92,2 @@
uiTooltipFormat format;
ImBuf *image;
short image_size[2];
uiTooltipImage *image = nullptr;
Member

std::optional seems simpler here than allocating a struct. I don't see a matching delete in this PR, so I'd expect a memory leak currently.

`std::optional` seems simpler here than allocating a struct. I don't see a matching `delete` in this PR, so I'd expect a memory leak currently.
Harley marked this conversation as resolved
@ -125,3 +124,3 @@
}
void UI_tooltip_image_field_add(uiTooltipData *data, const ImBuf *image, const short image_size[2])
void UI_tooltip_image_field_add(uiTooltipData *data, uiTooltipImage image_data)
Member

Think I'd pass this by const reference, it's not a small struct and it's not being std::moved here

Think I'd pass this by const reference, it's not a small struct and it's not being `std::move`d here
Harley marked this conversation as resolved
Harley Acheson added 2 commits 2024-03-17 03:37:22 +01:00
Hans Goudey approved these changes 2024-03-18 15:44:55 +01:00
Harley Acheson added 1 commit 2024-03-18 21:58:43 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
1e07731977
Merge branch 'main' of projects.blender.org:blender/blender into TooltipImageFlags
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson merged commit 061a9ee885 into main 2024-03-18 22:17:59 +01:00
Harley Acheson deleted branch TooltipImageFlags 2024-03-18 22:18:01 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#119437
No description provided.