Blender V5.0
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
8
9#include "interface_intern.hh"
10
11/* -------------------------------------------------------------------- */
14
16{
17 /* Don't create a new group if there is a "lock" on new groups. */
18 if (!block->button_groups.is_empty()) {
19 uiButtonGroup &last_group = block->button_groups.last();
20 if (last_group.flag & UI_BUTTON_GROUP_LOCK) {
21 return;
22 }
23 }
24
25 block->button_groups.append({});
26 block->button_groups.last().flag = flag;
27}
28
30{
31 if (block->button_groups.is_empty()) {
33 }
34
35 uiButtonGroup &current_group = block->button_groups.last();
36 current_group.buttons.append(but);
37}
38
39void ui_button_group_replace_but_ptr(uiBlock *block, const uiBut *old_but_ptr, uiBut *new_but)
40{
41 for (uiButtonGroup &group : block->button_groups) {
42 std::replace_if(
43 group.buttons.begin(),
44 group.buttons.end(),
45 [&](const uiBut *ptr) { return ptr == old_but_ptr; },
46 new_but);
47 }
48}
49
void append(const T &value)
const T & last(const int64_t n=0) const
bool is_empty() const
T * end()
T * begin()
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:4238
uint8_t flag
Definition wm_window.cc:145