Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | static bool ui_but_is_unit_radians(const uiBut *but) | ||||
| UnitSettings *unit = but->block->unit; | UnitSettings *unit = but->block->unit; | ||||
| const int unit_type = UI_but_unit_type_get(but); | const int unit_type = UI_but_unit_type_get(but); | ||||
| return ui_but_is_unit_radians_ex(unit, unit_type); | return ui_but_is_unit_radians_ex(unit, unit_type); | ||||
| } | } | ||||
| /* ************* window matrix ************** */ | /* ************* window matrix ************** */ | ||||
| void ui_block_to_window_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y) | void ui_block_to_region_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y) | ||||
| { | { | ||||
| const int getsizex = BLI_rcti_size_x(®ion->winrct) + 1; | const int getsizex = BLI_rcti_size_x(®ion->winrct) + 1; | ||||
| const int getsizey = BLI_rcti_size_y(®ion->winrct) + 1; | const int getsizey = BLI_rcti_size_y(®ion->winrct) + 1; | ||||
| const int sx = region->winrct.xmin; | |||||
| const int sy = region->winrct.ymin; | |||||
| float gx = *r_x; | float gx = *r_x; | ||||
| float gy = *r_y; | float gy = *r_y; | ||||
| if (block->panel) { | if (block->panel) { | ||||
| gx += block->panel->ofsx; | gx += block->panel->ofsx; | ||||
| gy += block->panel->ofsy; | gy += block->panel->ofsy; | ||||
| } | } | ||||
| *r_x = ((float)sx) + | *r_x = ((float)getsizex) * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + | ||||
| ((float)getsizex) * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + | |||||
| block->winmat[3][0])); | block->winmat[3][0])); | ||||
| *r_y = ((float)sy) + | *r_y = ((float)getsizey) * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + | ||||
| ((float)getsizey) * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + | |||||
| block->winmat[3][1])); | block->winmat[3][1])); | ||||
| } | } | ||||
| void ui_block_to_window_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y) | |||||
| { | |||||
| ui_block_to_region_fl(region, block, r_x, r_y); | |||||
| *r_x += region->winrct.xmin; | |||||
| *r_y += region->winrct.ymin; | |||||
| } | |||||
| void ui_block_to_window(const ARegion *region, uiBlock *block, int *r_x, int *r_y) | void ui_block_to_window(const ARegion *region, uiBlock *block, int *r_x, int *r_y) | ||||
| { | { | ||||
| float fx = *r_x; | float fx = *r_x; | ||||
| float fy = *r_y; | float fy = *r_y; | ||||
| ui_block_to_window_fl(region, block, &fx, &fy); | ui_block_to_window_fl(region, block, &fx, &fy); | ||||
| *r_x = (int)(fx + 0.5f); | *r_x = (int)(fx + 0.5f); | ||||
| *r_y = (int)(fy + 0.5f); | *r_y = (int)(fy + 0.5f); | ||||
| } | } | ||||
| void ui_block_to_region_rctf(const ARegion *region, | |||||
| uiBlock *block, | |||||
| rctf *rct_dst, | |||||
| const rctf *rct_src) | |||||
| { | |||||
| *rct_dst = *rct_src; | |||||
| ui_block_to_region_fl(region, block, &rct_dst->xmin, &rct_dst->ymin); | |||||
| ui_block_to_region_fl(region, block, &rct_dst->xmax, &rct_dst->ymax); | |||||
| } | |||||
| void ui_block_to_window_rctf(const ARegion *region, | void ui_block_to_window_rctf(const ARegion *region, | ||||
| uiBlock *block, | uiBlock *block, | ||||
| rctf *rct_dst, | rctf *rct_dst, | ||||
| const rctf *rct_src) | const rctf *rct_src) | ||||
| { | { | ||||
| *rct_dst = *rct_src; | *rct_dst = *rct_src; | ||||
| ui_block_to_window_fl(region, block, &rct_dst->xmin, &rct_dst->ymin); | ui_block_to_window_fl(region, block, &rct_dst->xmin, &rct_dst->ymin); | ||||
| ui_block_to_window_fl(region, block, &rct_dst->xmax, &rct_dst->ymax); | ui_block_to_window_fl(region, block, &rct_dst->xmax, &rct_dst->ymax); | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
| void ui_window_to_region_rcti(const ARegion *region, rcti *rect_dst, const rcti *rct_src) | void ui_window_to_region_rcti(const ARegion *region, rcti *rect_dst, const rcti *rct_src) | ||||
| { | { | ||||
| rect_dst->xmin = rct_src->xmin - region->winrct.xmin; | rect_dst->xmin = rct_src->xmin - region->winrct.xmin; | ||||
| rect_dst->xmax = rct_src->xmax - region->winrct.xmin; | rect_dst->xmax = rct_src->xmax - region->winrct.xmin; | ||||
| rect_dst->ymin = rct_src->ymin - region->winrct.ymin; | rect_dst->ymin = rct_src->ymin - region->winrct.ymin; | ||||
| rect_dst->ymax = rct_src->ymax - region->winrct.ymin; | rect_dst->ymax = rct_src->ymax - region->winrct.ymin; | ||||
| } | } | ||||
| void ui_window_to_region_rctf(const ARegion *region, rctf *rect_dst, const rctf *rct_src) | |||||
| { | |||||
| rect_dst->xmin = rct_src->xmin - region->winrct.xmin; | |||||
| rect_dst->xmax = rct_src->xmax - region->winrct.xmin; | |||||
| rect_dst->ymin = rct_src->ymin - region->winrct.ymin; | |||||
| rect_dst->ymax = rct_src->ymax - region->winrct.ymin; | |||||
| } | |||||
| void ui_region_to_window(const ARegion *region, int *r_x, int *r_y) | void ui_region_to_window(const ARegion *region, int *r_x, int *r_y) | ||||
| { | { | ||||
| *r_x += region->winrct.xmin; | *r_x += region->winrct.xmin; | ||||
| *r_y += region->winrct.ymin; | *r_y += region->winrct.ymin; | ||||
| } | } | ||||
| static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) | static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 2,167 Lines • ▼ Show 20 Lines | bool ui_but_is_rna_valid(uiBut *but) | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| * Checks if the button supports cycling next/previous menu items (ctrl+mouse-wheel). | * Checks if the button supports cycling next/previous menu items (ctrl+mouse-wheel). | ||||
| */ | */ | ||||
| bool ui_but_supports_cycling(const uiBut *but) | bool ui_but_supports_cycling(const uiBut *but) | ||||
| { | { | ||||
| return ((ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_LISTBOX)) || | return (ELEM(but->type, UI_BTYPE_ROW, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_LISTBOX) || | ||||
| (but->type == UI_BTYPE_MENU && ui_but_menu_step_poll(but)) || | (but->type == UI_BTYPE_MENU && ui_but_menu_step_poll(but)) || | ||||
| (but->type == UI_BTYPE_COLOR && ((uiButColor *)but)->is_pallete_color) || | (but->type == UI_BTYPE_COLOR && ((uiButColor *)but)->is_pallete_color) || | ||||
| (but->menu_step_func != NULL)); | (but->menu_step_func != NULL)); | ||||
| } | } | ||||
| double ui_but_value_get(uiBut *but) | double ui_but_value_get(uiBut *but) | ||||
| { | { | ||||
| double value = 0.0; | double value = 0.0; | ||||
| ▲ Show 20 Lines • Show All 991 Lines • ▼ Show 20 Lines | void UI_blocklist_update_window_matrix(const bContext *C, const ListBase *lb) | ||||
| LISTBASE_FOREACH (uiBlock *, block, lb) { | LISTBASE_FOREACH (uiBlock *, block, lb) { | ||||
| if (block->active) { | if (block->active) { | ||||
| ui_update_window_matrix(window, region, block); | ui_update_window_matrix(window, region, block); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void UI_blocklist_update_view_for_buttons(const bContext *C, const ListBase *lb) | |||||
| { | |||||
| LISTBASE_FOREACH (uiBlock *, block, lb) { | |||||
| if (block->active) { | |||||
| ui_but_update_view_for_active(C, block); | |||||
| } | |||||
| } | |||||
| } | |||||
| void UI_blocklist_draw(const bContext *C, const ListBase *lb) | void UI_blocklist_draw(const bContext *C, const ListBase *lb) | ||||
| { | { | ||||
| LISTBASE_FOREACH (uiBlock *, block, lb) { | LISTBASE_FOREACH (uiBlock *, block, lb) { | ||||
| if (block->active) { | if (block->active) { | ||||
| UI_block_draw(C, block); | UI_block_draw(C, block); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,690 Lines • ▼ Show 20 Lines | void UI_but_drag_set_id(uiBut *but, ID *id) | ||||
| but->dragtype = WM_DRAG_ID; | but->dragtype = WM_DRAG_ID; | ||||
| if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | ||||
| WM_drag_data_free(but->dragtype, but->dragpoin); | WM_drag_data_free(but->dragtype, but->dragpoin); | ||||
| but->dragflag &= ~UI_BUT_DRAGPOIN_FREE; | but->dragflag &= ~UI_BUT_DRAGPOIN_FREE; | ||||
| } | } | ||||
| but->dragpoin = (void *)id; | but->dragpoin = (void *)id; | ||||
| } | } | ||||
| /** | |||||
| * \param asset: May be passed from a temporary variable, drag data only stores a copy of this. | |||||
| */ | |||||
| void UI_but_drag_set_asset(uiBut *but, | void UI_but_drag_set_asset(uiBut *but, | ||||
| const char *name, | const AssetHandle *asset, | ||||
| const char *path, | const char *path, | ||||
| int id_type, | |||||
| int import_type, | int import_type, | ||||
| int icon, | int icon, | ||||
| struct ImBuf *imb, | struct ImBuf *imb, | ||||
| float scale) | float scale) | ||||
| { | { | ||||
| wmDragAsset *asset_drag = MEM_mallocN(sizeof(*asset_drag), "wmDragAsset"); | wmDragAsset *asset_drag = MEM_mallocN(sizeof(*asset_drag), "wmDragAsset"); | ||||
| BLI_strncpy(asset_drag->name, name, sizeof(asset_drag->name)); | asset_drag->asset_handle = MEM_mallocN(sizeof(asset_drag->asset_handle), | ||||
| "wmDragAsset asset handle"); | |||||
| *asset_drag->asset_handle = *asset; | |||||
| asset_drag->path = path; | asset_drag->path = path; | ||||
| asset_drag->id_type = id_type; | |||||
| asset_drag->import_type = import_type; | asset_drag->import_type = import_type; | ||||
| but->dragtype = WM_DRAG_ASSET; | but->dragtype = WM_DRAG_ASSET; | ||||
| ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesn't draw in button */ | ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesn't draw in button */ | ||||
| if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { | ||||
| WM_drag_data_free(but->dragtype, but->dragpoin); | WM_drag_data_free(but->dragtype, but->dragpoin); | ||||
| } | } | ||||
| but->dragpoin = asset_drag; | but->dragpoin = asset_drag; | ||||
| ▲ Show 20 Lines • Show All 1,032 Lines • Show Last 20 Lines | |||||