Blender V5.3
interface_panel.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9/* a full doc with API notes can be found in
10 * bf-blender/trunk/blender/doc/guides/interface_API.txt */
11
12#include <algorithm>
13#include <cctype>
14#include <cmath>
15#include <cstdlib>
16#include <cstring>
17
18#include "MEM_guardedalloc.h"
19
20#include "BLI_listbase.hh"
21#include "BLI_math_vector_c.hh"
22#include "BLI_string.hh"
23#include "BLI_string_utf8.hh"
24#include "BLI_time.hh"
25#include "BLI_utildefines.hh"
26
27#include "BLT_translation.hh"
28
29#include "DNA_screen_types.h"
30#include "DNA_userdef_types.h"
31
32#include "BKE_context.hh"
33#include "BKE_recents.hh"
34#include "BKE_screen.hh"
35
36#include "RNA_access.hh"
37
38#include "BLF_api.hh"
39
40#include "WM_api.hh"
41#include "WM_types.hh"
42
43#include "ED_screen.hh"
44
45#include "UI_interface_c.hh"
46#include "UI_interface_icons.hh"
47#include "UI_resources.hh"
48#include "UI_view2d.hh"
49
50#include "GPU_batch_presets.hh"
51#include "GPU_immediate.hh"
52#include "GPU_matrix.hh"
53#include "GPU_state.hh"
54
55#include "RNA_prototypes.hh"
56
57#include "interface_intern.hh"
58
59namespace blender::ui {
60
61/* -------------------------------------------------------------------- */
64
65#define ANIMATION_TIME 0.30
66#define ANIMATION_INTERVAL 0.02
67
90
91/* The state of the mouse position relative to the panel. */
98
104
107
108 /* Animation. */
110 double starttime;
111
112 /* Dragging. */
116};
117
123
124static void panel_set_expansion_from_list_data(const bContext *C, Panel *panel);
125static int get_panel_real_size_y(const Panel *panel);
126static void panel_activate_state(const bContext *C, Panel *panel, const HandlePanelState state);
127static bool panel_type_context_poll(ARegion *region,
128 const PanelType *panel_type,
129 const char *context);
130
132
133/* -------------------------------------------------------------------- */
136
137static bool panel_active_animation_changed(ListBaseT<Panel> *lb,
138 Panel **r_panel_animation,
139 bool *r_no_animation)
140{
141 for (Panel &panel : *lb) {
142 /* Detect panel active flag changes. */
143 if (!(panel.type && panel.type->parent)) {
144 if ((panel.runtime_flag & PANEL_WAS_ACTIVE) && !(panel.runtime_flag & PANEL_ACTIVE)) {
145 return true;
146 }
147 if (!(panel.runtime_flag & PANEL_WAS_ACTIVE) && (panel.runtime_flag & PANEL_ACTIVE)) {
148 return true;
149 }
150 }
151
152 /* Detect changes in panel expansions. */
153 if (bool(panel.runtime_flag & PANEL_WAS_CLOSED) != panel_is_closed(&panel)) {
154 *r_panel_animation = &panel;
155 return false;
156 }
157
158 if ((panel.runtime_flag & PANEL_ACTIVE) && !panel_is_closed(&panel)) {
159 if (panel_active_animation_changed(&panel.children, r_panel_animation, r_no_animation)) {
160 return true;
161 }
162 }
163
164 /* Detect animation. */
165 if (panel.activedata) {
166 HandlePanelData *data = static_cast<HandlePanelData *>(panel.activedata);
167 if (data->state == PANEL_STATE_ANIMATION) {
168 *r_panel_animation = &panel;
169 }
170 else {
171 /* Don't animate while handling other interaction. */
172 *r_no_animation = true;
173 }
174 }
175 if ((panel.runtime_flag & PANEL_ANIM_ALIGN) && !(*r_panel_animation)) {
176 *r_panel_animation = &panel;
177 }
178 }
179
180 return false;
181}
182
186static bool properties_space_needs_realign(const ScrArea *area, const ARegion *region)
187{
188 if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) {
189 const SpaceProperties *sbuts = area->spacedata.first_as<SpaceProperties>();
190
191 if (sbuts->mainbo != sbuts->mainb) {
192 return true;
193 }
194 }
195
196 return false;
197}
198
199static bool panels_need_realign(const ScrArea *area, ARegion *region, Panel **r_panel_animation)
200{
201 *r_panel_animation = nullptr;
202
203 if (properties_space_needs_realign(area, region)) {
204 return true;
205 }
206
207 /* Detect if a panel was added or removed. */
208 Panel *panel_animation = nullptr;
209 bool no_animation = false;
210 if (panel_active_animation_changed(&region->panels, &panel_animation, &no_animation)) {
211 return true;
212 }
213
214 /* Detect panel marked for animation, if we're not already animating. */
215 if (panel_animation) {
216 if (!no_animation) {
217 *r_panel_animation = panel_animation;
218 }
219 return true;
220 }
221
222 return false;
223}
224
226
227/* -------------------------------------------------------------------- */
230
231static Panel *panel_add_instanced(ListBaseT<Panel> *panels,
232 PanelType *panel_type,
233 PointerRNA *custom_data)
234{
235 Panel *panel = BKE_panel_new(panel_type);
236
237 panel->runtime->custom_data_ptr = custom_data;
239
240 /* Add the panel's children too. Although they aren't instanced panels, we can still use this
241 * function to create them, as panel_begin does other things we don't need to do. */
242 for (LinkData &child : panel_type->children) {
243 PanelType *child_type = static_cast<PanelType *>(child.data);
244 panel_add_instanced(&panel->children, child_type, custom_data);
245 }
246
247 /* Make sure the panel is added to the end of the display-order as well. This is needed for
248 * loading existing files.
249 *
250 * NOTE: We could use special behavior to place it after the panel that starts the list of
251 * instanced panels, but that would add complexity that isn't needed for now. */
252 int max_sortorder = 0;
253 for (Panel &existing_panel : *panels) {
254 max_sortorder = std::max(existing_panel.sortorder, max_sortorder);
255 }
256 panel->sortorder = max_sortorder + 1;
257
258 BLI_addtail(panels, panel);
259
260 return panel;
261}
262
264 ARegion *region,
265 ListBaseT<Panel> *panels,
266 const char *panel_idname,
267 PointerRNA *custom_data)
268{
269 ARegionType *region_type = region->runtime->type;
270
271 PanelType *panel_type = static_cast<PanelType *>(
272 BLI_findstring(&region_type->paneltypes, panel_idname, offsetof(PanelType, idname)));
273
274 if (panel_type == nullptr) {
275 printf("Panel type '%s' not found.\n", panel_idname);
276 return nullptr;
277 }
278
279 Panel *new_panel = panel_add_instanced(panels, panel_type, custom_data);
280
281 /* Do this after #panel_add_instanced so all sub-panels are added. */
283
284 return new_panel;
285}
286
287void list_panel_unique_str(Panel *panel, char *r_name)
288{
289 /* The panel sort-order will be unique for a specific panel type because the instanced
290 * panel list is regenerated for every change in the data order / length. */
292}
293
301static void panel_delete(ARegion *region, ListBaseT<Panel> *panels, Panel *panel)
302{
303 /* Recursively delete children. */
304 for (Panel &child : panel->children.items_mutable()) {
305 panel_delete(region, &panel->children, &child);
306 }
307 panel->children.free_no_destruct();
308
309 BLI_remlink(panels, panel);
310 BKE_panel_free(panel);
311}
312
313static void panel_exit_state_recursive(const bContext *C, Panel &panel)
314{
315 if (panel.activedata != nullptr) {
317 }
318 for (Panel &child : panel.children) {
320 }
321}
322
324{
325 /* Delete panels with the instanced flag. */
326 for (Panel &panel : region->panels.items_mutable()) {
327 if (!panel.type) {
328 continue;
329 }
330 if ((panel.type->flag & PANEL_TYPE_INSTANCED) == 0) {
331 continue;
332 }
333 /* Make sure any active handler is removed from this panel or its children before deleting
334 * them. */
335 if (C != nullptr) {
337 }
338
339 /* Free panel's custom data. */
340 if (panel.runtime->custom_data_ptr != nullptr) {
341 MEM_delete(panel.runtime->custom_data_ptr);
342 }
343
344 /* Free the panel and its sub-panels. */
345 panel_delete(region, &region->panels, &panel);
346 }
347}
348
350 ListBase *data,
351 ListPanelIDFromDataFunc panel_idname_func)
352{
353 /* Check for nullptr data. */
354 int data_len = 0;
355 Link *data_link = nullptr;
356 if (data == nullptr) {
357 data_len = 0;
358 data_link = nullptr;
359 }
360 else {
361 data_len = BLI_listbase_count(data);
362 data_link = static_cast<Link *>(data->first_);
363 }
364
365 int i = 0;
366 for (Panel &panel : region->panels) {
367 if (panel.type != nullptr && panel.type->flag & PANEL_TYPE_INSTANCED) {
368 /* The panels were reordered by drag and drop. */
370 return false;
371 }
372
373 /* We reached the last data item before the last instanced panel. */
374 if (data_link == nullptr) {
375 return false;
376 }
377
378 /* Check if the panel type matches the panel type from the data item. */
379 char panel_idname[MAX_NAME];
380 panel_idname_func(data_link, panel_idname);
381 if (!STREQ(panel_idname, panel.type->idname)) {
382 return false;
383 }
384
385 data_link = data_link->next;
386 i++;
387 }
388 }
389
390 /* If we didn't make it to the last list item, the panel list isn't complete. */
391 if (i != data_len) {
392 return false;
393 }
394
395 return true;
396}
397
398static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *drag_panel)
399{
400 /* Without a type we cannot access the reorder callback. */
401 if (drag_panel->type == nullptr) {
402 return;
403 }
404 /* Don't reorder if this instanced panel doesn't support drag and drop reordering. */
405 if (drag_panel->type->reorder == nullptr) {
406 return;
407 }
408
409 char *context = nullptr;
410 if (!panel_category_is_visible(region)) {
411 context = drag_panel->type->context;
412 }
413
414 /* Find how many instanced panels with this context string. */
415 int start_index = -1;
416 Vector<Panel *> panel_sort;
417 for (Panel &panel : region->panels) {
418 if (panel.type) {
419 if (panel.type->flag & PANEL_TYPE_INSTANCED) {
420 if (panel_type_context_poll(region, panel.type, context)) {
421 if (&panel == drag_panel) {
422 BLI_assert(start_index == -1); /* This panel should only appear once. */
423 start_index = panel_sort.size();
424 }
425 panel_sort.append(&panel);
426 }
427 }
428 }
429 }
430 BLI_assert(start_index != -1); /* The drag panel should definitely be in the list. */
431
432 /* Sort the matching instanced panels by their display order. */
433 std::stable_sort(panel_sort.begin(), panel_sort.end(), [](const Panel *a, const Panel *b) {
434 return a->sortorder < b->sortorder;
435 });
436
437 /* Find how many of those panels are above this panel. */
438 int move_to_index = 0;
439 for (; move_to_index < panel_sort.size(); move_to_index++) {
440 if (panel_sort[move_to_index] == drag_panel) {
441 break;
442 }
443 }
444
445 if (move_to_index == start_index) {
446 /* In this case, the reorder was not changed, so don't do any updates or call the callback. */
447 return;
448 }
449
450 /* Set the bit to tell the interface to instanced the list. */
452
453 CTX_store_set(C, drag_panel->runtime->context);
454
455 /* Finally, move this panel's list item to the new index in its list. */
456 drag_panel->type->reorder(C, drag_panel, move_to_index);
457
458 CTX_store_set(C, nullptr);
459}
460
466static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag, short *flag_index)
467{
468 const bool open = (flag & (1 << *flag_index));
469 bool changed = (open == panel_is_closed(panel));
470
471 SET_FLAG_FROM_TEST(panel->flag, !open, PNL_CLOSED);
472
473 for (Panel &child : panel->children) {
474 *flag_index = *flag_index + 1;
475 changed |= panel_set_expand_from_list_data_recursive(&child, flag, flag_index);
476 }
477 return changed;
478}
479
485{
486 BLI_assert(panel->type != nullptr);
488 if (panel->type->get_list_data_expand_flag == nullptr) {
489 /* Instanced panel doesn't support loading expansion. */
490 return;
491 }
492
493 const short expand_flag = panel->type->get_list_data_expand_flag(C, panel);
494 short flag_index = 0;
495
496 /* Start panel animation if the open state was changed. */
497 if (panel_set_expand_from_list_data_recursive(panel, expand_flag, &flag_index)) {
499 }
500}
501
506{
507 for (Panel &panel : region->panels) {
508 if (panel.runtime_flag & PANEL_ACTIVE) {
509 PanelType *panel_type = panel.type;
510 if (panel_type != nullptr && panel.type->flag & PANEL_TYPE_INSTANCED) {
512 }
513 }
514 }
515}
516
520static void get_panel_expand_flag(const Panel *panel, short *flag, short *flag_index)
521{
522 const bool open = !(panel->flag & PNL_CLOSED);
523 SET_FLAG_FROM_TEST(*flag, open, (1 << *flag_index));
524
525 for (const Panel &child : panel->children) {
526 *flag_index = *flag_index + 1;
527 get_panel_expand_flag(&child, flag, flag_index);
528 }
529}
530
539static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *region)
540{
541 for (Panel &panel : region->panels) {
542 PanelType *panel_type = panel.type;
543 if (panel_type == nullptr) {
544 continue;
545 }
546
547 /* Check for #PANEL_ACTIVE so we only set the expand flag for active panels. */
548 if (panel_type->flag & PANEL_TYPE_INSTANCED && panel.runtime_flag & PANEL_ACTIVE) {
549 short expand_flag;
550 short flag_index = 0;
551 get_panel_expand_flag(&panel, &expand_flag, &flag_index);
552 if (panel.type->set_list_data_expand_flag) {
553 panel.type->set_list_data_expand_flag(C, &panel, expand_flag);
554 }
555 }
556 }
557}
558
560
561/* -------------------------------------------------------------------- */
564
565static bool panel_custom_pin_to_last_get(const Panel *panel)
566{
567 if (panel->type->pin_to_last_property[0] != '\0') {
568 PointerRNA *ptr = panel_custom_data_get(panel);
569 if (ptr != nullptr && *ptr) {
570 return RNA_boolean_get(ptr, panel->type->pin_to_last_property);
571 }
572 }
573
574 return false;
575}
576
577static void panel_custom_pin_to_last_set(const bContext *C, const Panel *panel, const bool value)
578{
579 if (panel->type->pin_to_last_property[0] != '\0') {
580 PointerRNA *ptr = panel_custom_data_get(panel);
581 if (ptr != nullptr && *ptr) {
583 RNA_boolean_set(ptr, panel->type->pin_to_last_property, value);
584 RNA_property_update(const_cast<bContext *>(C), ptr, prop);
585 }
586 }
587}
588
589static bool panel_custom_data_active_get(const Panel *panel)
590{
591 /* The caller should make sure the panel is active and has a type. */
593 BLI_assert(panel->type != nullptr);
594
595 if (panel->type->active_property[0] != '\0') {
596 PointerRNA *ptr = panel_custom_data_get(panel);
597 if (ptr != nullptr && *ptr) {
598 return RNA_boolean_get(ptr, panel->type->active_property);
599 }
600 }
601
602 return false;
603}
604
606{
607 /* Since the panel is interacted with, it should be active and have a type. */
609 BLI_assert(panel->type != nullptr);
610
611 if (panel->type->active_property[0] != '\0') {
612 PointerRNA *ptr = panel_custom_data_get(panel);
614 if (ptr != nullptr && *ptr) {
615 RNA_boolean_set(ptr, panel->type->active_property, true);
616 }
617 }
618}
619
623static void panel_set_flag_recursive(Panel *panel, ePanel_Flag flag, bool value)
624{
625 SET_FLAG_FROM_TEST(panel->flag, value, flag);
626
627 for (Panel &child : panel->children) {
628 panel_set_flag_recursive(&child, flag, value);
629 }
630}
631
635static void panel_set_runtime_flag_recursive(Panel *panel, short flag, bool value)
636{
637 SET_FLAG_FROM_TEST(panel->runtime_flag, value, flag);
638
639 for (Panel &sub_panel : panel->children) {
640 panel_set_runtime_flag_recursive(&sub_panel, flag, value);
641 }
642}
643
644static void panels_collapse_all(ARegion *region, const Panel *from_panel)
645{
646 const bool has_category = panel_category_is_visible(region);
647 const char *category = has_category ? panel_category_active_get(region, false) : nullptr;
648 const PanelType *from_pt = from_panel->type;
649
650 for (Panel &panel : region->panels) {
651 PanelType *pt = panel.type;
652
653 /* Close panels with headers in the same context. */
654 if (pt && from_pt && !(pt->flag & PANEL_TYPE_NO_HEADER)) {
655 if (!pt->context[0] || !from_pt->context[0] || STREQ(pt->context, from_pt->context)) {
656 if ((panel.flag & PNL_PIN) || !category || !pt->category[0] ||
657 STREQ(pt->category, category))
658 {
659 panel.flag |= PNL_CLOSED;
660 }
661 }
662 }
663 }
664}
665
667 const PanelType *panel_type,
668 const char *context)
669{
670 if (!region->runtime->panels_category.is_empty()) {
671 return STREQ(panel_type->category, panel_category_active_get(region, false));
672 }
673
674 if (panel_type->context[0] && STREQ(panel_type->context, context)) {
675 return true;
676 }
677
678 return false;
679}
680
681Panel *panel_find_by_type(ListBaseT<Panel> *lb, const PanelType *pt)
682{
683 const char *idname = pt->idname;
684
685 for (Panel &panel : *lb) {
686 if (STREQLEN(panel.panelname, idname, sizeof(panel.panelname))) {
687 return &panel;
688 }
689 }
690 return nullptr;
691}
692
694 ARegion *region, ListBaseT<Panel> *lb, Block *block, PanelType *pt, Panel *panel, bool *r_open)
695{
696 Panel *panel_last;
697 const char *drawname = CTX_IFACE_(pt->translation_context, pt->label);
698 const bool newpanel = (panel == nullptr);
699
700 if (newpanel) {
701 panel = BKE_panel_new(pt);
702
704 panel->flag |= PNL_CLOSED;
706 }
707
708 panel->ofsx = 0;
709 panel->ofsy = 0;
710 panel->sizex = 0;
711 panel->sizey = 0;
712 panel->blocksizex = 0;
713 panel->blocksizey = 0;
715
716 BLI_addtail(lb, panel);
717 }
718 else {
719 /* Panel already exists. */
720 panel->type = pt;
721 }
722
723 panel->runtime->block = block;
724
725 panel_drawname_set(panel, drawname);
726
727 /* If a new panel is added, we insert it right after the panel that was last added.
728 * This way new panels are inserted in the right place between versions. */
729 for (panel_last = lb->first(); panel_last; panel_last = panel_last->next) {
730 if (panel_last->runtime_flag & PANEL_LAST_ADDED) {
731 BLI_remlink(lb, panel);
732 BLI_insertlinkafter(lb, panel_last, panel);
733 break;
734 }
735 }
736
737 if (newpanel) {
738 panel->sortorder = (panel_last) ? panel_last->sortorder + 1 : 0;
739
740 for (Panel &panel_next : *lb) {
741 if (&panel_next != panel && panel_next.sortorder >= panel->sortorder) {
742 panel_next.sortorder++;
743 }
744 }
745 }
746
747 if (newpanel && region->regiontype == RGN_TYPE_TOOLS &&
748 STRPREFIX(panel->panelname, "FILEBROWSER_PT_"))
749 {
750 const std::string panel_name_str = panel->panelname;
751 const int order = recents::Section("panel.sortorder").get<int>(panel_name_str);
752 if (order >= 0) {
753 panel->sortorder = order;
755 panel->flag, !recents::Section("panel.open").get<bool>(panel_name_str), PNL_CLOSED);
756 }
757 }
758
759 if (panel_last) {
760 panel_last->runtime_flag &= ~PANEL_LAST_ADDED;
761 }
762
763 /* Assign the new panel to the block. */
764 block->panel = panel;
766 if (region->alignment == RGN_ALIGN_FLOAT) {
768 }
769
770 *r_open = !panel_is_closed(panel);
771
772 return panel;
773}
774
781
783{
784 Block *block = panel->runtime->block;
785
786 /* A button group should always be created in #panel_header_buttons_begin. */
787 BLI_assert(!block->button_groups.is_empty());
788
789 ButtonGroup &button_group = block->button_groups.last();
790 button_group.flag &= ~UI_BUTTON_GROUP_LOCK;
791
792 /* Repurpose the first header button group if it is empty, in case the first button added to
793 * the panel doesn't add a new group (if the button is created directly rather than through an
794 * interface layout call). */
795 if (block->button_groups.size() == 1 && button_group.buttons.is_empty()) {
796 button_group.flag &= ~UI_BUTTON_GROUP_PANEL_HEADER;
797 }
798 else {
799 /* Always add a new button group. Although this may result in many empty groups, without it,
800 * new buttons in the panel body not protected with a #block_new_button_group call would
801 * end up in the panel header group. */
803 }
804}
805
806static float panel_region_offset_x_get(const ARegion *region)
807{
808 if (panel_category_tabs_is_visible(region)) {
811 }
812 }
813
814 return 0.0f;
815}
816
821static void panel_calculate_size_recursive(ARegion *region, Panel *panel)
822{
823 int width = panel->blocksizex;
824 int height = panel->blocksizey;
825
826 for (Panel &child_panel : panel->children) {
827 if (child_panel.runtime_flag & PANEL_ACTIVE) {
828 panel_calculate_size_recursive(region, &child_panel);
829 width = max_ii(width, child_panel.sizex);
830 height += get_panel_real_size_y(&child_panel);
831 }
832 }
833
834 /* Update total panel size. */
835 if (panel->runtime_flag & PANEL_NEW_ADDED) {
837 panel->sizex = width;
838 panel->sizey = height;
839 }
840 else {
841 const int old_sizex = panel->sizex, old_sizey = panel->sizey;
842 const int old_region_ofsx = panel->runtime->region_ofsx;
843
844 /* Update width/height if non-zero. */
845 if (width != 0) {
846 panel->sizex = width;
847 }
848 if (height != 0 || !panel_is_closed(panel)) {
849 panel->sizey = height;
850 }
851
852 /* Check if we need to do an animation. */
853 if (panel->sizex != old_sizex || panel->sizey != old_sizey) {
855 panel->ofsy += old_sizey - panel->sizey;
856 }
857
859 if (old_region_ofsx != panel->runtime->region_ofsx) {
861 }
862 }
863}
864
865void panel_end(Panel *panel, int width, int height)
866{
867 /* Store the size of the buttons layout in the panel. The actual panel size
868 * (including sub-panels) is calculated in #panels_end. */
869 panel->blocksizex = width;
870 panel->blocksizey = height;
871}
872
874{
875 MEM_SAFE_DELETE(panel->drawname);
876 panel->drawname = BLI_strdupn(name.data(), name.size());
877}
878
879static void offset_panel_block(Block *block)
880{
881 const uiStyle *style = style_get_dpi();
882
883 /* Compute bounds and offset. */
884 block_bounds_calc(block);
885
886 const int panels_space = style->panelspace;
887 const int ofsy = block->panel->sizey - panels_space;
888
889 for (Button &but : block->buttons()) {
890 but.rect.ymin += ofsy;
891 but.rect.ymax += ofsy;
892 }
893 for (LayoutPanelBody &body : block->panel->runtime->layout_panels.bodies) {
894 body.start_y -= panels_space;
895 body.end_y -= panels_space;
896 }
897 for (LayoutPanelHeader &header : block->panel->runtime->layout_panels.headers) {
898 header.start_y -= panels_space;
899 header.end_y -= panels_space;
900 }
901
902 block->rect.xmax = block->panel->sizex;
903 block->rect.ymax = block->panel->sizey;
904 block->rect.xmin = block->rect.ymin = 0.0;
905}
906
911
912static void panel_matches_search_filter_recursive(const Panel *panel, bool *filter_matches)
913{
914 *filter_matches |= bool(panel->runtime_flag & PANEL_SEARCH_FILTER_MATCH);
915
916 /* If the panel has no match we need to make sure that its children are too. */
917 if (!*filter_matches) {
918 for (const Panel &child_panel : panel->children) {
919 panel_matches_search_filter_recursive(&child_panel, filter_matches);
920 }
921 }
922}
923
925{
926 bool search_filter_matches = false;
927 panel_matches_search_filter_recursive(panel, &search_filter_matches);
928 return search_filter_matches;
929}
930
935 Panel *panel,
936 const bool use_search_closed)
937{
938 /* This has to run on inactive panels that may not have a type,
939 * but we can prevent running on header-less panels in some cases. */
940 if (panel->type == nullptr || !(panel->type->flag & PANEL_TYPE_NO_HEADER)) {
942 }
943
944 for (Panel &child_panel : panel->children) {
945 /* Don't check if the sub-panel is active, otherwise the
946 * expansion won't be reset when the parent is closed. */
947 panel_set_expansion_from_search_filter_recursive(C, &child_panel, use_search_closed);
948 }
949}
950
955 ARegion *region,
956 const bool use_search_closed)
957{
958 for (Panel &panel : region->panels) {
959 /* Don't check if the panel is active, otherwise the expansion won't
960 * be correct when switching back to tab after exiting search. */
961 panel_set_expansion_from_search_filter_recursive(C, &panel, use_search_closed);
962 }
964}
965
970static void panel_remove_invisible_layouts_recursive(Panel *panel, const Panel *parent_panel)
971{
972 Block *block = panel->runtime->block;
973 BLI_assert(block != nullptr);
974 BLI_assert(block->active);
975 if (parent_panel != nullptr && panel_is_closed(parent_panel)) {
976 /* The parent panel is closed, so this panel can be completely removed. */
977 block_set_search_only(block, true);
978 for (Button &but : block->buttons()) {
979 but.flag |= UI_HIDDEN;
980 }
981 }
982 else if (panel_is_closed(panel)) {
983 /* If sub-panels have no search results but the parent panel does, then the parent panel open
984 * and the sub-panels will close. In that case there must be a way to hide the buttons in the
985 * panel but keep the header buttons. */
986 for (const ButtonGroup &button_group : block->button_groups) {
987 if (button_group.flag & UI_BUTTON_GROUP_PANEL_HEADER) {
988 continue;
989 }
990 for (Button *but : button_group.buttons) {
991 but->flag |= UI_HIDDEN;
992 }
993 }
994 }
995
996 for (Panel &child_panel : panel->children) {
997 if (child_panel.runtime_flag & PANEL_ACTIVE) {
998 BLI_assert(child_panel.runtime->block != nullptr);
999 panel_remove_invisible_layouts_recursive(&child_panel, panel);
1000 }
1001 }
1002}
1003
1005{
1006 for (Panel &panel : region->panels) {
1007 if (panel.runtime_flag & PANEL_ACTIVE) {
1008 BLI_assert(panel.runtime->block != nullptr);
1010 }
1011 }
1012}
1013
1014bool panel_is_closed(const Panel *panel)
1015{
1016 /* Header-less panels can never be closed, otherwise they could disappear. */
1017 if (panel->type && panel->type->flag & PANEL_TYPE_NO_HEADER) {
1018 return false;
1019 }
1020
1022 return !panel_matches_search_filter(panel);
1023 }
1024
1025 return panel->flag & PNL_CLOSED;
1026}
1027
1028bool panel_is_active(const Panel *panel)
1029{
1030 return panel->runtime_flag & PANEL_ACTIVE;
1031}
1032
1034
1035/* -------------------------------------------------------------------- */
1038
1039void panels_draw(const bContext *C, ARegion *region)
1040{
1041 /* Draw in reverse order, because #Blocks are added in reverse order
1042 * and we need child panels to draw on top. */
1043 for (Block &block : region->runtime->uiblocks.items_reversed()) {
1044 if (block.active && block.panel && !panel_is_dragging(block.panel) &&
1045 !block_is_search_only(&block))
1046 {
1047 block_draw(C, &block);
1048 }
1049 }
1050
1051 for (Block &block : region->runtime->uiblocks.items_reversed()) {
1052 if (block.active && block.panel && panel_is_dragging(block.panel) &&
1053 !block_is_search_only(&block))
1054 {
1055 block_draw(C, &block);
1056 }
1057 }
1058}
1059
1061{
1062 for (ui::Block &block : region->runtime->uiblocks) {
1063 if (block.panel) {
1064 block.post_block_layout_fns_pending = false;
1065 if (block.active) {
1066 block_post_layout_callbacks_exec(C, region, &block);
1067 }
1068 }
1069 }
1070}
1071
1072#define PNL_ICON UI_UNIT_X /* Could be UI_UNIT_Y too. */
1073
1074void panel_label_offset(const Block *block, int *r_x, int *r_y)
1075{
1076 Panel *panel = block->panel;
1077 const bool is_subpanel = (panel->type && panel->type->parent);
1078
1079 *r_x = UI_UNIT_X * 1.0f;
1080 *r_y = UI_UNIT_Y * 1.5f;
1081
1082 if (is_subpanel) {
1083 *r_x += (0.7f * UI_UNIT_X);
1084 }
1085}
1086
1087static void panel_title_color_get(const Panel *panel,
1088 const bool show_background,
1089 const bool region_search_filter_active,
1090 uchar r_color[4])
1091{
1092 const bTheme *btheme = theme::theme_get();
1093
1094 if (!show_background) {
1095 /* Use menu colors for floating panels. */
1096 const uiWidgetColors *wcol = &btheme->tui.wcol_menu_back;
1097 copy_v4_v4_uchar(r_color, static_cast<const uchar *>(wcol->text));
1098 return;
1099 }
1100
1101 const bool search_match = panel_matches_search_filter(panel);
1102 copy_v4_v4_uchar(r_color, static_cast<const uchar *>(btheme->tui.panel_title));
1103 if (region_search_filter_active && !search_match) {
1104 r_color[0] *= 0.5;
1105 r_color[1] *= 0.5;
1106 r_color[2] *= 0.5;
1107 }
1108}
1109
1110static void panel_draw_border(const Panel *panel,
1111 const rcti *rect,
1112 const rcti *header_rect,
1113 const bool is_active)
1114{
1115 const bool is_subpanel = panel->type->parent != nullptr;
1116 if (is_subpanel) {
1117 return;
1118 }
1119
1120 float color[4];
1122 if (color[3] == 0.0f) {
1123 return; /* No border to draw. */
1124 }
1125
1126 const bTheme *btheme = theme::theme_get();
1127 const float aspect = panel->runtime->block->aspect;
1128 const float radius = (btheme->tui.panel_roundness * U.widget_unit * 0.5f) / aspect;
1130
1131 rctf box_rect;
1132 box_rect.xmin = rect->xmin;
1133 box_rect.xmax = rect->xmax;
1134 box_rect.ymin = panel_is_closed(panel) ? header_rect->ymin : rect->ymin;
1135 box_rect.ymax = header_rect->ymax;
1136 draw_roundbox_4fv(&box_rect, false, radius, color);
1137}
1138
1139static void panel_draw_aligned_widgets(const uiStyle *style,
1140 const Panel *panel,
1141 const rcti *header_rect,
1142 const float aspect,
1143 const bool show_pin,
1144 const bool show_background,
1145 const bool region_search_filter_active)
1146{
1147 const bool is_subpanel = panel->type->parent != nullptr;
1148 const uiFontStyle *fontstyle = (is_subpanel) ? &style->widget : &style->paneltitle;
1149
1150 const int header_height = BLI_rcti_size_y(header_rect);
1151 const int header_width = BLI_rcti_size_x(header_rect);
1152 const int scaled_unit = round_fl_to_int(UI_UNIT_X / aspect);
1153
1154 /* Offset triangle and text to the right for sub-panels. */
1155 rcti widget_rect;
1156 widget_rect.xmin = header_rect->xmin + (is_subpanel ? scaled_unit * 0.7f : 0);
1157 widget_rect.xmax = header_rect->xmax;
1158 widget_rect.ymin = header_rect->ymin;
1159 widget_rect.ymax = header_rect->ymax;
1160
1161 uchar title_color[4];
1162 panel_title_color_get(panel, show_background, region_search_filter_active, title_color);
1163 title_color[3] = 255;
1164
1165 /* Draw collapse icon. */
1166 {
1167 const float size_y = BLI_rcti_size_y(&widget_rect);
1169 float alpha = 0.8f;
1170 /* Dim as its space is reduced to zero. */
1171 if (header_width < (scaled_unit * 4)) {
1172 alpha *= std::max(float(header_width - scaled_unit) / float(scaled_unit * 3), 0.0f);
1173 }
1174 icon_draw_ex(widget_rect.xmin + size_y * 0.2f,
1175 widget_rect.ymin + size_y * (panel_is_closed(panel) ? 0.17f : 0.14f),
1176 panel_is_closed(panel) ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT,
1177 aspect * UI_INV_SCALE_FAC,
1178 alpha,
1179 0.0f,
1180 title_color,
1181 false,
1184 }
1185
1186 /* Draw text label. */
1187 if (panel->drawname && panel->drawname[0] != '\0') {
1188 rcti title_rect;
1189 title_rect.xmin = widget_rect.xmin + (panel->labelofs / aspect) + scaled_unit * 1.1f;
1190 title_rect.xmax = widget_rect.xmax;
1191 if (!is_subpanel && show_background) {
1192 /* Don't draw over the drag widget. */
1193 title_rect.xmax -= scaled_unit;
1194 }
1195 title_rect.ymin = widget_rect.ymin - 2.0f / aspect;
1196 title_rect.ymax = widget_rect.ymax;
1197
1198 FontStyleDrawParams params{};
1199 params.align = UI_STYLE_TEXT_LEFT;
1201 fontstyle, &title_rect, panel->drawname, strlen(panel->drawname), title_color, &params);
1202 }
1203
1204 /* Draw the pin icon. */
1205 if (show_pin && (panel->flag & PNL_PIN)) {
1207 icon_draw_ex(widget_rect.xmax - scaled_unit * 2.2f,
1208 widget_rect.ymin + 5.0f / aspect,
1209 ICON_PINNED,
1210 aspect * UI_INV_SCALE_FAC,
1211 1.0f,
1212 0.0f,
1213 title_color,
1214 false,
1217 }
1218
1219 /* Draw drag widget. */
1220 if (!is_subpanel && show_background) {
1221 const float x = widget_rect.xmax - scaled_unit * 1.15;
1222 const float y = widget_rect.ymin + (header_height - (header_height * 0.7f)) * 0.5f;
1223 const bool is_pin = panel_custom_pin_to_last_get(panel);
1224 const int icon = is_pin ? ICON_PINNED : ICON_GRIP;
1225 const float size = aspect * UI_INV_SCALE_FAC;
1226 float alpha = is_pin ? 1.0f : 0.5f;
1227 if (header_width < (scaled_unit * 5)) {
1228 alpha *= std::max((header_width - scaled_unit) / float(scaled_unit * 4), 0.0f);
1229 }
1230 icon_draw_ex(x, y, icon, size, alpha, 0.0f, title_color, false, UI_NO_ICON_OVERLAY_TEXT);
1231 }
1232}
1233
1235 const Panel *panel,
1236 const float radius,
1237 float subpanel_backcolor[4])
1238{
1239 /* Draw backdrops for layout panels. */
1240 const float aspect = block_is_popup_any(panel->runtime->block) ? panel->runtime->block->aspect :
1241 1.0f;
1242
1243 for (const LayoutPanelBody &body : panel->runtime->layout_panels.bodies) {
1244
1245 rctf panel_blockspace = panel->runtime->block->rect;
1246 panel_blockspace.ymax = panel->runtime->block->rect.ymax + body.end_y;
1247 panel_blockspace.ymin = panel->runtime->block->rect.ymax + body.start_y;
1248
1249 if (panel_blockspace.ymax <= panel->runtime->block->rect.ymin) {
1250 /* Layout panels no longer fits in block rectangle, stop drawing backdrops. */
1251 break;
1252 }
1253 if (panel_blockspace.ymin >= panel->runtime->block->rect.ymax) {
1254 /* Skip layout panels that scrolled to the top of the block rectangle. */
1255 continue;
1256 }
1257 /* If the layout panel is at the end of the root panel, it's bottom corners are rounded. */
1258 const bool is_main_panel_end = panel_blockspace.ymin - panel->runtime->block->rect.ymin <
1259 (10.0f * UI_SCALE_FAC / aspect);
1260 if (is_main_panel_end) {
1261 panel_blockspace.ymin = panel->runtime->block->rect.ymin;
1263 }
1264 else {
1266 }
1267 panel_blockspace.ymax = std::min(panel_blockspace.ymax, panel->runtime->block->rect.ymax);
1268
1269 rcti panel_pixelspace = rect_to_pixelrect(region, panel->runtime->block, &panel_blockspace);
1270 rctf panel_pixelspacef;
1271 BLI_rctf_rcti_copy(&panel_pixelspacef, &panel_pixelspace);
1272 draw_roundbox_4fv(&panel_pixelspacef, true, radius, subpanel_backcolor);
1273 }
1274}
1275
1276static void panel_draw_softshadow(const rctf *box_rect,
1277 const int roundboxalign,
1278 const float radius,
1279 const float shadow_width)
1280{
1281 const float outline = U.pixelsize;
1282
1283 rctf shadow_rect = *box_rect;
1284 BLI_rctf_pad(&shadow_rect, -outline, -outline);
1285 draw_roundbox_corner_set(roundboxalign);
1286
1287 const float shadow_alpha = theme::theme_get()->tui.menu_shadow_fac;
1288 draw_dropshadow(&shadow_rect, radius, shadow_width, 1.0f, shadow_alpha);
1289}
1290
1291static void panel_draw_aligned_backdrop(const ARegion *region,
1292 const Panel *panel,
1293 const rcti *rect,
1294 const rcti *header_rect)
1295{
1296 const bool is_open = !panel_is_closed(panel);
1297 const bool is_subpanel = panel->type->parent != nullptr;
1298 const bool has_header = (panel->type->flag & PANEL_TYPE_NO_HEADER) == 0;
1299 const bool is_dragging = panel_is_dragging(panel);
1300
1301 if (is_subpanel && !is_open) {
1302 return;
1303 }
1304
1305 const bTheme *btheme = theme::theme_get();
1306 const float aspect = panel->runtime->block->aspect;
1307 const float radius = btheme->tui.panel_roundness * U.widget_unit * 0.5f / aspect;
1308
1311
1312 /* Draw shadow on top-level panels with headers during drag or region overlap. */
1313 if (!is_subpanel && has_header && (region->overlap || is_dragging)) {
1314 /* Make shadow wider (at least 16px) while the panel is being dragged. */
1315 const float shadow_width = is_dragging ? max_ii(int(16.0f * UI_SCALE_FAC),
1318 const int roundboxalign = is_open ? CNR_BOTTOM_RIGHT | CNR_BOTTOM_LEFT : CNR_ALL;
1319
1320 rctf box_rect;
1321 box_rect.xmin = rect->xmin;
1322 box_rect.xmax = rect->xmax;
1323 box_rect.ymin = is_open ? rect->ymin : header_rect->ymin;
1324 box_rect.ymax = header_rect->ymax;
1325 panel_draw_softshadow(&box_rect, roundboxalign, radius, shadow_width);
1326 }
1327
1328 /* Panel backdrop. */
1329 if (is_open || !has_header) {
1330 float panel_backcolor[4];
1332 if (!has_header) {
1333 theme::get_color_4fv(TH_BACK, panel_backcolor);
1334 }
1335 else {
1336 theme::get_color_4fv((is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK), panel_backcolor);
1337 }
1338
1339 rctf box_rect;
1340 const float padding = is_subpanel ? U.widget_unit * 0.1f / aspect : 0.0f;
1341 box_rect.xmin = rect->xmin + padding;
1342 box_rect.xmax = rect->xmax - padding;
1343 box_rect.ymin = rect->ymin + padding;
1344 box_rect.ymax = rect->ymax;
1345 draw_roundbox_4fv(&box_rect, true, radius, panel_backcolor);
1346
1347 float subpanel_backcolor[4];
1348 theme::get_color_4fv(TH_PANEL_SUB_BACK, subpanel_backcolor);
1349 draw_layout_panels_backdrop(region, panel, radius, subpanel_backcolor);
1350 }
1351
1352 /* Panel header backdrops for non sub-panels. */
1353 if (!is_subpanel && has_header) {
1354 float panel_headercolor[4];
1355 if (panel_matches_search_filter(panel)) {
1356 /* NOTE: This should be replaced by global theme color. */
1358 }
1359 else {
1360 theme::get_color_4fv(TH_PANEL_HEADER, panel_headercolor);
1361 }
1362
1364
1365 /* Change the width a little bit to line up with the sides. */
1366 rctf box_rect;
1367 box_rect.xmin = rect->xmin;
1368 box_rect.xmax = rect->xmax;
1369 box_rect.ymin = header_rect->ymin;
1370 box_rect.ymax = header_rect->ymax;
1371 draw_roundbox_4fv(&box_rect, true, radius, panel_headercolor);
1372 }
1373
1376}
1377
1378void draw_aligned_panel(const ARegion *region,
1379 const uiStyle *style,
1380 const Block *block,
1381 const rcti *rect,
1382 const bool show_pin,
1383 const bool show_background,
1384 const bool region_search_filter_active)
1385{
1386 const Panel *panel = block->panel;
1387
1388 if (panel->sizex < 0 || panel->sizey < 0) {
1389 /* Nothing to draw. */
1390 return;
1391 }
1392
1393 /* Add 0.001f to prevent flicker from float inaccuracy. */
1394 const rcti header_rect = {
1395 rect->xmin,
1396 rect->xmax,
1397 rect->ymax,
1398 rect->ymax + int(floor(PNL_HEADER / block->aspect + 0.001f)),
1399 };
1400
1401 if (show_background || (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
1402 panel_draw_aligned_backdrop(region, panel, rect, &header_rect);
1403 }
1404
1405 /* Draw the widgets and text in the panel header. */
1406 if (!(panel->type->flag & PANEL_TYPE_NO_HEADER)) {
1408 panel,
1409 &header_rect,
1410 block->aspect,
1411 show_pin,
1412 show_background,
1413 region_search_filter_active);
1414 }
1415
1416 /* Draw the panel outline on non-transparent panels. */
1417 if (panel_should_show_background(region, panel->type)) {
1418 panel_draw_border(panel, rect, &header_rect, panel_custom_data_active_get(panel));
1419 }
1420}
1421
1422bool panel_should_show_background(const ARegion *region, const PanelType *panel_type)
1423{
1424 if (region->alignment == RGN_ALIGN_FLOAT) {
1425 return false;
1426 }
1427
1428 if (panel_type && panel_type->flag & PANEL_TYPE_NO_HEADER) {
1429 if (region->regiontype == RGN_TYPE_TOOLS) {
1430 /* We never want a background around active tools. */
1431 return false;
1432 }
1433 /* Without a header there is no background except for region overlap. */
1434 return region->overlap != 0;
1435 }
1436
1437 return true;
1438}
1439
1441
1442/* -------------------------------------------------------------------- */
1445
1446#define TABS_PADDING_BETWEEN_FACTOR 4.0f
1447#define TABS_PADDING_TEXT_FACTOR 6.0f
1448
1449static constexpr const char *panel_category_tabs_block_name = "panel_category_tabs";
1450
1452{
1453 const float aspect = BLI_rctf_size_y(&region->v2d.cur) /
1454 (BLI_rcti_size_y(&region->v2d.mask) + 1);
1455 const bool too_narrow = BLI_rcti_size_x(&region->winrct) <=
1457 aspect);
1458 if (!too_narrow) {
1459 return;
1460 }
1461 /* Enlarge region. */
1462 int new_width = region->runtime->type->prefsizex ? region->runtime->type->prefsizex : 250;
1463
1464 if (new_width < int(UI_PANEL_CATEGORY_MIN_WIDTH + PANEL_MIN_DRAW_WIDTH)) {
1466 new_width = UI_SIDEBAR_PANEL_WIDTH;
1467 }
1468
1469 panel_region_width_set(region, aspect, new_width);
1471 ED_region_tag_redraw(region);
1472 /* Reset scroll to the top (#38348). */
1473 view2d_offset(&region->v2d, -1.0f, 1.0f);
1474}
1475
1477 StringRef category,
1478 StringRef active)
1479{
1480 ARegion *region = CTX_wm_region(&C);
1481 if (category == active) {
1482 return;
1483 }
1484 expand_panel_region(C, region);
1485}
1486
1488 ARegion *region,
1489 const char *category_id_active)
1490{
1491 const bool is_left = RGN_ALIGN_ENUM_FROM_MASK(region->alignment) != RGN_ALIGN_RIGHT;
1492 View2D *v2d = &region->v2d;
1493 const uiStyle *style = style_get();
1494 const uiFontStyle *fstyle = &style->widget;
1495 fontstyle_set(fstyle);
1496 const int fontid = fstyle->uifont_id;
1497 const float aspect = BLI_rctf_size_y(&region->v2d.cur) /
1498 (BLI_rcti_size_y(&region->v2d.mask) + 1);
1499 const float zoom = 1.0f / aspect;
1500 const int px = U.pixelsize;
1501 const int category_tabs_width = std::round(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom);
1502 const float dpi_fac = UI_SCALE_FAC;
1503 /* Padding of tabs around text. */
1504 const int tab_v_pad_text = round_fl_to_int(TABS_PADDING_TEXT_FACTOR * dpi_fac * zoom) + 2 * px;
1505 /* Padding between tabs. */
1506 const int tab_v_pad = round_fl_to_int(TABS_PADDING_BETWEEN_FACTOR * dpi_fac * zoom);
1507
1508 /* Primary theme colors. */
1509 uchar theme_col_back[4];
1510 /* Draw the background. */
1511 uchar theme_col_tab_bg[4];
1512 theme::get_color_4ubv(TH_TAB_BACK, theme_col_tab_bg);
1513 theme::get_color_4ubv(TH_BACK, theme_col_back);
1514 const bool is_alpha = (region->overlap && (theme_col_back[3] != 255));
1515
1516 /* Draw background. */
1517 if (!is_alpha || theme_col_tab_bg[3] != 0) {
1518 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
1520
1521 if (is_alpha) {
1523 immUniformColor4ubv(theme_col_tab_bg);
1524 }
1525 else {
1526 immUniformColor3ubv(theme_col_tab_bg);
1527 }
1528
1529 if (is_left) {
1530 immRectf(pos,
1531 v2d->mask.xmin,
1532 v2d->mask.ymin,
1533 v2d->mask.xmin + category_tabs_width,
1534 v2d->mask.ymax);
1535 }
1536 else {
1537 immRectf(pos,
1538 v2d->mask.xmax - category_tabs_width,
1539 v2d->mask.ymin,
1540 v2d->mask.xmax + 1,
1541 v2d->mask.ymax);
1542 }
1543
1544 if (is_alpha) {
1546 }
1547
1549 }
1550 /* If the area is too small to show panels, then don't show any tabs as active. */
1551 const bool too_narrow = BLI_rcti_size_x(&region->winrct) <
1553 aspect);
1554 /* #widget_roundbox_set has this correction, keep in sync. */
1555 const int align_pad = (!region->overlap && !is_left) ? px : 0;
1556 /* Same for all tabs. */
1557 const int rct_xmin = is_left ? (v2d->mask.xmin + 3) :
1558 (v2d->mask.xmax - category_tabs_width + align_pad);
1559 const int rct_xmax = is_left ? (v2d->mask.xmin + category_tabs_width) : (v2d->mask.xmax - 3);
1560 /* NOTE: This block is created in window coordinates. */
1562
1563 const int w = (rct_xmax - rct_xmin);
1564
1565 Layout &layout = block_layout(block,
1568 rct_xmin,
1569 v2d->mask.ymax - 1,
1570 w,
1571 0,
1572 0,
1574 Layout &col = layout.column(true);
1576
1577 uiDefBut(block, ButtonType::Sepr, "", 0, 0, w, tab_v_pad, nullptr, 0.0, 0.0, "");
1578
1579 const bool compact = U.uiflag2 & USER_UIFLAG2_PANEL_TABS_COMPACT;
1580
1581 /* Check the region type supports categories to avoid an assert
1582 * for showing 3D view panels in the properties space. */
1585 }
1586 float fstyle_points = fstyle->points;
1587 fontscale(&fstyle_points, aspect);
1588 BLF_size(fontid, fstyle_points * UI_SCALE_FAC);
1589
1591 reinterpret_cast<ID *>(CTX_wm_screen(C)), RNA_Region, region);
1592 PropertyRNA *prop = RNA_struct_find_property(&ptr, "active_panel_category");
1593 for (auto [i, pc_dyn] : region->runtime->panels_category.enumerate()) {
1594 Button *button = nullptr;
1595 const char *category_id = pc_dyn.idname;
1596 const char *category_id_draw = IFACE_(category_id);
1597 const int category_width = round_fl_to_int(
1598 compact ? 0 : BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX));
1599
1600 const int h = compact ? w + align_pad : category_width + tab_v_pad_text * 2;
1601
1602 if (compact && pc_dyn.icon != ICON_NONE) {
1603 button = uiDefIconButR_prop(
1604 block, ButtonType::Tab, pc_dyn.icon, 0, 0, w, h, &ptr, prop, -1, 0, i, nullptr);
1605 }
1606 else {
1607 std::string title = category_id_draw;
1608 if (compact) {
1609 size_t category_draw_len = BLF_DRAW_STR_DUMMY_MAX;
1610
1611 int char_offset1 = BLI_str_utf8_offset_from_index(category_id_draw, category_draw_len, 1);
1612 if (char_offset1 > 2) {
1613 /* Only a single complex character, symbol, or emoji. */
1614 title = std::string(category_id_draw, char_offset1);
1615 }
1616 else {
1617 int char_offset2 = BLI_str_utf8_offset_from_index(
1618 category_id_draw, category_draw_len, 2);
1619 char *space = BLI_strcasestr(category_id_draw, " ");
1620 if (char_offset2 == 2 && isupper(category_id_draw[1])) {
1621 /* First two characters are Latin with second uppercase. */
1622 title = std::string(category_id_draw, char_offset2);
1623 }
1624 else if (space && category_draw_len > (space - category_id_draw)) {
1625 /* First characters from each of the first two words. */
1626 title = std::string(category_id_draw, char_offset1) + std::string(space + 1, 1);
1627 }
1628 else {
1629 /* First two characters of a single word. */
1630 title = std::string(category_id_draw, char_offset2);
1631 }
1632 }
1633 }
1634 button = uiDefIconTextButR_prop(
1635 block, ButtonType::Tab, ICON_NONE, title, 0, 0, w, h, &ptr, prop, -1, 0, i, nullptr);
1636 button->text_direction = compact ? TextDirection::Default :
1638 }
1639 button->flag |= ui::BUT_DRAG_LOCK_X;
1640 if (compact) {
1642 button, [category = std::string(category_id)](const blender::ui::Button * /*but*/) {
1643 return TIP_(category);
1644 });
1645 /* Avoid default enum button tooltip for `RNA_Region::active_panel_category`. */
1647 *button, [category = std::string(category_id)](bContext & /*C*/, ui::TooltipData &data) {
1649 data, TIP_(category), {}, TIP_STYLE_HEADER, TIP_LC_NORMAL, false);
1650 });
1651 }
1652 else {
1653 /* Avoid default enum button tooltip for `RNA_Region::active_panel_category`. */
1655 }
1656 button_func_set(button,
1657 [category = std::string(category_id),
1658 active = std::string(category_id_active)](bContext &C) -> void {
1659 expand_panel_region_on_category_change(C, category, active);
1660 });
1662 button,
1663 [category = std::string(category_id),
1664 active = std::string(category_id_active),
1665 too_narrow](const Button &) -> bool { return category == active && !too_narrow; });
1666
1667 if (!too_narrow && !region->runtime->search_filter.empty() &&
1668 !region->runtime->categories_search_match.contains_as(pc_dyn.idname))
1669 {
1671 }
1672
1673 if (pc_dyn.next) {
1674 uiDefBut(block, ButtonType::Sepr, "", 0, 0, w, tab_v_pad, nullptr, 0.0, 0.0, "");
1675 }
1676 }
1677 uiDefBut(block, ButtonType::Sepr, "", 0, 0, w, tab_v_pad, nullptr, 0.0, 0.0, "");
1678
1679 const int2 co = block_layout_resolve(block);
1680 const int max_scroll = std::max(-co.y, 0);
1681 const int scroll = std::clamp(region->category_scroll, 0, max_scroll);
1682 region->category_scroll = scroll;
1683 block_end(C, block);
1684 block->aspect = aspect;
1685
1686 block_translate(block, 0, region->category_scroll);
1687
1688 /* Align buttons the panel content when region overlap is disabled. */
1689 if (!is_alpha) {
1690 for (Button &button : block->buttons()) {
1691 button.drawflag |= is_left ? BUT_ALIGN_RIGHT : BUT_ALIGN_LEFT;
1692 }
1693 }
1694
1695 block_draw(C, block);
1696
1697 /* Avoid buttons being aligned to the region on redraws. */
1698 for (Button &button : block->buttons()) {
1699 button.drawflag &= ~BUT_ALIGN_ALL;
1700 }
1701}
1702
1703#undef TABS_PADDING_BETWEEN_FACTOR
1704#undef TABS_PADDING_TEXT_FACTOR
1705
1707
1708void panel_category_show_tab(const bContext &C, ARegion *region, StringRef category)
1709{
1711 const View2D *v2d = &region->v2d;
1712 const Block *block = region->runtime->block_name_map.lookup_as(panel_category_tabs_block_name);
1713 if (!block) {
1714 return;
1715 }
1717 reinterpret_cast<ID *>(CTX_wm_screen(&C)), RNA_Region, region);
1718 PropertyRNA *prop = RNA_struct_find_property(&ptr, "active_panel_category");
1719 for (auto [i, pc_dyn] : region->runtime->panels_category.enumerate()) {
1720 const bool found = category == pc_dyn.idname;
1721 if (!found) {
1722 continue;
1723 }
1724 for (Button &button : block->buttons()) {
1725 if (button.rnapoin.data == region && button.rnaprop == prop && button.hardmax == i) {
1726 region->category_scroll = -(button.rect.ymax - region->category_scroll - v2d->mask.ymax);
1727 break;
1728 }
1729 }
1730 break;
1731 }
1732 ED_region_tag_redraw(region);
1733 return;
1734}
1735
1736static int panel_category_show_active_tab(const bContext &C, ARegion *region, const int mval[2])
1737{
1738 if (!ED_region_panel_category_gutter_isect_xy(region, mval)) {
1740 }
1742 panel_category_show_tab(C, region, region->runtime->category);
1743 return WM_UI_HANDLER_BREAK;
1744}
1745
1746/* -------------------------------------------------------------------- */
1749
1750static int get_panel_size_y(const Panel *panel)
1751{
1752 if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
1753 return panel->sizey;
1754 }
1755
1756 return PNL_HEADER + panel->sizey;
1757}
1758
1759static int get_panel_real_size_y(const Panel *panel)
1760{
1761 const int sizey = panel_is_closed(panel) ? 0 : panel->sizey;
1762
1763 if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
1764 return sizey;
1765 }
1766
1767 return PNL_HEADER + sizey;
1768}
1769
1770int panel_size_y(const Panel *panel)
1771{
1772 return get_panel_real_size_y(panel);
1773}
1774
1779static int get_panel_real_ofsy(Panel *panel)
1780{
1781 if (panel_is_closed(panel)) {
1782 return panel->ofsy + panel->sizey;
1783 }
1784 return panel->ofsy;
1785}
1786
1787bool panel_is_dragging(const Panel *panel)
1788{
1789 return panel->runtime_flag & PANEL_IS_DRAG_DROP;
1790}
1791
1799
1800static bool find_highest_panel(const PanelSort &a, const PanelSort &b)
1801{
1802 /* Stick uppermost header-less panels to the top of the region -
1803 * prevent them from being sorted (multiple header-less panels have to be sorted though). */
1804 if (a.panel->type->flag & PANEL_TYPE_NO_HEADER && b.panel->type->flag & PANEL_TYPE_NO_HEADER) {
1805 /* Pass the no-header checks and check for `ofsy` and #Panel.sortorder below. */
1806 }
1807 else if (a.panel->type->flag & PANEL_TYPE_NO_HEADER) {
1808 return true;
1809 }
1810 else if (b.panel->type->flag & PANEL_TYPE_NO_HEADER) {
1811 return false;
1812 }
1813
1814 const bool pin_last_a = panel_custom_pin_to_last_get(a.panel);
1815 const bool pin_last_b = panel_custom_pin_to_last_get(b.panel);
1816 if (pin_last_a && !pin_last_b) {
1817 return false;
1818 }
1819 if (!pin_last_a && pin_last_b) {
1820 return true;
1821 }
1822
1823 if (a.panel->ofsy + a.panel->sizey < b.panel->ofsy + b.panel->sizey) {
1824 return false;
1825 }
1826 if (a.panel->ofsy + a.panel->sizey > b.panel->ofsy + b.panel->sizey) {
1827 return true;
1828 }
1829 return a.panel->sortorder < b.panel->sortorder;
1830}
1831
1832static bool compare_panel(const PanelSort &a, const PanelSort &b)
1833{
1834 return a.panel->sortorder < b.panel->sortorder;
1835}
1836
1837static void align_sub_panels(Panel *panel)
1838{
1839 /* Position sub panels. */
1840 int ofsy = panel->ofsy + panel->sizey - panel->blocksizey;
1841
1842 for (Panel &pachild : panel->children) {
1843 if (pachild.runtime_flag & PANEL_ACTIVE) {
1844 pachild.ofsx = panel->ofsx;
1845 pachild.ofsy = ofsy - get_panel_size_y(&pachild);
1846 ofsy -= get_panel_real_size_y(&pachild);
1847
1848 if (pachild.children.first_) {
1849 align_sub_panels(&pachild);
1850 }
1851 }
1852 }
1853}
1854
1858static bool uiAlignPanelStep(ARegion *region, const float factor, const bool drag)
1859{
1860 Vector<PanelSort> panel_sort;
1861 for (Panel &panel : region->panels) {
1862 if (panel.runtime_flag & PANEL_ACTIVE) {
1863 /* These panels should have types since they are currently displayed to the user. */
1864 BLI_assert(panel.type != nullptr);
1865 panel_sort.append({&panel, 0, 0});
1866 }
1867 }
1868 if (panel_sort.is_empty()) {
1869 return false;
1870 }
1871
1872 if (drag) {
1873 /* While dragging, sort based on location and update #Panel.sortorder. */
1874 std::stable_sort(panel_sort.begin(), panel_sort.end(), find_highest_panel);
1875 for (int i : panel_sort.index_range()) {
1876 panel_sort[i].panel->sortorder = i;
1877 }
1878 }
1879 else {
1880 /* Otherwise use #Panel.sortorder. */
1881 std::stable_sort(panel_sort.begin(), panel_sort.end(), compare_panel);
1882 }
1883 /* X offset. */
1884 const int region_offset_x = panel_region_offset_x_get(region);
1885 for (PanelSort &ps : panel_sort) {
1886 const bool show_background = panel_should_show_background(region, ps.panel->type);
1887 ps.panel->runtime->region_ofsx = region_offset_x;
1888 ps.new_offset_x = region_offset_x + (show_background ? UI_PANEL_MARGIN_X : 0);
1889 }
1890
1891 /* Y offset. */
1892 int y = 0;
1895 }
1896 for (PanelSort &ps : panel_sort) {
1897 const bool show_background = panel_should_show_background(region, ps.panel->type);
1898
1899 y -= get_panel_real_size_y(ps.panel);
1900
1901 /* Separate panel boxes a bit further (if they are drawn). */
1902 if (show_background) {
1904 }
1905 ps.new_offset_y = y;
1906 /* The header still draws offset by the size of closed panels, so apply the offset here. */
1907 if (panel_is_closed(ps.panel)) {
1908 ps.new_offset_y -= ps.panel->sizey;
1909 }
1910 }
1911
1912 /* Interpolate based on the input factor. */
1913 bool changed = false;
1914 for (PanelSort &ps : panel_sort) {
1915 if (ps.panel->flag & PNL_SELECT) {
1916 continue;
1917 }
1918
1919 if (ps.new_offset_x != ps.panel->ofsx) {
1920 const float x = interpf(float(ps.new_offset_x), float(ps.panel->ofsx), factor);
1921 ps.panel->ofsx = round_fl_to_int(x);
1922 changed = true;
1923 }
1924 if (ps.new_offset_y != ps.panel->ofsy) {
1925 const float y = interpf(float(ps.new_offset_y), float(ps.panel->ofsy), factor);
1926 ps.panel->ofsy = round_fl_to_int(y);
1927 changed = true;
1928 }
1929 }
1930
1931 /* Set locations for tabbed and sub panels. */
1932 for (Panel &panel : region->panels) {
1933 if (panel.runtime_flag & PANEL_ACTIVE) {
1934 if (panel.children.first_) {
1935 align_sub_panels(&panel);
1936 }
1937 }
1938 }
1939
1940 return changed;
1941}
1942
1943static void panels_size(ARegion *region, int *r_x, int *r_y)
1944{
1945 int sizex = 0;
1946 int sizey = 0;
1947 bool has_panel_with_background = false;
1948
1949 /* Compute size taken up by panels, for setting in view2d. */
1950 for (Panel &panel : region->panels) {
1951 if (panel.runtime_flag & PANEL_ACTIVE) {
1952 const int pa_sizex = panel.ofsx + panel.sizex;
1953 const int pa_sizey = get_panel_real_ofsy(&panel);
1954
1955 sizex = max_ii(sizex, pa_sizex);
1956 sizey = min_ii(sizey, pa_sizey);
1957 if (panel_should_show_background(region, panel.type)) {
1958 has_panel_with_background = true;
1959 }
1960 }
1961 }
1962
1963 if (sizex == 0) {
1964 sizex = UI_PANEL_WIDTH;
1965 }
1966 if (sizey == 0) {
1967 sizey = -UI_PANEL_WIDTH;
1968 }
1969 /* Extra margin after the list so the view scrolls a few pixels further than the panel border.
1970 * Also makes the bottom match the top margin. */
1971 if (has_panel_with_background) {
1972 sizey -= UI_PANEL_MARGIN_Y;
1973 }
1974
1975 *r_x = sizex;
1976 *r_y = sizey;
1977}
1978
1979static void do_animate(bContext *C, Panel *panel)
1980{
1981 HandlePanelData *data = static_cast<HandlePanelData *>(panel->activedata);
1982 ARegion *region = CTX_wm_region(C);
1983
1984 float fac = 1.0f;
1985 if (!(U.uiflag & USER_REDUCE_MOTION)) {
1986 fac = (BLI_time_now_seconds() - data->starttime) / ANIMATION_TIME;
1987 fac = min_ff(sqrtf(fac), 1.0f);
1988 }
1989
1990 if (uiAlignPanelStep(region, fac, false)) {
1991 ED_region_tag_redraw(region);
1992 }
1993 else {
1994 if (panel_is_dragging(panel)) {
1995 /* NOTE: doing this in #panel_activate_state would require
1996 * removing `const` for context in many other places. */
1997 reorder_instanced_panel_list(C, region, panel);
1998 }
1999
2001 }
2002}
2003
2004static void panels_layout_begin_clear_flags(ListBaseT<Panel> *lb)
2005{
2006 for (Panel &panel : *lb) {
2007 /* Flags to copy over to the next layout pass. */
2008 const short flag_copy = PANEL_USE_CLOSED_FROM_SEARCH | PANEL_IS_DRAG_DROP;
2009
2010 const bool was_active = panel.runtime_flag & PANEL_ACTIVE;
2011 const bool was_closed = panel_is_closed(&panel);
2012 panel.runtime_flag &= flag_copy;
2013 SET_FLAG_FROM_TEST(panel.runtime_flag, was_active, PANEL_WAS_ACTIVE);
2014 SET_FLAG_FROM_TEST(panel.runtime_flag, was_closed, PANEL_WAS_CLOSED);
2015
2016 panels_layout_begin_clear_flags(&panel.children);
2017 }
2018}
2019
2020void panels_begin(const bContext * /*C*/, ARegion *region)
2021{
2022 /* Set all panels as inactive, so that at the end we know which ones were used. Also
2023 * clear other flags so we know later that their values were set for the current redraw. */
2025}
2026
2027void panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y)
2028{
2029 ScrArea *area = CTX_wm_area(C);
2030
2032
2033 const bool region_search_filter_active = region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE;
2034
2035 if (properties_space_needs_realign(area, region)) {
2036 region_panels_set_expansion_from_search_filter(C, region, region_search_filter_active);
2037 }
2038 else if (region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE) {
2039 region_panels_set_expansion_from_search_filter(C, region, region_search_filter_active);
2040 }
2041
2042 if (region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE) {
2043 /* Clean up the extra panels and buttons created for searching. */
2045 }
2046
2047 for (Panel &panel : region->panels) {
2048 if (panel.runtime_flag & PANEL_ACTIVE) {
2049 BLI_assert(panel.runtime->block != nullptr);
2050 panel_calculate_size_recursive(region, &panel);
2051 }
2052 }
2053
2054 /* Offset contents. */
2055 for (Block &block : region->runtime->uiblocks) {
2056 if (block.active && block.panel) {
2057 offset_panel_block(&block);
2058
2059 /* Update bounds for all "views" in this block. Usually this is done in #block_end(), but
2060 * that wouldn't work because of the offset applied above. */
2061 block_views_end(region, &block);
2062 }
2063 }
2064
2065 /* Re-align, possibly with animation. */
2066 Panel *panel;
2067 if (panels_need_realign(area, region, &panel)) {
2068 if (panel) {
2070 }
2071 else {
2072 uiAlignPanelStep(region, 1.0, false);
2073 }
2074 }
2075
2076 /* Compute size taken up by panels. */
2077 panels_size(region, r_x, r_y);
2078}
2079
2081
2082/* -------------------------------------------------------------------- */
2085
2086#define DRAG_REGION_PAD (PNL_HEADER * 0.5)
2087static void do_drag(const bContext *C, const wmEvent *event, Panel *panel)
2088{
2089 HandlePanelData *data = static_cast<HandlePanelData *>(panel->activedata);
2090 ARegion *region = CTX_wm_region(C);
2091
2092 /* Keep the drag position in the region with a small pad to keep the panel visible. */
2093 const int y = clamp_i(event->xy[1], region->winrct.ymin, region->winrct.ymax + DRAG_REGION_PAD);
2094
2095 float dy = float(y - data->starty);
2096
2097 /* Adjust for region zoom. */
2098 dy *= BLI_rctf_size_y(&region->v2d.cur) / float(BLI_rcti_size_y(&region->winrct));
2099
2100 /* Add the movement of the view due to edge scrolling while dragging. */
2101 dy += (region->v2d.cur.ymin - data->start_cur_ymin);
2102
2103 panel->ofsy = data->startofsy + round_fl_to_int(dy);
2104
2105 uiAlignPanelStep(region, 0.2f, true);
2106
2107 ED_region_tag_redraw(region);
2108}
2109#undef DRAG_REGION_PAD
2110
2112
2113/* -------------------------------------------------------------------- */
2116
2118{
2119 for (LayoutPanelHeader &header : panel.runtime->layout_panels.headers) {
2120 if (IN_RANGE(float(my - panel.runtime->block->rect.ymax), header.start_y, header.end_y)) {
2121 return &header;
2122 }
2123 }
2124 return nullptr;
2125}
2126
2128 const Panel *panel,
2129 const int mx,
2130 const int my)
2131{
2132 if (!IN_RANGE(float(mx), block->rect.xmin, block->rect.xmax)) {
2133 return PANEL_MOUSE_OUTSIDE;
2134 }
2135
2136 if (IN_RANGE(float(my), block->rect.ymax, block->rect.ymax + PNL_HEADER)) {
2138 }
2139 if (layout_panel_header_under_mouse(*panel, my) != nullptr) {
2141 }
2142
2143 if (!panel_is_closed(panel)) {
2144 if (IN_RANGE(float(my), block->rect.ymin, block->rect.ymax + PNL_HEADER)) {
2146 }
2147 }
2148
2149 return PANEL_MOUSE_OUTSIDE;
2150}
2151
2156
2157static void panel_drag_collapse_handler_remove(bContext * /*C*/, void *userdata)
2158{
2159 PanelDragCollapseHandle *dragcol_data = static_cast<PanelDragCollapseHandle *>(userdata);
2160 MEM_delete(dragcol_data);
2161}
2162
2163static void panel_drag_collapse(const bContext *C,
2164 const PanelDragCollapseHandle *dragcol_data,
2165 const int xy_dst[2])
2166{
2167 ARegion *region = CTX_wm_region_popup(C);
2168 if (!region) {
2169 region = CTX_wm_region(C);
2170 }
2171 for (Block &block : region->runtime->uiblocks) {
2172 float xy_a_block[2] = {float(dragcol_data->xy_init[0]), float(dragcol_data->xy_init[1])};
2173 float xy_b_block[2] = {float(xy_dst[0]), float(xy_dst[1])};
2174 Panel *panel = block.panel;
2175
2176 if (panel == nullptr) {
2177 continue;
2178 }
2179
2180 /* Lock axis. */
2181 xy_b_block[0] = dragcol_data->xy_init[0];
2182
2183 /* Use cursor coords in block space. */
2184 window_to_block_fl(region, &block, &xy_a_block[0], &xy_a_block[1]);
2185 window_to_block_fl(region, &block, &xy_b_block[0], &xy_b_block[1]);
2186
2187 for (LayoutPanelHeader &header : panel->runtime->layout_panels.headers) {
2188 rctf rect = block.rect;
2189 rect.ymin = block.rect.ymax + header.start_y;
2190 rect.ymax = block.rect.ymax + header.end_y;
2191
2192 if (BLI_rctf_isect_segment(&rect, xy_a_block, xy_b_block)) {
2194 &header.open_owner_ptr, header.open_prop_name.c_str(), !dragcol_data->was_first_open);
2196 const_cast<bContext *>(C),
2197 &header.open_owner_ptr,
2198 RNA_struct_find_property(&header.open_owner_ptr, header.open_prop_name.c_str()));
2199 ED_region_tag_redraw(region);
2201 }
2202 }
2203
2204 if (panel->type && (panel->type->flag & PANEL_TYPE_NO_HEADER)) {
2205 continue;
2206 }
2207 const int oldflag = panel->flag;
2208
2209 /* Set up `rect` to match header size. */
2210 rctf rect = block.rect;
2211 rect.ymin = rect.ymax;
2212 rect.ymax = rect.ymin + PNL_HEADER;
2213
2214 /* Touch all panels between last mouse coordinate and the current one. */
2215 if (BLI_rctf_isect_segment(&rect, xy_a_block, xy_b_block)) {
2216 /* Force panel to open or close. */
2218 SET_FLAG_FROM_TEST(panel->flag, dragcol_data->was_first_open, PNL_CLOSED);
2219
2220 /* If panel->flag has changed this means a panel was opened/closed here. */
2221 if (panel->flag != oldflag) {
2223 }
2224 }
2225 }
2226 /* Update the instanced panel data expand flags with the changes made here. */
2228}
2229
2236static int panel_drag_collapse_handler(bContext *C, const wmEvent *event, void *userdata)
2237{
2238 wmWindow *win = CTX_wm_window(C);
2239 PanelDragCollapseHandle *dragcol_data = static_cast<PanelDragCollapseHandle *>(userdata);
2240 short retval = WM_UI_HANDLER_CONTINUE;
2241
2242 switch (event->type) {
2243 case MOUSEMOVE:
2244 panel_drag_collapse(C, dragcol_data, event->xy);
2245
2246 retval = WM_UI_HANDLER_BREAK;
2247 break;
2248 case LEFTMOUSE:
2249 if (event->val == KM_RELEASE) {
2250 /* Done! */
2254 dragcol_data,
2255 true);
2257 }
2258 /* Don't let any left-mouse event fall through! */
2259 retval = WM_UI_HANDLER_BREAK;
2260 break;
2261 default: {
2262 break;
2263 }
2264 }
2265
2266 return retval;
2267}
2268
2269void panel_drag_collapse_handler_add(const bContext *C, const bool was_open)
2270{
2271 wmWindow *win = CTX_wm_window(C);
2272 const wmEvent *event = win->runtime->eventstate;
2274
2275 dragcol_data->was_first_open = was_open;
2276 copy_v2_v2_int(dragcol_data->xy_init, event->xy);
2277
2279 &win->runtime->modalhandlers,
2282 dragcol_data,
2284}
2285
2287{
2288 const bool is_open = RNA_boolean_get(&header->open_owner_ptr, header->open_prop_name.c_str());
2289 RNA_boolean_set(&header->open_owner_ptr, header->open_prop_name.c_str(), !is_open);
2291 const_cast<bContext *>(C),
2292 &header->open_owner_ptr,
2293 RNA_struct_find_property(&header->open_owner_ptr, header->open_prop_name.c_str()));
2294 return !is_open;
2295}
2296
2298 bContext *C, const Block *block, const int /*mx*/, const int my, const int event_type)
2299{
2300 Panel *panel = block->panel;
2301 BLI_assert(panel->type != nullptr);
2302
2304 if (header == nullptr) {
2305 return;
2306 }
2307 const bool new_state = layout_panel_toggle_open(C, header);
2310
2311 if (event_type == LEFTMOUSE) {
2313 }
2314}
2315
2322static void handle_panel_header(const bContext *C,
2323 const Block *block,
2324 const int mx,
2325 const int event_type,
2326 const bool ctrl,
2327 const bool shift)
2328{
2329 Panel *panel = block->panel;
2330 ARegion *region = CTX_wm_region(C);
2331
2332 BLI_assert(panel->type != nullptr);
2334
2335 const bool is_subpanel = (panel->type->parent != nullptr);
2336 const bool use_pin = panel_category_tabs_is_visible(region) && panel_can_be_pinned(panel);
2337 const bool show_pin = use_pin && (panel->flag & PNL_PIN);
2338 const bool show_drag = !is_subpanel;
2339
2340 /* Handle panel pinning. */
2341 if (use_pin && ELEM(event_type, EVT_RETKEY, EVT_PADENTER, LEFTMOUSE) && shift) {
2342 panel->flag ^= PNL_PIN;
2343 ED_region_tag_redraw(region);
2344 return;
2345 }
2346
2347 float expansion_area_xmax = block->rect.xmax;
2348 if (show_drag) {
2349 expansion_area_xmax -= (PNL_ICON * 1.5f);
2350 }
2351 if (show_pin) {
2352 expansion_area_xmax -= PNL_ICON;
2353 }
2354
2355 /* Collapse and expand panels. */
2356 if (ELEM(event_type, EVT_RETKEY, EVT_PADENTER, EVT_AKEY) || mx < expansion_area_xmax) {
2357 if (ctrl && !is_subpanel) {
2358 /* For parent panels, collapse all other panels or toggle children. */
2359 if (panel_is_closed(panel) || panel->children.is_empty()) {
2360 panels_collapse_all(region, panel);
2361
2362 /* Reset the view - we don't want to display a view without content. */
2363 view2d_offset(&region->v2d, 0.0f, 1.0f);
2364 }
2365 else {
2366 /* If a panel has sub-panels and it's open, toggle the expansion
2367 * of the sub-panels (based on the expansion of the first sub-panel). */
2368 Panel *first_child = panel->children.first();
2369 BLI_assert(first_child != nullptr);
2371 panel->flag |= PNL_CLOSED;
2372 }
2373 }
2374
2376
2377 if (event_type == LEFTMOUSE) {
2379 }
2380
2381 /* Set panel custom data (modifier) active when expanding sub-panels, but not top-level
2382 * panels to allow collapsing and expanding without setting the active element. */
2383 if (is_subpanel) {
2385 }
2386
2389 return;
2390 }
2391
2392 /* Handle panel dragging. For now don't allow dragging in floating regions. */
2393 if (show_drag && !(region->alignment == RGN_ALIGN_FLOAT)) {
2394 const float drag_area_xmin = block->rect.xmax - (PNL_ICON * 1.5f);
2395 const float drag_area_xmax = block->rect.xmax;
2396 if (IN_RANGE(mx, drag_area_xmin, drag_area_xmax)) {
2397 if (panel_custom_pin_to_last_get(panel)) {
2398 panel_custom_pin_to_last_set(C, panel, false);
2399 return;
2400 }
2402 return;
2403 }
2404 }
2405
2406 /* Handle panel unpinning. */
2407 if (show_pin) {
2408 const float pin_area_xmin = expansion_area_xmax;
2409 const float pin_area_xmax = pin_area_xmin + PNL_ICON;
2410 if (IN_RANGE(mx, pin_area_xmin, pin_area_xmax)) {
2411 panel->flag ^= PNL_PIN;
2412 ED_region_tag_redraw(region);
2413 return;
2414 }
2415 }
2416}
2417
2419{
2420 /* Check for more than one category. */
2421 return region->runtime->panels_category.first_ &&
2423 region->runtime->panels_category.first_ != region->runtime->panels_category.last());
2424}
2425
2427{
2428 return panel_category_is_visible(region) &&
2430}
2431
2432PanelCategoryDyn *panel_category_find(const ARegion *region, const char *idname)
2433{
2434 return static_cast<PanelCategoryDyn *>(BLI_findstring(
2435 &region->runtime->panels_category, idname, offsetof(PanelCategoryDyn, idname)));
2436}
2437
2438int panel_category_index_find(ARegion *region, const char *idname)
2439{
2440 return BLI_findstringindex(
2441 &region->runtime->panels_category, idname, offsetof(PanelCategoryDyn, idname));
2442}
2443
2445{
2446 return static_cast<PanelCategoryStack *>(BLI_findstring(
2447 &region->panels_category_active, idname, offsetof(PanelCategoryStack, idname)));
2448}
2449
2450static void panel_category_active_set(ARegion *region, const char *idname, bool fallback)
2451{
2452 ListBaseT<PanelCategoryStack> *lb = &region->panels_category_active;
2453 PanelCategoryStack *pc_act = panel_category_active_find(region, idname);
2454
2455 if (pc_act) {
2456 BLI_remlink(lb, pc_act);
2457 }
2458 else {
2459 pc_act = MEM_new<PanelCategoryStack>(__func__);
2460 STRNCPY_UTF8(pc_act->idname, idname);
2461 }
2462
2463 if (fallback) {
2464 /* For fall-backs, add at the end so explicitly chosen categories have priority. */
2465 BLI_addtail(lb, pc_act);
2466 }
2467 else {
2468 BLI_addhead(lb, pc_act);
2469 }
2470
2471 /* Validate all active panels. We could do this on load, they are harmless -
2472 * but we should remove them somewhere.
2473 * (Add-ons could define panels and gather cruft over time). */
2474 {
2475 PanelCategoryStack *pc_act_next;
2476 /* intentionally skip first */
2477 pc_act_next = pc_act->next;
2478 while ((pc_act = pc_act_next)) {
2479 pc_act_next = pc_act->next;
2480 if (!BLI_findstring(
2481 &region->runtime->type->paneltypes, pc_act->idname, offsetof(PanelType, category)))
2482 {
2483 BLI_remlink(lb, pc_act);
2484 MEM_delete(pc_act);
2485 }
2486 }
2487 }
2488 ED_region_tag_redraw(region);
2489}
2490
2491void panel_category_active_set(ARegion *region, const char *idname)
2492{
2493 panel_category_active_set(region, idname, false);
2494}
2495
2497{
2498 PanelCategoryDyn *pc_dyn = static_cast<PanelCategoryDyn *>(
2500 if (!pc_dyn) {
2501 return;
2502 }
2503
2504 panel_category_active_set(region, pc_dyn->idname, false);
2505}
2506
2507void panel_category_active_set_default(ARegion *region, const char *idname)
2508{
2509 if (!panel_category_active_find(region, idname)) {
2510 panel_category_active_set(region, idname, true);
2511 }
2512}
2513
2514const char *panel_category_active_get(ARegion *region, bool set_fallback)
2515{
2516 for (PanelCategoryStack &pc_act : region->panels_category_active) {
2517 if (panel_category_find(region, pc_act.idname)) {
2518 return pc_act.idname;
2519 }
2520 }
2521
2522 if (set_fallback) {
2523 PanelCategoryDyn *pc_dyn = static_cast<PanelCategoryDyn *>(
2524 region->runtime->panels_category.first_);
2525 if (pc_dyn) {
2526 panel_category_active_set(region, pc_dyn->idname, true);
2527 return pc_dyn->idname;
2528 }
2529 }
2530
2531 return nullptr;
2532}
2533
2534void panel_category_add(ARegion *region, const char *name, int icon)
2535{
2536 PanelCategoryDyn *pc_dyn = MEM_new<PanelCategoryDyn>(__func__);
2537 BLI_addtail(&region->runtime->panels_category, pc_dyn);
2538
2539 STRNCPY_UTF8(pc_dyn->idname, name);
2540 pc_dyn->icon = icon;
2541
2542 /* 'pc_dyn->rect' must be set on draw. */
2543}
2544
2546{
2547 region->runtime->panels_category.free_no_destruct();
2548}
2549
2550static bool panel_categories_tab_is_mouse_over(ARegion *region, const wmEvent *event)
2551{
2553
2554 const float aspect = BLI_rctf_size_y(&region->v2d.cur) /
2555 (BLI_rcti_size_y(&region->v2d.mask) + 1);
2556 const float zoom = 1.0f / aspect;
2557 const int category_tabs_width = round_fl_to_int(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom);
2558 const bool is_left = RGN_ALIGN_ENUM_FROM_MASK(region->alignment) != RGN_ALIGN_RIGHT;
2559
2560 const View2D *v2d = &region->v2d;
2561 int ymin = region->overlap ? region->v2d.mask.ymax : region->v2d.mask.ymin;
2562 if (region->overlap) {
2563 if (const Block *block = region->runtime->block_name_map.lookup_as(
2565 block && !block->buttons_ptrs.is_empty())
2566 {
2567 ymin = std::max(region->v2d.mask.ymin, int(block->buttons_ptrs.last()->rect.ymin));
2568 }
2569 }
2570 const rcti rect = {
2571 .xmin = is_left ? v2d->mask.xmin + 3 : (v2d->mask.xmax - category_tabs_width),
2572 .xmax = is_left ? v2d->mask.xmin + category_tabs_width : (v2d->mask.xmax - 3),
2573 .ymin = ymin,
2574 .ymax = region->v2d.mask.ymax,
2575 };
2576
2577 return BLI_rcti_isect_pt(&rect, event->mval[0], event->mval[1]);
2578}
2579
2581 ARegion *region,
2582 const Button *active_but)
2583{
2585
2586 const bool is_mousewheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE);
2587 const bool inside_tabregion = panel_categories_tab_is_mouse_over(region, event);
2588
2589 /* If mouse is inside non-tab region, ctrl key is required. */
2590 if (is_mousewheel && (event->modifier & KM_CTRL) == 0 && !inside_tabregion) {
2592 }
2593
2594 if (active_but && button_supports_cycling(active_but)) {
2595 /* Skip - exception to make cycling buttons using ctrl+mousewheel work in tabbed regions. */
2596 }
2597 else {
2598 const char *category = panel_category_active_get(region, false);
2599 if (category) [[likely]] {
2600 PanelCategoryDyn *pc_dyn = panel_category_find(region, category);
2601 /* Cyclic behavior between categories
2602 * using Ctrl+Tab (+Shift for backwards) or Ctrl+Wheel Up/Down. */
2603 if (LIKELY(pc_dyn) && (event->modifier & KM_CTRL)) {
2604 if (is_mousewheel) {
2605 /* We can probably get rid of this and only allow Ctrl-Tabbing. */
2606 pc_dyn = (event->type == WHEELDOWNMOUSE) ? pc_dyn->next : pc_dyn->prev;
2607 }
2608 else {
2609 const bool backwards = event->modifier & KM_SHIFT;
2610 pc_dyn = backwards ? pc_dyn->prev : pc_dyn->next;
2611 if (!pc_dyn) {
2612 /* Proper cyclic behavior, back to first/last category (only used for ctrl+tab). */
2613 pc_dyn = backwards ? region->runtime->panels_category.last() :
2614 region->runtime->panels_category.first();
2615 }
2616 }
2617
2618 if (pc_dyn) {
2619 /* Intentionally don't reset scroll in this case,
2620 * allowing for quick browsing between tabs. */
2621 panel_category_active_set(region, pc_dyn->idname);
2622 }
2623 return WM_UI_HANDLER_BREAK;
2624 }
2625 }
2626 }
2627
2629}
2630
2631void panel_region_width_set(ARegion *region, const float aspect, int unscaled_size)
2632{
2634 const float size_new = unscaled_size / aspect;
2635 if (region->alignment & RGN_ALIGN_RIGHT) {
2636 region->winrct.xmin = region->winrct.xmax - (size_new * UI_SCALE_FAC);
2637 }
2638 else {
2639 region->winrct.xmax = region->winrct.xmin + (size_new * UI_SCALE_FAC);
2640 }
2641 region->winx = size_new * UI_SCALE_FAC;
2642 region->sizex = size_new;
2643 region->v2d.winx = region->winx;
2644 region->v2d.cur.xmin = 0;
2645 region->v2d.cur.xmax = size_new * UI_SCALE_FAC;
2646 region->v2d.mask.xmin = 0;
2647 region->v2d.mask.xmax = size_new * UI_SCALE_FAC;
2648 view2d_curRect_validate(&region->v2d);
2649}
2650
2652 const wmEvent *event,
2653 ARegion *region,
2654 const Button *active_but)
2655{
2656 if (event->val == KM_RELEASE) {
2658 }
2659
2660 /* Scroll-bars can overlap panels now, they have handling priority. */
2661 if (view2d_mouse_in_scrollers(region, &region->v2d, event->xy)) {
2663 }
2664
2665 int retval = WM_UI_HANDLER_CONTINUE;
2666
2667 /* Handle category tabs. */
2668 if (panel_category_tabs_is_visible(region)) {
2669 if (event->type == LEFTMOUSE && event->val == KM_PRESS &&
2671 {
2672 const Button *active_button = region_find_active_but(region);
2673 /* Expand/collapse panels when clicking the active category button. */
2675 reinterpret_cast<ID *>(CTX_wm_screen(C)), RNA_Region, region);
2676 const int val = RNA_enum_get(&ptr, "active_panel_category");
2677 if (active_button && active_button->hardmax == val) {
2678 const float aspect = BLI_rctf_size_y(&region->v2d.cur) /
2679 (BLI_rcti_size_y(&region->v2d.mask) + 1);
2680 const bool too_narrow = BLI_rcti_size_x(&region->winrct) <
2681 int(std::floor(
2683 UI_SCALE_FAC / aspect));
2684 if (too_narrow) {
2685 expand_panel_region(*C, region);
2686 }
2687 else {
2688 /* Minimize region. */
2689 region->runtime->type->prefsizex = int(float(BLI_rcti_size_x(&region->winrct) + 1) /
2690 UI_SCALE_FAC * aspect);
2693 ED_region_tag_redraw(region);
2694 /* Reset scroll to the top (#38348). */
2695 view2d_offset(&region->v2d, -1.0f, 1.0f);
2696 }
2697 /* Do not break event, let click drag activate panel categories. */
2698 }
2699 }
2700 else if (((event->type == EVT_TABKEY) && (event->modifier & KM_CTRL)) ||
2702 {
2703 /* Cycle tabs. */
2705 retval = handle_panel_category_cycling(event, region, active_but);
2706 }
2707 else if (event->type == EVT_PADPERIOD) {
2709 retval = panel_category_show_active_tab(*C, region, event->xy);
2710 }
2711 else if ((event->type == RIGHTMOUSE) && panel_categories_tab_is_mouse_over(region, event)) {
2714 retval = popup_context_menu_for_panel(C, region, nullptr);
2715 }
2716 }
2717
2718 if (retval == WM_UI_HANDLER_BREAK) {
2719 return retval;
2720 }
2721
2722 const Button *region_active_but = region_find_active_but(region);
2723 const bool region_has_active_button = region_active_but &&
2724 region_active_but->type != ButtonType::Label;
2725
2726 for (Block &block : region->runtime->uiblocks) {
2727 Panel *panel = block.panel;
2728 if (panel == nullptr || panel->type == nullptr) {
2729 continue;
2730 }
2731 /* We can't expand or collapse panels without headers, they would disappear. Layout panels can
2732 * be expanded and collapsed though. */
2733 const bool has_panel_header = !(panel->type->flag & PANEL_TYPE_NO_HEADER);
2734
2735 int mx = event->xy[0];
2736 int my = event->xy[1];
2737 window_to_block(region, &block, &mx, &my);
2738
2739 const PanelMouseState mouse_state = panel_mouse_state_get(&block, panel, mx, my);
2740
2741 if (has_panel_header && mouse_state != PANEL_MOUSE_OUTSIDE) {
2742 /* Mark panels that have been interacted with so their expansion
2743 * doesn't reset when property search finishes. */
2746
2747 /* The panel collapse / expand key "A" is special as it takes priority over
2748 * active button handling. */
2749 if ((event->type == EVT_AKEY) && (event->modifier == 0)) {
2750 retval = WM_UI_HANDLER_BREAK;
2752 C, &block, mx, event->type, event->modifier & KM_CTRL, event->modifier & KM_SHIFT);
2753 break;
2754 }
2755 }
2756
2757 /* Don't do any other panel handling with an active button. */
2758 if (region_has_active_button) {
2759 continue;
2760 }
2761
2762 if ((has_panel_header && mouse_state == PANEL_MOUSE_INSIDE_HEADER)) {
2763 /* All mouse clicks inside panel headers should return in break. */
2764 if (ELEM(event->type, EVT_RETKEY, EVT_PADENTER, LEFTMOUSE)) {
2765 retval = WM_UI_HANDLER_BREAK;
2767 C, &block, mx, event->type, event->modifier & KM_CTRL, event->modifier & KM_SHIFT);
2768 }
2769 else if (event->type == RIGHTMOUSE) {
2770 retval = popup_context_menu_for_panel(C, region, block.panel);
2771 }
2772 break;
2773 }
2774 if (mouse_state == PANEL_MOUSE_INSIDE_LAYOUT_PANEL_HEADER) {
2775 if (ELEM(event->type, EVT_RETKEY, EVT_PADENTER, LEFTMOUSE)) {
2776 retval = WM_UI_HANDLER_BREAK;
2777 handle_layout_panel_header(C, &block, mx, my, event->type);
2778 }
2779 }
2780 }
2781
2782 return retval;
2783}
2784
2785static void panel_custom_data_set_recursive(Panel *panel, PointerRNA *custom_data)
2786{
2787 panel->runtime->custom_data_ptr = custom_data;
2788
2789 for (Panel &child_panel : panel->children) {
2790 panel_custom_data_set_recursive(&child_panel, custom_data);
2791 }
2792}
2793
2794void panel_context_pointer_set(Panel *panel, const char *name, PointerRNA *ptr)
2795{
2796 panel->layout->context_ptr_set(name, ptr);
2797 panel->runtime->context = panel->layout->context_store();
2798}
2799
2800void panel_custom_data_set(Panel *panel, PointerRNA *custom_data)
2801{
2802 BLI_assert(panel->type != nullptr);
2803
2804 /* Free the old custom data, which should be shared among all of the panel's sub-panels. */
2805 if (panel->runtime->custom_data_ptr != nullptr) {
2806 MEM_delete(panel->runtime->custom_data_ptr);
2807 }
2808
2809 panel_custom_data_set_recursive(panel, custom_data);
2810}
2811
2813{
2814 return panel->runtime->custom_data_ptr;
2815}
2816
2818{
2819 ARegion *region = CTX_wm_region(C);
2820 if (region) {
2821 for (Block &block : region->runtime->uiblocks) {
2822 Panel *panel = block.panel;
2823 if (panel == nullptr) {
2824 continue;
2825 }
2826
2827 int mx = event->xy[0];
2828 int my = event->xy[1];
2829 window_to_block(region, &block, &mx, &my);
2830 const int mouse_state = panel_mouse_state_get(&block, panel, mx, my);
2832 return panel_custom_data_get(panel);
2833 }
2834 }
2835 }
2836
2837 return nullptr;
2838}
2839
2840bool panel_can_be_pinned(const Panel *panel)
2841{
2842 return (panel->type->parent == nullptr) && !(panel->type->flag & PANEL_TYPE_INSTANCED);
2843}
2844
2846
2847/* -------------------------------------------------------------------- */
2850
2851/* NOTE: this is modal handler and should not swallow events for animation. */
2852static int handler_panel(bContext *C, const wmEvent *event, void *userdata)
2853{
2854 Panel *panel = static_cast<Panel *>(userdata);
2855 HandlePanelData *data = static_cast<HandlePanelData *>(panel->activedata);
2856
2857 /* Verify if we can stop. */
2858 if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
2860 }
2861 else if (event->type == MOUSEMOVE) {
2862 if (data->state == PANEL_STATE_DRAG) {
2863 do_drag(C, event, panel);
2864 }
2865 }
2866 else if (event->type == TIMER && event->customdata == data->animtimer) {
2867 if (data->state == PANEL_STATE_ANIMATION) {
2868 do_animate(C, panel);
2869 }
2870 else if (data->state == PANEL_STATE_DRAG) {
2871 do_drag(C, event, panel);
2872 }
2873 }
2874
2875 data = static_cast<HandlePanelData *>(panel->activedata);
2876
2877 if (data && data->state == PANEL_STATE_ANIMATION) {
2879 }
2880 return WM_UI_HANDLER_BREAK;
2881}
2882
2883static void handler_remove_panel(bContext *C, void *userdata)
2884{
2885 Panel *panel = static_cast<Panel *>(userdata);
2886
2888}
2889
2891 wmWindow *win,
2892 const ARegion *region,
2893 Panel *panel,
2894 const HandlePanelState state)
2895{
2897
2898 if (panel->activedata == nullptr) {
2901 &win->runtime->modalhandlers,
2904 panel,
2906 }
2907
2908 HandlePanelData *data = static_cast<HandlePanelData *>(panel->activedata);
2909
2910 /* Only create a new timer if necessary. Reuse can occur when PANEL_STATE_ANIMATION follows
2911 * PANEL_STATE_DRAG for example (i.e. panel->activedata was present already). */
2912 if (!data->animtimer) {
2914 }
2915
2916 data->state = state;
2917 data->startx = win->runtime->eventstate->xy[0];
2918 data->starty = win->runtime->eventstate->xy[1];
2919 data->startofsx = panel->ofsx;
2920 data->startofsy = panel->ofsy;
2921 data->start_cur_xmin = region->v2d.cur.xmin;
2922 data->start_cur_ymin = region->v2d.cur.ymin;
2923 data->starttime = BLI_time_now_seconds();
2924}
2925
2931static void panel_activate_state(const bContext *C, Panel *panel, const HandlePanelState state)
2932{
2933 HandlePanelData *data = static_cast<HandlePanelData *>(panel->activedata);
2934 wmWindow *win = CTX_wm_window(C);
2935 ARegion *region = CTX_wm_region(C);
2936
2937 if (data != nullptr && data->state == state) {
2938 return;
2939 }
2940
2941 if (state == PANEL_STATE_DRAG) {
2943
2946
2947 panel_handle_data_ensure(C, win, region, panel, state);
2948
2949 /* Initiate edge panning during drags for scrolling beyond the initial region view. */
2950 wmOperatorType *ot = WM_operatortype_find("VIEW2D_OT_edge_pan", true);
2952 }
2953 else if (state == PANEL_STATE_ANIMATION) {
2954 panel_set_flag_recursive(panel, PNL_SELECT, false);
2955
2956 panel_handle_data_ensure(C, win, region, panel, state);
2957 }
2958 else if (state == PANEL_STATE_EXIT) {
2960
2961 BLI_assert(data != nullptr);
2962
2963 if (data->animtimer) {
2964 WM_event_timer_remove(CTX_wm_manager(C), win, data->animtimer);
2965 data->animtimer = nullptr;
2966 }
2967
2968 /* Save File Browser panel order and open/close state. */
2969 if (CTX_wm_area(C)->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_TOOLS) {
2970 for (Panel &pnl : region->panels) {
2971 if (STRPREFIX(pnl.panelname, "FILEBROWSER_PT_")) {
2972 const std::string pnl_name_str = pnl.panelname;
2973 recents::Section("panel.sortorder").set(pnl_name_str, pnl.sortorder);
2974 recents::Section("panel.open").set(pnl_name_str, !(pnl.flag & PNL_CLOSED));
2975 }
2976 }
2977 }
2978
2979 MEM_delete(data);
2980 panel->activedata = nullptr;
2981
2984 }
2985
2986 ED_region_tag_redraw(region);
2987}
2988
2990{
2991 if (panel->activedata) {
2993 }
2994}
2995
2997{
2998 const float aspect = BLI_rctf_size_y(&region->v2d.cur) /
2999 (BLI_rcti_size_y(&region->v2d.mask) + 1);
3000 return BLI_rcti_size_x(&region->winrct) <=
3001 int(std::ceil(UI_PANEL_CATEGORY_MIN_WIDTH * UI_SCALE_FAC / aspect));
3002}
3003
3005{
3006 Vector<PanelSort> panel_sort;
3007 for (Panel &panel : region->panels) {
3008 if (panel.runtime_flag & PANEL_ACTIVE) {
3009 /* These panels should have types since they are currently displayed to the user. */
3010 BLI_assert(panel.type != nullptr);
3011 panel_sort.append({&panel, 0, 0});
3012 }
3013 }
3014 if (panel_sort.is_empty()) {
3015 return;
3016 }
3017 std::stable_sort(panel_sort.begin(), panel_sort.end(), find_highest_panel);
3018 panel_activate_state(C, panel_sort.first().panel, PANEL_STATE_ANIMATION);
3019}
3020
3022{
3025 return false;
3026 }
3027 const float aspect = BLI_rctf_size_y(&region->v2d.cur) /
3028 (BLI_rcti_size_y(&region->v2d.mask) + 1);
3029 const int new_width = region->runtime->type->prefsizex ? region->runtime->type->prefsizex : 250;
3030 panel_region_width_set(region, aspect, new_width);
3031 return true;
3032}
3033
3035
3036} // namespace blender::ui
#define BLF_DRAW_STR_DUMMY_MAX
Definition BLF_api.hh:456
#define STRNCPY_UTF8(dst, src)
Platform independent time functions.
#define TIP_(msgid)
#define CTX_IFACE_(context, msgid)
#define IFACE_(msgid)
#define MAX_NAME
Definition DNA_defs.h:63
#define RGN_ALIGN_ENUM_FROM_MASK(align)
#define UI_SCALE_FAC
#define UI_INV_SCALE_FAC
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_SIDEBAR_PANEL_WIDTH
#define INSTANCED_PANEL_UNIQUE_STR_SIZE
#define UI_PANEL_WIDTH
#define UI_PANEL_CATEGORY_MIN_WIDTH
#define UI_PANEL_MARGIN_X
#define UI_PANEL_SEARCH_BLOCK_MARGIN_HEIGHT
#define UI_PANEL_CATEGORY_MARGIN_WIDTH
#define UI_PANEL_MARGIN_Y
#define UI_UNIT_X
#define UI_NO_ICON_OVERLAY_TEXT
#define WM_UI_HANDLER_CONTINUE
Definition WM_types.hh:361
#define NC_SCREEN
Definition WM_types.hh:390
#define NA_EDITED
Definition WM_types.hh:634
#define WM_UI_HANDLER_BREAK
Definition WM_types.hh:362
#define STRPREFIX(a, b)
#define STREQLEN(a, b, n)
#define IN_RANGE(a, b, c)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define STREQ(a, b)
#define LIKELY(x)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
bool contains_as(const ForwardKey &key) const
Definition BLI_set.hh:314
constexpr int64_t size() const
constexpr const char * data() const
void append(const T &value)
IndexRange index_range() const
const T & first() const
T get(const std::string &item_key) const
Definition recents.cc:224
void set(const std::string &item_key, const T &value)
Definition recents.cc:285
#define offsetof(t, d)
#define floor
#define PNL_HEADER
#define ANIMATION_TIME
#define DRAG_REGION_PAD
#define PNL_ICON
#define TABS_PADDING_BETWEEN_FACTOR
#define ANIMATION_INTERVAL
#define TABS_PADDING_TEXT_FACTOR
const int state
void get_color_4ubv(int colorid, unsigned char col[4])
void get_color_4fv(int colorid, float col[4])
const bTheme * theme_get()
void get_color_type_4fv(int colorid, int spacetype, float col[4])
static void handle_layout_panel_header(bContext *C, const Block *block, const int, const int my, const int event_type)
void panel_drawname_set(Panel *panel, StringRef name)
static void panel_delete(ARegion *region, ListBaseT< Panel > *panels, Panel *panel)
void panel_context_pointer_set(Panel *panel, const char *name, PointerRNA *ptr)
LayoutPanelHeader * layout_panel_header_under_mouse(const Panel &panel, const int my)
int panel_size_y(const Panel *panel)
void panel_category_add(ARegion *region, const char *name, int icon=0)
static void panel_exit_state_recursive(const bContext *C, Panel &panel)
static void panels_collapse_all(ARegion *region, const Panel *from_panel)
static void panels_size(ARegion *region, int *r_x, int *r_y)
static void do_drag(const bContext *C, const wmEvent *event, Panel *panel)
bool button_supports_cycling(const Button *but)
void panels_begin(const bContext *C, ARegion *region)
bool layout_panel_toggle_open(const bContext *C, LayoutPanelHeader *header)
bool region_panels_fits_only_categories(const ARegion *region)
void button_func_tooltip_custom_set_cpp(Button &but, Func &&func)
static int handle_panel_category_cycling(const wmEvent *event, ARegion *region, const Button *active_but)
static void panel_set_runtime_flag_recursive(Panel *panel, short flag, bool value)
void panel_category_clear_all(ARegion *region)
void block_set_search_only(Block *block, bool search_only)
static void panel_title_color_get(const Panel *panel, const bool show_background, const bool region_search_filter_active, uchar r_color[4])
void button_func_set(Button *but, std::function< void(bContext &)> func)
PointerRNA * region_panel_custom_data_under_cursor(const bContext *C, const wmEvent *event)
bool panel_can_be_pinned(const Panel *panel)
bool panel_region_visible_width_ensure(ARegion *region)
static void expand_panel_region(bContext &C, ARegion *region)
static bool panel_categories_tab_is_mouse_over(ARegion *region, const wmEvent *event)
void view2d_curRect_validate(View2D *v2d)
Definition view2d.cc:810
static void panels_layout_begin_clear_flags(ListBaseT< Panel > *lb)
bool panel_should_show_background(const ARegion *region, const PanelType *panel_type)
static void panel_calculate_size_recursive(ARegion *region, Panel *panel)
static void handler_remove_panel(bContext *C, void *userdata)
const uiStyle * style_get()
void block_translate(Block *block, float x, float y)
Definition interface.cc:408
void panels_draw(const bContext *C, ARegion *region)
void draw_aligned_panel(const ARegion *region, const uiStyle *style, const Block *block, const rcti *rect, bool show_pin, bool show_background, bool region_search_filter_active)
int popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *panel)
bool panel_list_matches_data(ARegion *region, ListBase *data, ListPanelIDFromDataFunc panel_idname_func)
PanelCategoryDyn * panel_category_find(const ARegion *region, const char *idname)
static void panel_draw_aligned_widgets(const uiStyle *style, const Panel *panel, const rcti *header_rect, const float aspect, const bool show_pin, const bool show_background, const bool region_search_filter_active)
void panels_do_after_block_layout_fns(const bContext *C, ARegion *region)
void panel_drag_collapse_handler_add(const bContext *C, const bool was_open)
static void panel_custom_pin_to_last_set(const bContext *C, const Panel *panel, const bool value)
int handler_panel_region(bContext *C, const wmEvent *event, ARegion *region, const Button *active_but)
static bool find_highest_panel(const PanelSort &a, const PanelSort &b)
static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *drag_panel)
static void get_panel_expand_flag(const Panel *panel, short *flag, short *flag_index)
void window_to_block(const ARegion *region, const Block *block, int *x, int *y)
Definition interface.cc:230
static bool panel_custom_pin_to_last_get(const Panel *panel)
int panel_category_index_find(ARegion *region, const char *idname)
void block_post_layout_callbacks_exec(const bContext *C, ARegion *region, Block *block)
static int handler_panel(bContext *C, const wmEvent *event, void *userdata)
void icon_draw_ex(float x, float y, int icon_id, float aspect, float alpha, float desaturate, const uchar mono_color[4], bool mono_border, const IconTextOverlay *text_overlay, const bool inverted=false, float scale=1.0f)
void(*)(void *data_link, char *r_idname) ListPanelIDFromDataFunc
void fontstyle_set(const uiFontStyle *fs)
void button_func_pushed_state_set(Button *but, std::function< bool(const Button &)> func)
@ PANEL_MOUSE_INSIDE_LAYOUT_PANEL_HEADER
void block_views_end(ARegion *region, const Block *block)
void draw_dropshadow(const rctf *rct, float radius, float width, float aspect, float alpha)
char char view2d_mouse_in_scrollers(const ARegion *region, const View2D *v2d, const int xy[2]) ATTR_NONNULL(1
Definition view2d.cc:2044
void region_panels_sort_for_search_filter_visibility_change(bContext *C, const ARegion *region)
Button * region_find_active_but(ARegion *region) ATTR_WARN_UNUSED_RESULT
static void panel_remove_invisible_layouts_recursive(Panel *panel, const Panel *parent_panel)
static bool properties_space_needs_realign(const ScrArea *area, const ARegion *region)
static void do_animate(bContext *C, Panel *panel)
void panel_category_active_set(ARegion *region, const char *idname)
static void offset_panel_block(Block *block)
static void panel_drag_collapse_handler_remove(bContext *, void *userdata)
void fontscale(float *points, float aspect)
bool panel_is_closed(const Panel *panel)
void panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y)
void panel_end(Panel *panel, int width, int height)
static int panel_drag_collapse_handler(bContext *C, const wmEvent *event, void *userdata)
rcti rect_to_pixelrect(const ARegion *region, const Block *block, const rctf *src_rect)
static int get_panel_size_y(const Panel *panel)
static void region_panels_set_expansion_from_search_filter(const bContext *C, ARegion *region, const bool use_search_closed)
bool panel_matches_search_filter(const Panel *panel)
static void panel_set_expansion_from_list_data(const bContext *C, Panel *panel)
const uiStyle * style_get_dpi()
Button * uiDefIconButR_prop(Block *block, ButtonType type, int icon, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< StringRef > tip)
static void panel_drag_collapse(const bContext *C, const PanelDragCollapseHandle *dragcol_data, const int xy_dst[2])
static void expand_panel_region_on_category_change(bContext &C, StringRef category, StringRef active)
void button_func_quick_tooltip_set(Button *but, std::function< std::string(const Button *but)> func)
void panel_header_buttons_end(Panel *panel)
void fontstyle_draw(const uiFontStyle *fs, const rcti *rect, const char *str, size_t str_len, const uchar col[4], const FontStyleDrawParams *fs_params)
void button_drawflag_enable(Button *but, int flag)
void panel_category_show_tab(const bContext &C, ARegion *region, StringRef category)
void panel_category_active_set_default(ARegion *region, const char *idname)
static void panel_draw_aligned_backdrop(const ARegion *region, const Panel *panel, const rcti *rect, const rcti *header_rect)
static constexpr int PANEL_MIN_DRAW_WIDTH
static void align_sub_panels(Panel *panel)
void button_flag_enable(Button *but, int64_t flag)
Block * block_begin(const bContext *C, ARegion *region, std::string name, EmbossType emboss)
PanelCategoryStack * panel_category_active_find(ARegion *region, const char *idname)
Button * uiDefBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< StringRef > tip)
void handle_afterfunc_add_operator(wmOperatorType *ot, wm::OpCallContext opcontext)
static void panel_handle_data_ensure(const bContext *C, wmWindow *win, const ARegion *region, Panel *panel, const HandlePanelState state)
void draw_roundbox_corner_set(int type)
static int get_panel_real_size_y(const Panel *panel)
bool panel_category_tabs_is_visible(const ARegion *region)
void block_theme_style_set(Block *block, char theme_style)
static void panel_matches_search_filter_recursive(const Panel *panel, bool *filter_matches)
static void panel_draw_softshadow(const rctf *box_rect, const int roundboxalign, const float radius, const float shadow_width)
void panels_free_instanced(const bContext *C, ARegion *region)
static float panel_region_offset_x_get(const ARegion *region)
bool block_is_search_only(const Block *block)
Panel * panel_begin(ARegion *region, ListBaseT< Panel > *lb, Block *block, PanelType *pt, Panel *panel, bool *r_open)
void panel_label_offset(const Block *block, int *r_x, int *r_y)
static void handle_panel_header(const bContext *C, const Block *block, const int mx, const int event_type, const bool ctrl, const bool shift)
void block_new_button_group(Block *block, ButtonGroupFlag flag)
static bool compare_panel(const PanelSort &a, const PanelSort &b)
bool panel_is_active(const Panel *panel)
void tooltip_text_field_add(TooltipData &data, std::string text, std::string suffix, const TooltipStyle style, const TooltipColorID color_id, const bool is_pad=false)
static PanelMouseState panel_mouse_state_get(const Block *block, const Panel *panel, const int mx, const int my)
static constexpr const char * panel_category_tabs_block_name
Button * uiDefIconTextButR_prop(Block *block, ButtonType type, int icon, std::optional< StringRef > str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< StringRef > tip)
static bool panel_type_context_poll(ARegion *region, const PanelType *panel_type, const char *context)
void list_panel_unique_str(Panel *panel, char *r_name)
void block_draw(const bContext *C, Block *block)
static void region_panels_set_expansion_from_list_data(const bContext *C, ARegion *region)
static void region_panels_remove_invisible_layouts(ARegion *region)
void block_end(const bContext *C, Block *block, bool postpone_callbacks=false)
int2 block_layout_resolve(Block *block)
static void panel_draw_border(const Panel *panel, const rcti *rect, const rcti *header_rect, const bool is_active)
void panel_custom_data_set(Panel *panel, PointerRNA *custom_data)
Panel * panel_add_instanced(const bContext *C, ARegion *region, ListBaseT< Panel > *panels, const char *panel_idname, PointerRNA *custom_data)
static int panel_category_show_active_tab(const bContext &C, ARegion *region, const int mval[2])
static bool uiAlignPanelStep(ARegion *region, const float factor, const bool drag)
static void panel_custom_data_set_recursive(Panel *panel, PointerRNA *custom_data)
void panel_header_buttons_begin(Panel *panel)
static bool panel_active_animation_changed(ListBaseT< Panel > *lb, Panel **r_panel_animation, bool *r_no_animation)
static bool panel_custom_data_active_get(const Panel *panel)
static bool panels_need_realign(const ScrArea *area, ARegion *region, Panel **r_panel_animation)
void panel_stop_animation(const bContext *C, Panel *panel)
static void panel_set_expansion_from_search_filter_recursive(const bContext *C, Panel *panel, const bool use_search_closed)
PointerRNA * panel_custom_data_get(const Panel *panel)
void window_to_block_fl(const ARegion *region, const Block *block, float *x, float *y)
Definition interface.cc:193
static void panel_set_flag_recursive(Panel *panel, ePanel_Flag flag, bool value)
void panel_category_tabs_draw_all(const bContext *C, ARegion *region, const char *category_id_active)
static void panel_custom_data_active_set(Panel *panel)
void draw_layout_panels_backdrop(const ARegion *region, const Panel *panel, const float radius, float subpanel_backcolor[4])
Layout & block_layout(Block *block, LayoutDirection direction, LayoutType type, int x, int y, int size, int em, int padding, const uiStyle *style)
bool panel_category_is_visible(const ARegion *region)
void panel_category_index_active_set(ARegion *region, const int index)
static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag, short *flag_index)
static int get_panel_real_ofsy(Panel *panel)
void block_bounds_calc(Block *block)
Definition interface.cc:496
void panel_tag_search_filter_match(Panel *panel)
static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *region)
bool block_is_popup_any(const Block *block) ATTR_WARN_UNUSED_RESULT
void panel_region_width_set(ARegion *region, const float aspect, int unscaled_size)
const char * panel_category_active_get(ARegion *region, bool set_fallback)
void draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
void view2d_offset(View2D *v2d, float xfac, float yfac)
Definition view2d.cc:1954
static void panel_activate_state(const bContext *C, Panel *panel, const HandlePanelState state)
bool panel_is_dragging(const Panel *panel)
Panel * panel_find_by_type(ListBaseT< Panel > *lb, const PanelType *pt)
MINLINE float min_ff(float a, float b)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
ScrArea * CTX_wm_area(const bContext *C)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
int RNA_enum_get(PointerRNA *ptr, const char *name)
uint padding(uint offset, uint alignment)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Panel * BKE_panel_new(PanelType *panel_type)
Definition screen.cc:685
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
Definition blf.cc:835
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
unsigned int uint
Definition BKE_text.h:55
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
MINLINE int round_fl_to_int(float a)
wmEventHandler_UI * WM_event_add_ui_handler(const bContext *C, ListBaseT< wmEventHandler > *handlers, wmUIHandlerFunc handle_fn, wmUIHandlerRemoveFunc remove_fn, void *user_data, const eWM_EventHandlerFlag flag)
@ USER_UIFLAG2_PANEL_TABS_COMPACT
GPUVertFormat * immVertexFormat()
bool BKE_regiontype_uses_category_tabs(const ARegionType *region_type)
Definition screen.cc:407
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:615
wmWindow * CTX_wm_window(const bContext *C)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
@ TH_PANEL_SUB_BACK
@ TH_PANEL_OUTLINE
@ TH_PANEL_ACTIVE
@ TH_PANEL_HEADER
void WM_tooltip_clear(bContext *C, wmWindow *win)
Definition wm_tooltip.cc:84
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
bool ED_region_panel_category_gutter_isect_xy(const ARegion *region, const int event_xy[2])
Definition area_query.cc:95
int char * BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void immUnbindProgram()
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void immUniformColor3ubv(const unsigned char rgb[3])
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
int BLI_findstringindex(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:794
void BLF_size(int fontid, float size)
Definition blf.cc:445
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
VecBase< int32_t, 2 > int2
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
unsigned char uchar
Definition BKE_text.h:58
void ED_region_tag_refresh_ui(ARegion *region)
Definition area.cc:738
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
eWM_EventHandlerFlag
Definition WM_api.hh:707
BMesh const char void * data
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:339
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
wmWindowManager * CTX_wm_manager(const bContext *C)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:531
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
@ PNL_INSTANCED_LIST_ORDER_CHANGED
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
void BKE_panel_free(Panel *panel)
Definition screen.cc:702
int BLI_str_utf8_offset_from_index(const char *str, size_t str_len, int index_target) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
@ PANEL_TYPE_DEFAULT_CLOSED
@ PANEL_TYPE_NO_HEADER
@ PANEL_TYPE_INSTANCED
void WM_event_remove_ui_handler(ListBaseT< wmEventHandler > *handlers, wmUIHandlerFunc handle_fn, wmUIHandlerRemoveFunc remove_fn, void *user_data, const bool postpone)
ARegion * CTX_wm_region_popup(const bContext *C)
@ KM_RELEASE
Definition WM_types.hh:325
MINLINE float interpf(float target, float origin, float t)
double BLI_time_now_seconds()
Definition time.cc:30
bool BKE_region_panel_categories_search_filter_visible(const ARegion *region)
Definition screen.cc:422
bScreen * CTX_wm_screen(const bContext *C)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
@ RGN_FLAG_SEARCH_FILTER_ACTIVE
@ RGN_FLAG_SEARCH_FILTER_UPDATE
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const wmEventType event_type, const double time_step)
void CTX_store_set(bContext *C, const bContextStore *store)
void immUniformColor4ubv(const unsigned char rgba[4])
MINLINE int min_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
ARegion * CTX_wm_region(const bContext *C)
bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2])
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
Definition rct.cc:651
#define sqrtf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
float menu_shadow_fac
uiWidgetColors wcol_menu_back
float panel_roundness
unsigned char panel_title[4]
ThemeUI tui
ARegionTypeFlag flag
ListBaseT< PanelType > paneltypes
ListBaseT< Panel > panels
bke::ARegionRuntime * runtime
eRegion_Alignment alignment
eRegion_Type regiontype
ListBaseT< PanelCategoryStack > panels_category_active
Vector< LayoutPanelBody > bodies
Vector< LayoutPanelHeader > headers
struct PanelCategoryDyn * next
struct PanelCategoryDyn * prev
struct PanelCategoryStack * next
void(*) reorder(bContext *C, Panel *pa, int new_index)
char active_property[BKE_ST_MAXNAME]
char translation_context[BKE_ST_MAXNAME]
short(*) get_list_data_expand_flag(const bContext *C, Panel *pa)
PanelType * parent
ListBaseT< LinkData > children
char context[BKE_ST_MAXNAME]
char pin_to_last_property[BKE_ST_MAXNAME]
char category[BKE_ST_MAXNAME]
void(*) set_list_data_expand_flag(const bContext *C, Panel *pa, short expand_flag)
char idname[BKE_ST_MAXNAME]
char label[BKE_ST_MAXNAME]
LayoutPanels layout_panels
bContextStore * context
PointerRNA * custom_data_ptr
struct PanelType * type
ListBaseT< Panel > children
ui::Layout * layout
struct Panel * next
struct Panel_Runtime * runtime
ListBaseT< SpaceLink > spacedata
eSpaceButtons_Context mainbo
eSpaceButtons_Context mainb
ListBaseT< ui::Block > uiblocks
ListBaseT< PanelCategoryDyn > panels_category
Map< std::string, ui::Block * > block_name_map
struct ARegionType * type
Set< std::string > categories_search_match
ListBaseT< wmEventHandler > modalhandlers
Vector< ButtonGroup > button_groups
std::ranges::transform_view< std::ranges::ref_view< const Vector< std::unique_ptr< Button > > >, Button &(*)(const std::unique_ptr< Button > &)> buttons() const
TextDirection text_direction
void alignment_set(LayoutAlign alignment)
bContextStore * context_store() const
Layout & column(bool align)
void context_ptr_set(StringRef name, const PointerRNA *ptr)
wmEventType type
Definition WM_types.hh:817
wmEventModifierFlag modifier
Definition WM_types.hh:834
bke::WindowRuntime * runtime
uiFontStyle paneltitle
short panelspace
uiFontStyle widget
unsigned char text[4]