WIP: #104303: WM panel parent API #105193

Draft
Pratyaksh Raj wants to merge 2 commits from Pratyaksh-Raj/blender:WM-Panel-API into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
First-time contributor
  1. The function 'WM_paneltype_subpanel_add' adds a sub-panel to a parent panel in Blender's user interface.

  2. The function takes three arguments: 'pt', 'parent', and 'use_order'. 'pt' is a pointer to the sub-panel to be added, 'parent' is a pointer to the parent panel, and 'use_order' is a boolean flag that determines whether the sub-panel should be added in a specific order.

  3. The first thing the function does is set the 'parent' of the 'pt' sub-panel to the 'parent' panel passed as an argument.

  4. If 'parent' is not NULL, the function checks if 'use_order' is true. If it is, the function iterates through the children of the 'parent' panel to find the correct position for the sub-panel based on its order property. If 'use_order' is false, the function simply adds the sub-panel to the end of the children list of the 'parent' panel.

  5. The function then sets the 'owner_id' property of the 'pt' sub-panel to the current owner ID using the 'RNA_struct_state_owner_get' function.

  6. Finally, the function adds the 'pt' sub-panel to the global 'paneltypes' list using the 'WM_paneltype_add' function.

'WM_paneltype_subpanel_add' function improve the usability and functionality of Blender's user interface, which can ultimately benefit both developers and users alike.

1. The function **'WM_paneltype_subpanel_add'** adds a sub-panel to a parent panel in Blender's user interface. 2. The function takes three arguments: 'pt', 'parent', and 'use_order'. 'pt' is a pointer to the sub-panel to be added, 'parent' is a pointer to the parent panel, and 'use_order' is a boolean flag that determines whether the sub-panel should be added in a specific order. 3. The first thing the function does is set the 'parent' of the 'pt' sub-panel to the 'parent' panel passed as an argument. 4. If 'parent' is not NULL, the function checks if 'use_order' is true. If it is, the function iterates through the children of the 'parent' panel to find the correct position for the sub-panel based on its order property. If 'use_order' is false, the function simply adds the sub-panel to the end of the children list of the 'parent' panel. 5. The function then sets the 'owner_id' property of the 'pt' sub-panel to the current owner ID using the 'RNA_struct_state_owner_get' function. 6. Finally, the function adds the 'pt' sub-panel to the global 'paneltypes' list using the 'WM_paneltype_add' function. **'WM_paneltype_subpanel_add'** function improve the usability and functionality of Blender's user interface, which can ultimately benefit both developers and users alike.
Pratyaksh Raj added 1 commit 2023-02-24 22:31:38 +01:00
Pratyaksh Raj requested review from Bastien Montagne 2023-02-24 22:33:24 +01:00
Hans Goudey changed title from WIP: WM-PANEL-PARENT-API to WIP: WM panel parent API 2023-02-26 14:39:27 +01:00
Bastien Montagne added this to the User Interface project 2023-02-27 11:25:18 +01:00
Bastien Montagne added the
Interest
Core
label 2023-02-27 11:25:25 +01:00
Bastien Montagne changed title from WIP: WM panel parent API to WIP: #104303: WM panel parent API 2023-02-27 11:25:51 +01:00
Bastien Montagne requested changes 2023-02-27 12:26:34 +01:00
Bastien Montagne left a comment
Owner

Thanks for the patch, it's already a great improvement.

However, please ensure your code builds, and do basic testing of it, before submitting a patch. There are at least to critical errors noted below that won't even allow it to build.

Also added a few notes about required changes (you put a bit too much into that new WM_paneltype_subpanel_add function ;) ).

Thanks for the patch, it's already a great improvement. However, please ensure your code builds, and do basic testing of it, before submitting a patch. There are at least to critical errors noted below that won't even allow it to build. Also added a few notes about required changes (you put a bit too much into that new `WM_paneltype_subpanel_add` function ;) ).
@ -213,3 +213,3 @@
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);
BLI_addtail(&region_type->paneltypes, panel_type);*/

Please remove code, do not comment it out. It makes patch less readable, and we do not want to keep dead code around.

Same for other cases below.

