Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_channels_draw.c
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2022 Blender Foundation. All rights reserved. */ | * Copyright 2022 Blender Foundation. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup sequencer | * \ingroup sequencer | ||||
| */ | */ | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_video_edit_types.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | static void displayed_channel_range_get(const SeqChannelDrawContext *context, | ||||
| int r_channel_range[2]) | int r_channel_range[2]) | ||||
| { | { | ||||
| /* Channel 0 is not usable, so should never be drawn. */ | /* Channel 0 is not usable, so should never be drawn. */ | ||||
| r_channel_range[0] = max_ii(1, floor(context->timeline_region_v2d->cur.ymin)); | r_channel_range[0] = max_ii(1, floor(context->timeline_region_v2d->cur.ymin)); | ||||
| r_channel_range[1] = ceil(context->timeline_region_v2d->cur.ymax); | r_channel_range[1] = ceil(context->timeline_region_v2d->cur.ymax); | ||||
| rctf strip_boundbox; | rctf strip_boundbox; | ||||
| BLI_rctf_init(&strip_boundbox, 0.0f, 0.0f, 1.0f, r_channel_range[1]); | BLI_rctf_init(&strip_boundbox, 0.0f, 0.0f, 1.0f, r_channel_range[1]); | ||||
| SEQ_timeline_expand_boundbox(context->scene, context->seqbase, &strip_boundbox); | SEQ_timeline_expand_boundbox(context->video_edit, context->seqbase, &strip_boundbox); | ||||
| CLAMP(r_channel_range[0], strip_boundbox.ymin, strip_boundbox.ymax); | CLAMP(r_channel_range[0], strip_boundbox.ymin, strip_boundbox.ymax); | ||||
| CLAMP(r_channel_range[1], strip_boundbox.ymin, MAXSEQ); | CLAMP(r_channel_range[1], strip_boundbox.ymin, MAXSEQ); | ||||
| } | } | ||||
| static char *draw_channel_widget_tooltip(bContext *UNUSED(C), void *argN, const char *UNUSED(tip)) | static char *draw_channel_widget_tooltip(bContext *UNUSED(C), void *argN, const char *UNUSED(tip)) | ||||
| { | { | ||||
| char *dyn_tooltip = argN; | char *dyn_tooltip = argN; | ||||
| return BLI_strdup(dyn_tooltip); | return BLI_strdup(dyn_tooltip); | ||||
| } | } | ||||
| static float draw_channel_widget_mute(const SeqChannelDrawContext *context, | static float draw_channel_widget_mute(const SeqChannelDrawContext *context, | ||||
| uiBlock *block, | uiBlock *block, | ||||
| const int channel_index, | const int channel_index, | ||||
| const float offset) | const float offset) | ||||
| { | { | ||||
| float y = channel_index_y_min(context, channel_index) + widget_y_offset(context); | float y = channel_index_y_min(context, channel_index) + widget_y_offset(context); | ||||
| const float width = icon_width_get(context); | const float width = icon_width_get(context); | ||||
| SeqTimelineChannel *channel = SEQ_channel_get_by_index(context->channels, channel_index); | SeqTimelineChannel *channel = SEQ_channel_get_by_index(context->channels, channel_index); | ||||
| const int icon = SEQ_channel_is_muted(channel) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT; | const int icon = SEQ_channel_is_muted(channel) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create(&context->scene->id, &RNA_SequenceTimelineChannel, channel, &ptr); | RNA_pointer_create(&context->video_edit->id, &RNA_SequenceTimelineChannel, channel, &ptr); | ||||
| PropertyRNA *hide_prop = RNA_struct_type_find_property(&RNA_SequenceTimelineChannel, "mute"); | PropertyRNA *hide_prop = RNA_struct_type_find_property(&RNA_SequenceTimelineChannel, "mute"); | ||||
| UI_block_emboss_set(block, UI_EMBOSS_NONE); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| uiBut *but = uiDefIconButR_prop(block, | uiBut *but = uiDefIconButR_prop(block, | ||||
| UI_BTYPE_TOGGLE, | UI_BTYPE_TOGGLE, | ||||
| 1, | 1, | ||||
| icon, | icon, | ||||
| context->v2d->cur.xmax / context->scale - offset, | context->v2d->cur.xmax / context->scale - offset, | ||||
| Show All 24 Lines | static float draw_channel_widget_lock(const SeqChannelDrawContext *context, | ||||
| float y = channel_index_y_min(context, channel_index) + widget_y_offset(context); | float y = channel_index_y_min(context, channel_index) + widget_y_offset(context); | ||||
| const float width = icon_width_get(context); | const float width = icon_width_get(context); | ||||
| SeqTimelineChannel *channel = SEQ_channel_get_by_index(context->channels, channel_index); | SeqTimelineChannel *channel = SEQ_channel_get_by_index(context->channels, channel_index); | ||||
| const int icon = SEQ_channel_is_locked(channel) ? ICON_LOCKED : ICON_UNLOCKED; | const int icon = SEQ_channel_is_locked(channel) ? ICON_LOCKED : ICON_UNLOCKED; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create(&context->scene->id, &RNA_SequenceTimelineChannel, channel, &ptr); | RNA_pointer_create(&context->video_edit->id, &RNA_SequenceTimelineChannel, channel, &ptr); | ||||
| PropertyRNA *hide_prop = RNA_struct_type_find_property(&RNA_SequenceTimelineChannel, "lock"); | PropertyRNA *hide_prop = RNA_struct_type_find_property(&RNA_SequenceTimelineChannel, "lock"); | ||||
| UI_block_emboss_set(block, UI_EMBOSS_NONE); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| uiBut *but = uiDefIconButR_prop(block, | uiBut *but = uiDefIconButR_prop(block, | ||||
| UI_BTYPE_TOGGLE, | UI_BTYPE_TOGGLE, | ||||
| 1, | 1, | ||||
| icon, | icon, | ||||
| context->v2d->cur.xmax / context->scale - offset, | context->v2d->cur.xmax / context->scale - offset, | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | static void draw_channel_labels(const SeqChannelDrawContext *context, | ||||
| if (BLI_rctf_size_y(&rect) <= 1.0f || BLI_rctf_size_x(&rect) <= 1.0f) { | if (BLI_rctf_size_y(&rect) <= 1.0f || BLI_rctf_size_x(&rect) <= 1.0f) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (channel_is_being_renamed(sseq, channel_index)) { | if (channel_is_being_renamed(sseq, channel_index)) { | ||||
| SeqTimelineChannel *channel = SEQ_channel_get_by_index(context->channels, channel_index); | SeqTimelineChannel *channel = SEQ_channel_get_by_index(context->channels, channel_index); | ||||
| PointerRNA ptr = {NULL}; | PointerRNA ptr = {NULL}; | ||||
| RNA_pointer_create(&context->scene->id, &RNA_SequenceTimelineChannel, channel, &ptr); | RNA_pointer_create(&context->video_edit->id, &RNA_SequenceTimelineChannel, channel, &ptr); | ||||
| PropertyRNA *prop = RNA_struct_name_property(ptr.type); | PropertyRNA *prop = RNA_struct_name_property(ptr.type); | ||||
| UI_block_emboss_set(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| uiBut *but = uiDefButR(block, | uiBut *but = uiDefButR(block, | ||||
| UI_BTYPE_TEXT, | UI_BTYPE_TEXT, | ||||
| 1, | 1, | ||||
| "", | "", | ||||
| rect.xmin, | rect.xmin, | ||||
| Show All 9 Lines | uiBut *but = uiDefButR(block, | ||||
| 0, | 0, | ||||
| NULL); | NULL); | ||||
| UI_block_emboss_set(block, UI_EMBOSS_NONE); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| if (UI_but_active_only(context->C, context->region, block, but) == false) { | if (UI_but_active_only(context->C, context->region, block, but) == false) { | ||||
| sseq->runtime.rename_channel_index = 0; | sseq->runtime.rename_channel_index = 0; | ||||
| } | } | ||||
| WM_event_add_notifier(context->C, NC_SCENE | ND_SEQUENCER, context->scene); | WM_event_add_notifier(context->C, NC_VIDEO_EDIT | ND_SEQUENCER, context->video_edit); | ||||
| } | } | ||||
| else { | else { | ||||
| const char *label = SEQ_channel_name_get(context->channels, channel_index); | const char *label = SEQ_channel_name_get(context->channels, channel_index); | ||||
| uiDefBut(block, | uiDefBut(block, | ||||
| UI_BTYPE_LABEL, | UI_BTYPE_LABEL, | ||||
| 0, | 0, | ||||
| label, | label, | ||||
| rect.xmin, | rect.xmin, | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| void channel_draw_context_init(const bContext *C, | void channel_draw_context_init(const bContext *C, | ||||
| ARegion *region, | ARegion *region, | ||||
| SeqChannelDrawContext *r_context) | SeqChannelDrawContext *r_context) | ||||
| { | { | ||||
| r_context->C = C; | r_context->C = C; | ||||
| r_context->area = CTX_wm_area(C); | r_context->area = CTX_wm_area(C); | ||||
| r_context->region = region; | r_context->region = region; | ||||
| r_context->v2d = ®ion->v2d; | r_context->v2d = ®ion->v2d; | ||||
| r_context->scene = CTX_data_scene(C); | r_context->video_edit = CTX_data_video_edit(C); | ||||
| r_context->ed = SEQ_editing_get(r_context->scene); | r_context->seqbase = SEQ_active_seqbase_get(r_context->video_edit); | ||||
| r_context->seqbase = SEQ_active_seqbase_get(r_context->ed); | r_context->channels = SEQ_channels_displayed_get(r_context->video_edit); | ||||
| r_context->channels = SEQ_channels_displayed_get(r_context->ed); | |||||
| r_context->timeline_region = timeline_region_get(CTX_wm_area(C)); | r_context->timeline_region = timeline_region_get(CTX_wm_area(C)); | ||||
| r_context->timeline_region_v2d = &r_context->timeline_region->v2d; | r_context->timeline_region_v2d = &r_context->timeline_region->v2d; | ||||
| r_context->channel_height = channel_height_pixelspace_get(r_context->timeline_region_v2d); | r_context->channel_height = channel_height_pixelspace_get(r_context->timeline_region_v2d); | ||||
| r_context->frame_width = frame_width_pixelspace_get(r_context->timeline_region_v2d); | r_context->frame_width = frame_width_pixelspace_get(r_context->timeline_region_v2d); | ||||
| r_context->draw_offset = draw_offset_get(r_context->timeline_region_v2d); | r_context->draw_offset = draw_offset_get(r_context->timeline_region_v2d); | ||||
| r_context->scale = min_ff(r_context->channel_height / (U.widget_unit * 0.6), 1); | r_context->scale = min_ff(r_context->channel_height / (U.widget_unit * 0.6), 1); | ||||
| } | } | ||||
| void draw_channels(const bContext *C, ARegion *region) | void draw_channels(const bContext *C, ARegion *region) | ||||
| { | { | ||||
| draw_background(); | draw_background(); | ||||
| Editing *ed = SEQ_editing_get(CTX_data_scene(C)); | |||||
| if (ed == NULL) { | |||||
| return; | |||||
| } | |||||
| SeqChannelDrawContext context; | SeqChannelDrawContext context; | ||||
| channel_draw_context_init(C, region, &context); | channel_draw_context_init(C, region, &context); | ||||
| UI_view2d_view_ortho(context.v2d); | UI_view2d_view_ortho(context.v2d); | ||||
| draw_channel_headers(&context); | draw_channel_headers(&context); | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| } | } | ||||