Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/area.c
| Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | |||||
| void ED_region_pixelspace(ARegion *region) | void ED_region_pixelspace(ARegion *region) | ||||
| { | { | ||||
| wmOrtho2_region_pixelspace(region); | wmOrtho2_region_pixelspace(region); | ||||
| GPU_matrix_identity_set(); | GPU_matrix_identity_set(); | ||||
| } | } | ||||
| /* only exported for WM */ | /* only exported for WM */ | ||||
| void ED_region_do_listen( | void ED_region_do_listen(wmRegionListenerParams *params) | ||||
| wmWindow *win, ScrArea *area, ARegion *region, wmNotifier *note, const Scene *scene) | |||||
| { | { | ||||
| ARegion *region = params->region; | |||||
| wmNotifier *notifier = params->notifier; | |||||
| /* generic notes first */ | /* generic notes first */ | ||||
| switch (note->category) { | switch (notifier->category) { | ||||
| case NC_WM: | case NC_WM: | ||||
| if (note->data == ND_FILEREAD) { | if (notifier->data == ND_FILEREAD) { | ||||
| ED_region_tag_redraw(region); | ED_region_tag_redraw(region); | ||||
| } | } | ||||
| break; | break; | ||||
| case NC_WINDOW: | case NC_WINDOW: | ||||
| ED_region_tag_redraw(region); | ED_region_tag_redraw(region); | ||||
| break; | break; | ||||
| } | } | ||||
| if (region->type && region->type->listener) { | if (region->type && region->type->listener) { | ||||
| region->type->listener(win, area, region, note, scene); | region->type->listener(params); | ||||
| } | } | ||||
| } | } | ||||
| /* only exported for WM */ | /* only exported for WM */ | ||||
| void ED_area_do_listen(wmWindow *win, ScrArea *area, wmNotifier *note, Scene *scene) | void ED_area_do_listen(wmSpaceTypeListenerParams *params) | ||||
| { | { | ||||
| /* no generic notes? */ | /* no generic notes? */ | ||||
| if (area->type && area->type->listener) { | if (params->area->type && params->area->type->listener) { | ||||
| area->type->listener(win, area, note, scene); | params->area->type->listener(params); | ||||
| } | } | ||||
| } | } | ||||
| /* only exported for WM */ | /* only exported for WM */ | ||||
| void ED_area_do_refresh(bContext *C, ScrArea *area) | void ED_area_do_refresh(bContext *C, ScrArea *area) | ||||
| { | { | ||||
| /* no generic notes? */ | /* no generic notes? */ | ||||
| if (area->type && area->type->refresh) { | if (area->type && area->type->refresh) { | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | case AE_RIGHT_TO_TOPLEFT: | ||||
| UI_draw_roundbox_corner_set(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); | UI_draw_roundbox_corner_set(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); | ||||
| break; | break; | ||||
| } | } | ||||
| /* Workaround for different color spaces between normal areas and the ones using GPUViewports. */ | /* Workaround for different color spaces between normal areas and the ones using GPUViewports. */ | ||||
| float alpha = WM_region_use_viewport(area, region) ? 0.6f : 0.4f; | float alpha = WM_region_use_viewport(area, region) ? 0.6f : 0.4f; | ||||
| const float color[4] = {0.05f, 0.05f, 0.05f, alpha}; | const float color[4] = {0.05f, 0.05f, 0.05f, alpha}; | ||||
| UI_draw_roundbox_aa( | UI_draw_roundbox_aa( | ||||
| true, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, color); | &(const rctf){ | ||||
| .xmin = (float)az->x1, | |||||
| .xmax = (float)az->x2, | |||||
| .ymin = (float)az->y1, | |||||
| .ymax = (float)az->y2, | |||||
| }, | |||||
| true, | |||||
| 4.0f, | |||||
| color); | |||||
| draw_azone_arrow((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, az->edge); | draw_azone_arrow((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, az->edge); | ||||
| } | } | ||||
| static void area_azone_tag_update(ScrArea *area) | static void area_azone_tag_update(ScrArea *area) | ||||
| { | { | ||||
| area->flag |= AREA_FLAG_ACTIONZONES_UPDATE; | area->flag |= AREA_FLAG_ACTIONZONES_UPDATE; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | if (overlap) { | ||||
| const float y1 = pad; | const float y1 = pad; | ||||
| const float y2 = region->winy - pad; | const float y2 = region->winy - pad; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| float color[4] = {0.0f, 0.0f, 0.0f, 0.5f}; | float color[4] = {0.0f, 0.0f, 0.0f, 0.5f}; | ||||
| UI_GetThemeColor3fv(TH_BACK, color); | UI_GetThemeColor3fv(TH_BACK, color); | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox_aa(true, x1, y1, x2, y2, 4.0f, color); | UI_draw_roundbox_aa( | ||||
| &(const rctf){ | |||||
| .xmin = x1, | |||||
| .xmax = x2, | |||||
| .ymin = y1, | |||||
| .ymax = y2, | |||||
| }, | |||||
| true, | |||||
| 4.0f, | |||||
| color); | |||||
| UI_FontThemeColor(fontid, TH_TEXT); | UI_FontThemeColor(fontid, TH_TEXT); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_FontThemeColor(fontid, TH_TEXT); | UI_FontThemeColor(fontid, TH_TEXT); | ||||
| } | } | ||||
| BLF_position(fontid, x, y, 0.0f); | BLF_position(fontid, x, y, 0.0f); | ||||
| Show All 28 Lines | void ED_area_do_msg_notify_tag_refresh( | ||||
| bContext *UNUSED(C), | bContext *UNUSED(C), | ||||
| wmMsgSubscribeKey *UNUSED(msg_key), | wmMsgSubscribeKey *UNUSED(msg_key), | ||||
| wmMsgSubscribeValue *msg_val) | wmMsgSubscribeValue *msg_val) | ||||
| { | { | ||||
| ScrArea *area = msg_val->user_data; | ScrArea *area = msg_val->user_data; | ||||
| ED_area_tag_refresh(area); | ED_area_tag_refresh(area); | ||||
| } | } | ||||
| void ED_area_do_mgs_subscribe_for_tool_header( | |||||
| /* Follow ARegionType.message_subscribe */ | /* Follow ARegionType.message_subscribe */ | ||||
| const struct bContext *UNUSED(C), | void ED_area_do_mgs_subscribe_for_tool_header(const wmRegionMessageSubscribeParams *params) | ||||
| struct WorkSpace *workspace, | |||||
| struct Scene *UNUSED(scene), | |||||
| struct bScreen *UNUSED(screen), | |||||
| struct ScrArea *UNUSED(area), | |||||
| struct ARegion *region, | |||||
| struct wmMsgBus *mbus) | |||||
| { | { | ||||
| struct wmMsgBus *mbus = params->message_bus; | |||||
| WorkSpace *workspace = params->workspace; | |||||
| ARegion *region = params->region; | |||||
| BLI_assert(region->regiontype == RGN_TYPE_TOOL_HEADER); | BLI_assert(region->regiontype == RGN_TYPE_TOOL_HEADER); | ||||
| wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { | wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { | ||||
| .owner = region, | .owner = region, | ||||
| .user_data = region, | .user_data = region, | ||||
| .notify = ED_region_do_msg_notify_tag_redraw, | .notify = ED_region_do_msg_notify_tag_redraw, | ||||
| }; | }; | ||||
| WM_msg_subscribe_rna_prop( | WM_msg_subscribe_rna_prop( | ||||
| mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw); | mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw); | ||||
| } | } | ||||
| void ED_area_do_mgs_subscribe_for_tool_ui( | void ED_area_do_mgs_subscribe_for_tool_ui(const wmRegionMessageSubscribeParams *params) | ||||
| /* Follow ARegionType.message_subscribe */ | |||||
| const struct bContext *UNUSED(C), | |||||
| struct WorkSpace *workspace, | |||||
| struct Scene *UNUSED(scene), | |||||
| struct bScreen *UNUSED(screen), | |||||
| struct ScrArea *UNUSED(area), | |||||
| struct ARegion *region, | |||||
| struct wmMsgBus *mbus) | |||||
| { | { | ||||
| struct wmMsgBus *mbus = params->message_bus; | |||||
| WorkSpace *workspace = params->workspace; | |||||
| ARegion *region = params->region; | |||||
| BLI_assert(region->regiontype == RGN_TYPE_UI); | BLI_assert(region->regiontype == RGN_TYPE_UI); | ||||
| const char *panel_category_tool = "Tool"; | const char *panel_category_tool = "Tool"; | ||||
| const char *category = UI_panel_category_active_get(region, false); | const char *category = UI_panel_category_active_get(region, false); | ||||
| bool update_region = false; | bool update_region = false; | ||||
| if (category && STREQ(category, panel_category_tool)) { | if (category && STREQ(category, panel_category_tool)) { | ||||
| update_region = true; | update_region = true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | if (ELEM( | ||||
| .owner = region, | .owner = region, | ||||
| .user_data = region, | .user_data = region, | ||||
| .notify = ED_region_do_msg_notify_tag_redraw, | .notify = ED_region_do_msg_notify_tag_redraw, | ||||
| }; | }; | ||||
| /* All properties for this space type. */ | /* All properties for this space type. */ | ||||
| WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_region_tag_redraw, __func__); | WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_region_tag_redraw, __func__); | ||||
| } | } | ||||
| ED_region_message_subscribe(C, workspace, scene, screen, area, region, mbus); | wmRegionMessageSubscribeParams message_subscribe_params = { | ||||
| .context = C, | |||||
| .message_bus = mbus, | |||||
| .workspace = workspace, | |||||
| .scene = scene, | |||||
| .screen = screen, | |||||
| .area = area, | |||||
| .region = region, | |||||
| }; | |||||
| ED_region_message_subscribe(&message_subscribe_params); | |||||
| } | } | ||||
| } | } | ||||
| /* ********************************** | /* ********************************** | ||||
| * maybe silly, but let's try for now | * maybe silly, but let's try for now | ||||
| * to keep these tags protected | * to keep these tags protected | ||||
| * ********************************** */ | * ********************************** */ | ||||
| ▲ Show 20 Lines • Show All 3,376 Lines • ▼ Show 20 Lines | if (num_segments) { | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Generate subscriptions for this region. | * Generate subscriptions for this region. | ||||
| */ | */ | ||||
| void ED_region_message_subscribe(bContext *C, | void ED_region_message_subscribe(wmRegionMessageSubscribeParams *params) | ||||
| struct WorkSpace *workspace, | |||||
| struct Scene *scene, | |||||
| struct bScreen *screen, | |||||
| struct ScrArea *area, | |||||
| struct ARegion *region, | |||||
| struct wmMsgBus *mbus) | |||||
| { | { | ||||
| ARegion *region = params->region; | |||||
| const bContext *C = params->context; | |||||
| struct wmMsgBus *mbus = params->message_bus; | |||||
| if (region->gizmo_map != NULL) { | if (region->gizmo_map != NULL) { | ||||
| WM_gizmomap_message_subscribe(C, region->gizmo_map, region, mbus); | WM_gizmomap_message_subscribe(C, region->gizmo_map, region, mbus); | ||||
| } | } | ||||
| if (!BLI_listbase_is_empty(®ion->uiblocks)) { | if (!BLI_listbase_is_empty(®ion->uiblocks)) { | ||||
| UI_region_message_subscribe(region, mbus); | UI_region_message_subscribe(region, mbus); | ||||
| } | } | ||||
| if (region->type->message_subscribe != NULL) { | if (region->type->message_subscribe != NULL) { | ||||
| region->type->message_subscribe(C, workspace, scene, screen, area, region, mbus); | region->type->message_subscribe(params); | ||||
| } | } | ||||
| } | } | ||||
| int ED_region_snap_size_test(const ARegion *region) | int ED_region_snap_size_test(const ARegion *region) | ||||
| { | { | ||||
| /* Use a larger value because toggling scrollbars can jump in size. */ | /* Use a larger value because toggling scrollbars can jump in size. */ | ||||
| const int snap_match_threshold = 16; | const int snap_match_threshold = 16; | ||||
| if (region->type->snap_size != NULL) { | if (region->type->snap_size != NULL) { | ||||
| Show All 31 Lines | |||||