Please remove code, do not comment it out. It makes patch less readable, and we do not want to keep dead code around. Same for other cases below.
@ -215,1 +215,3 @@
BLI_addtail(&region_type->paneltypes, panel_type);
BLI_addtail(&region_type->paneltypes, panel_type);*/
WM_paneltype_subpanel_add(parent, NULL, pt, true);

There are four parameters here, function only takes three of them...

Same for other cases below.

There are four parameters here, function only takes three of them... Same for other cases below.
@ -46,6 +46,37 @@ bool WM_paneltype_add(PanelType *pt)
BLI_ghash_insert(g_paneltypes_hash, pt->idname, pt);
return true;
}
void WM_paneltype_subpanel_add(PanelType *pt, PanelType *parent, bool use_order)

Style: Please leave an empty line between function definitions.

Style: Please leave an empty line between function definitions.
@ -49,0 +65,4 @@
BLI_addtail(&parent->children, BLI_genericNodeN(pt));
}
BLI_addtail(&art->paneltypes, pt);

Wondering where art comes from here...? Missing parameter?

Wondering where `art` comes from here...? Missing parameter?
@ -49,0 +73,4 @@
if (owner_id) {
BLI_strncpy(pt->owner_id, owner_id, sizeof(pt->owner_id));
}
}

That block about the owner_id does not belong to that function, it's specific to the RNA registration code and should be kept there.

That block about the `owner_id` does not belong to that function, it's specific to the RNA registration code and should be kept there.
@ -49,0 +75,4 @@
}
}
WM_paneltype_add(pt);

This should also be left out of this function, since it is not relevant to parenting a panel to another one, and not all panels need to be registered globally at the WM level.

This should also be left out of this function, since it is not relevant to parenting a panel to another one, and not all panels need to be registered globally at the WM level.
@ -1 +1 @@
Subproject commit e133fc08cd3254bb3d3bd1345028c8486700bca4
Subproject commit 27826b4aed138b7e3aed882d0eab96740c3a55c7

This should not be here, in fact this has been removed recently, you need to update your patch against latest main branch.

This should not be here, in fact this has been removed recently, you need to update your patch against latest `main` branch.
Author
First-time contributor

Sir In my 2nd commit there is no such submodule. Updated my main branch. Now For removing this should I need to change my branch and then put another PR?

Sir In my 2nd commit there is no such submodule. Updated my main branch. Now For removing this should I need to change my branch and then put another PR?

Yes just rebase on latest main branch, and force-push on your fork.

Yes just rebase on latest `main` branch, and force-push on your fork.
Author
First-time contributor

Thank you very much for your valuable feedback, Sir. I appreciate your insights and will definitely take them into consideration as I work to improve.

Thank you very much for your valuable feedback, Sir. I appreciate your insights and will definitely take them into consideration as I work to improve.
Pratyaksh Raj added 1 commit 2023-03-03 11:12:03 +01:00
Pratyaksh Raj requested review from Bastien Montagne 2023-03-03 11:57:58 +01:00
Bastien Montagne requested changes 2023-03-06 14:25:35 +01:00
Bastien Montagne left a comment
Owner

Getting there, but still some issues to fix. Once again, please build and do test your changes before submitting the patch... The missing BLI_addtail(&region_type->paneltypes, panel_type); lines and similar will not break compilation, but will definitely at least break the related UI areas.

Getting there, but still some issues to fix. Once again, please build *and* do test your changes before submitting the patch... The missing `BLI_addtail(&region_type->paneltypes, panel_type);` lines and similar will not break compilation, but will definitely at least break the related UI areas.
@ -212,4 +211,0 @@
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);

This line should not be removed, it's not handled by the call to WM_paneltype_subpanel_add.

This line should not be removed, it's not handled by the call to `WM_paneltype_subpanel_add`.
@ -213,3 +211,1 @@
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);
WM_paneltype_subpanel_add(parent,pt, true);

WM_paneltype_subpanel_add(parent, pt, false); (you do not want to use order here).

