Cleanup: Move four interface files to C++
This commit is contained in:
parent
4029cdee7b
commit
afd16c487d
|
@ -37,15 +37,15 @@ set(SRC
|
|||
interface.cc
|
||||
interface_align.c
|
||||
interface_anim.cc
|
||||
interface_button_group.c
|
||||
interface_context_menu.c
|
||||
interface_button_group.cc
|
||||
interface_context_menu.cc
|
||||
interface_context_path.cc
|
||||
interface_drag.cc
|
||||
interface_draw.c
|
||||
interface_draw.cc
|
||||
interface_dropboxes.cc
|
||||
interface_handlers.c
|
||||
interface_icons.c
|
||||
interface_icons_event.c
|
||||
interface_icons_event.cc
|
||||
interface_layout.c
|
||||
interface_ops.cc
|
||||
interface_panel.cc
|
||||
|
|
|
@ -18,14 +18,13 @@ 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 (!BLI_listbase_is_empty(&block->button_groups)) {
|
||||
uiButtonGroup *last_button_group = block->button_groups.last;
|
||||
uiButtonGroup *last_button_group = static_cast<uiButtonGroup *>(block->button_groups.last);
|
||||
if (last_button_group->flag & UI_BUTTON_GROUP_LOCK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uiButtonGroup *new_group = MEM_mallocN(sizeof(uiButtonGroup), __func__);
|
||||
BLI_listbase_clear(&new_group->buttons);
|
||||
uiButtonGroup *new_group = MEM_cnew<uiButtonGroup>(__func__);
|
||||
new_group->flag = flag;
|
||||
BLI_addtail(&block->button_groups, new_group);
|
||||
}
|
||||
|
@ -33,10 +32,10 @@ void ui_block_new_button_group(uiBlock *block, uiButtonGroupFlag flag)
|
|||
void ui_button_group_add_but(uiBlock *block, uiBut *but)
|
||||
{
|
||||
if (BLI_listbase_is_empty(&block->button_groups)) {
|
||||
ui_block_new_button_group(block, 0);
|
||||
ui_block_new_button_group(block, uiButtonGroupFlag(0));
|
||||
}
|
||||
|
||||
uiButtonGroup *current_button_group = block->button_groups.last;
|
||||
uiButtonGroup *current_button_group = static_cast<uiButtonGroup *>(block->button_groups.last);
|
||||
|
||||
/* We can't use the button directly because adding it to
|
||||
* this list would mess with its `prev` and `next` pointers. */
|
|
@ -6,7 +6,7 @@
|
|||
* Generic context popup menus.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -59,8 +59,8 @@ static IDProperty *shortcut_property_from_rna(bContext *C, uiBut *but)
|
|||
* Support can be added at #wm_context_member_from_ptr. */
|
||||
char *final_data_path = WM_context_path_resolve_property_full(
|
||||
C, &but->rnapoin, but->rnaprop, but->rnaindex);
|
||||
if (final_data_path == NULL) {
|
||||
return NULL;
|
||||
if (final_data_path == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Create ID property of data path, to pass to the operator. */
|
||||
|
@ -77,7 +77,9 @@ static const char *shortcut_get_operator_property(bContext *C, uiBut *but, IDPro
|
|||
{
|
||||
if (but->optype) {
|
||||
/* Operator */
|
||||
*r_prop = (but->opptr && but->opptr->data) ? IDP_CopyProperty(but->opptr->data) : NULL;
|
||||
*r_prop = (but->opptr && but->opptr->data) ?
|
||||
IDP_CopyProperty(static_cast<IDProperty *>(but->opptr->data)) :
|
||||
nullptr;
|
||||
return but->optype->idname;
|
||||
}
|
||||
|
||||
|
@ -87,23 +89,23 @@ static const char *shortcut_get_operator_property(bContext *C, uiBut *but, IDPro
|
|||
if (rnaprop_type == PROP_BOOLEAN) {
|
||||
/* Boolean */
|
||||
*r_prop = shortcut_property_from_rna(C, but);
|
||||
if (*r_prop == NULL) {
|
||||
return NULL;
|
||||
if (*r_prop == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return "WM_OT_context_toggle";
|
||||
}
|
||||
if (rnaprop_type == PROP_ENUM) {
|
||||
/* Enum */
|
||||
*r_prop = shortcut_property_from_rna(C, but);
|
||||
if (*r_prop == NULL) {
|
||||
return NULL;
|
||||
if (*r_prop == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return "WM_OT_context_menu_enum";
|
||||
}
|
||||
}
|
||||
|
||||
*r_prop = NULL;
|
||||
return NULL;
|
||||
*r_prop = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void shortcut_free_operator_property(IDProperty *prop)
|
||||
|
@ -120,7 +122,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
|
|||
|
||||
IDProperty *prop;
|
||||
const char *idname = shortcut_get_operator_property(C, but, &prop);
|
||||
if (idname == NULL) {
|
||||
if (idname == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -131,7 +133,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
|
|||
}
|
||||
else {
|
||||
/* simply strip the shortcut */
|
||||
ui_but_add_shortcut(but, NULL, true);
|
||||
ui_but_add_shortcut(but, nullptr, true);
|
||||
}
|
||||
|
||||
shortcut_free_operator_property(prop);
|
||||
|
@ -156,7 +158,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *region, void *arg)
|
|||
&km);
|
||||
U.runtime.is_dirty = true;
|
||||
|
||||
BLI_assert(kmi != NULL);
|
||||
BLI_assert(kmi != nullptr);
|
||||
|
||||
RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
|
||||
|
||||
|
@ -178,8 +180,8 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *region, void *arg)
|
|||
uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), ICON_HAND);
|
||||
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
|
||||
|
||||
UI_block_bounds_set_popup(
|
||||
block, 6 * U.dpi_fac, (const int[2]){-100 * U.dpi_fac, 36 * U.dpi_fac});
|
||||
const int bounds_offset[2] = {int(-100 * U.dpi_fac), int(36 * U.dpi_fac)};
|
||||
UI_block_bounds_set_popup(block, 6 * U.dpi_fac, bounds_offset);
|
||||
|
||||
shortcut_free_operator_property(prop);
|
||||
|
||||
|
@ -202,17 +204,15 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg)
|
|||
/* XXX this guess_opname can potentially return a different keymap
|
||||
* than being found on adding later... */
|
||||
wmKeyMap *km = WM_keymap_guess_opname(C, idname);
|
||||
wmKeyMapItem *kmi = WM_keymap_add_item(km,
|
||||
idname,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_AKEY,
|
||||
.value = KM_PRESS,
|
||||
.modifier = 0,
|
||||
.direction = KM_ANY,
|
||||
});
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_AKEY;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = 0;
|
||||
params.direction = KM_ANY;
|
||||
wmKeyMapItem *kmi = WM_keymap_add_item(km, idname, ¶ms);
|
||||
const int kmi_id = kmi->id;
|
||||
|
||||
/* This takes ownership of prop, or prop can be NULL for reset. */
|
||||
/* This takes ownership of prop, or prop can be nullptr for reset. */
|
||||
WM_keymap_item_properties_reset(kmi, prop);
|
||||
|
||||
/* update and get pointers again */
|
||||
|
@ -241,8 +241,8 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg)
|
|||
uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Assign Shortcut"), ICON_HAND);
|
||||
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
|
||||
|
||||
UI_block_bounds_set_popup(
|
||||
block, 6 * U.dpi_fac, (const int[2]){-100 * U.dpi_fac, 36 * U.dpi_fac});
|
||||
const int bounds_offset[2] = {int(-100 * U.dpi_fac), int(36 * U.dpi_fac)};
|
||||
UI_block_bounds_set_popup(block, 6 * U.dpi_fac, bounds_offset);
|
||||
|
||||
#ifdef USE_KEYMAP_ADD_HACK
|
||||
g_kmi_id_hack = kmi_id;
|
||||
|
@ -251,7 +251,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg)
|
|||
return block;
|
||||
}
|
||||
|
||||
static void menu_add_shortcut_cancel(struct bContext *C, void *arg1)
|
||||
static void menu_add_shortcut_cancel(bContext *C, void *arg1)
|
||||
{
|
||||
uiBut *but = (uiBut *)arg1;
|
||||
|
||||
|
@ -272,13 +272,13 @@ static void menu_add_shortcut_cancel(struct bContext *C, void *arg1)
|
|||
WM_keymap_remove_item(km, kmi);
|
||||
}
|
||||
|
||||
static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
|
||||
static void popup_change_shortcut_func(bContext *C, void *arg1, void * /*arg2*/)
|
||||
{
|
||||
uiBut *but = (uiBut *)arg1;
|
||||
UI_popup_block_invoke(C, menu_change_shortcut, but, NULL);
|
||||
UI_popup_block_invoke(C, menu_change_shortcut, but, nullptr);
|
||||
}
|
||||
|
||||
static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
|
||||
static void remove_shortcut_func(bContext *C, void *arg1, void * /*arg2*/)
|
||||
{
|
||||
uiBut *but = (uiBut *)arg1;
|
||||
IDProperty *prop;
|
||||
|
@ -292,7 +292,7 @@ static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
|
|||
EVT_TYPE_MASK_HOTKEY_INCLUDE,
|
||||
EVT_TYPE_MASK_HOTKEY_EXCLUDE,
|
||||
&km);
|
||||
BLI_assert(kmi != NULL);
|
||||
BLI_assert(kmi != nullptr);
|
||||
|
||||
WM_keymap_remove_item(km, kmi);
|
||||
U.runtime.is_dirty = true;
|
||||
|
@ -301,10 +301,10 @@ static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
|
|||
but_shortcut_name_func(C, but, 0);
|
||||
}
|
||||
|
||||
static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
|
||||
static void popup_add_shortcut_func(bContext *C, void *arg1, void * /*arg2*/)
|
||||
{
|
||||
uiBut *but = (uiBut *)arg1;
|
||||
UI_popup_block_ex(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but, NULL);
|
||||
UI_popup_block_ex(C, menu_add_shortcut, nullptr, menu_add_shortcut_cancel, but, nullptr);
|
||||
}
|
||||
|
||||
static bool ui_but_is_user_menu_compatible(bContext *C, uiBut *but)
|
||||
|
@ -316,7 +316,7 @@ static bool ui_but_is_user_menu_compatible(bContext *C, uiBut *but)
|
|||
else if (but->rnaprop) {
|
||||
if (RNA_property_type(but->rnaprop) == PROP_BOOLEAN) {
|
||||
char *data_path = WM_context_path_resolve_full(C, &but->rnapoin);
|
||||
if (data_path != NULL) {
|
||||
if (data_path != nullptr) {
|
||||
MEM_freeN(data_path);
|
||||
result = true;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ static bool ui_but_is_user_menu_compatible(bContext *C, uiBut *but)
|
|||
static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu *um)
|
||||
{
|
||||
if (but->optype) {
|
||||
IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
|
||||
IDProperty *prop = (but->opptr) ? static_cast<IDProperty *>(but->opptr->data) : nullptr;
|
||||
return (bUserMenuItem *)ED_screen_user_menu_item_find_operator(
|
||||
&um->items, but->optype, prop, but->opcontext);
|
||||
}
|
||||
|
@ -346,10 +346,10 @@ static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu *
|
|||
}
|
||||
|
||||
MenuType *mt = UI_but_menutype_get(but);
|
||||
if (mt != NULL) {
|
||||
if (mt != nullptr) {
|
||||
return (bUserMenuItem *)ED_screen_user_menu_item_find_menu(&um->items, mt);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
|
||||
|
@ -359,7 +359,7 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
|
|||
char drawstr[sizeof(but->drawstr)];
|
||||
ui_but_drawstr_without_sep_char(but, drawstr, sizeof(drawstr));
|
||||
|
||||
MenuType *mt = NULL;
|
||||
MenuType *mt = nullptr;
|
||||
if (but->optype) {
|
||||
if (drawstr[0] == '\0') {
|
||||
/* Hard code overrides for generic operators. */
|
||||
|
@ -368,7 +368,7 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
|
|||
RNA_string_get(but->opptr, "name", idname);
|
||||
#ifdef WITH_PYTHON
|
||||
{
|
||||
const char *expr_imports[] = {"bpy", "bl_ui", NULL};
|
||||
const char *expr_imports[] = {"bpy", "bl_ui", nullptr};
|
||||
char expr[256];
|
||||
SNPRINTF(expr,
|
||||
"bl_ui.space_toolsystem_common.item_from_id("
|
||||
|
@ -376,8 +376,8 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
|
|||
"bpy.context.space_data.type, "
|
||||
"'%s').label",
|
||||
idname);
|
||||
char *expr_result = NULL;
|
||||
if (BPY_run_string_as_string(C, expr_imports, expr, NULL, &expr_result)) {
|
||||
char *expr_result = nullptr;
|
||||
if (BPY_run_string_as_string(C, expr_imports, expr, nullptr, &expr_result)) {
|
||||
STRNCPY(drawstr, expr_result);
|
||||
MEM_freeN(expr_result);
|
||||
}
|
||||
|
@ -392,7 +392,11 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
|
|||
}
|
||||
}
|
||||
ED_screen_user_menu_item_add_operator(
|
||||
&um->items, drawstr, but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext);
|
||||
&um->items,
|
||||
drawstr,
|
||||
but->optype,
|
||||
but->opptr ? static_cast<const IDProperty *>(but->opptr->data) : nullptr,
|
||||
but->opcontext);
|
||||
}
|
||||
else if (but->rnaprop) {
|
||||
/* NOTE: 'member_id' may be a path. */
|
||||
|
@ -407,9 +411,9 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
|
|||
}
|
||||
}
|
||||
|
||||
static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *UNUSED(arg2))
|
||||
static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void * /*arg2*/)
|
||||
{
|
||||
uiBut *but = arg1;
|
||||
uiBut *but = static_cast<uiBut *>(arg1);
|
||||
bUserMenu *um = ED_screen_user_menu_ensure(C);
|
||||
U.runtime.is_dirty = true;
|
||||
ui_but_user_menu_add(C, but, um);
|
||||
|
@ -417,8 +421,8 @@ static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *U
|
|||
|
||||
static void popup_user_menu_remove_func(bContext *UNUSED(C), void *arg1, void *arg2)
|
||||
{
|
||||
bUserMenu *um = arg1;
|
||||
bUserMenuItem *umi = arg2;
|
||||
bUserMenu *um = static_cast<bUserMenu *>(arg1);
|
||||
bUserMenuItem *umi = static_cast<bUserMenuItem *>(arg2);
|
||||
U.runtime.is_dirty = true;
|
||||
ED_screen_user_menu_item_remove(&um->items, umi);
|
||||
}
|
||||
|
@ -444,7 +448,7 @@ static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, Pr
|
|||
ot,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&props_ptr);
|
||||
|
@ -455,7 +459,7 @@ static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, Pr
|
|||
ot,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&props_ptr);
|
||||
|
@ -474,10 +478,10 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
uiLayout *layout;
|
||||
bContextStore *previous_ctx = CTX_store_get(C);
|
||||
{
|
||||
uiStringInfo label = {BUT_GET_LABEL, NULL};
|
||||
uiStringInfo label = {BUT_GET_LABEL, nullptr};
|
||||
|
||||
/* highly unlikely getting the label ever fails */
|
||||
UI_but_string_info_get(C, but, &label, NULL);
|
||||
UI_but_string_info_get(C, but, &label, nullptr);
|
||||
|
||||
pup = UI_popup_menu_begin(C, label.strinfo ? label.strinfo : "", ICON_NONE);
|
||||
layout = UI_popup_menu_layout(pup);
|
||||
|
@ -755,13 +759,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
#if 0 /* Disabled for now. */
|
||||
ot = WM_operatortype_find("UI_OT_override_type_set_button", false);
|
||||
uiItemFullO_ptr(
|
||||
layout, ot, "Overrides Type", ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
|
||||
layout, ot, "Overrides Type", ICON_NONE, nullptr, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
|
||||
RNA_boolean_set(&op_ptr, "all", true);
|
||||
uiItemFullO_ptr(layout,
|
||||
ot,
|
||||
"Single Override Type",
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
|
@ -786,7 +790,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
"UI_OT_override_type_set_button",
|
||||
"Override Type",
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
|
@ -807,7 +811,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
ot,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Define Overrides"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
|
@ -816,7 +820,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
ot,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Define Single Override"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
|
@ -827,7 +831,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
"UI_OT_override_type_set_button",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Define Override"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
|
@ -938,17 +942,17 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
|
||||
/* If the button represents an id, it can set the "id" context pointer. */
|
||||
if (ED_asset_can_mark_single_from_context(C)) {
|
||||
ID *id = CTX_data_pointer_get_type(C, "id", &RNA_ID).data;
|
||||
const ID *id = static_cast<const ID *>(CTX_data_pointer_get_type(C, "id", &RNA_ID).data);
|
||||
|
||||
/* Gray out items depending on if data-block is an asset. Preferably this could be done via
|
||||
* operator poll, but that doesn't work since the operator also works with "selected_ids",
|
||||
* which isn't cheap to check. */
|
||||
uiLayout *sub = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetEnabled(sub, !id->asset_data);
|
||||
uiItemO(sub, NULL, ICON_NONE, "ASSET_OT_mark");
|
||||
uiItemO(sub, nullptr, ICON_NONE, "ASSET_OT_mark");
|
||||
sub = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetEnabled(sub, id->asset_data);
|
||||
uiItemO(sub, NULL, ICON_NONE, "ASSET_OT_clear");
|
||||
uiItemO(sub, nullptr, ICON_NONE, "ASSET_OT_clear");
|
||||
uiItemS(layout);
|
||||
}
|
||||
|
||||
|
@ -984,11 +988,11 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
bUserMenu **um_array = ED_screen_user_menus_find(C, &um_array_len);
|
||||
for (int um_index = 0; um_index < um_array_len; um_index++) {
|
||||
bUserMenu *um = um_array[um_index];
|
||||
if (um == NULL) {
|
||||
if (um == nullptr) {
|
||||
continue;
|
||||
}
|
||||
bUserMenuItem *umi = ui_but_user_menu_find(C, but, um);
|
||||
if (umi != NULL) {
|
||||
if (umi != nullptr) {
|
||||
uiBut *but2 = uiDefIconTextBut(
|
||||
block,
|
||||
UI_BTYPE_BUT,
|
||||
|
@ -999,7 +1003,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
0,
|
||||
w,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@ -1024,13 +1028,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
0,
|
||||
w,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"Add to a user defined context menu (stored in the user preferences)");
|
||||
UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL);
|
||||
UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, nullptr);
|
||||
}
|
||||
|
||||
uiItemS(layout);
|
||||
|
@ -1039,7 +1043,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
/* Shortcut menu */
|
||||
IDProperty *prop;
|
||||
const char *idname = shortcut_get_operator_property(C, but, &prop);
|
||||
if (idname != NULL) {
|
||||
if (idname != nullptr) {
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
const int w = uiLayoutGetWidth(layout);
|
||||
|
||||
|
@ -1073,13 +1077,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
0,
|
||||
w,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"");
|
||||
UI_but_func_set(but2, popup_change_shortcut_func, but, NULL);
|
||||
UI_but_func_set(but2, popup_change_shortcut_func, but, nullptr);
|
||||
}
|
||||
else {
|
||||
uiBut *but2 = uiDefIconTextBut(block,
|
||||
|
@ -1091,7 +1095,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
0,
|
||||
w,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@ -1111,13 +1115,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
0,
|
||||
w,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"");
|
||||
UI_but_func_set(but2, remove_shortcut_func, but, NULL);
|
||||
UI_but_func_set(but2, remove_shortcut_func, but, nullptr);
|
||||
}
|
||||
/* only show 'assign' if there's a suitable key map for it to go in */
|
||||
else if (WM_keymap_guess_opname(C, idname)) {
|
||||
|
@ -1131,13 +1135,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
0,
|
||||
w,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
"");
|
||||
UI_but_func_set(but2, popup_add_shortcut_func, but, NULL);
|
||||
UI_but_func_set(but2, popup_add_shortcut_func, but, nullptr);
|
||||
}
|
||||
|
||||
shortcut_free_operator_property(prop);
|
||||
|
@ -1163,7 +1167,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
"WM_OT_doc_view",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
0,
|
||||
&ptr_props);
|
||||
|
@ -1173,26 +1177,32 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
}
|
||||
|
||||
if (but->optype && U.flag & USER_DEVELOPER_UI) {
|
||||
uiItemO(layout, NULL, ICON_NONE, "UI_OT_copy_python_command_button");
|
||||
uiItemO(layout, nullptr, ICON_NONE, "UI_OT_copy_python_command_button");
|
||||
}
|
||||
|
||||
/* perhaps we should move this into (G.debug & G_DEBUG) - campbell */
|
||||
if (U.flag & USER_DEVELOPER_UI) {
|
||||
if (ui_block_is_menu(but->block) == false) {
|
||||
uiItemFullO(
|
||||
layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
|
||||
uiItemFullO(layout,
|
||||
"UI_OT_editsource",
|
||||
nullptr,
|
||||
ICON_NONE,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (BKE_addon_find(&U.addons, "ui_translate")) {
|
||||
uiItemFullO(layout,
|
||||
"UI_OT_edittranslation_init",
|
||||
NULL,
|
||||
nullptr,
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
NULL);
|
||||
nullptr);
|
||||
}
|
||||
|
||||
/* Show header tools for header buttons. */
|
||||
|
@ -1203,25 +1213,27 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
|
|||
/* skip */
|
||||
}
|
||||
else if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
|
||||
uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL);
|
||||
uiItemMenuF(
|
||||
layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, nullptr);
|
||||
}
|
||||
else if (region->regiontype == RGN_TYPE_NAV_BAR) {
|
||||
uiItemMenuF(layout,
|
||||
IFACE_("Navigation Bar"),
|
||||
ICON_NONE,
|
||||
ED_screens_navigation_bar_tools_menu_create,
|
||||
NULL);
|
||||
nullptr);
|
||||
}
|
||||
else if (region->regiontype == RGN_TYPE_FOOTER) {
|
||||
uiItemMenuF(layout, IFACE_("Footer"), ICON_NONE, ED_screens_footer_tools_menu_create, NULL);
|
||||
uiItemMenuF(
|
||||
layout, IFACE_("Footer"), ICON_NONE, ED_screens_footer_tools_menu_create, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* UI List item context menu. Scripts can add items to it, by default there's nothing shown. */
|
||||
const ARegion *region = CTX_wm_menu(C) ? CTX_wm_menu(C) : CTX_wm_region(C);
|
||||
const bool is_inside_listbox = ui_list_find_mouse_over(region, event) != NULL;
|
||||
const bool is_inside_listbox = ui_list_find_mouse_over(region, event) != nullptr;
|
||||
const bool is_inside_listrow = is_inside_listbox ?
|
||||
ui_list_row_find_mouse_over(region, event->xy) != NULL :
|
||||
ui_list_row_find_mouse_over(region, event->xy) != nullptr :
|
||||
false;
|
||||
if (is_inside_listrow) {
|
||||
MenuType *mt = WM_menutype_find("UI_MT_list_item_context_menu", true);
|
||||
|
@ -1257,7 +1269,7 @@ void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *panel)
|
|||
if (!any_item_visible) {
|
||||
return;
|
||||
}
|
||||
if (panel->type->parent != NULL) {
|
||||
if (panel->type->parent != nullptr) {
|
||||
return;
|
||||
}
|
||||
if (!UI_panel_can_be_pinned(panel)) {
|
||||
|
@ -1282,7 +1294,7 @@ void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *panel)
|
|||
/* evil, force shortcut flag */
|
||||
{
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
uiBut *but = block->buttons.last;
|
||||
uiBut *but = static_cast<uiBut *>(block->buttons.last);
|
||||
but->flag |= UI_BUT_HAS_SEP_CHAR;
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@
|
|||
* \ingroup edinterface
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "DNA_color_types.h"
|
||||
#include "DNA_curve_types.h"
|
||||
|
@ -76,49 +76,33 @@ void UI_draw_roundbox_4fv_ex(const rctf *rect,
|
|||
{
|
||||
/* WATCH: This is assuming the ModelViewProjectionMatrix is area pixel space.
|
||||
* If it has been scaled, then it's no longer valid. */
|
||||
uiWidgetBaseParameters widget_params = {
|
||||
.recti.xmin = rect->xmin + outline_width,
|
||||
.recti.ymin = rect->ymin + outline_width,
|
||||
.recti.xmax = rect->xmax - outline_width,
|
||||
.recti.ymax = rect->ymax - outline_width,
|
||||
.rect = *rect,
|
||||
.radi = rad,
|
||||
.rad = rad,
|
||||
.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f,
|
||||
.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f,
|
||||
.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f,
|
||||
.round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f,
|
||||
.color_inner1[0] = inner1 ? inner1[0] : 0.0f,
|
||||
.color_inner1[1] = inner1 ? inner1[1] : 0.0f,
|
||||
.color_inner1[2] = inner1 ? inner1[2] : 0.0f,
|
||||
.color_inner1[3] = inner1 ? inner1[3] : 0.0f,
|
||||
.color_inner2[0] = inner2 ? inner2[0] :
|
||||
inner1 ? inner1[0] :
|
||||
0.0f,
|
||||
.color_inner2[1] = inner2 ? inner2[1] :
|
||||
inner1 ? inner1[1] :
|
||||
0.0f,
|
||||
.color_inner2[2] = inner2 ? inner2[2] :
|
||||
inner1 ? inner1[2] :
|
||||
0.0f,
|
||||
.color_inner2[3] = inner2 ? inner2[3] :
|
||||
inner1 ? inner1[3] :
|
||||
0.0f,
|
||||
.color_outline[0] = outline ? outline[0] :
|
||||
inner1 ? inner1[0] :
|
||||
0.0f,
|
||||
.color_outline[1] = outline ? outline[1] :
|
||||
inner1 ? inner1[1] :
|
||||
0.0f,
|
||||
.color_outline[2] = outline ? outline[2] :
|
||||
inner1 ? inner1[2] :
|
||||
0.0f,
|
||||
.color_outline[3] = outline ? outline[3] :
|
||||
inner1 ? inner1[3] :
|
||||
0.0f,
|
||||
.shade_dir = shade_dir,
|
||||
.alpha_discard = 1.0f,
|
||||
};
|
||||
uiWidgetBaseParameters widget_params{};
|
||||
widget_params.recti.xmin = rect->xmin + outline_width;
|
||||
widget_params.recti.ymin = rect->ymin + outline_width;
|
||||
widget_params.recti.xmax = rect->xmax - outline_width;
|
||||
widget_params.recti.ymax = rect->ymax - outline_width;
|
||||
widget_params.rect = *rect;
|
||||
widget_params.radi = rad;
|
||||
widget_params.rad = rad;
|
||||
widget_params.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f;
|
||||
widget_params.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f;
|
||||
widget_params.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f;
|
||||
widget_params.round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f;
|
||||
widget_params.color_inner1[0] = inner1 ? inner1[0] : 0.0f;
|
||||
widget_params.color_inner1[1] = inner1 ? inner1[1] : 0.0f;
|
||||
widget_params.color_inner1[2] = inner1 ? inner1[2] : 0.0f;
|
||||
widget_params.color_inner1[3] = inner1 ? inner1[3] : 0.0f;
|
||||
widget_params.color_inner2[0] = inner2 ? inner2[0] : inner1 ? inner1[0] : 0.0f;
|
||||
widget_params.color_inner2[1] = inner2 ? inner2[1] : inner1 ? inner1[1] : 0.0f;
|
||||
widget_params.color_inner2[2] = inner2 ? inner2[2] : inner1 ? inner1[2] : 0.0f;
|
||||
widget_params.color_inner2[3] = inner2 ? inner2[3] : inner1 ? inner1[3] : 0.0f;
|
||||
widget_params.color_outline[0] = outline ? outline[0] : inner1 ? inner1[0] : 0.0f;
|
||||
widget_params.color_outline[1] = outline ? outline[1] : inner1 ? inner1[1] : 0.0f;
|
||||
widget_params.color_outline[2] = outline ? outline[2] : inner1 ? inner1[2] : 0.0f;
|
||||
widget_params.color_outline[3] = outline ? outline[3] : inner1 ? inner1[3] : 0.0f;
|
||||
widget_params.shade_dir = shade_dir;
|
||||
widget_params.alpha_discard = 1.0f;
|
||||
|
||||
GPUBatch *batch = ui_batch_roundbox_widget_get();
|
||||
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
|
||||
GPU_batch_uniform_4fv_array(batch, "parameters", 11, (const float(*)[4]) & widget_params);
|
||||
|
@ -131,19 +115,19 @@ void UI_draw_roundbox_3ub_alpha(
|
|||
const rctf *rect, bool filled, float rad, const uchar col[3], uchar alpha)
|
||||
{
|
||||
const float colv[4] = {
|
||||
((float)col[0]) / 255,
|
||||
((float)col[1]) / 255,
|
||||
((float)col[2]) / 255,
|
||||
((float)alpha) / 255,
|
||||
(float(col[0])) / 255.0f,
|
||||
(float(col[1])) / 255.0f,
|
||||
(float(col[2])) / 255.0f,
|
||||
(float(alpha)) / 255.0f,
|
||||
};
|
||||
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : NULL, NULL, 1.0f, colv, U.pixelsize, rad);
|
||||
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : nullptr, nullptr, 1.0f, colv, U.pixelsize, rad);
|
||||
}
|
||||
|
||||
void UI_draw_roundbox_3fv_alpha(
|
||||
const rctf *rect, bool filled, float rad, const float col[3], float alpha)
|
||||
{
|
||||
const float colv[4] = {col[0], col[1], col[2], alpha};
|
||||
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : NULL, NULL, 1.0f, colv, U.pixelsize, rad);
|
||||
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : nullptr, nullptr, 1.0f, colv, U.pixelsize, rad);
|
||||
}
|
||||
|
||||
void UI_draw_roundbox_aa(const rctf *rect, bool filled, float rad, const float color[4])
|
||||
|
@ -155,13 +139,13 @@ void UI_draw_roundbox_aa(const rctf *rect, bool filled, float rad, const float c
|
|||
colv[3] *= 0.65f;
|
||||
}
|
||||
|
||||
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : NULL, NULL, 1.0f, colv, U.pixelsize, rad);
|
||||
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : nullptr, nullptr, 1.0f, colv, U.pixelsize, rad);
|
||||
}
|
||||
|
||||
void UI_draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
|
||||
{
|
||||
/* Exactly the same as UI_draw_roundbox_aa but does not do the legacy transparency. */
|
||||
UI_draw_roundbox_4fv_ex(rect, (filled) ? col : NULL, NULL, 1.0f, col, U.pixelsize, rad);
|
||||
UI_draw_roundbox_4fv_ex(rect, (filled) ? col : nullptr, nullptr, 1.0f, col, U.pixelsize, rad);
|
||||
}
|
||||
|
||||
void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4])
|
||||
|
@ -269,9 +253,9 @@ void ui_draw_but_TAB_outline(const rcti *rect,
|
|||
immUnbindProgram();
|
||||
}
|
||||
|
||||
void ui_draw_but_IMAGE(ARegion *UNUSED(region),
|
||||
void ui_draw_but_IMAGE(ARegion * /*region*/,
|
||||
uiBut *but,
|
||||
const uiWidgetColors *UNUSED(wcol),
|
||||
const uiWidgetColors * /*wcol*/,
|
||||
const rcti *rect)
|
||||
{
|
||||
#ifdef WITH_HEADLESS
|
||||
|
@ -311,8 +295,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(region),
|
|||
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_3D_IMAGE_COLOR);
|
||||
immDrawPixelsTexTiled(&state,
|
||||
(float)rect->xmin,
|
||||
(float)rect->ymin,
|
||||
float(rect->xmin),
|
||||
float(rect->ymin),
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
GPU_RGBA8,
|
||||
|
@ -365,16 +349,12 @@ static void draw_scope_end(const rctf *rect)
|
|||
/* outline */
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
const float color[4] = {0.0f, 0.0f, 0.0f, 0.5f};
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = rect->xmin - 1,
|
||||
.xmax = rect->xmax + 1,
|
||||
.ymin = rect->ymin,
|
||||
.ymax = rect->ymax + 1,
|
||||
},
|
||||
false,
|
||||
3.0f,
|
||||
color);
|
||||
rctf box_rect{};
|
||||
box_rect.xmin = rect->xmin - 1;
|
||||
box_rect.xmax = rect->xmax + 1;
|
||||
box_rect.ymin = rect->ymin;
|
||||
box_rect.ymax = rect->ymax + 1;
|
||||
UI_draw_roundbox_4fv(&box_rect, false, 3.0f, color);
|
||||
}
|
||||
|
||||
static void histogram_draw_one(float r,
|
||||
|
@ -408,7 +388,7 @@ static void histogram_draw_one(float r,
|
|||
|
||||
immBegin(GPU_PRIM_LINE_STRIP, res);
|
||||
for (int i = 0; i < res; i++) {
|
||||
const float x2 = x + i * (w / (float)res);
|
||||
const float x2 = x + i * (w / float(res));
|
||||
immVertex2f(pos_attr, x2, y + (data[i] * h));
|
||||
}
|
||||
immEnd();
|
||||
|
@ -421,7 +401,7 @@ static void histogram_draw_one(float r,
|
|||
immVertex2f(pos_attr, x, y);
|
||||
immVertex2f(pos_attr, x, y + (data[0] * h));
|
||||
for (int i = 1; i < res; i++) {
|
||||
const float x2 = x + i * (w / (float)res);
|
||||
const float x2 = x + i * (w / float(res));
|
||||
immVertex2f(pos_attr, x2, y + (data[i] * h));
|
||||
immVertex2f(pos_attr, x2, y);
|
||||
}
|
||||
|
@ -433,7 +413,7 @@ static void histogram_draw_one(float r,
|
|||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
immBegin(GPU_PRIM_LINE_STRIP, res);
|
||||
for (int i = 0; i < res; i++) {
|
||||
const float x2 = x + i * (w / (float)res);
|
||||
const float x2 = x + i * (w / float(res));
|
||||
immVertex2f(pos_attr, x2, y + (data[i] * h));
|
||||
}
|
||||
immEnd();
|
||||
|
@ -444,21 +424,20 @@ static void histogram_draw_one(float r,
|
|||
|
||||
#define HISTOGRAM_TOT_GRID_LINES 4
|
||||
|
||||
void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
|
||||
void ui_draw_but_HISTOGRAM(ARegion * /*region*/,
|
||||
uiBut *but,
|
||||
const uiWidgetColors *UNUSED(wcol),
|
||||
const uiWidgetColors * /*wcol*/,
|
||||
const rcti *recti)
|
||||
{
|
||||
Histogram *hist = (Histogram *)but->poin;
|
||||
const int res = hist->x_resolution;
|
||||
const bool is_line = (hist->flag & HISTO_FLAG_LINE) != 0;
|
||||
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1,
|
||||
};
|
||||
rctf rect{};
|
||||
rect.xmin = float(recti->xmin + 1);
|
||||
rect.xmax = float(recti->xmax - 1);
|
||||
rect.ymin = float(recti->ymin + 1);
|
||||
rect.ymax = float(recti->ymax - 1);
|
||||
|
||||
const float w = BLI_rctf_size_x(&rect);
|
||||
const float h = BLI_rctf_size_y(&rect) * hist->ymax;
|
||||
|
@ -468,16 +447,13 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
|
|||
float color[4];
|
||||
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = rect.xmin - 1,
|
||||
.xmax = rect.xmax + 1,
|
||||
.ymin = rect.ymin - 1,
|
||||
.ymax = rect.ymax + 1,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
color);
|
||||
rctf back_rect{};
|
||||
back_rect.xmin = rect.xmin - 1;
|
||||
back_rect.xmax = rect.xmax + 1;
|
||||
back_rect.ymin = rect.ymin - 1;
|
||||
back_rect.ymax = rect.ymax + 1;
|
||||
|
||||
UI_draw_roundbox_4fv(&back_rect, true, 3.0f, color);
|
||||
|
||||
/* need scissor test, histogram can draw outside of boundary */
|
||||
int scissor[4];
|
||||
|
@ -495,7 +471,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
|
|||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
|
||||
/* draw grid lines here */
|
||||
for (int i = 1; i <= HISTOGRAM_TOT_GRID_LINES; i++) {
|
||||
const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES;
|
||||
const float fac = float(i) / float(HISTOGRAM_TOT_GRID_LINES);
|
||||
|
||||
/* so we can tell the 1.0 color point */
|
||||
if (i == HISTOGRAM_TOT_GRID_LINES) {
|
||||
|
@ -558,7 +534,7 @@ static void waveform_draw_one(float *waveform, int waveform_num, const float col
|
|||
GPU_vertbuf_attr_fill(vbo, pos_id, waveform);
|
||||
|
||||
/* TODO: store the #GPUBatch inside the scope. */
|
||||
GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO);
|
||||
GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, nullptr, GPU_BATCH_OWNS_VBO);
|
||||
GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
GPU_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f);
|
||||
GPU_batch_draw(batch);
|
||||
|
@ -566,9 +542,9 @@ static void waveform_draw_one(float *waveform, int waveform_num, const float col
|
|||
GPU_batch_discard(batch);
|
||||
}
|
||||
|
||||
void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
|
||||
void ui_draw_but_WAVEFORM(ARegion * /*region*/,
|
||||
uiBut *but,
|
||||
const uiWidgetColors *UNUSED(wcol),
|
||||
const uiWidgetColors * /*wcol*/,
|
||||
const rcti *recti)
|
||||
{
|
||||
Scopes *scopes = (Scopes *)but->poin;
|
||||
|
@ -579,16 +555,15 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
|
|||
float colors_alpha[3][3], colorsycc_alpha[3][3];
|
||||
float min, max;
|
||||
|
||||
if (scopes == NULL) {
|
||||
if (scopes == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1,
|
||||
};
|
||||
rctf rect{};
|
||||
rect.xmin = float(recti->xmin + 1);
|
||||
rect.xmax = float(recti->xmax - 1);
|
||||
rect.ymin = float(recti->ymin + 1);
|
||||
rect.ymax = float(recti->ymax - 1);
|
||||
|
||||
if (scopes->wavefrm_yfac < 0.5f) {
|
||||
scopes->wavefrm_yfac = 0.98f;
|
||||
|
@ -618,16 +593,12 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
|
|||
float color[4];
|
||||
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = rect.xmin - 1,
|
||||
.xmax = rect.xmax + 1,
|
||||
.ymin = rect.ymin - 1,
|
||||
.ymax = rect.ymax + 1,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
color);
|
||||
rctf back_rect{};
|
||||
back_rect.xmin = rect.xmin - 1.0f;
|
||||
back_rect.xmax = rect.xmax + 1.0f;
|
||||
back_rect.ymin = rect.ymin - 1.0f;
|
||||
back_rect.ymax = rect.ymax + 1.0f;
|
||||
UI_draw_roundbox_4fv(&back_rect, true, 3.0f, color);
|
||||
|
||||
/* need scissor test, waveform can draw outside of boundary */
|
||||
GPU_scissor_get(scissor);
|
||||
|
@ -712,7 +683,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
|
|||
immEnd();
|
||||
}
|
||||
|
||||
if (scopes->ok && scopes->waveform_1 != NULL) {
|
||||
if (scopes->ok && scopes->waveform_1 != nullptr) {
|
||||
GPU_blend(GPU_BLEND_ADDITIVE);
|
||||
GPU_point_size(1.0);
|
||||
|
||||
|
@ -835,10 +806,10 @@ static void vectorscope_draw_target(
|
|||
tangle = atanf(v / u);
|
||||
}
|
||||
else if (u > 0 && v < 0) {
|
||||
tangle = atanf(v / u) + 2.0f * (float)M_PI;
|
||||
tangle = atanf(v / u) + 2.0f * float(M_PI);
|
||||
}
|
||||
else if (u < 0) {
|
||||
tangle = atanf(v / u) + (float)M_PI;
|
||||
tangle = atanf(v / u) + float(M_PI);
|
||||
}
|
||||
else if (u == 0 && v > 0.0f) {
|
||||
tangle = M_PI_2;
|
||||
|
@ -918,9 +889,9 @@ static void vectorscope_draw_target(
|
|||
immEnd();
|
||||
}
|
||||
|
||||
void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
|
||||
void ui_draw_but_VECTORSCOPE(ARegion * /*region*/,
|
||||
uiBut *but,
|
||||
const uiWidgetColors *UNUSED(wcol),
|
||||
const uiWidgetColors * /*wcol*/,
|
||||
const rcti *recti)
|
||||
{
|
||||
const float skin_rad = DEG2RADF(123.0f); /* angle in radians of the skin tone line */
|
||||
|
@ -935,12 +906,11 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
|
|||
{0.75, 0.0, 0.75},
|
||||
};
|
||||
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1,
|
||||
};
|
||||
rctf rect{};
|
||||
rect.xmin = float(recti->xmin + 1);
|
||||
rect.xmax = float(recti->xmax - 1);
|
||||
rect.ymin = float(recti->ymin + 1);
|
||||
rect.ymax = float(recti->ymax - 1);
|
||||
|
||||
const float w = BLI_rctf_size_x(&rect);
|
||||
const float h = BLI_rctf_size_y(&rect);
|
||||
|
@ -955,16 +925,12 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
|
|||
float color[4];
|
||||
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = rect.xmin - 1,
|
||||
.xmax = rect.xmax + 1,
|
||||
.ymin = rect.ymin - 1,
|
||||
.ymax = rect.ymax + 1,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
color);
|
||||
rctf back_rect{};
|
||||
back_rect.xmin = rect.xmin - 1;
|
||||
back_rect.xmax = rect.xmax + 1;
|
||||
back_rect.ymin = rect.ymin - 1;
|
||||
back_rect.ymax = rect.ymax + 1;
|
||||
UI_draw_roundbox_4fv(&back_rect, true, 3.0f, color);
|
||||
|
||||
/* need scissor test, hvectorscope can draw outside of boundary */
|
||||
int scissor[4];
|
||||
|
@ -995,9 +961,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
|
|||
/* circles */
|
||||
for (int j = 0; j < 5; j++) {
|
||||
const int increment = 15;
|
||||
immBegin(GPU_PRIM_LINE_LOOP, (int)(360 / increment));
|
||||
immBegin(GPU_PRIM_LINE_LOOP, int(360 / increment));
|
||||
for (int i = 0; i <= 360 - increment; i += increment) {
|
||||
const float a = DEG2RADF((float)i);
|
||||
const float a = DEG2RADF(float(i));
|
||||
const float r = (j + 1) * 0.1f;
|
||||
immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a));
|
||||
}
|
||||
|
@ -1018,7 +984,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
|
|||
vectorscope_draw_target(pos, centerx, centery, diam, colors[i]);
|
||||
}
|
||||
|
||||
if (scopes->ok && scopes->vecscope != NULL) {
|
||||
if (scopes->ok && scopes->vecscope != nullptr) {
|
||||
/* pixel point cloud */
|
||||
const float col[3] = {alpha, alpha, alpha};
|
||||
|
||||
|
@ -1108,7 +1074,7 @@ static void ui_draw_colorband_handle(uint shdr_pos,
|
|||
const rcti *rect,
|
||||
float x,
|
||||
const float rgb[3],
|
||||
struct ColorManagedDisplay *display,
|
||||
ColorManagedDisplay *display,
|
||||
bool active)
|
||||
{
|
||||
const float sizey = BLI_rcti_size_y(rect);
|
||||
|
@ -1202,15 +1168,16 @@ static void ui_draw_colorband_handle(uint shdr_pos,
|
|||
shdr_pos, x - (half_width - 2), y1 + 1, x + (half_width - 2), y1 + height - 2, true);
|
||||
}
|
||||
|
||||
void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const rcti *rect)
|
||||
void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors * /*wcol*/, const rcti *rect)
|
||||
{
|
||||
struct ColorManagedDisplay *display = ui_block_cm_display_get(but->block);
|
||||
ColorManagedDisplay *display = ui_block_cm_display_get(but->block);
|
||||
uint pos_id, col_id;
|
||||
|
||||
uiButColorBand *but_coba = (uiButColorBand *)but;
|
||||
ColorBand *coba = (but_coba->edit_coba == NULL) ? (ColorBand *)but->poin : but_coba->edit_coba;
|
||||
ColorBand *coba = (but_coba->edit_coba == nullptr) ? (ColorBand *)but->poin :
|
||||
but_coba->edit_coba;
|
||||
|
||||
if (coba == NULL) {
|
||||
if (coba == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1257,7 +1224,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
|
|||
|
||||
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
|
||||
for (int a = 0; a <= sizex; a++) {
|
||||
const float pos = ((float)a) / sizex;
|
||||
const float pos = (float(a)) / sizex;
|
||||
BKE_colorband_evaluate(coba, pos, colf);
|
||||
if (display) {
|
||||
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
|
||||
|
@ -1277,7 +1244,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
|
|||
|
||||
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
|
||||
for (int a = 0; a <= sizex; a++) {
|
||||
const float pos = ((float)a) / sizex;
|
||||
const float pos = (float(a)) / sizex;
|
||||
BKE_colorband_evaluate(coba, pos, colf);
|
||||
if (display) {
|
||||
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
|
||||
|
@ -1352,17 +1319,12 @@ void ui_draw_but_UNITVEC(uiBut *but,
|
|||
|
||||
/* backdrop */
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_3ub_alpha(
|
||||
&(const rctf){
|
||||
.xmin = rect->xmin,
|
||||
.xmax = rect->xmax,
|
||||
.ymin = rect->ymin,
|
||||
.ymax = rect->ymax,
|
||||
},
|
||||
true,
|
||||
radius,
|
||||
wcol->inner,
|
||||
255);
|
||||
rctf box_rect{};
|
||||
box_rect.xmin = rect->xmin;
|
||||
box_rect.xmax = rect->xmax;
|
||||
box_rect.ymin = rect->ymin;
|
||||
box_rect.ymax = rect->ymax;
|
||||
UI_draw_roundbox_3ub_alpha(&box_rect, true, radius, wcol->inner, 255);
|
||||
|
||||
GPU_face_culling(GPU_CULL_BACK);
|
||||
|
||||
|
@ -1383,11 +1345,11 @@ void ui_draw_but_UNITVEC(uiBut *but,
|
|||
GPU_matrix_scale_1f(size);
|
||||
|
||||
GPUBatch *sphere = GPU_batch_preset_sphere(2);
|
||||
struct SimpleLightingData simple_lighting_data;
|
||||
SimpleLightingData simple_lighting_data;
|
||||
copy_v4_fl4(simple_lighting_data.color, diffuse[0], diffuse[1], diffuse[2], 1.0f);
|
||||
copy_v3_v3(simple_lighting_data.light, light);
|
||||
GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(
|
||||
sizeof(struct SimpleLightingData), &simple_lighting_data, __func__);
|
||||
sizeof(SimpleLightingData), &simple_lighting_data, __func__);
|
||||
|
||||
GPU_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING);
|
||||
GPU_batch_uniformbuf_bind(sphere, "simple_lighting_data", ubo);
|
||||
|
@ -1475,8 +1437,8 @@ static void gl_shaded_color(const uchar *color, int shade)
|
|||
void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol, const rcti *rect)
|
||||
{
|
||||
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
|
||||
CurveMapping *cumap = (but_cumap->edit_cumap == NULL) ? (CurveMapping *)but->poin :
|
||||
but_cumap->edit_cumap;
|
||||
CurveMapping *cumap = (but_cumap->edit_cumap == nullptr) ? (CurveMapping *)but->poin :
|
||||
but_cumap->edit_cumap;
|
||||
|
||||
const float clip_size_x = BLI_rctf_size_x(&cumap->curr);
|
||||
const float clip_size_y = BLI_rctf_size_y(&cumap->curr);
|
||||
|
@ -1502,12 +1464,11 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
|
|||
/* need scissor test, curve can draw outside of boundary */
|
||||
int scissor[4];
|
||||
GPU_scissor_get(scissor);
|
||||
rcti scissor_new = {
|
||||
.xmin = rect->xmin,
|
||||
.ymin = rect->ymin,
|
||||
.xmax = rect->xmax,
|
||||
.ymax = rect->ymax,
|
||||
};
|
||||
rcti scissor_new{};
|
||||
scissor_new.xmin = rect->xmin;
|
||||
scissor_new.ymin = rect->ymin;
|
||||
scissor_new.xmax = rect->xmax;
|
||||
scissor_new.ymax = rect->ymax;
|
||||
const rcti scissor_region = {0, region->winx, 0, region->winy};
|
||||
BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
|
||||
GPU_scissor(scissor_new.xmin,
|
||||
|
@ -1520,13 +1481,11 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
|
|||
/* magic trigger for curve backgrounds */
|
||||
const float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
|
||||
|
||||
rcti grid = {
|
||||
.xmin = rect->xmin + zoomx * (-offsx),
|
||||
.xmax = grid.xmin + zoomx,
|
||||
.ymin = rect->ymin + zoomy * (-offsy),
|
||||
.ymax = grid.ymin + zoomy,
|
||||
};
|
||||
|
||||
rcti grid{};
|
||||
grid.xmin = rect->xmin + zoomx * (-offsx);
|
||||
grid.xmax = grid.xmin + zoomx;
|
||||
grid.ymin = rect->ymin + zoomy * (-offsy);
|
||||
grid.ymax = grid.ymin + zoomy;
|
||||
ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f);
|
||||
}
|
||||
|
||||
|
@ -1631,7 +1590,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
|
|||
}
|
||||
immUnbindProgram();
|
||||
|
||||
if (cuma->table == NULL) {
|
||||
if (cuma->table == nullptr) {
|
||||
BKE_curvemapping_changed(cumap, false);
|
||||
}
|
||||
|
||||
|
@ -1756,8 +1715,8 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
|
|||
float fx, fy;
|
||||
|
||||
uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
|
||||
CurveProfile *profile = (but_profile->edit_profile == NULL) ? (CurveProfile *)but->poin :
|
||||
but_profile->edit_profile;
|
||||
CurveProfile *profile = (but_profile->edit_profile == nullptr) ? (CurveProfile *)but->poin :
|
||||
but_profile->edit_profile;
|
||||
|
||||
/* Calculate offset and zoom. */
|
||||
const float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&profile->view_rect);
|
||||
|
@ -1773,12 +1732,12 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
|
|||
/* Test needed because path can draw outside of boundary. */
|
||||
int scissor[4];
|
||||
GPU_scissor_get(scissor);
|
||||
rcti scissor_new = {
|
||||
.xmin = rect->xmin,
|
||||
.ymin = rect->ymin,
|
||||
.xmax = rect->xmax,
|
||||
.ymax = rect->ymax,
|
||||
};
|
||||
rcti scissor_new{};
|
||||
scissor_new.xmin = rect->xmin;
|
||||
scissor_new.ymin = rect->ymin;
|
||||
scissor_new.xmax = rect->xmax;
|
||||
scissor_new.ymax = rect->ymax;
|
||||
|
||||
const rcti scissor_region = {0, region->winx, 0, region->winy};
|
||||
BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
|
||||
GPU_scissor(scissor_new.xmin,
|
||||
|
@ -1819,7 +1778,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
|
|||
ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f);
|
||||
|
||||
/* Draw the path's fill. */
|
||||
if (profile->table == NULL) {
|
||||
if (profile->table == nullptr) {
|
||||
BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
|
||||
}
|
||||
CurveProfilePoint *pts = profile->table;
|
||||
|
@ -1830,7 +1789,8 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
|
|||
const uint tot_triangles = tot_points - 2;
|
||||
|
||||
/* Create array of the positions of the table's points. */
|
||||
float(*table_coords)[2] = MEM_mallocN(sizeof(*table_coords) * tot_points, "table x coords");
|
||||
float(*table_coords)[2] = static_cast<float(*)[2]>(
|
||||
MEM_mallocN(sizeof(*table_coords) * tot_points, __func__));
|
||||
for (uint i = 0; i < (uint)BKE_curveprofile_table_size(profile); i++) {
|
||||
/* Only add the points from the table here. */
|
||||
table_coords[i][0] = pts[i].x;
|
||||
|
@ -1870,7 +1830,8 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
|
|||
|
||||
/* Calculate the table point indices of the triangles for the profile's fill. */
|
||||
if (tot_triangles > 0) {
|
||||
uint(*tri_indices)[3] = MEM_mallocN(sizeof(*tri_indices) * tot_triangles, __func__);
|
||||
uint(*tri_indices)[3] = static_cast<uint(*)[3]>(
|
||||
MEM_mallocN(sizeof(*tri_indices) * tot_triangles, __func__));
|
||||
BLI_polyfill_calc(table_coords, tot_points, -1, tri_indices);
|
||||
|
||||
/* Draw the triangles for the profile fill. */
|
||||
|
@ -1954,10 +1915,10 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
|
|||
float color_vert[4], color_vert_select[4], color_sample[4];
|
||||
UI_GetThemeColor4fv(TH_TEXT_HI, color_vert);
|
||||
UI_GetThemeColor4fv(TH_TEXT, color_vert_select);
|
||||
color_sample[0] = (float)wcol->item[0] / 255.0f;
|
||||
color_sample[1] = (float)wcol->item[1] / 255.0f;
|
||||
color_sample[2] = (float)wcol->item[2] / 255.0f;
|
||||
color_sample[3] = (float)wcol->item[3] / 255.0f;
|
||||
color_sample[0] = float(wcol->item[0]) / 255.0f;
|
||||
color_sample[1] = float(wcol->item[1]) / 255.0f;
|
||||
color_sample[2] = float(wcol->item[2]) / 255.0f;
|
||||
color_sample[3] = float(wcol->item[3]) / 255.0f;
|
||||
if (len_squared_v3v3(color_vert, color_vert_select) < 0.1f) {
|
||||
interp_v3_v3v3(color_vert, color_vert_select, color_backdrop, 0.75f);
|
||||
}
|
||||
|
@ -2032,20 +1993,19 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
|
|||
immUnbindProgram();
|
||||
}
|
||||
|
||||
void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
|
||||
void ui_draw_but_TRACKPREVIEW(ARegion * /*region*/,
|
||||
uiBut *but,
|
||||
const uiWidgetColors *UNUSED(wcol),
|
||||
const uiWidgetColors * /*wcol*/,
|
||||
const rcti *recti)
|
||||
{
|
||||
bool ok = false;
|
||||
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
|
||||
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1,
|
||||
};
|
||||
rctf rect{};
|
||||
rect.xmin = float(recti->xmin + 1);
|
||||
rect.xmax = float(recti->xmax - 1);
|
||||
rect.ymin = float(recti->ymin + 1);
|
||||
rect.ymax = float(recti->ymax - 1);
|
||||
|
||||
const int width = BLI_rctf_size_x(&rect) + 1;
|
||||
const int height = BLI_rctf_size_y(&rect);
|
||||
|
@ -2063,16 +2023,12 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
|
|||
if (scopes->track_disabled) {
|
||||
const float color[4] = {0.7f, 0.3f, 0.3f, 0.3f};
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = rect.xmin - 1,
|
||||
.xmax = rect.xmax + 1,
|
||||
.ymin = rect.ymin,
|
||||
.ymax = rect.ymax + 1,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
color);
|
||||
rctf disabled_rect{};
|
||||
disabled_rect.xmin = rect.xmin - 1;
|
||||
disabled_rect.xmax = rect.xmax + 1;
|
||||
disabled_rect.ymin = rect.ymin;
|
||||
disabled_rect.ymax = rect.ymax + 1;
|
||||
UI_draw_roundbox_4fv(&disabled_rect, true, 3.0f, color);
|
||||
|
||||
ok = true;
|
||||
}
|
||||
|
@ -2120,16 +2076,12 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
|
|||
if (scopes->use_track_mask) {
|
||||
const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = rect.xmin - 1,
|
||||
.xmax = rect.xmax + 1,
|
||||
.ymin = rect.ymin,
|
||||
.ymax = rect.ymax + 1,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
color);
|
||||
rctf mask_rect{};
|
||||
mask_rect.xmin = rect.xmin - 1;
|
||||
mask_rect.xmax = rect.xmax + 1;
|
||||
mask_rect.ymin = rect.ymin;
|
||||
mask_rect.ymax = rect.ymax + 1;
|
||||
UI_draw_roundbox_4fv(&mask_rect, true, 3.0f, color);
|
||||
}
|
||||
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_3D_IMAGE_COLOR);
|
||||
|
@ -2143,7 +2095,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
|
|||
drawibuf->rect,
|
||||
1.0f,
|
||||
1.0f,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
/* draw cross for pixel position */
|
||||
GPU_matrix_translate_2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
|
||||
|
@ -2191,16 +2143,12 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
|
|||
if (!ok) {
|
||||
const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = rect.xmin - 1,
|
||||
.xmax = rect.xmax + 1,
|
||||
.ymin = rect.ymin,
|
||||
.ymax = rect.ymax + 1,
|
||||
},
|
||||
true,
|
||||
3.0f,
|
||||
color);
|
||||
rctf box_rect{};
|
||||
box_rect.xmin = rect.xmin - 1;
|
||||
box_rect.xmax = rect.xmax + 1;
|
||||
box_rect.ymin = rect.ymin;
|
||||
box_rect.ymax = rect.ymax + 1;
|
||||
UI_draw_roundbox_4fv(&box_rect, true, 3.0f, color);
|
||||
}
|
||||
|
||||
/* Restore scissor test. */
|
||||
|
@ -2304,8 +2252,7 @@ void UI_draw_box_shadow(const rctf *rect, uchar alpha)
|
|||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
||||
|
||||
void ui_draw_dropshadow(
|
||||
const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
|
||||
void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int /*select*/)
|
||||
{
|
||||
/* This undoes the scale of the view for higher zoom factors to clamp the shadow size. */
|
||||
const float clamped_aspect = smoothminf(aspect, 1.0f, 0.5f);
|
||||
|
@ -2319,23 +2266,22 @@ void ui_draw_dropshadow(
|
|||
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
uiWidgetBaseParameters widget_params = {
|
||||
.recti.xmin = rct->xmin,
|
||||
.recti.ymin = rct->ymin,
|
||||
.recti.xmax = rct->xmax,
|
||||
.recti.ymax = rct->ymax - shadow_offset,
|
||||
.rect.xmin = rct->xmin - shadow_softness,
|
||||
.rect.ymin = rct->ymin - shadow_softness,
|
||||
.rect.xmax = rct->xmax + shadow_softness,
|
||||
.rect.ymax = rct->ymax - shadow_offset + shadow_softness,
|
||||
.radi = rad,
|
||||
.rad = rad + shadow_softness,
|
||||
.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f,
|
||||
.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f,
|
||||
.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f,
|
||||
.round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f,
|
||||
.alpha_discard = 1.0f,
|
||||
};
|
||||
uiWidgetBaseParameters widget_params{};
|
||||
widget_params.recti.xmin = rct->xmin;
|
||||
widget_params.recti.ymin = rct->ymin;
|
||||
widget_params.recti.xmax = rct->xmax;
|
||||
widget_params.recti.ymax = rct->ymax - shadow_offset;
|
||||
widget_params.rect.xmin = rct->xmin - shadow_softness;
|
||||
widget_params.rect.ymin = rct->ymin - shadow_softness;
|
||||
widget_params.rect.xmax = rct->xmax + shadow_softness;
|
||||
widget_params.rect.ymax = rct->ymax - shadow_offset + shadow_softness;
|
||||
widget_params.radi = rad;
|
||||
widget_params.rad = rad + shadow_softness;
|
||||
widget_params.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f;
|
||||
widget_params.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f;
|
||||
widget_params.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f;
|
||||
widget_params.round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f;
|
||||
widget_params.alpha_discard = 1.0f;
|
||||
|
||||
GPUBatch *batch = ui_batch_roundbox_shadow_get();
|
||||
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW);
|
||||
|
@ -2345,16 +2291,12 @@ void ui_draw_dropshadow(
|
|||
|
||||
/* outline emphasis */
|
||||
const float color[4] = {0.0f, 0.0f, 0.0f, 0.4f};
|
||||
UI_draw_roundbox_4fv(
|
||||
&(const rctf){
|
||||
.xmin = rct->xmin - 0.5f,
|
||||
.xmax = rct->xmax + 0.5f,
|
||||
.ymin = rct->ymin - 0.5f,
|
||||
.ymax = rct->ymax + 0.5f,
|
||||
},
|
||||
false,
|
||||
radius + 0.5f,
|
||||
color);
|
||||
rctf rect{};
|
||||
rect.xmin = rct->xmin - 0.5f;
|
||||
rect.xmax = rct->xmax + 0.5f;
|
||||
rect.ymin = rct->ymin - 0.5f;
|
||||
rect.ymax = rct->ymax + 0.5f;
|
||||
UI_draw_roundbox_4fv(&rect, false, radius + 0.5f, color);
|
||||
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
|
@ -9,9 +9,9 @@
|
|||
* Event codes are used as identifiers.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -77,20 +77,15 @@ static void icon_draw_rect_input_text(
|
|||
BLF_batch_draw_flush();
|
||||
}
|
||||
|
||||
void icon_draw_rect_input(float x,
|
||||
float y,
|
||||
int w,
|
||||
int h,
|
||||
float UNUSED(alpha),
|
||||
short event_type,
|
||||
short UNUSED(event_value))
|
||||
void icon_draw_rect_input(
|
||||
float x, float y, int w, int h, float /*alpha*/, short event_type, short /*event_value*/)
|
||||
{
|
||||
rctf rect = {
|
||||
.xmin = (int)x - U.pixelsize,
|
||||
.xmax = (int)(x + w + U.pixelsize),
|
||||
.ymin = (int)(y),
|
||||
.ymax = (int)(y + h),
|
||||
};
|
||||
rctf rect{};
|
||||
rect.xmin = int(x) - U.pixelsize;
|
||||
rect.xmax = int(x + w + U.pixelsize);
|
||||
rect.ymin = int(y);
|
||||
rect.ymax = int(y + h);
|
||||
|
||||
float color[4];
|
||||
GPU_line_width(1.0f);
|
||||
UI_GetThemeColor4fv(TH_TEXT, color);
|
||||
|
@ -113,7 +108,7 @@ void icon_draw_rect_input(float x,
|
|||
;
|
||||
|
||||
if ((event_type >= EVT_AKEY) && (event_type <= EVT_ZKEY)) {
|
||||
const char str[2] = {'A' + (event_type - EVT_AKEY), '\0'};
|
||||
const char str[2] = {char('A' + (event_type - EVT_AKEY)), '\0'};
|
||||
icon_draw_rect_input_text(&rect, color, str, 13.0f, 0.0f);
|
||||
}
|
||||
else if ((event_type >= EVT_F1KEY) && (event_type <= EVT_F24KEY)) {
|
||||
|
@ -122,11 +117,13 @@ void icon_draw_rect_input(float x,
|
|||
icon_draw_rect_input_text(&rect, color, str, event_type > EVT_F9KEY ? 8.5f : 11.5f, 0.0f);
|
||||
}
|
||||
else if (event_type == EVT_LEFTSHIFTKEY) { /* Right Shift has already been converted to left. */
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x87, 0xa7, 0x0}, 16.0f, 0.0f);
|
||||
const char str[] = {0xe2, 0x87, 0xa7, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f);
|
||||
}
|
||||
else if (event_type == EVT_LEFTCTRLKEY) { /* Right Shift has already been converted to left. */
|
||||
if (platform == MACOS) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8c, 0x83, 0x0}, 21.0f, -8.0f);
|
||||
const char str[] = {0xe2, 0x8c, 0x83, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 21.0f, -8.0f);
|
||||
}
|
||||
else {
|
||||
icon_draw_rect_input_text(&rect, color, "Ctrl", 9.0f, 0.0f);
|
||||
|
@ -134,7 +131,8 @@ void icon_draw_rect_input(float x,
|
|||
}
|
||||
else if (event_type == EVT_LEFTALTKEY) { /* Right Alt has already been converted to left. */
|
||||
if (platform == MACOS) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8c, 0xa5, 0x0}, 13.0f, 0.0f);
|
||||
const char str[] = {0xe2, 0x8c, 0xa5, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 13.0f, 0.0f);
|
||||
}
|
||||
else {
|
||||
icon_draw_rect_input_text(&rect, color, "Alt", 10.0f, 0.0f);
|
||||
|
@ -142,10 +140,12 @@ void icon_draw_rect_input(float x,
|
|||
}
|
||||
else if (event_type == EVT_OSKEY) {
|
||||
if (platform == MACOS) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8c, 0x98, 0x0}, 16.0f, 0.0f);
|
||||
const char str[] = {0xe2, 0x8c, 0x98, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f);
|
||||
}
|
||||
else if (platform == MSWIN) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x9d, 0x96, 0x0}, 16.0f, 0.0f);
|
||||
const char str[] = {0xe2, 0x9d, 0x96, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f);
|
||||
}
|
||||
else {
|
||||
icon_draw_rect_input_text(&rect, color, "OS", 10.0f, 0.0f);
|
||||
|
@ -155,7 +155,8 @@ void icon_draw_rect_input(float x,
|
|||
icon_draw_rect_input_text(&rect, color, "Del", 9.0f, 0.0f);
|
||||
}
|
||||
else if (event_type == EVT_TABKEY) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0xad, 0xbe, 0x0}, 18.0f, -1.5f);
|
||||
const char str[] = {0xe2, 0xad, 0xbe, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 18.0f, -1.5f);
|
||||
}
|
||||
else if (event_type == EVT_HOMEKEY) {
|
||||
icon_draw_rect_input_text(&rect, color, "Home", 6.0f, 0.0f);
|
||||
|
@ -164,37 +165,44 @@ void icon_draw_rect_input(float x,
|
|||
icon_draw_rect_input_text(&rect, color, "End", 8.0f, 0.0f);
|
||||
}
|
||||
else if (event_type == EVT_RETKEY) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8f, 0x8e, 0x0}, 17.0f, -1.0f);
|
||||
const char str[] = {0xe2, 0x8f, 0x8e, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 17.0f, -1.0f);
|
||||
}
|
||||
else if (event_type == EVT_ESCKEY) {
|
||||
if (platform == MACOS) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x8e, 0x8b, 0x0}, 21.0f, -1.0f);
|
||||
const char str[] = {0xe2, 0x8e, 0x8b, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 21.0f, -1.0f);
|
||||
}
|
||||
else {
|
||||
icon_draw_rect_input_text(&rect, color, "Esc", 8.5f, 0.0f);
|
||||
}
|
||||
}
|
||||
else if (event_type == EVT_PAGEUPKEY) {
|
||||
icon_draw_rect_input_text(
|
||||
&rect, color, (const char[]){'P', 0xe2, 0x86, 0x91, 0x0}, 12.0f, 0.0f);
|
||||
const char str[] = {'P', 0xe2, 0x86, 0x91, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 12.0f, 0.0f);
|
||||
}
|
||||
else if (event_type == EVT_PAGEDOWNKEY) {
|
||||
icon_draw_rect_input_text(
|
||||
&rect, color, (const char[]){'P', 0xe2, 0x86, 0x93, 0x0}, 12.0f, 0.0f);
|
||||
const char str[] = {'P', 0xe2, 0x86, 0x93, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 12.0f, 0.0f);
|
||||
}
|
||||
else if (event_type == EVT_LEFTARROWKEY) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x86, 0x90, 0x0}, 18.0f, -1.5f);
|
||||
const char str[] = {0xe2, 0x86, 0x90, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 18.0f, -1.5f);
|
||||
}
|
||||
else if (event_type == EVT_UPARROWKEY) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x86, 0x91, 0x0}, 16.0f, 0.0f);
|
||||
const char str[] = {0xe2, 0x86, 0x91, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f);
|
||||
}
|
||||
else if (event_type == EVT_RIGHTARROWKEY) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x86, 0x92, 0x0}, 18.0f, -1.5f);
|
||||
const char str[] = {0xe2, 0x86, 0x92, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 18.0f, -1.5f);
|
||||
}
|
||||
else if (event_type == EVT_DOWNARROWKEY) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x86, 0x93, 0x0}, 16.0f, 0.0f);
|
||||
const char str[] = {0xe2, 0x86, 0x93, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f);
|
||||
}
|
||||
else if (event_type == EVT_SPACEKEY) {
|
||||
icon_draw_rect_input_text(&rect, color, (const char[]){0xe2, 0x90, 0xa3, 0x0}, 20.0f, 2.0f);
|
||||
const char str[] = {0xe2, 0x90, 0xa3, 0x0};
|
||||
icon_draw_rect_input_text(&rect, color, str, 20.0f, 2.0f);
|
||||
}
|
||||
}
|
|
@ -1020,7 +1020,7 @@ extern void ui_draw_aligned_panel(const struct uiStyle *style,
|
|||
bool region_search_filter_active);
|
||||
void ui_panel_tag_search_filter_match(struct Panel *panel);
|
||||
|
||||
/* interface_draw.c */
|
||||
/* interface_draw.cc */
|
||||
|
||||
extern void ui_draw_dropshadow(
|
||||
const rctf *rct, float radius, float aspect, float alpha, int select);
|
||||
|
@ -1287,7 +1287,7 @@ void uiStyleInit(void);
|
|||
void ui_icon_ensure_deferred(const struct bContext *C, int icon_id, bool big);
|
||||
int ui_id_icon_get(const struct bContext *C, struct ID *id, bool big);
|
||||
|
||||
/* interface_icons_event.c */
|
||||
/* interface_icons_event.cc */
|
||||
|
||||
void icon_draw_rect_input(
|
||||
float x, float y, int w, int h, float alpha, short event_type, short event_value);
|
||||
|
@ -1325,7 +1325,7 @@ void ui_layout_list_set_labels_active(uiLayout *layout);
|
|||
void ui_item_menutype_func(struct bContext *C, struct uiLayout *layout, void *arg_mt);
|
||||
void ui_item_paneltype_func(struct bContext *C, struct uiLayout *layout, void *arg_pt);
|
||||
|
||||
/* interface_button_group.c */
|
||||
/* interface_button_group.cc */
|
||||
|
||||
/**
|
||||
* Every function that adds a set of buttons must create another group,
|
||||
|
@ -1474,7 +1474,7 @@ struct ARegion *ui_screen_region_find_mouse_over_ex(struct bScreen *screen, cons
|
|||
struct ARegion *ui_screen_region_find_mouse_over(struct bScreen *screen,
|
||||
const struct wmEvent *event);
|
||||
|
||||
/* interface_context_menu.c */
|
||||
/* interface_context_menu.cc */
|
||||
|
||||
bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but, const struct wmEvent *event);
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue