Cleanup: Reduce Variable scope clip_buttons
This commit is contained in:
parent
8d3d4c8840
commit
b4b888fd2a
@ -104,17 +104,11 @@ void ED_clip_buttons_register(ARegionType *art)
|
|||||||
void uiTemplateMovieClip(
|
void uiTemplateMovieClip(
|
||||||
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, bool compact)
|
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, bool compact)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop;
|
|
||||||
PointerRNA clipptr;
|
|
||||||
MovieClip *clip;
|
|
||||||
uiLayout *row, *split;
|
|
||||||
uiBlock *block;
|
|
||||||
|
|
||||||
if (!ptr->data) {
|
if (!ptr->data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop = RNA_struct_find_property(ptr, propname);
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
printf(
|
printf(
|
||||||
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
||||||
@ -129,8 +123,8 @@ void uiTemplateMovieClip(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clipptr = RNA_property_pointer_get(ptr, prop);
|
PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
|
||||||
clip = clipptr.data;
|
MovieClip *clip = clipptr.data;
|
||||||
|
|
||||||
uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr);
|
uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr);
|
||||||
|
|
||||||
@ -149,20 +143,18 @@ void uiTemplateMovieClip(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (clip) {
|
if (clip) {
|
||||||
uiLayout *col;
|
uiLayout *row = uiLayoutRow(layout, false);
|
||||||
|
uiBlock *block = uiLayoutGetBlock(row);
|
||||||
row = uiLayoutRow(layout, false);
|
|
||||||
block = uiLayoutGetBlock(row);
|
|
||||||
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("File Path:"), 0, 19, 145, 19, NULL, 0, 0, 0, 0, "");
|
uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("File Path:"), 0, 19, 145, 19, NULL, 0, 0, 0, 0, "");
|
||||||
|
|
||||||
row = uiLayoutRow(layout, false);
|
row = uiLayoutRow(layout, false);
|
||||||
split = uiLayoutSplit(row, 0.0f, false);
|
uiLayout *split = uiLayoutSplit(row, 0.0f, false);
|
||||||
row = uiLayoutRow(split, true);
|
row = uiLayoutRow(split, true);
|
||||||
|
|
||||||
uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE);
|
uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE);
|
||||||
uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload");
|
uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload");
|
||||||
|
|
||||||
col = uiLayoutColumn(layout, false);
|
uiLayout *col = uiLayoutColumn(layout, false);
|
||||||
uiTemplateColorspaceSettings(col, &clipptr, "colorspace_settings");
|
uiTemplateColorspaceSettings(col, &clipptr, "colorspace_settings");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,17 +163,11 @@ void uiTemplateMovieClip(
|
|||||||
|
|
||||||
void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop;
|
|
||||||
PointerRNA scopesptr;
|
|
||||||
uiBlock *block;
|
|
||||||
uiLayout *col;
|
|
||||||
MovieClipScopes *scopes;
|
|
||||||
|
|
||||||
if (!ptr->data) {
|
if (!ptr->data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop = RNA_struct_find_property(ptr, propname);
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
printf(
|
printf(
|
||||||
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
||||||
@ -196,8 +182,8 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scopesptr = RNA_property_pointer_get(ptr, prop);
|
PointerRNA scopesptr = RNA_property_pointer_get(ptr, prop);
|
||||||
scopes = (MovieClipScopes *)scopesptr.data;
|
MovieClipScopes *scopes = (MovieClipScopes *)scopesptr.data;
|
||||||
|
|
||||||
if (scopes->track_preview_height < UI_UNIT_Y) {
|
if (scopes->track_preview_height < UI_UNIT_Y) {
|
||||||
scopes->track_preview_height = UI_UNIT_Y;
|
scopes->track_preview_height = UI_UNIT_Y;
|
||||||
@ -206,8 +192,8 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
|||||||
scopes->track_preview_height = UI_UNIT_Y * 20;
|
scopes->track_preview_height = UI_UNIT_Y * 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
col = uiLayoutColumn(layout, true);
|
uiLayout *col = uiLayoutColumn(layout, true);
|
||||||
block = uiLayoutGetBlock(col);
|
uiBlock *block = uiLayoutGetBlock(col);
|
||||||
|
|
||||||
uiDefBut(block,
|
uiDefBut(block,
|
||||||
UI_BTYPE_TRACK_PREVIEW,
|
UI_BTYPE_TRACK_PREVIEW,
|
||||||
@ -319,8 +305,6 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
|
|||||||
}
|
}
|
||||||
else if (event == B_MARKER_PAT_DIM) {
|
else if (event == B_MARKER_PAT_DIM) {
|
||||||
float dim[2], pat_dim[2], pat_min[2], pat_max[2];
|
float dim[2], pat_dim[2], pat_min[2], pat_max[2];
|
||||||
float scale_x, scale_y;
|
|
||||||
int a;
|
|
||||||
|
|
||||||
BKE_tracking_marker_pattern_minmax(cb->marker, pat_min, pat_max);
|
BKE_tracking_marker_pattern_minmax(cb->marker, pat_min, pat_max);
|
||||||
|
|
||||||
@ -329,10 +313,10 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
|
|||||||
dim[0] = cb->marker_pat[0] / width;
|
dim[0] = cb->marker_pat[0] / width;
|
||||||
dim[1] = cb->marker_pat[1] / height;
|
dim[1] = cb->marker_pat[1] / height;
|
||||||
|
|
||||||
scale_x = dim[0] / pat_dim[0];
|
float scale_x = dim[0] / pat_dim[0];
|
||||||
scale_y = dim[1] / pat_dim[1];
|
float scale_y = dim[1] / pat_dim[1];
|
||||||
|
|
||||||
for (a = 0; a < 4; a++) {
|
for (int a = 0; a < 4; a++) {
|
||||||
cb->marker->pattern_corners[a][0] *= scale_x;
|
cb->marker->pattern_corners[a][0] *= scale_x;
|
||||||
cb->marker->pattern_corners[a][1] *= scale_y;
|
cb->marker->pattern_corners[a][1] *= scale_y;
|
||||||
}
|
}
|
||||||
@ -415,23 +399,11 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
PointerRNA *trackptr,
|
PointerRNA *trackptr,
|
||||||
bool compact)
|
bool compact)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop;
|
|
||||||
uiBlock *block;
|
|
||||||
uiBut *bt;
|
|
||||||
PointerRNA clipptr;
|
|
||||||
MovieClip *clip;
|
|
||||||
MovieClipUser *user;
|
|
||||||
MovieTrackingTrack *track;
|
|
||||||
MovieTrackingMarker *marker;
|
|
||||||
MarkerUpdateCb *cb;
|
|
||||||
const char *tip;
|
|
||||||
float pat_min[2], pat_max[2];
|
|
||||||
|
|
||||||
if (!ptr->data) {
|
if (!ptr->data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop = RNA_struct_find_property(ptr, propname);
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
printf(
|
printf(
|
||||||
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
||||||
@ -446,15 +418,15 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clipptr = RNA_property_pointer_get(ptr, prop);
|
PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
|
||||||
clip = (MovieClip *)clipptr.data;
|
MovieClip *clip = (MovieClip *)clipptr.data;
|
||||||
user = userptr->data;
|
MovieClipUser *user = userptr->data;
|
||||||
track = trackptr->data;
|
MovieTrackingTrack *track = trackptr->data;
|
||||||
|
|
||||||
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
|
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
|
||||||
marker = BKE_tracking_marker_get(track, clip_framenr);
|
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr);
|
||||||
|
|
||||||
cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb");
|
MarkerUpdateCb *cb = MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb");
|
||||||
cb->compact = compact;
|
cb->compact = compact;
|
||||||
cb->clip = clip;
|
cb->clip = clip;
|
||||||
cb->user = user;
|
cb->user = user;
|
||||||
@ -464,7 +436,8 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
cb->framenr = user->framenr;
|
cb->framenr = user->framenr;
|
||||||
|
|
||||||
if (compact) {
|
if (compact) {
|
||||||
block = uiLayoutGetBlock(layout);
|
const char *tip;
|
||||||
|
uiBlock *block = uiLayoutGetBlock(layout);
|
||||||
|
|
||||||
if (cb->marker_flag & MARKER_DISABLED) {
|
if (cb->marker_flag & MARKER_DISABLED) {
|
||||||
tip = TIP_("Marker is disabled at current frame");
|
tip = TIP_("Marker is disabled at current frame");
|
||||||
@ -473,7 +446,7 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
tip = TIP_("Marker is enabled at current frame");
|
tip = TIP_("Marker is enabled at current frame");
|
||||||
}
|
}
|
||||||
|
|
||||||
bt = uiDefIconButBitI(block,
|
uiBut *bt = uiDefIconButBitI(block,
|
||||||
UI_BTYPE_TOGGLE_N,
|
UI_BTYPE_TOGGLE_N,
|
||||||
MARKER_DISABLED,
|
MARKER_DISABLED,
|
||||||
0,
|
0,
|
||||||
@ -492,15 +465,13 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
|
UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int width, height, step, digits;
|
int width, height;
|
||||||
float pat_dim[2], search_dim[2], search_pos[2];
|
|
||||||
uiLayout *col;
|
|
||||||
|
|
||||||
BKE_movieclip_get_size(clip, user, &width, &height);
|
BKE_movieclip_get_size(clip, user, &width, &height);
|
||||||
|
|
||||||
if (track->flag & TRACK_LOCKED) {
|
if (track->flag & TRACK_LOCKED) {
|
||||||
uiLayoutSetActive(layout, false);
|
uiLayoutSetActive(layout, false);
|
||||||
block = uiLayoutAbsoluteBlock(layout);
|
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
||||||
uiDefBut(block,
|
uiDefBut(block,
|
||||||
UI_BTYPE_LABEL,
|
UI_BTYPE_LABEL,
|
||||||
0,
|
0,
|
||||||
@ -519,8 +490,8 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
step = 100;
|
float pat_min[2], pat_max[2];
|
||||||
digits = 2;
|
float pat_dim[2], search_dim[2], search_pos[2];
|
||||||
|
|
||||||
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
|
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
|
||||||
|
|
||||||
@ -538,10 +509,14 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
|
|
||||||
cb->marker_flag = marker->flag;
|
cb->marker_flag = marker->flag;
|
||||||
|
|
||||||
block = uiLayoutAbsoluteBlock(layout);
|
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
||||||
UI_block_func_handle_set(block, marker_block_handler, cb);
|
UI_block_func_handle_set(block, marker_block_handler, cb);
|
||||||
UI_block_funcN_set(block, marker_update_cb, cb, NULL);
|
UI_block_funcN_set(block, marker_update_cb, cb, NULL);
|
||||||
|
|
||||||
|
const char *tip;
|
||||||
|
int step = 100;
|
||||||
|
int digits = 2;
|
||||||
|
|
||||||
if (cb->marker_flag & MARKER_DISABLED) {
|
if (cb->marker_flag & MARKER_DISABLED) {
|
||||||
tip = TIP_("Marker is disabled at current frame");
|
tip = TIP_("Marker is disabled at current frame");
|
||||||
}
|
}
|
||||||
@ -565,7 +540,7 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
0,
|
0,
|
||||||
tip);
|
tip);
|
||||||
|
|
||||||
col = uiLayoutColumn(layout, true);
|
uiLayout *col = uiLayoutColumn(layout, true);
|
||||||
uiLayoutSetActive(col, (cb->marker_flag & MARKER_DISABLED) == 0);
|
uiLayoutSetActive(col, (cb->marker_flag & MARKER_DISABLED) == 0);
|
||||||
|
|
||||||
block = uiLayoutAbsoluteBlock(col);
|
block = uiLayoutAbsoluteBlock(col);
|
||||||
@ -585,7 +560,7 @@ void uiTemplateMarker(uiLayout *layout,
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"");
|
"");
|
||||||
bt = uiDefButF(block,
|
uiBut *bt = uiDefButF(block,
|
||||||
UI_BTYPE_NUM,
|
UI_BTYPE_NUM,
|
||||||
B_MARKER_POS,
|
B_MARKER_POS,
|
||||||
IFACE_("X:"),
|
IFACE_("X:"),
|
||||||
@ -802,21 +777,11 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
|
|||||||
const char *propname,
|
const char *propname,
|
||||||
PointerRNA *userptr)
|
PointerRNA *userptr)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop;
|
|
||||||
PointerRNA clipptr;
|
|
||||||
MovieClip *clip;
|
|
||||||
MovieClipUser *user;
|
|
||||||
uiLayout *col;
|
|
||||||
char str[1024];
|
|
||||||
int width, height, framenr;
|
|
||||||
ImBuf *ibuf;
|
|
||||||
size_t ofs = 0;
|
|
||||||
|
|
||||||
if (!ptr->data) {
|
if (!ptr->data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop = RNA_struct_find_property(ptr, propname);
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
printf(
|
printf(
|
||||||
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
||||||
@ -831,17 +796,21 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clipptr = RNA_property_pointer_get(ptr, prop);
|
PointerRNA clipptr = RNA_property_pointer_get(ptr, prop);
|
||||||
clip = (MovieClip *)clipptr.data;
|
MovieClip *clip = (MovieClip *)clipptr.data;
|
||||||
user = userptr->data;
|
MovieClipUser *user = userptr->data;
|
||||||
|
|
||||||
col = uiLayoutColumn(layout, false);
|
uiLayout *col = uiLayoutColumn(layout, false);
|
||||||
uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_RIGHT);
|
uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_RIGHT);
|
||||||
|
|
||||||
ibuf = BKE_movieclip_get_ibuf_flag(clip, user, clip->flag, MOVIECLIP_CACHE_SKIP);
|
ImBuf *ibuf = BKE_movieclip_get_ibuf_flag(clip, user, clip->flag, MOVIECLIP_CACHE_SKIP);
|
||||||
|
|
||||||
|
int width, height;
|
||||||
/* Display frame dimensions, channels number and byffer type. */
|
/* Display frame dimensions, channels number and byffer type. */
|
||||||
BKE_movieclip_get_size(clip, user, &width, &height);
|
BKE_movieclip_get_size(clip, user, &width, &height);
|
||||||
|
|
||||||
|
char str[1024];
|
||||||
|
size_t ofs = 0;
|
||||||
ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, TIP_("%d x %d"), width, height);
|
ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, TIP_("%d x %d"), width, height);
|
||||||
|
|
||||||
if (ibuf) {
|
if (ibuf) {
|
||||||
@ -882,7 +851,7 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
|
|||||||
uiItemL(col, str, ICON_NONE);
|
uiItemL(col, str, ICON_NONE);
|
||||||
|
|
||||||
/* Display current frame number. */
|
/* Display current frame number. */
|
||||||
framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
|
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
|
||||||
if (framenr <= clip->len) {
|
if (framenr <= clip->len) {
|
||||||
BLI_snprintf(str, sizeof(str), TIP_("Frame: %d / %d"), framenr, clip->len);
|
BLI_snprintf(str, sizeof(str), TIP_("Frame: %d / %d"), framenr, clip->len);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user