Files
test2/source/blender/editors/interface/interface_button_group.cc
Sergey Sharybin c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00

55 lines
1.3 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup edinterface
*/
#include "BLI_listbase.h"
#include "MEM_guardedalloc.h"
#include "interface_intern.hh"
/* -------------------------------------------------------------------- */
/** \name Button Groups
* \{ */
void ui_block_new_button_group(uiBlock *block, uiButtonGroupFlag flag)
{
/* Don't create a new group if there is a "lock" on new groups. */
if (!block->button_groups.is_empty()) {
uiButtonGroup &last_group = block->button_groups.last();
if (last_group.flag & UI_BUTTON_GROUP_LOCK) {
return;
}
}
block->button_groups.append({});
block->button_groups.last().flag = flag;
}
void ui_button_group_add_but(uiBlock *block, uiBut *but)
{
if (block->button_groups.is_empty()) {
ui_block_new_button_group(block, uiButtonGroupFlag(0));
}
uiButtonGroup &current_group = block->button_groups.last();
current_group.buttons.append(but);
}
void ui_button_group_replace_but_ptr(uiBlock *block, const uiBut *old_but_ptr, uiBut *new_but)
{
for (uiButtonGroup &group : block->button_groups) {
std::replace_if(
group.buttons.begin(),
group.buttons.end(),
[&](const uiBut *ptr) { return ptr == old_but_ptr; },
new_but);
}
}
/** \} */