Refactor: Rename functions and structs in keyframes_draw.cc #111510

Merged
Christoph Lendenfeld merged 8 commits from ChrisLend/blender:keyframes_draw_renames into main 2023-09-12 16:08:23 +02:00

No functional changes.

While looking at the Dope Sheet drawing code to see if it can be made faster I came across a bunch of functions with confusing names.

This PR tries to address that by:

  • removing the ED_ prefix from static functions
  • adding it to non static functions
  • renaming AnimKeylistDrawListElem to ChannelListElement
  • renaming AnimKeylistDrawList to ChannelDrawList
  • all draw_..._channel renamed to ED_add_..._channel since the function itself doesn't actually do any drawing
  • generally simplifying the function names
No functional changes. While looking at the Dope Sheet drawing code to see if it can be made faster I came across a bunch of functions with confusing names. This PR tries to address that by: * removing the `ED_` prefix from static functions * adding it to non static functions * renaming `AnimKeylistDrawListElem` to `ChannelListElement` * renaming `AnimKeylistDrawList` to `ChannelDrawList` * all `draw_..._channel` renamed to `ED_add_..._channel` since the function itself doesn't actually do any drawing * generally simplifying the function names
Christoph Lendenfeld added the
Interest
Grease Pencil
Module
Animation & Rigging
labels 2023-08-25 11:22:21 +02:00
Christoph Lendenfeld added 1 commit 2023-08-25 11:22:36 +02:00
Christoph Lendenfeld requested review from Jeroen Bakker 2023-08-25 11:22:57 +02:00
Christoph Lendenfeld requested review from Nathan Vegdahl 2023-08-25 11:23:06 +02:00
Christoph Lendenfeld requested review from Falk David 2023-08-25 11:23:15 +02:00
Falk David requested changes 2023-08-25 12:01:15 +02:00
Falk David left a comment
Member

Happy to see someone working on refactoring this code! Thank you :)

I have some inline comments and one suggestion: I think renaming the functions to use an ED_ prefix is good, but what would be even better imho is to use a namespace. Something like ed::animation::draw.

But I'll let the others decide if they think that's better or not :)

