Blender V4.3
interface_button_group.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "MEM_guardedalloc.h"
10
11#include "interface_intern.hh"
12
13/* -------------------------------------------------------------------- */
18{
19 /* Don't create a new group if there is a "lock" on new groups. */
20 if (!block->button_groups.is_empty()) {
21 uiButtonGroup &last_group = block->button_groups.last();
22 if (last_group.flag & UI_BUTTON_GROUP_LOCK) {
23 return;
24 }
25 }
26
27 block->button_groups.append({});
28 block->button_groups.last().flag = flag;
29}
30
32{
33 if (block->button_groups.is_empty()) {
35 }
36
37 uiButtonGroup &current_group = block->button_groups.last();
38 current_group.buttons.append(but);
39}
40
41void ui_button_group_replace_but_ptr(uiBlock *block, const uiBut *old_but_ptr, uiBut *new_but)
42{
43 for (uiButtonGroup &group : block->button_groups) {
44 std::replace_if(
45 group.buttons.begin(),
46 group.buttons.end(),
47 [&](const uiBut *ptr) { return ptr == old_but_ptr; },
48 new_but);
49 }
50}
51
Read Guarded memory(de)allocation.
void append(const T &value)
const T & last(const int64_t n=0) const
bool is_empty() const
void ui_button_group_replace_but_ptr(uiBlock *block, const uiBut *old_but_ptr, uiBut *new_but)
void ui_block_new_button_group(uiBlock *block, uiButtonGroupFlag flag)
void ui_button_group_add_but(uiBlock *block, uiBut *but)
uiButtonGroupFlag
@ UI_BUTTON_GROUP_LOCK
blender::Vector< uiButtonGroup > button_groups
uiButtonGroupFlag flag
blender::Vector< uiBut * > buttons
PointerRNA * ptr
Definition wm_files.cc:4126
uint8_t flag
Definition wm_window.cc:138