Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_button_group.c
| Show All 26 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Button Groups | /** \name Button Groups | ||||
| * \{ */ | * \{ */ | ||||
| /** | /** | ||||
| * Every function that adds a set of buttons must create another group, | * Every function that adds a set of buttons must create another group, | ||||
| * then #ui_def_but adds buttons to the current group (the last). | * then #ui_def_but adds buttons to the current group (the last). | ||||
| */ | */ | ||||
| void ui_block_new_button_group(uiBlock *block) | void ui_block_new_button_group(uiBlock *block, short flag) | ||||
| { | { | ||||
| /* Don't create a new group if there is a "lock" on new groups. */ | |||||
| if (!BLI_listbase_is_empty(&block->button_groups)) { | |||||
| uiButtonGroup *last_button_group = block->button_groups.last; | |||||
| if (last_button_group->flag & UI_BUTTON_GROUP_LOCK) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| uiButtonGroup *new_group = MEM_mallocN(sizeof(uiButtonGroup), __func__); | uiButtonGroup *new_group = MEM_mallocN(sizeof(uiButtonGroup), __func__); | ||||
| BLI_listbase_clear(&new_group->buttons); | BLI_listbase_clear(&new_group->buttons); | ||||
| new_group->flag = flag; | |||||
| BLI_addtail(&block->button_groups, new_group); | BLI_addtail(&block->button_groups, new_group); | ||||
| } | } | ||||
| void ui_button_group_add_but(uiBlock *block, uiBut *but) | void ui_button_group_add_but(uiBlock *block, uiBut *but) | ||||
| { | { | ||||
| if (BLI_listbase_is_empty(&block->button_groups)) { | if (BLI_listbase_is_empty(&block->button_groups)) { | ||||
| ui_block_new_button_group(block); | ui_block_new_button_group(block, 0); | ||||
| } | } | ||||
| uiButtonGroup *current_button_group = block->button_groups.last; | uiButtonGroup *current_button_group = block->button_groups.last; | ||||
| /* We can't use the button directly because adding it to | /* We can't use the button directly because adding it to | ||||
| * this list would mess with its prev and next pointers. */ | * this list would mess with its prev and next pointers. */ | ||||
| LinkData *button_link = BLI_genericNodeN(but); | LinkData *button_link = BLI_genericNodeN(but); | ||||
| BLI_addtail(¤t_button_group->buttons, button_link); | BLI_addtail(¤t_button_group->buttons, button_link); | ||||
| Show All 32 Lines | |||||