` WM_paneltype_subpanel_add(parent, pt, false);` (you do not want to use order here).
@ -685,3 +683,2 @@
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
WM_paneltype_subpanel_add(pt_properties, pt, true);
BLI_addtail(&art->paneltypes, pt);

No need to remove that line

No need to remove that line
@ -669,3 +668,3 @@
pt->flag = PANEL_TYPE_DEFAULT_CLOSED;
pt->poll = nla_strip_eval_panel_poll;
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
WM_paneltype_subpanel_add(pt_properties, pt, true);

WM_paneltype_subpanel_add(parent, pt, false); (you do not want to use order here).

` WM_paneltype_subpanel_add(parent, pt, false);` (you do not want to use order here).
@ -672,2 +670,3 @@
WM_paneltype_subpanel_add(pt_properties, pt, true);
BLI_addtail(&art->paneltypes, pt);

Remove extra spaces...

Remove extra spaces...
@ -683,3 +681,3 @@
pt->flag = PANEL_TYPE_DEFAULT_CLOSED;
pt->poll = nla_strip_eval_panel_poll;
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
WM_paneltype_subpanel_add(pt_properties, pt, true);

WM_paneltype_subpanel_add(parent, pt, false); (you do not want to use order here).

` WM_paneltype_subpanel_add(parent, pt, false);` (you do not want to use order here).
@ -395,4 +394,0 @@
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);

This line should not be removed, it's not handled by the call to WM_paneltype_subpanel_add.

This line should not be removed, it's not handled by the call to `WM_paneltype_subpanel_add`.
@ -396,3 +394,1 @@
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);
WM_paneltype_subpanel_add(parent, pt, true);

WM_paneltype_subpanel_add(parent, pt, false); (you do not want to use order here).

` WM_paneltype_subpanel_add(parent, pt, false);` (you do not want to use order here).
@ -413,1 +403,3 @@
WM_paneltype_add(pt);
WM_paneltype_add(pt);

No need for extra empty lines here.

No need for extra empty lines here.
@ -487,4 +486,0 @@
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);

This line should not be removed, it's not handled by the call to WM_paneltype_subpanel_add.

This line should not be removed, it's not handled by the call to `WM_paneltype_subpanel_add`.
@ -488,3 +486,1 @@
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);
WM_paneltype_subpanel_add(parent, pt, true);

WM_paneltype_subpanel_add(parent, pt, false); (you do not want to use order here).

` WM_paneltype_subpanel_add(parent, pt, false);` (you do not want to use order here).
@ -266,4 +265,0 @@
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);

This line should not be removed, it's not handled by the call to WM_paneltype_subpanel_add.

This line should not be removed, it's not handled by the call to `WM_paneltype_subpanel_add`.
@ -267,3 +265,1 @@
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);
WM_paneltype_subpanel_add(parent, pt, true);

WM_paneltype_subpanel_add(parent, pt, false); (you do not want to use order here).

` WM_paneltype_subpanel_add(parent, pt, false);` (you do not want to use order here).
Member

Only blender organization members with write access can start builds. See documentation for details.

Only blender organization members with write access can start builds. See [documentation](https://projects.blender.org/infrastructure/blender-bot) for details.
Author
First-time contributor

Thank You @mont29 sir for your guidance, here I have updated the change in my PR #105645. I have build and test this PR which work fine. I request you to to review.

Thank You @mont29 sir for your guidance, here I have updated the change in my PR https://projects.blender.org/blender/blender/pulls/105645. I have build and test this PR which work fine. I request you to to review.
This pull request has changes conflicting with the target branch.
  • source/blender/editors/animation/fmodifier_ui.c
  • source/blender/editors/space_nla/nla_buttons.c
  • source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
  • source/blender/makesrna/intern/rna_ui.c
  • source/blender/modifiers/intern/MOD_ui_common.c
  • source/blender/shader_fx/intern/FX_ui_common.c
  • source/blender/windowmanager/WM_api.h
  • source/blender/windowmanager/intern/wm_panel_type.c
  • source/tools

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u WM-Panel-API:Pratyaksh-Raj-WM-Panel-API
git checkout Pratyaksh-Raj-WM-Panel-API
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
Asset Browser Project
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
3 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#105193
No description provided.