Happy to see someone working on refactoring this code! Thank you :) I have some inline comments and one suggestion: I think renaming the functions to use an `ED_` prefix is good, but what would be even better imho is to use a `namespace`. Something like `ed::animation::draw`. But I'll let the others decide if they think that's better or not :)
@ -396,2 +394,4 @@
struct ChannelListElement {
ChannelListElement *next, *prev;
AnimKeylist *keylist;
eAnimKeylistDrawListElemType type;
Member

Since we're renaming this struct, I would rename the enum as well. Maybe just ChannelType. And I'd make it an enum class while we're at it. Then the fields can all drop the ANIM_KEYLIST_ prefix and we get somthing like ChannelType::Summary, ChannelType::Scene, etc.

Since we're renaming this struct, I would rename the enum as well. Maybe just `ChannelType`. And I'd make it an `enum class` while we're at it. Then the fields can all drop the `ANIM_KEYLIST_` prefix and we get somthing like `ChannelType::Summary`, `ChannelType::Scene`, etc.
Author
Member

renamed to eChannelType
I am not sure if the e prefix is still needed. Do you know anything about that?

renamed to `eChannelType` I am not sure if the `e` prefix is still needed. Do you know anything about that?
Member

No, in C++ we generally don't add a prefix anymore, because the type is known and doesn't need to be hinted at in the name. E.g. C++ will not let you do some operations that you would be able to do in C like it was just an int.

No, in C++ we generally don't add a prefix anymore, because the type is known and doesn't need to be hinted at in the name. E.g. C++ will not let you do some operations that you would be able to do in C like it was just an `int`.
filedescriptor marked this conversation as resolved
@ -768,3 +772,1 @@
float ypos,
float yscale_fac,
int saction_flag)
void ED_add_gpl_channel(ChannelDrawList *channel_list,
Member

Since we're renaming things, this should really be named something like ED_add_gp_layer_legacy_channel.

Since we're renaming things, this should really be named something like `ED_add_gp_layer_legacy_channel`.
Member

Agreed. When I first read the function name, I thought, "GNU Public License channel...?" Of course, I knew that's not what it would be, but it wasn't immediately clear what it was.

Since the function just above spells out grease_pencil, maybe do that here as well? ED_add_grease_pencil_layer_legacy_channel

Agreed. When I first read the function name, I thought, "GNU Public License channel...?" Of course, I knew that's not what it would be, but it wasn't immediately clear what it *was*. Since the function just above spells out `grease_pencil`, maybe do that here as well? `ED_add_grease_pencil_layer_legacy_channel`
Author
Member

renamed the function to ED_add_grease_pencil_layer_legacy_channel
is more consistent with the other function names

renamed the function to `ED_add_grease_pencil_layer_legacy_channel` is more consistent with the other function names
nathanvegdahl marked this conversation as resolved
@ -783,3 +787,1 @@
float ypos,
float yscale_fac,
int saction_flag)
void ED_add_masklay_channel(ChannelDrawList *channel_list,
Member

I would prefer ED_add_mask_layer_channel

I would prefer `ED_add_mask_layer_channel`
filedescriptor marked this conversation as resolved
Member

Although I touched this code 4 years ago, I will leave it to Nathan for review as it is part of the animation module.

Although I touched this code 4 years ago, I will leave it to Nathan for review as it is part of the animation module.
Jeroen Bakker refused to review 2023-08-25 15:07:43 +02:00
Nathan Vegdahl reviewed 2023-08-31 16:13:34 +02:00
@ -693,3 +688,1 @@
float ypos,
float yscale_fac,
int saction_flag)
void ED_add_agroup_channel(ChannelDrawList *channel_list,
Member

Not sure how deep the renaming rabbit hole would go, but could agroup be expanded? It's not immediately clear what that is (action group? animation group?).

Maybe that's out of scope for this PR, if it would require touching too many other things to make everything consistent.

Not sure how deep the renaming rabbit hole would go, but could `agroup` be expanded? It's not immediately clear what that is (action group? animation group?). Maybe that's out of scope for this PR, if it would require touching too many other things to make everything consistent.
Author
Member

renamed it. In the end it wasn't a lot
Functions now no longer refer to agroup but there is still bPose->agroups

renamed it. In the end it wasn't a lot Functions now no longer refer to `agroup` but there is still `bPose->agroups`
nathanvegdahl marked this conversation as resolved
Member

This generally looks good to me, and certainly reads a lot more clearly. I agree with the notes from @filedescriptor, and had one additional suggestion that might be out of scope for this PR.

This generally looks good to me, and certainly reads a lot more clearly. I agree with the notes from @filedescriptor, and had one additional suggestion that might be out of scope for this PR.
Christoph Lendenfeld added 2 commits 2023-08-31 16:42:19 +02:00
Christoph Lendenfeld added 1 commit 2023-08-31 16:44:04 +02:00
Christoph Lendenfeld added 2 commits 2023-08-31 16:55:31 +02:00
Christoph Lendenfeld requested review from Falk David 2023-08-31 16:57:53 +02:00
Falk David approved these changes 2023-09-11 11:47:12 +02:00
Falk David left a comment
Member

Apart from the eChannelType -> ChannelType thing, LGTM.

Apart from the `eChannelType` -> `ChannelType` thing, LGTM.
Christoph Lendenfeld added 2 commits 2023-09-12 14:35:16 +02:00
Nathan Vegdahl approved these changes 2023-09-12 15:51:58 +02:00
Nathan Vegdahl left a comment
Member

Looks good to me too!

Looks good to me too!
Christoph Lendenfeld merged commit 12f8f926b2 into main 2023-09-12 16:08:23 +02:00
Christoph Lendenfeld deleted branch keyframes_draw_renames 2023-09-12 16:08:24 +02: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
4 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#111510
No description provided.