diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-06-24 14:29:26 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-06-24 14:29:26 +0400 |
commit | 1f7ae143a29b090ed97cdd7eb47a9c2dbd7f72a2 (patch) | |
tree | fff560080a8bbf37ee087653df1b8a30173537b1 /source/blender/editors | |
parent | d38ba6b5d25ca42f76b6d1b746217a565f26228f (diff) | |
parent | 74c9c24d273863319a55c18234e03b7d27a43a87 (diff) |
Merged changes in the trunk up to revision 48227.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_file/filelist.c
Diffstat (limited to 'source/blender/editors')
105 files changed, 3692 insertions, 2777 deletions
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 67ed77bcc4b..084006ce277 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -24,6 +24,7 @@ if(WITH_BLENDER) add_subdirectory(curve) add_subdirectory(gpencil) add_subdirectory(interface) + add_subdirectory(io) add_subdirectory(mask) add_subdirectory(mesh) add_subdirectory(metaball) diff --git a/source/blender/editors/SConscript b/source/blender/editors/SConscript index d08b496f0ef..6233ea0dc39 100644 --- a/source/blender/editors/SConscript +++ b/source/blender/editors/SConscript @@ -6,6 +6,7 @@ SConscript(['datafiles/SConscript', 'space_api/SConscript', 'util/SConscript', 'interface/SConscript', + 'io/SConscript', 'animation/SConscript', 'armature/SConscript', 'mask/SConscript', diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 103b23be466..c9b0f55740a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -184,7 +184,7 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction) //MovieClip *clip = ac->scene->clip; // struct Mask *mask = seq ? seq->mask : NULL; - saction->ads.source = (ID *)ac->scene;; + saction->ads.source = (ID *)ac->scene; ac->datatype = ANIMCONT_MASK; ac->data = &saction->ads; diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index ea875567705..8c1e2bedd86 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -123,7 +123,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* basic settings (backdrop + mode selector + some padding) */ - /* col= uiLayoutColumn(layout, 1); */ /* UNUSED */ + /* col = uiLayoutColumn(layout, TRUE); */ /* UNUSED */ block = uiLayoutGetBlock(layout); uiBlockBeginAlign(block); but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL); @@ -141,7 +141,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, width - 30, 19, &data->poly_order, 1, 100, 0, 0, @@ -150,7 +150,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* draw controls for each coefficient and a + sign at end of row */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); cp = data->coefficients; @@ -177,7 +177,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, "+", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* next coefficient on a new row */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); } else { @@ -194,7 +194,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0, 0, width - 30, 19, &data->poly_order, 1, 100, 0, 0, @@ -203,7 +203,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* draw controls for each pair of coefficients */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); cp = data->coefficients; @@ -230,7 +230,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* set up new row for the next pair of coefficients*/ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); } else @@ -253,11 +253,11 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* add the settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE); uiItemR(col, &ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); // no grouping for now + col = uiLayoutColumn(layout, FALSE); // no grouping for now uiItemR(col, &ptr, "amplitude", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "phase_multiplier", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "phase_offset", 0, NULL, ICON_NONE); @@ -278,16 +278,16 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor /* split into 2 columns * NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* before range */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemL(col, IFACE_("Before:"), ICON_NONE); uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE); uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE); /* after range */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemL(col, IFACE_("After:"), ICON_NONE); uiItemR(col, &ptr, "mode_after", 0, "", ICON_NONE); uiItemR(col, &ptr, "cycles_after", 0, NULL, ICON_NONE); @@ -308,15 +308,15 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short uiItemR(layout, &ptr, "blend_type", 0, NULL, ICON_NONE); /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* col 1 */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); /* col 2 */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE); } @@ -499,18 +499,18 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr); /* general settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Envelope:"), ICON_NONE); uiItemR(col, &ptr, "reference_value", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); /* control points header */ // TODO: move this control-point control stuff to using the new special widgets for lists // the current way is far too cramped - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 1, IFACE_("Control Points:"), 0, 0, 150, 20, NULL, 0.0, 0.0, 0, 0, ""); @@ -522,7 +522,7 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh /* control points list */ for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* get a new row to operate on */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); uiBlockBeginAlign(block); @@ -555,36 +555,36 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* row 1: minimum */ { - /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ + /* row = uiLayoutRow(layout, FALSE); */ /* UNUSED */ /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* x-minimum */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE); } /* row 2: maximum */ { - /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ + /* row = uiLayoutRow(layout, FALSE); */ /* UNUSED */ /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* x-minimum */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "max_y", 0, NULL, ICON_NONE); } @@ -602,23 +602,23 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho RNA_pointer_create(id, &RNA_FModifierStepped, fcm, &ptr); /* block 1: "stepping" settings */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE); /* block 2: start range settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); /* block 3: end range settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); } @@ -642,11 +642,11 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* get layout-row + UI-block for this */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); // err... /* left-align -------------------------------------------- */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -664,7 +664,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier uiItemL(sub, "<Unknown Modifier>", ICON_NONE); /* right-align ------------------------------------------- */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); @@ -726,28 +726,28 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier box = uiLayoutBox(layout); /* restricted range ----------------------------------------------------- */ - col = uiLayoutColumn(box, 1); + col = uiLayoutColumn(box, TRUE); /* top row: use restricted range */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE); if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) { /* second row: settings */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(row, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); /* third row: blending influence */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "blend_in", 0, IFACE_("In"), ICON_NONE); uiItemR(row, &ptr, "blend_out", 0, IFACE_("Out"), ICON_NONE); } /* influence -------------------------------------------------------------- */ - col = uiLayoutColumn(box, 1); + col = uiLayoutColumn(box, TRUE); /* top row: use influence */ uiItemR(col, &ptr, "use_influence", 0, NULL, ICON_NONE); diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index a8f8d2974e5..3883dce7671 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -156,7 +156,7 @@ void duplicate_fcurve_keys(FCurve *fcu) memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1)); memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); - memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof (BezTriple) * (fcu->totvert - (i + 1))); + memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof(BezTriple) * (fcu->totvert - (i + 1))); fcu->totvert++; /* reassign pointers... (free old, and add new) */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index b8601419d51..6250424d655 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -559,7 +559,6 @@ static short visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) const char *identifier = NULL; /* validate data */ - // TODO: this check is probably not needed, but it won't hurt if (ELEM3(NULL, ptr, ptr->data, prop)) return 0; @@ -635,6 +634,9 @@ static short visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) case CONSTRAINT_TYPE_TRACKTO: if (searchtype == VISUALKEY_ROT) return 1; break; + case CONSTRAINT_TYPE_DAMPTRACK: + if (searchtype == VISUALKEY_ROT) return 1; + break; case CONSTRAINT_TYPE_ROTLIMIT: if (searchtype == VISUALKEY_ROT) return 1; break; diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 4c125ebe013..dabc0ad1081 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -113,14 +113,14 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* get layout-row + UI-block for header */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* err... */ uiBlockSetEmboss(block, UI_EMBOSSN); /* left-align ............................... */ - sub = uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); /* active */ block = uiLayoutGetBlock(sub); @@ -151,7 +151,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* delete button (only if hidden but not locked!) */ if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED)) { /* right-align ............................... */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); block = uiLayoutGetBlock(sub); /* XXX... err... */ @@ -179,7 +179,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* delete 'button' */ uiBlockSetEmboss(block, UI_EMBOSSN); /* right-align ............................... */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); block = uiLayoutGetBlock(sub); /* XXX... err... */ @@ -190,14 +190,14 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* new backdrop ----------------------------------- */ box = uiLayoutBox(layout); - split = uiLayoutSplit(box, 0.5f, 0); + split = uiLayoutSplit(box, 0.5f, FALSE); /* draw settings ---------------------------------- */ /* left column ..................... */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* color */ - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -210,10 +210,10 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons } /* right column ................... */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* onion-skinning */ - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiItemR(sub, &ptr, "use_onion_skinning", 0, NULL, ICON_NONE); uiItemR(sub, &ptr, "ghost_range_max", 0, IFACE_("Frames"), ICON_NONE); @@ -236,14 +236,14 @@ static void draw_gpencil_space_specials(const bContext *C, uiLayout *layout) uiLayout *col, *row; SpaceClip *sc = CTX_wm_space_clip(C); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (sc) { bScreen *screen = CTX_wm_screen(C); PointerRNA sc_ptr; RNA_pointer_create(&screen->id, &RNA_SpaceClipEditor, sc, &sc_ptr); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &sc_ptr, "grease_pencil_source", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } @@ -262,7 +262,7 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin RNA_id_pointer_create((ID *)gpd, &gpd_ptr); /* draw gpd settings first ------------------------------------- */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); /* current Grease Pencil block */ /* TODO: show some info about who owns this? */ @@ -270,7 +270,7 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* add new layer button - can be used even when no data, since it can add a new block too */ uiItemO(col, IFACE_("New Layer"), ICON_NONE, "GPENCIL_OT_layer_add"); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); @@ -280,12 +280,12 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* draw each layer --------------------------------------------- */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); gp_drawui_layer(col, gpd, gpl, is_v3d); } /* draw gpd drawing settings first ------------------------------------- */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* label */ uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); @@ -298,17 +298,17 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin } /* drawing space options */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); if (sc == NULL) { - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiLayoutSetActive(row, v3d_stroke_opts); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON); uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index ed530bea4bd..3f53f0403d7 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -146,7 +146,7 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) case SPACE_CLIP: /* Nodes Editor */ { SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (clip) { if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 6d90824668e..12b002ef612 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -56,6 +56,7 @@ #include "ED_gpencil.h" #include "ED_screen.h" #include "ED_view3d.h" +#include "ED_clip.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -1032,8 +1033,9 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) p->custom_color[3] = 0.9f; if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { - int framenr = sc->user.framenr; - MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); + MovieClip *clip = ED_space_clip_get_clip(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); + MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking); MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr); p->imat[3][0] -= marker->pos[0]; diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 649266beec7..2670fb5b042 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -41,7 +41,9 @@ struct MovieClip; struct SpaceClip; struct wmEvent; -/* clip_editor.c */ +/* ** clip_editor.c ** */ + +/* common poll functions */ int ED_space_clip_poll(struct bContext *C); int ED_space_clip_view_clip_poll(struct bContext *C); @@ -50,40 +52,40 @@ int ED_space_clip_tracking_poll(struct bContext *C); int ED_space_clip_maskedit_poll(struct bContext *C); int ED_space_clip_maskedit_mask_poll(bContext *C); -void ED_space_clip_set(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip); -struct MovieClip *ED_space_clip(struct SpaceClip *sc); -struct Mask *ED_space_clip_mask(struct SpaceClip *sc); -void ED_space_clip_size(struct SpaceClip *sc, int *width, int *height); -void ED_space_clip_zoom(struct SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy); -void ED_space_clip_aspect(struct SpaceClip *sc, float *aspx, float *aspy); -void ED_space_clip_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy); - -int ED_space_clip_clip_framenr(struct SpaceClip *sc); +void ED_space_clip_get_size(const struct bContext *C, int *width, int *height); +void ED_space_clip_get_zoom(const struct bContext *C, float *zoomx, float *zoomy); +void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy); +void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy); -void ED_space_clip_mask_size(struct SpaceClip *sc, int *width, int *height); -void ED_space_clip_mask_aspect(struct SpaceClip *sc, float *aspx, float *aspy); +int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle); void ED_clip_update_frame(const struct Main *mainp, int cfra); -int ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit); +int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit); + +void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2]); +void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr); +void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]); +void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); + +int ED_space_clip_check_show_trackedit(struct SpaceClip *sc); +int ED_space_clip_check_show_maskedit(struct SpaceClip *sc); -void ED_clip_point_undistorted_pos(SpaceClip * sc, const float co[2], float r_co[2]); -void ED_clip_point_stable_pos(struct bContext *C, float x, float y, float *xr, float *yr); -void ED_clip_point_stable_pos__reverse(SpaceClip * sc, ARegion *ar, const float co[2], float r_co[2]); -void ED_clip_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]); +struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc); +void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip); +struct Mask *ED_space_clip_get_mask(struct SpaceClip *sc); +void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask); + +/* textures buffer */ int ED_space_clip_texture_buffer_supported(struct SpaceClip *sc); int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf); void ED_space_clip_unload_movieclip_buffer(struct SpaceClip *sc); void ED_space_clip_free_texture_buffer(struct SpaceClip *sc); -int ED_space_clip_show_trackedit(struct SpaceClip *sc); -int ED_space_clip_show_maskedit(struct SpaceClip *sc); -void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask); - -/* clip_ops.c */ +/* ** clip_ops.c ** */ void ED_operatormacros_clip(void); -#endif /* ED_TEXT_H */ +#endif /* ED_CLIP_H */ diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 66e65d114cb..0979e3ec92b 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -61,6 +61,9 @@ void ED_node_link_insert(struct ScrArea *sa); void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree); void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node); + +void ED_node_sample_set(const float col[4]); + /* node ops.c */ void ED_operatormacros_node(void); diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h index cea567254de..7ba26f30c39 100644 --- a/source/blender/editors/include/ED_sequencer.h +++ b/source/blender/editors/include/ED_sequencer.h @@ -33,4 +33,6 @@ struct Sequence; void ED_sequencer_select_sequence_single(struct Scene *scene, struct Sequence *seq, int deselect_all); void ED_sequencer_deselect_all(struct Scene *scene); +void ED_operatormacros_sequencer(void); + #endif /* __ED_SEQUENCER_H__ */ diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 3c802020747..c14e27562b4 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -878,7 +878,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), glPopMatrix(); /* min max */ - glColor3f(.5f, .5f, .5f); + glColor3f(0.5f, 0.5f, 0.5f); min = yofs + scopes->minmax[0][0] * h; max = yofs + scopes->minmax[0][1] * h; CLAMP(min, rect.ymin, rect.ymax); @@ -1012,7 +1012,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco int i, j; float w, h, centerx, centery, diam; float alpha; - const float colors[6][3] = {{.75, 0, 0}, {.75, .75, 0}, {0, .75, 0}, {0, .75, .75}, {0, 0, .75}, {.75, 0, .75}}; + const float colors[6][3] = { + {0.75, 0.0, 0.0}, {0.75, 0.75, 0.0}, {0.0, 0.75, 0.0}, + {0.0, 0.75, 0.75}, {0.0, 0.0, 0.75}, {0.75, 0.0, 0.75}}; GLint scissor[4]; rect.xmin = (float)recti->xmin + 1; @@ -1308,7 +1310,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o fx = rect->xmin + zoomx * (-offsx); if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin)); while (fx < rect->xmax) { - glVertex2f(fx, rect->ymin); + glVertex2f(fx, rect->ymin); glVertex2f(fx, rect->ymax); fx += dx; } @@ -1317,7 +1319,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o fy = rect->ymin + zoomy * (-offsy); if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin)); while (fy < rect->ymax) { - glVertex2f(rect->xmin, fy); + glVertex2f(rect->xmin, fy); glVertex2f(rect->xmax, fy); fy += dy; } @@ -1344,7 +1346,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin); cuma = cumap->cm + cumap->cur; - + /* need scissor test, curve can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); scissor_new.xmin = ar->winrct.xmin + rect->xmin; @@ -1361,53 +1363,54 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect offsy = cumap->curr.ymin - but->aspect / zoomy; /* backdrop */ - if (cumap->flag & CUMA_DO_CLIP) { - gl_shaded_color((unsigned char *)wcol->inner, -20); - glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - glColor3ubv((unsigned char *)wcol->inner); - glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx), - rect->ymin + zoomy * (cumap->clipr.ymin - offsy), - rect->xmin + zoomx * (cumap->clipr.xmax - offsx), - rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); + if (but->a1 == UI_GRAD_H) { + /* magic trigger for curve backgrounds */ + rcti grid; + float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ + + grid.xmin = rect->xmin + zoomx * (-offsx); + grid.xmax = rect->xmax + zoomx * (-offsx); + grid.ymin = rect->ymin + zoomy * (-offsy); + grid.ymax = rect->ymax + zoomy * (-offsy); + + ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f); + + /* grid, hsv uses different grid */ + gl_shaded_color((unsigned char *)wcol->inner, -16); + /* TODO, grid lines does not line up with colors, need to look into this */ + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.1666666f); } else { - glColor3ubv((unsigned char *)wcol->inner); - glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - } - - /* grid, every .25 step */ - gl_shaded_color((unsigned char *)wcol->inner, -16); - ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); - /* grid, every 1.0 step */ - gl_shaded_color((unsigned char *)wcol->inner, -24); - ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); - /* axes */ - gl_shaded_color((unsigned char *)wcol->inner, -50); - glBegin(GL_LINES); - glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy)); - glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy)); - glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin); - glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax); - glEnd(); - - /* magic trigger for curve backgrounds */ - if (but->a1 != -1) { - if (but->a1 == UI_GRAD_H) { - rcti grid; - float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ - - grid.xmin = rect->xmin + zoomx * (-offsx); - grid.xmax = rect->xmax + zoomx * (-offsx); - grid.ymin = rect->ymin + zoomy * (-offsy); - grid.ymax = rect->ymax + zoomy * (-offsy); - - glEnable(GL_BLEND); - ui_draw_gradient(&grid, col, UI_GRAD_H, 0.5f); - glDisable(GL_BLEND); + if (cumap->flag & CUMA_DO_CLIP) { + gl_shaded_color((unsigned char *)wcol->inner, -20); + glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + glColor3ubv((unsigned char *)wcol->inner); + glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx), + rect->ymin + zoomy * (cumap->clipr.ymin - offsy), + rect->xmin + zoomx * (cumap->clipr.xmax - offsx), + rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); + } + else { + glColor3ubv((unsigned char *)wcol->inner); + glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } + + /* grid, every 0.25 step */ + gl_shaded_color((unsigned char *)wcol->inner, -16); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); + /* grid, every 1.0 step */ + gl_shaded_color((unsigned char *)wcol->inner, -24); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); + /* axes */ + gl_shaded_color((unsigned char *)wcol->inner, -50); + glBegin(GL_LINES); + glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy)); + glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy)); + glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax); + glEnd(); } - - + /* cfra option */ /* XXX 2.48 */ #if 0 @@ -1421,11 +1424,21 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect #endif /* sample option */ - /* XXX 2.48 */ -#if 0 if (cumap->flag & CUMA_DRAW_SAMPLE) { - if (cumap->cur == 3) { - float lum = cumap->sample[0] * 0.35f + cumap->sample[1] * 0.45f + cumap->sample[2] * 0.2f; + if (but->a1 == UI_GRAD_H) { + float tsample[3]; + float hsv[3]; + linearrgb_to_srgb_v3_v3(tsample, cumap->sample); + rgb_to_hsv_v(tsample, hsv); + glColor3ub(240, 240, 240); + + glBegin(GL_LINES); + glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymax); + glEnd(); + } + else if (cumap->cur == 3) { + float lum = rgb_to_bw(cumap->sample); glColor3ub(240, 240, 240); glBegin(GL_LINES); @@ -1447,7 +1460,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glEnd(); } } -#endif /* the curve */ glColor3ubv((unsigned char *)wcol->item); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index a8a7a55c653..b82e7c3a1e2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6244,9 +6244,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle case YKEY: case ZKEY: { - if ((event->val == KM_PRESS) && + if ((event->val == KM_PRESS) && (event->shift == FALSE) && - (event->ctrl == FALSE) && + (event->ctrl == FALSE) && (event->oskey == FALSE)) { for (but = block->buttons.first; but; but = but->next) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 385f74acbd2..737c0377f27 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -347,7 +347,7 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(a glColor4f(0.0f, 0.0f, 0.0f, 1); viconutil_draw_lineloop_smooth(pts, 3); - glColor3f(.9f, .9f, .9f); + glColor3f(0.9f, 0.9f, 0.9f); viconutil_draw_points(pts, 3, 1); } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9af3ff3bdd8..1f88db033a4 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -447,7 +447,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *r /* interface_draw.c */ extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select); -void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha); +void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha); void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 4c2d86de502..3270015271a 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -370,7 +370,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int colbuts = len / (2 * cols); int layer_used = 0; - uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 0)); + uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE)); unit = UI_UNIT_X * 0.75; butw = unit; @@ -409,7 +409,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */ int row, col; - uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 1)); + uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, TRUE)); totdim = RNA_property_array_dimension(ptr, prop, dim_size); if (totdim != 2) return; /* only 2D matrices supported in UI so far */ @@ -532,7 +532,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n PropertySubType subtype; int labelw; - sub = uiLayoutRow(layout, 0); + sub = uiLayoutRow(layout, FALSE); uiBlockSetCurLayout(block, sub); if (name[0]) { @@ -550,7 +550,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n subtype = RNA_property_subtype(prop); if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { - uiBlockSetCurLayout(block, uiLayoutRow(sub, 1)); + uiBlockSetCurLayout(block, uiLayoutRow(sub, TRUE)); uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h); /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */ @@ -798,8 +798,8 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname if (prop && RNA_property_type(prop) == PROP_ENUM) { EnumPropertyItem *item; int totitem, i, free; - uiLayout *split = uiLayoutSplit(layout, 0, 0); - uiLayout *column = uiLayoutColumn(split, 0); + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = uiLayoutColumn(split, FALSE); RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item, &totitem, &free); @@ -825,7 +825,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname else { if (item[i].name) { if (i != 0) { - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); /* inconsistent, but menus with labels do not look good flipped */ block->flag |= UI_BLOCK_NO_FLIP; } @@ -843,6 +843,14 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname MEM_freeN(item); } } + else if (prop && RNA_property_type(prop) != PROP_ENUM) { + RNA_warning("%s.%s, not an enum type", RNA_struct_identifier(ptr.type), propname); + return; + } + else { + RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname); + return; + } } void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) @@ -1203,8 +1211,8 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname else { EnumPropertyItem *item; int totitem, i, free; - uiLayout *split = uiLayoutSplit(layout, 0, 0); - uiLayout *column = uiLayoutColumn(split, 0); + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = uiLayoutColumn(split, FALSE); RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); @@ -1215,7 +1223,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname else { if (item[i].name) { if (i != 0) { - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); /* inconsistent, but menus with labels do not look good flipped */ block->flag |= UI_BLOCK_NO_FLIP; } @@ -2301,7 +2309,7 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout) uiBlock *block; block = uiLayoutGetBlock(layout); - uiLayoutAbsolute(layout, 0); + uiLayoutAbsolute(layout, FALSE); return block; } @@ -2893,7 +2901,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, i uiBut *but; uiLayout *col; /* needed to avoid alignment errors with previous buttons */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefIconTextBut(block, BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, 18, 20, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults")); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index dd6be9141ca..40f28de50fa 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1729,7 +1729,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a } /* create items */ - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); for (a = 0; a < md->nitems; a++) { if (a == column_end) { @@ -1748,7 +1748,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a } } - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); } if (block->flag & UI_BLOCK_NO_FLIP) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index eae721ef484..40d530a13d4 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -371,7 +371,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str if ((idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); template->preview = 1; } else if (flag & UI_ID_BROWSE) { @@ -529,7 +529,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const * - template_ID makes a copy of the template data and assigns it to the relevant buttons */ if (template->idlb) { - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); template_ID(C, layout, template, type, idcode, flag, newop, openop, unlinkop); } @@ -577,7 +577,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co } /* Start drawing UI Elements using standard defines */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); /* Label - either use the provided text, or will become "ID-Block:" */ if (text) { @@ -618,7 +618,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna } /* Start drawing UI Elements using standard defines */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); /* Path (existing string) Widget */ uiItemR(row, ptr, propname, 0, text, ICON_RNA); @@ -731,14 +731,14 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, /* create RNA pointer */ RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr); - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetContextPointer(column, "modifier", &ptr); /* rounded header ------------------------------------------------------------------- */ box = uiLayoutBox(column); if (isVirtual) { - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* VIRTUAL MODIFIER */ @@ -752,7 +752,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, } else { /* REAL MODIFIER */ - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -837,7 +837,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (!isVirtual && (md->mode & eModifierMode_Expanded)) { /* apply/convert/copy */ box = uiLayoutBox(column); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { /* only here obdata, the rest of modifiers is ob level */ @@ -869,14 +869,14 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, } /* result is the layout block inside the box, that we return so that modifier settings can be drawn */ - result = uiLayoutColumn(box, 0); + result = uiLayoutColumn(box, FALSE); block = uiLayoutAbsoluteBlock(box); } /* error messages */ if (md->error) { box = uiLayoutBox(column); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, md->error, ICON_ERROR); } @@ -1006,11 +1006,11 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetContextPointer(col, "constraint", &ptr); box = uiLayoutBox(col); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(box); /* Draw constraint header */ @@ -1198,8 +1198,8 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* layout */ block = uiLayoutGetBlock(layout); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiLayoutSetKeepAspect(col, 1); /* add preview */ @@ -1216,7 +1216,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Create RNA Pointer */ RNA_pointer_create(id, &RNA_Material, ma, &material_ptr); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiLayoutSetScaleX(col, 1.5); uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", ICON_NONE); } @@ -1225,7 +1225,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Create RNA Pointer */ RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr); - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); if (GS(parent->name) == ID_MA) uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); @@ -1237,7 +1237,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Alpha button for texture preview */ if (*pr_texture != TEX_PR_OTHER) { - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE); } } @@ -1365,7 +1365,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand /* better to use rna so we can animate them */ PointerRNA ptr; RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &ptr, "position", 0, "Pos", ICON_NONE); bt = block->buttons.last; @@ -1776,11 +1776,11 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe block = uiLayoutGetBlock(layout); /* curve chooser */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if (labeltype == 'v') { /* vector */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[0].curve) { @@ -1798,7 +1798,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe } else if (labeltype == 'c') { /* color */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[3].curve) { @@ -1820,7 +1820,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe } else if (labeltype == 'h') { /* HSV */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[0].curve) { @@ -1843,7 +1843,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe bg = UI_GRAD_H; /* operation buttons */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1873,16 +1873,16 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe /* curve itself */ size = uiLayoutGetWidth(layout); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 200), cumap, 0.0f, 1.0f, bg, 0, ""); /* black/white levels */ if (levels) { - split = uiLayoutSplit(layout, 0, 0); - uiItemR(uiLayoutColumn(split, 0), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiItemR(uiLayoutColumn(split, 0), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + split = uiLayoutSplit(layout, 0.0f, FALSE); + uiItemR(uiLayoutColumn(split, FALSE), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(uiLayoutColumn(split, FALSE), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiLayoutRow(layout, 0); + uiLayoutRow(layout, FALSE); bt = uiDefBut(block, BUT, 0, IFACE_("Reset"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Reset Black/White point and curves")); uiButSetNFunc(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap); @@ -1941,8 +1941,8 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 1); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, TRUE); but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, ""); @@ -2033,13 +2033,13 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, /* layers are laid out going across rows, with the columns being divided into groups */ for (group = 0; group < groups; group++) { - uCol = uiLayoutColumn(layout, 1); + uCol = uiLayoutColumn(layout, TRUE); for (row = 0; row < 2; row++) { uiBlock *block; uiBut *but; - uRow = uiLayoutRow(uCol, 1); + uRow = uiLayoutRow(uCol, TRUE); block = uiLayoutGetBlock(uRow); layer = groups * cols_per_group * row + cols_per_group * group; @@ -2113,12 +2113,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe overlap = uiLayoutOverlap(layout); /* list item behind label & other buttons */ - sub = uiLayoutRow(overlap, 0); + sub = uiLayoutRow(overlap, FALSE); but = uiDefButR_prop(block, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); - sub = uiLayoutRow(overlap, 0); + sub = uiLayoutRow(overlap, FALSE); /* retrieve icon and name */ icon = list_item_icon_get(C, itemptr, rnaicon, 0); @@ -2173,12 +2173,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe Key *key = (Key *)itemptr->id.data; KeyBlock *kb = (KeyBlock *)itemptr->data; - split = uiLayoutSplit(sub, 0.66f, 0); + split = uiLayoutSplit(sub, 0.66f, FALSE); uiItemL(split, name, icon); uiBlockSetEmboss(block, UI_EMBOSSN); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); if (i == 0 || (key->type != KEY_RELATIVE)) uiItemL(row, "", ICON_NONE); else uiItemR(row, itemptr, "value", 0, "", ICON_NONE); uiItemR(row, itemptr, "mute", 0, "", 0); @@ -2186,7 +2186,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe if ((kb->flag & KEYBLOCK_MUTE) || (ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH))) { - uiLayoutSetActive(row, 0); + uiLayoutSetActive(row, FALSE); } uiBlockSetEmboss(block, UI_EMBOSS); } @@ -2234,7 +2234,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe else if (itemptr->type == &RNA_MovieTrackingObject) { MovieTrackingObject *tracking_object = (MovieTrackingObject *)itemptr->data; - split = uiLayoutSplit(sub, 0.75f, 0); + split = uiLayoutSplit(sub, 0.75f, FALSE); if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { uiItemL(split, name, ICON_CAMERA_DATA); } @@ -2243,12 +2243,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe } } else if (itemptr->type == &RNA_MaskLayer) { - split = uiLayoutSplit(sub, 0.5f, 0); + split = uiLayoutSplit(sub, 0.5f, FALSE); uiItemL(split, name, icon); uiBlockSetEmboss(block, UI_EMBOSSN); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); // uiItemR(row, itemptr, "alpha", 0, "", ICON_NONE); // enable when used uiItemR(row, itemptr, "hide", 0, "", 0); uiItemR(row, itemptr, "hide_select", 0, "", 0); @@ -2278,7 +2278,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe * for the string prop, after the name of each item of the collection. */ else if (prop_list_id) { - row = uiLayoutRow(sub, 1); + row = uiLayoutRow(sub, TRUE); uiItemL(row, name, icon); /* XXX: Check, as sometimes we get an itemptr looking like @@ -2379,8 +2379,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if (listtype == 'i') { box = uiLayoutListBox(layout, ptr, prop, activeptr, activeprop); - col = uiLayoutColumn(box, 1); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(box, TRUE); + row = uiLayoutRow(col, FALSE); if (ptr->data && prop) { /* create list items */ @@ -2388,7 +2388,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * { /* create button */ if (!(i % 9)) - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); icon = list_item_icon_get(C, &itemptr, rnaicon, 1); but = uiDefIconButR_prop(block, LISTROW, 0, icon, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); @@ -2403,7 +2403,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * else if (listtype == 'c') { /* compact layout */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (ptr->data && prop) { /* create list items */ @@ -2448,8 +2448,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* layout */ box = uiLayoutListBox(layout, ptr, prop, activeptr, activeprop); - row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 1); + row = uiLayoutRow(box, FALSE); + col = uiLayoutColumn(row, TRUE); /* init numbers */ RNA_property_int_range(activeptr, activeprop, &min, &max); @@ -2489,7 +2489,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* add scrollbar */ if (len > items) { - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &pa->list_scroll, 0, len - items, items, 0, ""); } } @@ -2625,7 +2625,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) if (owner) { uiLayout *ui_abs; - ui_abs = uiLayoutAbsolute(layout, 0); + ui_abs = uiLayoutAbsolute(layout, FALSE); (void)ui_abs; // UNUSED uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, @@ -2633,7 +2633,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner), UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress")); - uiLayoutRow(layout, 0); + uiLayoutRow(layout, FALSE); } if (WM_jobs_test(wm, screen)) uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, @@ -2665,7 +2665,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) if (!rti || rti->widthfac == 0.0f || !report) return; - ui_abs = uiLayoutAbsolute(layout, 0); + ui_abs = uiLayoutAbsolute(layout, FALSE); block = uiLayoutGetBlock(ui_abs); width = BLF_width(style->widget.uifont_id, report->message); @@ -2726,7 +2726,7 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title, if (title) uiItemL(layout, title, ICON_NONE); - flow = uiLayoutColumnFlow(layout, 2, 0); + flow = uiLayoutColumnFlow(layout, 2, FALSE); RNA_STRUCT_BEGIN (ptr, prop) { diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 9773918e508..8ff8e0824d6 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -158,17 +158,17 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, name = RNA_property_ui_name(prop); if (label_align == 'V') { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); if (!is_boolean) uiItemL(col, name, ICON_NONE); } else if (label_align == 'H') { - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemL(col, (is_boolean) ? "" : name, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); } else { col = NULL; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 004c5306d65..07b1217b1bd 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1946,8 +1946,9 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* ************ custom buttons, old stuff ************** */ /* draws in resolution of 20x4 colors */ -void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) +void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha) { + const float color_step = (type == UI_GRAD_H) ? 0.02 : 0.05f; int a; float h = hsv[0], s = hsv[1], v = hsv[2]; float dx, dy, sx1, sx2, sy; @@ -2004,7 +2005,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) /* old below */ - for (dx = 0.0f; dx < 1.0f; dx += 0.05f) { + for (dx = 0.0f; dx < 1.0f; dx += color_step) { // previous color copy_v3_v3(col0[0], col1[0]); copy_v3_v3(col0[1], col1[1]); @@ -2032,11 +2033,15 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) hsv_to_rgb(dx, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]); break; case UI_GRAD_H: - hsv_to_rgb(dx, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); + { + /* annoying but without this the color shifts - could be solved some other way + * - campbell */ + hsv_to_rgb(dx + color_step, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); copy_v3_v3(col1[1], col1[0]); copy_v3_v3(col1[2], col1[0]); copy_v3_v3(col1[3], col1[0]); break; + } case UI_GRAD_S: hsv_to_rgb(h, dx, 1.0, &col1[1][0], &col1[1][1], &col1[1][2]); copy_v3_v3(col1[0], col1[1]); @@ -2053,7 +2058,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) // rect sx1 = rect->xmin + dx * (rect->xmax - rect->xmin); - sx2 = rect->xmin + (dx + 0.05f) * (rect->xmax - rect->xmin); + sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin); sy = rect->ymin; dy = (rect->ymax - rect->ymin) / 3.0; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index f39510666ec..e5a10dc9201 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -743,7 +743,8 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255); - rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw + /* alpha 80 is not meant editable, used for wire+action draw */ + rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255); rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index b2227405d8b..51e1b30f0bf 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2078,18 +2078,21 @@ void UI_view2d_text_cache_draw(ARegion *ar) { View2DString *v2s; int col_pack_prev = 0; + + /* investigate using BLF_ascender() */ + const float default_height = strings.first ? BLF_height_default("28") : 0.0f; // glMatrixMode(GL_PROJECTION); // glPushMatrix(); // glMatrixMode(GL_MODELVIEW); // glPushMatrix(); ED_region_pixelspace(ar); - + for (v2s = strings.first; v2s; v2s = v2s->next) { const char *str = (const char *)(v2s + 1); int xofs = 0, yofs; - yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28"))); + yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - default_height)); if (yofs < 1) yofs = 1; if (col_pack_prev != v2s->col.pack) { diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt new file mode 100644 index 00000000000..0c417c5dfb9 --- /dev/null +++ b/source/blender/editors/io/CMakeLists.txt @@ -0,0 +1,46 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Blender Foundation +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + ../include + ../../blenfont + ../../blenkernel + ../../blenlib + ../../blenloader + ../../bmesh + ../../makesdna + ../../makesrna + ../../windowmanager + ../../collada +) + +set(SRC + io_collada.c + io_ops.c + + io_collada.h + io_ops.h +) + +if(WITH_OPENCOLLADA) + add_definitions(-DWITH_COLLADA) +endif() + +blender_add_lib(bf_editor_io "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/io/SConscript b/source/blender/editors/io/SConscript new file mode 100644 index 00000000000..d012576637c --- /dev/null +++ b/source/blender/editors/io/SConscript @@ -0,0 +1,14 @@ +#!/usr/bin/python + +Import ('env') + +sources = env.Glob('*.c') +defs = [] + +incs = '../include ../../blenfont ../../blenkernel ../../blenlib ../../blenloader ../../bmesh' +incs += '../../makesdna ../../makesrna ../../windowmanager ../../collada' + +if env['WITH_BF_COLLADA']: + defs += ['WITH_COLLADA'] + +env.BlenderLib ( 'bf_editor_io', sources, Split(incs), defines=defs, libtype=['core','player'], priority=[330,210] ) diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c new file mode 100644 index 00000000000..dca38e53934 --- /dev/null +++ b/source/blender/editors/io/io_collada.c @@ -0,0 +1,324 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/io/collada.c + * \ingroup collada + */ +#ifdef WITH_COLLADA +#include "DNA_scene_types.h" + +#include "BLF_translation.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_report.h" + +#include "ED_screen.h" +#include "ED_object.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "../../collada/collada.h" + +static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + char filepath[FILE_MAX]; + + if (G.main->name[0] == 0) + BLI_strncpy(filepath, "untitled", sizeof(filepath)); + else + BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + + BLI_replace_extension(filepath, sizeof(filepath), ".dae"); + RNA_string_set(op->ptr, "filepath", filepath); + } + + WM_event_add_fileselect(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +/* function used for WM_OT_save_mainfile too */ +static int wm_collada_export_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + int apply_modifiers; + int export_mesh_type; + int selected; + int include_children; + int include_armatures; + int deform_bones_only; + + int include_uv_textures; + int include_material_textures; + int use_texture_copies; + int active_uv_only; + + int use_object_instantiation; + int sort_by_name; + int second_life; + + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + BKE_report(op->reports, RPT_ERROR, "No filename given"); + return OPERATOR_CANCELLED; + } + + RNA_string_get(op->ptr, "filepath", filepath); + BLI_ensure_extension(filepath, sizeof(filepath), ".dae"); + + /* Options panel */ + apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); + export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection"); + selected = RNA_boolean_get(op->ptr, "selected"); + include_children = RNA_boolean_get(op->ptr, "include_children"); + include_armatures = RNA_boolean_get(op->ptr, "include_armatures"); + deform_bones_only = RNA_boolean_get(op->ptr, "deform_bones_only"); + + include_uv_textures = RNA_boolean_get(op->ptr, "include_uv_textures"); + include_material_textures= RNA_boolean_get(op->ptr, "include_material_textures"); + use_texture_copies = RNA_boolean_get(op->ptr, "use_texture_copies"); + active_uv_only = RNA_boolean_get(op->ptr, "active_uv_only"); + + use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); + sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name"); + second_life = RNA_boolean_get(op->ptr, "second_life"); + + /* get editmode results */ + ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ + + if (collada_export( + CTX_data_scene(C), + filepath, + apply_modifiers, + export_mesh_type, + selected, + include_children, + include_armatures, + deform_bones_only, + + active_uv_only, + include_uv_textures, + include_material_textures, + use_texture_copies, + + use_object_instantiation, + sort_by_name, + second_life)) { + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) +{ + uiLayout *box, *row, *col, *split; + + /* Export Options: */ + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA); + + row = uiLayoutRow(box, 0); + split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT); + col = uiLayoutColumn(split,0); + uiItemR(col, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split,0); + uiItemR(col, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE); + uiLayoutSetEnabled(col, RNA_boolean_get(imfptr, "apply_modifiers")); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE); + uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); + uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); + + // Texture options + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "active_uv_only", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "include_uv_textures", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "include_material_textures", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE); + + + // Armature options + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE); + + /* Collada options: */ + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); + +} + +static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op) +{ + PointerRNA ptr; + + RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + uiCollada_exportSettings(op->layout, &ptr); +} + +void WM_OT_collada_export(wmOperatorType *ot) +{ + static EnumPropertyItem prop_bc_export_mesh_type[] = { + {BC_MESH_TYPE_VIEW, "view", 0, "View", "Apply modifier's view settings"}, + {BC_MESH_TYPE_RENDER, "render", 0, "Render", "Apply modifier's render settings"}, + {0, NULL, 0, NULL, NULL} + }; + + ot->name = "Export COLLADA"; + ot->description = "Save a Collada file"; + ot->idname = "WM_OT_collada_export"; + + ot->invoke = wm_collada_export_invoke; + ot->exec = wm_collada_export_exec; + ot->poll = WM_operator_winactive; + + ot->flag |= OPTYPE_PRESET; + + ot->ui = wm_collada_export_draw; + + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + + RNA_def_boolean(ot->srna, + "apply_modifiers", 0, "Apply Modifiers", + "Apply modifiers to exported mesh (non destructive))"); + + RNA_def_int(ot->srna, "export_mesh_type", 0, INT_MIN, INT_MAX, + "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX); + + RNA_def_enum(ot->srna, "export_mesh_type_selection", prop_bc_export_mesh_type, 0, + "Resolution", "Modifier resolution for export"); + + RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", + "Export only selected elements"); + + RNA_def_boolean(ot->srna, "include_children", 0, "Include Children", + "Export all children of selected objects (even if not selected)"); + + RNA_def_boolean(ot->srna, "include_armatures", 0, "Include Armatures", + "Export related armatures (even if not selected)"); + + RNA_def_boolean(ot->srna, "deform_bones_only", 0, "Deform Bones only", + "Only export deforming bones with armatures"); + + + RNA_def_boolean(ot->srna, "active_uv_only", 0, "Only Active UV layer", + "Export textures assigned to the object UV maps"); + + RNA_def_boolean(ot->srna, "include_uv_textures", 0, "Include UV Textures", + "Export textures assigned to the object UV maps"); + + RNA_def_boolean(ot->srna, "include_material_textures", 0, "Include Material Textures", + "Export textures assigned to the object Materials"); + + RNA_def_boolean(ot->srna, "use_texture_copies", 1, "copy", + "Copy textures to same folder where the .dae file is exported"); + + + RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instances", + "Instantiate multiple Objects from same Data"); + + RNA_def_boolean(ot->srna, "sort_by_name", 0, "Sort by Object name", + "Sort exported data by Object name"); + + RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", + "Compatibility mode for Second Life"); +} + + +/* function used for WM_OT_save_mainfile too */ +static int wm_collada_import_exec(bContext *C, wmOperator *op) +{ + char filename[FILE_MAX]; + + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + BKE_report(op->reports, RPT_ERROR, "No filename given"); + return OPERATOR_CANCELLED; + } + + RNA_string_get(op->ptr, "filepath", filename); + if (collada_import(C, filename)) return OPERATOR_FINISHED; + + BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log."); + + return OPERATOR_FINISHED; +} + +void WM_OT_collada_import(wmOperatorType *ot) +{ + ot->name = "Import COLLADA"; + ot->description = "Load a Collada file"; + ot->idname = "WM_OT_collada_import"; + + ot->invoke = WM_operator_filesel; + ot->exec = wm_collada_import_exec; + ot->poll = WM_operator_winactive; + + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} +#endif diff --git a/source/blender/editors/io/io_collada.h b/source/blender/editors/io/io_collada.h new file mode 100644 index 00000000000..5cb255e1b7c --- /dev/null +++ b/source/blender/editors/io/io_collada.h @@ -0,0 +1,39 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2007 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editor/io/io_collada.h + * \ingroup editor/io + */ + +#ifndef __IO_COLLADA_H__ +#define __IO_COLLADA_H__ + +struct wmOperatorType; + +void WM_OT_collada_export(struct wmOperatorType *ot); +void WM_OT_collada_import(struct wmOperatorType *ot); + +#endif diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c new file mode 100644 index 00000000000..b724db6e737 --- /dev/null +++ b/source/blender/editors/io/io_ops.c @@ -0,0 +1,44 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/io/io_ops.c + * \ingroup collada + */ + + +#include "io_collada.h" + +#include "WM_types.h" +#include "WM_api.h" + +void ED_operatortypes_io(void) +{ +#ifdef WITH_COLLADA + // Collada operators: + WM_operatortype_append(WM_OT_collada_export); + WM_operatortype_append(WM_OT_collada_import); +#endif +} diff --git a/source/blender/editors/io/io_ops.h b/source/blender/editors/io/io_ops.h new file mode 100644 index 00000000000..1e2c4443e43 --- /dev/null +++ b/source/blender/editors/io/io_ops.h @@ -0,0 +1,36 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2007 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editor/io/io_collada.h + * \ingroup editor/io + */ + +#ifndef __IO_OPS_H__ +#define __IO_OPS_H__ + +void ED_operatortypes_io(void); + +#endif diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 0bc9adb6577..c9f6dc0c5fb 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -52,7 +52,7 @@ #include "mask_intern.h" /* own include */ -static int find_nearest_diff_point(bContext *C, Mask *mask, const float normal_co[2], int threshold, int feather, +static int find_nearest_diff_point(const bContext *C, Mask *mask, const float normal_co[2], int threshold, int feather, MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r, float *u_r, float tangent[2], const short use_deform) @@ -176,7 +176,7 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, const float normal_c /******************** add vertex *********************/ -static void setup_vertex_point(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, +static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, const float point_co[2], const float tangent[2], const float u, MaskSplinePoint *reference_point, const short reference_adjacent) { @@ -365,7 +365,7 @@ static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index) spline->tot_point++; } -static int add_vertex_subdivide(bContext *C, Mask *mask, const float co[2]) +static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2]) { MaskLayer *masklay; MaskSpline *spline; @@ -399,7 +399,7 @@ static int add_vertex_subdivide(bContext *C, Mask *mask, const float co[2]) return FALSE; } -static int add_vertex_extrude(bContext *C, Mask *mask, MaskLayer *masklay, const float co[2]) +static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay, const float co[2]) { MaskSpline *spline; MaskSplinePoint *point; @@ -500,7 +500,7 @@ static int add_vertex_extrude(bContext *C, Mask *mask, MaskLayer *masklay, const return TRUE; } -static int add_vertex_new(bContext *C, Mask *mask, MaskLayer *masklay, const float co[2]) +static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, const float co[2]) { MaskSpline *spline; MaskSplinePoint *point; diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 678186f0e8c..83337a18223 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -116,7 +116,8 @@ static void draw_spline_parents(MaskLayer *UNUSED(masklay), MaskSpline *spline) #endif /* return non-zero if spline is selected */ -static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline) +static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline, + const char UNUSED(draw_flag), const char draw_type) { const int is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0; unsigned char rgb_spline[4]; @@ -188,8 +189,20 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline) /* draw handle segment */ if (has_handle) { - glColor3ubv(rgb_spline); + /* this could be split into its own loop */ + if (draw_type == MASK_DT_OUTLINE) { + const unsigned char rgb_grey[4] = {0x60, 0x60, 0x60, 0xff}; + glLineWidth(3); + glColor4ubv(rgb_grey); + glBegin(GL_LINES); + glVertex3fv(vert); + glVertex3fv(handle); + glEnd(); + glLineWidth(1); + } + + glColor3ubv(rgb_spline); glBegin(GL_LINES); glVertex3fv(vert); glVertex3fv(handle); @@ -415,7 +428,7 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type if (!(masklay->restrictflag & MASK_RESTRICT_SELECT)) { /* ...and then handles over the curve so they're nicely visible */ - draw_spline_points(masklay, spline); + draw_spline_points(masklay, spline, draw_flag, draw_type); } /* show undeform for testing */ @@ -425,7 +438,7 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type spline->points_deform = NULL; draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height); // draw_spline_parents(masklay, spline); - draw_spline_points(masklay, spline); + draw_spline_points(masklay, spline, draw_flag, draw_type); spline->points_deform = back; } } @@ -441,10 +454,7 @@ void ED_mask_draw(const bContext *C, if (!mask) return; - /* TODO: for now, in the future better to make sure all utility functions - * are using const specifier for non-changing pointers - */ - ED_mask_size((bContext *)C, &width, &height); + ED_mask_size(C, &width, &height); draw_masklays(mask, draw_flag, draw_type, width, height); } diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 52711c8da55..6e0da5fd756 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -76,7 +76,7 @@ int ED_maskedit_mask_poll(bContext *C) /********************** registration *********************/ -void ED_mask_mouse_pos(bContext *C, wmEvent *event, float co[2]) +void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -92,7 +92,7 @@ void ED_mask_mouse_pos(bContext *C, wmEvent *event, float co[2]) /* input: x/y - mval space * output: xr/yr - mask point space */ -void ED_mask_point_pos(bContext *C, float x, float y, float *xr, float *yr) +void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr) { SpaceClip *sc = CTX_wm_space_clip(C); float co[2]; @@ -110,7 +110,7 @@ void ED_mask_point_pos(bContext *C, float x, float y, float *xr, float *yr) *yr = co[1]; } -void ED_mask_point_pos__reverse(bContext *C, float x, float y, float *xr, float *yr) +void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); @@ -121,7 +121,7 @@ void ED_mask_point_pos__reverse(bContext *C, float x, float y, float *xr, float co[0] = x; co[1] = y; BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co); - ED_clip_point_stable_pos__reverse(sc, ar, co, co); + ED_clip_point_stable_pos__reverse(C, co, co); } else { /* possible other spaces from which mask editing is available */ @@ -132,13 +132,12 @@ void ED_mask_point_pos__reverse(bContext *C, float x, float y, float *xr, float *yr = co[1]; } -void ED_mask_size(bContext *C, int *width, int *height) +void ED_mask_size(const bContext *C, int *width, int *height) { ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { if (sa->spacetype == SPACE_CLIP) { - SpaceClip *sc = sa->spacedata.first; - ED_space_clip_mask_size(sc, width, height); + ED_space_clip_get_size(C, width, height); return; } else if (sa->spacetype == SPACE_SEQ) { @@ -154,12 +153,12 @@ void ED_mask_size(bContext *C, int *width, int *height) *height = 0; } -void ED_mask_aspect(bContext *C, float *aspx, float *aspy) +void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - ED_space_clip_mask_aspect(sc, aspx, aspy); + ED_space_clip_get_aspect(sc, aspx, aspy); } else { /* possible other spaces from which mask editing is available */ @@ -168,18 +167,17 @@ void ED_mask_aspect(bContext *C, float *aspx, float *aspy) } } -void ED_mask_pixelspace_factor(bContext *C, float *scalex, float *scaley) +void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - ARegion *ar = CTX_wm_region(C); int width, height; float zoomx, zoomy, aspx, aspy; - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); *scalex = ((float)width * aspx) * zoomx; *scaley = ((float)height * aspy) * zoomy; @@ -239,6 +237,7 @@ void ED_operatortypes_mask(void) WM_operatortype_append(MASK_OT_shape_key_insert); WM_operatortype_append(MASK_OT_shape_key_clear); WM_operatortype_append(MASK_OT_shape_key_feather_reset); + WM_operatortype_append(MASK_OT_shape_key_rekey); } void ED_keymap_mask(wmKeyConfig *keyconf) diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index c34558d2a01..f1d72f59078 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -61,12 +61,12 @@ void MASK_OT_normals_make_consistent(struct wmOperatorType *ot); void MASK_OT_handle_type_set(struct wmOperatorType *ot); int ED_mask_feather_find_nearest( - struct bContext *C, struct Mask *mask, float normal_co[2], int threshold, + const struct bContext *C, struct Mask *mask, float normal_co[2], int threshold, struct MaskLayer **masklay_r, struct MaskSpline **spline_r, struct MaskSplinePoint **point_r, struct MaskSplinePointUW **uw_r, float *score); struct MaskSplinePoint *ED_mask_point_find_nearest( - struct bContext *C, struct Mask *mask, float normal_co[2], int threshold, + const struct bContext *C, struct Mask *mask, float normal_co[2], int threshold, struct MaskLayer **masklay_r, struct MaskSpline **spline_r, int *is_handle_r, float *score); @@ -97,18 +97,19 @@ void ED_mask_select_flush_all(struct Mask *mask); int ED_maskedit_poll(struct bContext *C); int ED_maskedit_mask_poll(struct bContext *C); -void ED_mask_size(struct bContext *C, int *width, int *height); -void ED_mask_aspect(struct bContext *C, float *aspx, float *aspy); +void ED_mask_size(const struct bContext *C, int *width, int *height); +void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy); -void ED_mask_pixelspace_factor(struct bContext *C, float *scalex, float *scaley); -void ED_mask_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]); +void ED_mask_pixelspace_factor(const struct bContext *C, float *scalex, float *scaley); +void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); -void ED_mask_point_pos(struct bContext *C, float x, float y, float *xr, float *yr); -void ED_mask_point_pos__reverse(struct bContext *C, float x, float y, float *xr, float *yr); +void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr); +void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr); /* mask_shapekey.c */ void MASK_OT_shape_key_insert(struct wmOperatorType *ot); void MASK_OT_shape_key_clear(struct wmOperatorType *ot); void MASK_OT_shape_key_feather_reset(struct wmOperatorType *ot); +void MASK_OT_shape_key_rekey(struct wmOperatorType *ot); #endif /* __MASK_INTERN_H__ */ diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index b770e5e9dba..91ba05c1ab2 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -57,7 +57,7 @@ /******************** utility functions *********************/ -MaskSplinePoint *ED_mask_point_find_nearest(bContext *C, Mask *mask, float normal_co[2], int threshold, +MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float normal_co[2], int threshold, MaskLayer **masklay_r, MaskSpline **spline_r, int *is_handle_r, float *score) { @@ -153,7 +153,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(bContext *C, Mask *mask, float norma return NULL; } -int ED_mask_feather_find_nearest(bContext *C, Mask *mask, float normal_co[2], int threshold, +int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[2], int threshold, MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r, MaskSplinePointUW **uw_r, float *score) { diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c index 7ba3c27e18d..a1f2539ce7c 100644 --- a/source/blender/editors/mask/mask_relationships.c +++ b/source/blender/editors/mask/mask_relationships.c @@ -44,6 +44,7 @@ #include "WM_types.h" #include "ED_screen.h" +#include "ED_clip.h" /* frame remapping functions */ #include "ED_mask.h" /* own include */ #include "mask_intern.h" /* own include */ @@ -104,21 +105,25 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) MovieClip *clip; MovieTrackingTrack *track; MovieTrackingMarker *marker; - MovieTrackingObject *tracking; + MovieTrackingObject *tracking_object; /* done */ + int framenr; + float marker_pos_ofs[2]; float parmask_pos[2]; if ((NULL == (sc = CTX_wm_space_clip(C))) || (NULL == (clip = sc->clip)) || (NULL == (track = clip->tracking.act_track)) || - (NULL == (marker = BKE_tracking_marker_get(track, sc->user.framenr))) || - (NULL == (tracking = BKE_tracking_object_get_active(&clip->tracking)))) + (NULL == (tracking_object = BKE_tracking_object_get_active(&clip->tracking)))) { return OPERATOR_CANCELLED; } + framenr = ED_space_clip_get_clip_frame_number(sc); + marker = BKE_tracking_marker_get(track, framenr); + add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); BKE_mask_coord_from_movieclip(clip, &sc->user, parmask_pos, marker_pos_ofs); @@ -138,7 +143,7 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) if (MASKPOINT_ISSEL_ANY(point)) { point->parent.id_type = ID_MC; point->parent.id = &clip->id; - strcpy(point->parent.parent, tracking->name); + strcpy(point->parent.parent, tracking_object->name); strcpy(point->parent.sub_parent, track->name); copy_v2_v2(point->parent.parent_orig, parmask_pos); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 55e09529320..e619277456e 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -581,8 +581,6 @@ static int circle_select_exec(bContext *C, wmOperator *op) MaskLayer *masklay; int i; - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); int x, y, radius, width, height, mode, change = FALSE; float zoomx, zoomy, offset[2], ellipse[2]; @@ -595,8 +593,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) /* TODO - make generic! - this is SpaceClip only! */ /* compute ellipse and position in unified coordinates */ - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); width = height = MAX2(width, height); ellipse[0] = width * zoomx / radius; diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index 8da083ab400..a619ac7e3cd 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -29,7 +29,11 @@ * \ingroup edmask */ +#include <stdlib.h> + #include "BLI_utildefines.h" +#include "BLI_listbase.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -39,6 +43,9 @@ #include "DNA_mask_types.h" #include "DNA_scene_types.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "WM_api.h" #include "WM_types.h" @@ -233,6 +240,175 @@ void MASK_OT_shape_key_feather_reset(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/* + * - loop over selected shapekeys. + * - find firstsel/lastsel pairs. + * - move these into a temp list. + * - re-key all the original shapes. + * - copy unselected values back from the original. + * - free the original. + */ +static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + const int frame = CFRA; + Mask *mask = CTX_data_edit_mask(C); + MaskLayer *masklay; + int change = FALSE; + + const short do_feather = RNA_boolean_get(op->ptr, "feather"); + const short do_location = RNA_boolean_get(op->ptr, "location"); + + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + + if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { + continue; + } + + /* we need at least one point selected here to bother re-interpolating */ + if (!ED_mask_layer_select_check(masklay)) { + continue; + } + + if (masklay->splines_shapes.first) { + MaskLayerShape *masklay_shape; + MaskLayerShape *masklay_shape_lastsel = NULL; + + for (masklay_shape = masklay->splines_shapes.first; + masklay_shape; + masklay_shape = masklay_shape->next) + { + MaskLayerShape *masklay_shape_a = NULL; + MaskLayerShape *masklay_shape_b = NULL; + + /* find contiguous selections */ + if (masklay_shape->flag & MASK_SHAPE_SELECT) { + if (masklay_shape_lastsel == NULL) { + masklay_shape_lastsel = masklay_shape; + } + if ((masklay_shape->next == NULL) || + (((MaskLayerShape *)masklay_shape->next)->flag & MASK_SHAPE_SELECT) == 0) + { + masklay_shape_a = masklay_shape_lastsel; + masklay_shape_b = masklay_shape; + masklay_shape_lastsel = NULL; + } + } + + /* we have a from<>to? - re-interpolate! */ + if (masklay_shape_a && masklay_shape_b) { + ListBase shapes_tmp = {NULL, NULL}; + MaskLayerShape *masklay_shape_tmp; + MaskLayerShape *masklay_shape_tmp_next; + MaskLayerShape *masklay_shape_tmp_last = masklay_shape_b->next; + MaskLayerShape *masklay_shape_tmp_rekey; + + /* move keys */ + for (masklay_shape_tmp = masklay_shape_a; + masklay_shape_tmp && (masklay_shape_tmp != masklay_shape_tmp_last); + masklay_shape_tmp = masklay_shape_tmp_next) + { + masklay_shape_tmp_next = masklay_shape_tmp->next; + BLI_remlink(&masklay->splines_shapes, masklay_shape_tmp); + BLI_addtail(&shapes_tmp, masklay_shape_tmp); + } + + /* re-key, note: cant modify the keys here since it messes uop */ + for (masklay_shape_tmp = shapes_tmp.first; + masklay_shape_tmp; + masklay_shape_tmp = masklay_shape_tmp->next) + { + BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, TRUE); + masklay_shape_tmp_rekey = BKE_mask_layer_shape_varify_frame(masklay, masklay_shape_tmp->frame); + BKE_mask_layer_shape_from_mask(masklay, masklay_shape_tmp_rekey); + masklay_shape_tmp_rekey->flag = masklay_shape_tmp->flag & MASK_SHAPE_SELECT; + } + + /* restore unselected points and free copies */ + for (masklay_shape_tmp = shapes_tmp.first; + masklay_shape_tmp; + masklay_shape_tmp = masklay_shape_tmp_next) + { + /* restore */ + int i_abs = 0; + int i; + MaskSpline *spline; + MaskLayerShapeElem *shape_ele_src; + MaskLayerShapeElem *shape_ele_dst; + + masklay_shape_tmp_next = masklay_shape_tmp->next; + + /* we know this exists, added above */ + masklay_shape_tmp_rekey = BKE_mask_layer_shape_find_frame(masklay, masklay_shape_tmp->frame); + + shape_ele_src = (MaskLayerShapeElem *)masklay_shape_tmp->data; + shape_ele_dst = (MaskLayerShapeElem *)masklay_shape_tmp_rekey->data; + + for (spline = masklay->splines.first; spline; spline = spline->next) { + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &spline->points[i]; + + /* not especially efficient but makes this easier to follow */ + SWAP(MaskLayerShapeElem, *shape_ele_src, *shape_ele_dst); + + if (MASKPOINT_ISSEL_ANY(point)) { + if (do_location) { + memcpy(shape_ele_dst->value, shape_ele_src->value, sizeof(float) * 6); + } + if (do_feather) { + shape_ele_dst->value[6] = shape_ele_src->value[6]; + } + } + + shape_ele_src++; + shape_ele_dst++; + + i_abs++; + } + } + + BKE_mask_layer_shape_free(masklay_shape_tmp); + } + + change = TRUE; + } + } + + /* re-evaluate */ + BKE_mask_layer_evaluate(masklay, frame, TRUE); + } + } + + if (change) { + WM_event_add_notifier(C, NC_MASK | ND_DATA, mask); + DAG_id_tag_update(&mask->id, 0); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void MASK_OT_shape_key_rekey(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Re-Key Points of Selected Shapes"; + ot->description = "Recalculates animation data on selected points for frames selected in the dopesheet"; + ot->idname = "MASK_OT_shape_key_rekey"; + + /* api callbacks */ + ot->exec = mask_shape_key_rekey_exec; + ot->poll = ED_maskedit_mask_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "location", TRUE, "Location", ""); + RNA_def_boolean(ot->srna, "feather", TRUE, "Feather", ""); +} + /* *** Shape Key Utils *** */ diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index f154aec2eb4..898399f723d 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1468,6 +1468,8 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo if (cure && p) { if (!kcd->ignore_edge_snapping || !(cure->e)) { + KnifeVert *edgesnap = NULL; + if (kcd->snap_midpoints) { mid_v3_v3v3(p, cure->v1->co, cure->v2->co); mid_v3_v3v3(cagep, cure->v1->cageco, cure->v2->cageco); @@ -1479,6 +1481,13 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo d = len_v3v3(cagep, cure->v1->cageco) / len_v3v3(cure->v1->cageco, cure->v2->cageco); interp_v3_v3v3(p, cure->v1->co, cure->v2->co, d); } + + /* update mouse coordinates to the snapped-to edge's screen coordinates + * this is important for angle snap, which uses the previous mouse position */ + edgesnap = new_knife_vert(kcd, p, cagep); + kcd->cur.mval[0] = (int)edgesnap->sco[0]; + kcd->cur.mval[1] = (int)edgesnap->sco[1]; + } else { return NULL; @@ -1557,6 +1566,11 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo if (curv && p) { copy_v3_v3(p, curv->co); copy_v3_v3(cagep, curv->cageco); + + /* update mouse coordinates to the snapped-to vertex's screen coordinates + * this is important for angle snap, which uses the previous mouse position */ + kcd->cur.mval[0] = (int)curv->sco[0]; + kcd->cur.mval[1] = (int)curv->sco[1]; } return curv; @@ -1617,7 +1631,11 @@ static int knife_update_active(KnifeTool_OpData *kcd) kcd->cur.mval[0] = kcd->vc.mval[0]; kcd->cur.mval[1] = kcd->vc.mval[1]; + /* XXX knife_snap_angle updates the view coordinate mouse values to constrained angles, + * which current mouse values are set to current mouse values are then used + * for vertex and edge snap detection, without regard to the exact angle constraint */ kcd->cur.vert = knife_find_closest_vert(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space); + if (!kcd->cur.vert) { kcd->cur.edge = knife_find_closest_edge(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space); } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index bf299ffaa61..6940b05e86c 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1046,6 +1046,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) // if (EM_texFaceCheck()) /* sets as active, useful for other tools */ +#if 0 if (select) { if (em->selectmode & SCE_SELECT_VERTEX) { /* TODO: would be nice if the edge vertex chosen here @@ -1060,6 +1061,8 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) * belongs to the selected edge could be set to * active here in face select mode */ } +#endif + mouse_mesh(C, mval, select, TRUE, FALSE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 5ad663b92d3..908c0a6f4f2 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1752,6 +1752,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", ""); prop = RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_enum_funcs(prop, gameprops_itemf); ot->prop = prop; } diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index b47591dddee..48104c9274d 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -160,7 +160,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) +static int group_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -180,21 +180,114 @@ static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void GROUP_OT_objects_remove(wmOperatorType *ot) +void GROUP_OT_objects_remove_all(wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove From Groups"; - ot->description = "Remove selected objects from all groups"; - ot->idname = "GROUP_OT_objects_remove"; + ot->name = "Remove From All Groups"; + ot->description = "Remove selected objects from all groups or a selected group"; + ot->idname = "GROUP_OT_objects_remove_all"; /* api callbacks */ - ot->exec = group_objects_remove_exec; + ot->exec = group_objects_remove_all_exec; ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +static int group_objects_remove_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_context(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + int group_object_index = RNA_enum_get(op->ptr, "group"); + + /* first get the group back from the enum index, quite awkward and UI spesific */ + if (ob) { + Group *group = NULL; + int i = 0; + + while ((group = find_group(ob, group))) { + if (i == group_object_index) { + break; + } + i++; + } + + /* now remove all selected objects from the group */ + if (group) { + + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + { + rem_from_group(group, base->object, scene, base); + } + CTX_DATA_END; + + DAG_scene_sort(bmain, scene); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + + return OPERATOR_FINISHED; + } + } + + return OPERATOR_CANCELLED; +} + + +/* can be called with C == NULL */ +static EnumPropertyItem *group_objects_remove_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) +{ + Object *ob = ED_object_context(C); + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + + if (C == NULL) { + return DummyRNA_NULL_items; + } + + /* check that the action exists */ + if (ob) { + Group *group = NULL; + int i = 0; + + while ((group = find_group(ob, group))) { + item_tmp.identifier = item_tmp.name = group->id.name + 2; + /* item_tmp.icon = ICON_ARMATURE_DATA; */ + item_tmp.value = i; + RNA_enum_item_add(&item, &totitem, &item_tmp); + i++; + } + } + + RNA_enum_item_end(&item, &totitem); + *free = 1; + + return item; +} + +void GROUP_OT_objects_remove(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Remove From Group"; + ot->description = "Remove selected objects from all groups or a selected group"; + ot->idname = "GROUP_OT_objects_remove"; + + /* api callbacks */ + ot->exec = group_objects_remove_exec; + ot->invoke = WM_menu_invoke; + ot->poll = ED_operator_objectmode; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to remove this object from"); + RNA_def_enum_funcs(prop, group_objects_remove_itemf); + ot->prop = prop; +} + static int group_create_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 4b33c5663ba..f7e7c87d956 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -139,6 +139,7 @@ void LATTICE_OT_make_regular(struct wmOperatorType *ot); /* object_group.c */ void GROUP_OT_create(struct wmOperatorType *ot); +void GROUP_OT_objects_remove_all(struct wmOperatorType *ot); void GROUP_OT_objects_remove(struct wmOperatorType *ot); void GROUP_OT_objects_add_active(struct wmOperatorType *ot); void GROUP_OT_objects_remove_active(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 0a9944debe1..e85f47837ef 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -102,7 +102,7 @@ void make_editLatt(Object *obedit) if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; - lt->editlatt->latt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); + lt->editlatt->latt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot); } @@ -162,7 +162,7 @@ void load_editLatt(Object *obedit) if (editlt->dvert) { tot = lt->pntsu * lt->pntsv * lt->pntsw; - lt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); + lt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->dvert, editlt->dvert, tot); } } diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index d0a93302b7f..cec849efca7 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -105,6 +105,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_select_mirror); WM_operatortype_append(GROUP_OT_create); + WM_operatortype_append(GROUP_OT_objects_remove_all); WM_operatortype_append(GROUP_OT_objects_remove); WM_operatortype_append(GROUP_OT_objects_add_active); WM_operatortype_append(GROUP_OT_objects_remove_active); @@ -394,6 +395,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_all", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 37ab87780b5..3533a337aa1 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1241,6 +1241,8 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) else WM_cursor_set(win, CURSOR_X_MOVE); } + else + WM_cursor_set(win, CURSOR_STD); } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4e98d2ae967..cacd6d01291 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -460,7 +460,7 @@ int ED_operator_mask(bContext *C) { SpaceClip *sc= CTX_wm_space_clip(C); - return ED_space_clip_show_maskedit(sc); + return ED_space_clip_check_show_maskedit(sc); } /* *************************** action zone operator ************************** */ @@ -1175,7 +1175,7 @@ static int area_split_menu_init(bContext *C, wmOperator *op) sAreaSplitData *sd; /* custom data */ - sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; sd->sarea = CTX_wm_area(C); @@ -1210,7 +1210,7 @@ static int area_split_init(bContext *C, wmOperator *op) if (dir == 'h' && sa->winy < 2 * areaminy) return 0; /* custom data */ - sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; sd->sarea = sa; @@ -2180,7 +2180,7 @@ static int area_join_init(bContext *C, wmOperator *op) return 0; } - jd = (sAreaJoinData *)MEM_callocN(sizeof (sAreaJoinData), "op_area_join"); + jd = (sAreaJoinData *)MEM_callocN(sizeof(sAreaJoinData), "op_area_join"); jd->sa1 = sa1; jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 4dee83dbb82..a1ade77d068 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -2344,8 +2344,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* Use tf_uv_pxoffset instead of tf->uv so we can offset the UV half a pixel * this is done so we can avoid offsetting all the pixels by 0.5 which causes * problems when wrapping negative coords */ - xhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 3.0f) ) / ibuf_xf; - yhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 4.0f) ) / ibuf_yf; + xhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 3.0f)) / ibuf_xf; + yhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 4.0f)) / ibuf_yf; /* Note about (PROJ_GEOM_TOLERANCE/x) above... * Needed to add this offset since UV coords are often quads aligned to pixels. @@ -5096,8 +5096,8 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* This can be removed once fixed properly in * BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user) - * at zero pressure we should do nothing 1/2^12 is .0002 which is the sensitivity of the most sensitive pen tablet available */ - if (tablet && (pressure < .0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) + * at zero pressure we should do nothing 1/2^12 is 0.0002 which is the sensitivity of the most sensitive pen tablet available */ + if (tablet && (pressure < 0.0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) return; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 89dbe14f62a..e6c061a06ec 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -592,7 +592,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis, distsq = len_squared_v3v3(mirror, cache->true_location); if (distsq <= 4.0f * (cache->radius_squared)) - return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius)); + return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius)); else return 0; } diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index d233c45a230..f327f67be33 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -269,7 +269,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) SculptSession *ss = ob->sculpt; SculptUndoNode *unode; MultiresModifierData *mmd; - int update = 0, rebuild = 1; + int update = FALSE, rebuild = FALSE; sculpt_update_mesh_elements(scene, sd, ob, 0); @@ -297,15 +297,15 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) switch (unode->type) { case SCULPT_UNDO_COORDS: if (sculpt_undo_restore_coords(C, dm, unode)) - update = 1; + update = TRUE; break; case SCULPT_UNDO_HIDDEN: if (sculpt_undo_restore_hidden(C, dm, unode)) - rebuild = 1; + rebuild = TRUE; break; case SCULPT_UNDO_MASK: if (sculpt_undo_restore_mask(C, dm, unode)) - update = 1; + update = TRUE; break; } } diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt index 137cda9c285..0abdd134046 100644 --- a/source/blender/editors/space_api/CMakeLists.txt +++ b/source/blender/editors/space_api/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../include + ../io ../../blenkernel ../../blenlib ../../blenloader diff --git a/source/blender/editors/space_api/SConscript b/source/blender/editors/space_api/SConscript index 6bf901cf8ad..9b818b074ba 100644 --- a/source/blender/editors/space_api/SConscript +++ b/source/blender/editors/space_api/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.c') -incs = '../include ../../blenlib ../../blenkernel ../../blenloader ../../makesdna' +incs = '../include ../io ../../blenlib ../../blenkernel ../../blenloader ../../makesdna' incs += ' ../../windowmanager ../../python ../../makesrna ../../bmesh' incs += ' #/intern/guardedalloc #/extern/glew/include' diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index fa77249a7a1..2cbcbcdbc9a 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -63,6 +63,9 @@ #include "ED_logic.h" #include "ED_clip.h" #include "ED_mask.h" +#include "ED_sequencer.h" + +#include "io_ops.h" /* only call once on startup, storage is global in BKE kernel listbase */ void ED_spacetypes_init(void) @@ -113,6 +116,7 @@ void ED_spacetypes_init(void) ED_operatortypes_render(); ED_operatortypes_logic(); ED_operatortypes_mask(); + ED_operatortypes_io(); UI_view2d_operatortypes(); UI_buttons_operatortypes(); @@ -136,7 +140,8 @@ void ED_spacetypes_init(void) ED_operatormacros_clip(); ED_operatormacros_curve(); ED_operatormacros_mask(); - + ED_operatormacros_sequencer(); + /* register dropboxes (can use macros) */ spacetypes = BKE_spacetypes_list(); for (type = spacetypes->first; type; type = type->next) { diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index d1c2c1e092f..6154a1cc5ce 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -991,7 +991,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) if (!path) return; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); block = uiLayoutGetBlock(row); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index d1737fcd065..c894c1a980b 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -333,6 +333,9 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) buttons_area_redraw(sa, BCONTEXT_DATA); sbuts->preview = 1; break; + case NC_GROUP: + buttons_area_redraw(sa, BCONTEXT_OBJECT); + break; case NC_BRUSH: buttons_area_redraw(sa, BCONTEXT_TEXTURE); break; diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 9b3d713d040..e561b2a9e79 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -118,13 +118,13 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL); if (clip) { - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, ""); - row = uiLayoutRow(layout, 0); - split = uiLayoutSplit(row, 0.0, 0); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(layout, FALSE); + split = uiLayoutSplit(row, 0.0f, FALSE); + row = uiLayoutRow(split, TRUE); uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload"); @@ -396,7 +396,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P BKE_movieclip_get_size(clip, user, &width, &height); if (track->flag & TRACK_LOCKED) { - uiLayoutSetActive(layout, 0); + uiLayoutSetActive(layout, FALSE); block = uiLayoutAbsoluteBlock(layout); uiDefBut(block, LABEL, 0, "Track is locked", 0, 0, 300, 19, NULL, 0, 0, 0, 0, ""); @@ -434,7 +434,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P uiDefButBitI(block, OPTIONN, MARKER_DISABLED, B_MARKER_FLAG, "Enabled", 10, 190, 145, 19, &cb->marker_flag, 0, 0, 0, 0, tip); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(col, (cb->marker_flag & MARKER_DISABLED) == 0); block = uiLayoutAbsoluteBlock(col); diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 361a3a7d906..83d895067cc 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -146,7 +146,7 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; /* frame range */ @@ -256,7 +256,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); View2D *v2d = &ar->v2d; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking; MovieTrackingDopesheet *dopesheet; MovieTrackingDopesheetChannel *channel; diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index 716994f7487..6d1610f3f91 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -91,7 +91,7 @@ static int dopesheet_select_channel_poll(bContext *C) static int dopesheet_select_channel_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 8deb83b6f0d..37da40e11b3 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -226,7 +226,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; char str[256] = {0}; int block = FALSE; @@ -255,7 +255,7 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, int width, int height, float zoomx, float zoomy) { int x, y; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); /* find window pixel coordinates of origin */ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); @@ -344,7 +344,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if (count == 0) return; - start_frame = framenr = ED_space_clip_clip_framenr(sc); + start_frame = framenr = ED_space_clip_get_clip_frame_number(sc); marker = BKE_tracking_marker_get(track, framenr); if (marker->framenr != framenr || marker->flag & MARKER_DISABLED) @@ -813,7 +813,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) { int i; float pat_min[2], pat_max[2]; - float dx = 12.0f / width, dy = 12.0f / height; +/* float dx = 12.0f / width, dy = 12.0f / height;*/ /* XXX UNUSED */ float tilt_ctrl[2]; if (!outline) { @@ -837,25 +837,30 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glEnable(GL_LINE_STIPPLE); glLineStipple(3, 0xaaaa); - glBegin(GL_LINE_LOOP); - glVertex2f(pat_min[0] - dx, pat_min[1] - dy); - glVertex2f(pat_max[0] + dx, pat_min[1] - dy); - glVertex2f(pat_max[0] + dx, pat_max[1] + dy); - glVertex2f(pat_min[0] - dx, pat_max[1] + dy); - glEnd(); +#if 0 + /* TODO: disable for now, needs better approach visualizing this */ - glBegin(GL_LINES); - glVertex2f(0.0f, 0.0f); - glVertex2fv(tilt_ctrl); + glBegin(GL_LINE_LOOP); + glVertex2f(pat_min[0] - dx, pat_min[1] - dy); + glVertex2f(pat_max[0] + dx, pat_min[1] - dy); + glVertex2f(pat_max[0] + dx, pat_max[1] + dy); + glVertex2f(pat_min[0] - dx, pat_max[1] + dy); glEnd(); - glDisable(GL_LINE_STIPPLE); - /* marker's offset slider */ draw_marker_slide_square(pat_min[0] - dx, pat_max[1] + dy, patdx, patdy, outline, px); /* pattern re-sizing triangle */ draw_marker_slide_triangle(pat_max[0] + dx, pat_min[1] - dy, patdx, patdy, outline, px); +#endif + + glBegin(GL_LINES); + glVertex2f(0.0f, 0.0f); + glVertex2fv(tilt_ctrl); + glEnd(); + + glDisable(GL_LINE_STIPPLE); + /* slider to control pattern tilt */ draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px); @@ -919,7 +924,7 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra if (marker->flag & MARKER_DISABLED) strcpy(state, "disabled"); - else if (marker->framenr != ED_space_clip_clip_framenr(sc)) + else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc)) strcpy(state, "estimated"); else if (marker->flag & MARKER_TRACKED) strcpy(state, "tracked"); @@ -967,7 +972,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track, *act_track; MovieTrackingMarker *marker; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int undistort = sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT; float *marker_pos = NULL, *fp, *active_pos = NULL, cur_pos[2]; @@ -1313,7 +1318,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); if (track) { - int framenr = sc->user.framenr; + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr); offsx = marker->pos[0]; @@ -1403,19 +1408,23 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); } -void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) +void clip_draw_main(const bContext *C, ARegion *ar) { - MovieClip *clip = ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); + Scene *scene = CTX_data_scene(C); ImBuf *ibuf; int width, height; float zoomx, zoomy; + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + /* if no clip, nothing to do */ - if (!clip) + if (!clip) { + ED_region_grid_draw(ar, zoomx, zoomy); return; - - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); + } if (sc->flag & SC_SHOW_STABLE) { float smat[4][4], ismat[4][4]; @@ -1471,7 +1480,7 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) void clip_draw_grease_pencil(bContext *C, int onlyv2d) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (!clip) return; @@ -1487,12 +1496,10 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); if (track) { - int framenr = sc->user.framenr; - /* don't get the exact marker since it may not exist for the frame */ + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); - if (marker) { - glTranslatef(marker->pos[0], marker->pos[1], 0.0f); - } + + glTranslatef(marker->pos[0], marker->pos[1], 0.0f); } } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 0bad9f86ea1..b57b16707d4 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -91,7 +91,7 @@ int ED_space_clip_tracking_poll(bContext *C) SpaceClip *sc = CTX_wm_space_clip(C); if (sc && sc->clip) - return ED_space_clip_show_trackedit(sc); + return ED_space_clip_check_show_trackedit(sc); return FALSE; } @@ -101,7 +101,7 @@ int ED_space_clip_maskedit_poll(bContext *C) SpaceClip *sc = CTX_wm_space_clip(C); if (sc && sc->clip) { - return ED_space_clip_show_maskedit(sc); + return ED_space_clip_check_show_maskedit(sc); } return FALSE; @@ -122,90 +122,12 @@ int ED_space_clip_maskedit_mask_poll(bContext *C) return FALSE; } -/* ******** editing functions ******** */ +/* ******** common editing functions ******** */ -void ED_space_clip_set(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip) +void ED_space_clip_get_size(const bContext *C, int *width, int *height) { - MovieClip *old_clip; - - if (!screen && C) - screen = CTX_wm_screen(C); - - old_clip = sc->clip; - sc->clip = clip; - - if (sc->clip && sc->clip->id.us == 0) - sc->clip->id.us = 1; - - if (screen && sc->view == SC_VIEW_CLIP) { - ScrArea *area; - SpaceLink *sl; - - for (area = screen->areabase.first; area; area = area->next) { - for (sl = area->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_CLIP) { - SpaceClip *cur_sc = (SpaceClip *) sl; - - if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) { - if (cur_sc->clip == old_clip || cur_sc->clip == NULL) { - cur_sc->clip = clip; - } - } - } - } - } - } - - if (C) - WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); -} - -MovieClip *ED_space_clip(SpaceClip *sc) -{ - return sc->clip; -} - -Mask *ED_space_clip_mask(SpaceClip *sc) -{ - return sc->mask; -} - -ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) -{ - if (sc->clip) { - ImBuf *ibuf; - - ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); - - if (ibuf && (ibuf->rect || ibuf->rect_float)) - return ibuf; - - if (ibuf) - IMB_freeImBuf(ibuf); - } - - return NULL; -} - -ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) -{ - if (sc->clip) { - ImBuf *ibuf; - - ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); - - if (ibuf && (ibuf->rect || ibuf->rect_float)) - return ibuf; - - if (ibuf) - IMB_freeImBuf(ibuf); - } - - return NULL; -} + SpaceClip *sc = CTX_wm_space_clip(C); -void ED_space_clip_size(SpaceClip *sc, int *width, int *height) -{ if (!sc->clip) { *width = *height = 0; } @@ -214,40 +136,25 @@ void ED_space_clip_size(SpaceClip *sc, int *width, int *height) } } -void ED_space_clip_mask_size(SpaceClip *sc, int *width, int *height) +void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy) { - /* quite the same as ED_space_clip_size, but it also runs aspect correction on output resolution - * this is needed because mask should be rasterized with exactly the same resolution as - * currently displaying frame and it doesn't have access to aspect correction currently - * used for display. (sergey) - */ - - if (!sc->mask) { - *width = 0; - *height = 0; - } else { - float aspx, aspy; + ARegion *ar = CTX_wm_region(C); + int width, height; - ED_space_clip_size(sc, width, height); - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &width, &height); - *width *= aspx; - *height *= aspy; - } + *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); + *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); } -void ED_space_clip_mask_aspect(SpaceClip *sc, float *aspx, float *aspy) +void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy) { - int w, h; - - ED_space_clip_aspect(sc, aspx, aspy); - ED_space_clip_size(sc, &w, &h); + MovieClip *clip = ED_space_clip_get_clip(sc); - /* now this is not accounted for! */ -#if 0 - *aspx *= (float)w; - *aspy *= (float)h; -#endif + if (clip) + BKE_movieclip_aspect(clip, aspx, aspy); + else + *aspx = *aspy = 1.0f; if (*aspx < *aspy) { *aspy = *aspy / *aspx; @@ -259,27 +166,7 @@ void ED_space_clip_mask_aspect(SpaceClip *sc, float *aspx, float *aspy) } } -void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) -{ - int width, height; - - ED_space_clip_size(sc, &width, &height); - - *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); -} - -void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) -{ - MovieClip *clip = ED_space_clip(sc); - - if (clip) - BKE_movieclip_aspect(clip, aspx, aspy); - else - *aspx = *aspy = 1.0f; -} - -void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy) +void ED_space_clip_get_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy) { int w, h; @@ -290,11 +177,11 @@ void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *asp * mainly this is sued for transformation stuff */ - ED_space_clip_aspect(sc, aspx, aspy); - ED_space_clip_size(sc, &w, &h); + ED_space_clip_get_aspect(sc, aspx, aspy); + BKE_movieclip_get_size(sc->clip, &sc->user, &w, &h); - *aspx *= (float)w; - *aspy *= (float)h; + *aspx *= (float) w; + *aspy *= (float) h; if (*aspx < *aspy) { *aspy = *aspy / *aspx; @@ -306,6 +193,48 @@ void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *asp } } +/* return current frame number in clip space */ +int ED_space_clip_get_clip_frame_number(SpaceClip *sc) +{ + MovieClip *clip = ED_space_clip_get_clip(sc); + + return BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr); +} + +ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) +{ + if (sc->clip) { + ImBuf *ibuf; + + ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); + + if (ibuf && (ibuf->rect || ibuf->rect_float)) + return ibuf; + + if (ibuf) + IMB_freeImBuf(ibuf); + } + + return NULL; +} + +ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) +{ + if (sc->clip) { + ImBuf *ibuf; + + ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); + + if (ibuf && (ibuf->rect || ibuf->rect_float)) + return ibuf; + + if (ibuf) + IMB_freeImBuf(ibuf); + } + + return NULL; +} + void ED_clip_update_frame(const Main *mainp, int cfra) { wmWindowManager *wm; @@ -329,29 +258,23 @@ void ED_clip_update_frame(const Main *mainp, int cfra) } } -/* return current frame number in clip space */ -int ED_space_clip_clip_framenr(SpaceClip *sc) +static int selected_boundbox(const bContext *C, float min[2], float max[2]) { - MovieClip *clip = ED_space_clip(sc); - - return BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr); -} - -static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) -{ - MovieClip *clip = ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height, ok = FALSE; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); + int framenr = ED_space_clip_get_clip_frame_number(sc); INIT_MINMAX2(min, max); - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, sc->user.framenr); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (marker) { float pos[3]; @@ -383,22 +306,23 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) return ok; } -int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) +int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) { + SpaceClip *sc = CTX_wm_space_clip(C); int w, h, frame_width, frame_height; float min[2], max[2]; - ED_space_clip_size(sc, &frame_width, &frame_height); + ED_space_clip_get_size(C, &frame_width, &frame_height); if (frame_width == 0 || frame_height == 0) return FALSE; - if (!selected_boundbox(sc, min, max)) + if (!selected_boundbox(C, min, max)) return FALSE; /* center view */ - clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), - (max[1] + min[1]) / (2 * frame_height)); + clip_view_center_to_point(C, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -408,7 +332,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) int width, height; float zoomx, zoomy, newzoom, aspx, aspy; - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); width = ar->winrct.xmax - ar->winrct.xmin + 1; height = ar->winrct.ymax - ar->winrct.ymin + 1; @@ -430,11 +354,11 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[ copy_v2_v2(r_co, co); if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); float aspy = 1.0f / clip->tracking.camera.pixel_aspect; int width, height; - ED_space_clip_size(sc, &width, &height); + BKE_movieclip_get_size(sc->clip, &sc->user, &width, &height); r_co[0] *= width; r_co[1] *= height * aspy; @@ -446,15 +370,15 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[ } } -void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *yr) +void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, float *yr) { ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); int sx, sy, width, height; float zoomx, zoomy, pos[3], imat[4][4]; - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); @@ -469,7 +393,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y *yr = pos[1] / height; if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; float aspy = 1.0f / tracking->camera.pixel_aspect; float tmp[2] = {*xr * width, *yr * height * aspy}; @@ -485,16 +409,18 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y * \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords. * better name here? view_to_track / track_to_view or so? */ -void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float co[2], float r_co[2]) +void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], float r_co[2]) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float zoomx, zoomy; float pos[3]; int width, height; int sx, sy; UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); ED_clip_point_undistorted_pos(sc, co, pos); pos[2] = 0.0f; @@ -506,11 +432,92 @@ void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float c r_co[1] = (pos[1] * height * zoomy) + (float)sy; } -void ED_clip_mouse_pos(bContext *C, wmEvent *event, float co[2]) +void ED_clip_mouse_pos(const bContext *C, wmEvent *event, float co[2]) { ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]); } +int ED_space_clip_check_show_trackedit(SpaceClip *sc) +{ + if (sc) { + return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION); + } + + return FALSE; +} + +int ED_space_clip_check_show_maskedit(SpaceClip *sc) +{ + if (sc) { + return sc->mode == SC_MODE_MASKEDIT; + } + + return FALSE; +} + +/* ******** clip editing functions ******** */ + +MovieClip *ED_space_clip_get_clip(SpaceClip *sc) +{ + return sc->clip; +} + +void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip) +{ + MovieClip *old_clip; + + if (!screen && C) + screen = CTX_wm_screen(C); + + old_clip = sc->clip; + sc->clip = clip; + + if (sc->clip && sc->clip->id.us == 0) + sc->clip->id.us = 1; + + if (screen && sc->view == SC_VIEW_CLIP) { + ScrArea *area; + SpaceLink *sl; + + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_CLIP) { + SpaceClip *cur_sc = (SpaceClip *) sl; + + if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) { + if (cur_sc->clip == old_clip || cur_sc->clip == NULL) { + cur_sc->clip = clip; + } + } + } + } + } + } + + if (C) + WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); +} + +/* ******** masking editing functions ******** */ + +Mask *ED_space_clip_get_mask(SpaceClip *sc) +{ + return sc->mask; +} + +void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask) +{ + sc->mask = mask; + + if (sc->mask && sc->mask->id.us == 0) { + sc->clip->id.us = 1; + } + + if (C) { + WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask); + } +} + /* OpenGL draw context */ typedef struct SpaceClipDrawContext { @@ -552,7 +559,7 @@ int ED_space_clip_texture_buffer_supported(SpaceClip *sc) int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) { SpaceClipDrawContext *context = sc->draw_context; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int need_rebind = 0; context->last_texture = glaGetOneInteger(GL_TEXTURE_2D); @@ -654,36 +661,3 @@ void ED_space_clip_free_texture_buffer(SpaceClip *sc) MEM_freeN(context); } } - -/* ******** masking editing related functions ******** */ - -int ED_space_clip_show_trackedit(SpaceClip *sc) -{ - if (sc) { - return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION); - } - - return FALSE; -} - -int ED_space_clip_show_maskedit(SpaceClip *sc) -{ - if (sc) { - return sc->mode == SC_MODE_MASKEDIT; - } - - return FALSE; -} - -void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask) -{ - sc->mask = mask; - - if (sc->mask && sc->mask->id.us == 0) { - sc->clip->id.us = 1; - } - - if (C) { - WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask); - } -} diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 323594ea469..91501971d9d 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -147,7 +147,7 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track, static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); int width, height; @@ -181,7 +181,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) static void draw_frame_curves(SpaceClip *sc) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); int i, lines = 0, prevfra = 0; @@ -214,7 +214,7 @@ static void draw_frame_curves(SpaceClip *sc) void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; View2DGrid *grid; short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES; diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index b7687eba717..abf7f416b9c 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -166,7 +166,7 @@ static void mouse_select_init_data(MouseSelectUserData *userdata, float *co) static int mouse_select_knot(bContext *C, float co[2], int extend) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; MovieTracking *tracking = &clip->tracking; @@ -211,7 +211,7 @@ static int mouse_select_knot(bContext *C, float co[2], int extend) static int mouse_select_curve(bContext *C, float co[2], int extend) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); MouseSelectUserData userdata; @@ -345,7 +345,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); BorderSelectuserData userdata; @@ -400,7 +400,7 @@ void CLIP_OT_graph_select_border(wmOperatorType *ot) static int graph_select_all_markers_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); MovieTrackingMarker *marker; @@ -466,7 +466,7 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot) static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); @@ -498,7 +498,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot) static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); @@ -648,7 +648,7 @@ void CLIP_OT_graph_center_current_frame(wmOperatorType *ot) static int graph_disable_markers_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); MovieTrackingMarker *marker; diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 5bc195a1ae2..c61a0baa82e 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -69,7 +69,7 @@ void clip_draw_dopesheet_channels(const struct bContext *C, struct ARegion *ar); void CLIP_OT_dopesheet_select_channel(struct wmOperatorType *ot); /* clip_draw.c */ -void clip_draw_main(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); +void clip_draw_main(const struct bContext *C, struct ARegion *ar); void clip_draw_grease_pencil(struct bContext *C, int onlyv2d); void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y); @@ -125,7 +125,7 @@ void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int in void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track); void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker); -void clip_view_center_to_point(struct SpaceClip *sc, float x, float y); +void clip_view_center_to_point(const struct bContext *C, float x, float y); void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index d5ec65e68c7..e76edcf0290 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -69,8 +69,10 @@ /******************** view navigation utilities *********************/ -static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float location[2]) +static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float oldzoom = sc->zoom; int width, height; @@ -78,7 +80,7 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio if (sc->zoom < 0.1f || sc->zoom > 4.0f) { /* check zoom limits */ - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); width *= sc->zoom; height *= sc->zoom; @@ -92,22 +94,22 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio } if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; } } -static void sclip_zoom_set_factor(SpaceClip *sc, ARegion *ar, float zoomfac, float location[2]) +static void sclip_zoom_set_factor(const bContext *C, float zoomfac, float location[2]) { - sclip_zoom_set(sc, ar, sc->zoom*zoomfac, location); + SpaceClip *sc = CTX_wm_space_clip(C); + + sclip_zoom_set(C, sc->zoom * zoomfac, location); } static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2], *mpos = NULL; if (event) { @@ -115,7 +117,7 @@ static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor mpos = location; } - sclip_zoom_set_factor(sc, ar, factor, mpos); + sclip_zoom_set_factor(C, factor, mpos); ED_region_tag_redraw(CTX_wm_region(C)); } @@ -208,7 +210,7 @@ static int open_exec(bContext *C, wmOperator *op) RNA_property_update(C, &pprop->ptr, pprop->prop); } else if (sc) { - ED_space_clip_set(C, screen, sc, clip); + ED_space_clip_set_clip(C, screen, sc, clip); } WM_event_add_notifier(C, NC_MOVIECLIP | NA_ADDED, clip); @@ -225,7 +227,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) MovieClip *clip = NULL; if (sc) - clip = ED_space_clip(sc); + clip = ED_space_clip_get_clip(sc); if (clip) { strncpy(path, clip->name, sizeof(path)); @@ -494,10 +496,7 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel) static int view_zoom_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); - - sclip_zoom_set_factor(sc, ar, RNA_float_get(op->ptr, "factor"), NULL); + sclip_zoom_set_factor(C, RNA_float_get(op->ptr, "factor"), NULL); ED_region_tag_redraw(CTX_wm_region(C)); @@ -525,8 +524,6 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); ViewZoomData *vpd = op->customdata; float factor; @@ -534,7 +531,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) case MOUSEMOVE: factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f; RNA_float_set(op->ptr, "factor", factor); - sclip_zoom_set(sc, ar, vpd->zoom * factor, vpd->location); + sclip_zoom_set(C, vpd->zoom * factor, vpd->location); ED_region_tag_redraw(CTX_wm_region(C)); break; default: @@ -582,13 +579,11 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) static int view_zoom_in_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); - sclip_zoom_set_factor(sc, ar, 1.25f, location); + sclip_zoom_set_factor(C, 1.25f, location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -624,13 +619,11 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) static int view_zoom_out_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); - sclip_zoom_set_factor(sc, ar, 0.8f, location); + sclip_zoom_set_factor(C, 0.8f, location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -669,9 +662,8 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) static int view_zoom_ratio_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); - sclip_zoom_set(sc, ar, RNA_float_get(op->ptr, "ratio"), NULL); + sclip_zoom_set(C, RNA_float_get(op->ptr, "ratio"), NULL); /* ensure pixel exact locations for draw */ sc->xof = (int) sc->xof; @@ -713,8 +705,8 @@ static int view_all_exec(bContext *C, wmOperator *op) sc = CTX_wm_space_clip(C); ar = CTX_wm_region(C); - ED_space_clip_size(sc, &w, &h); - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &w, &h); + ED_space_clip_get_aspect(sc, &aspx, &aspy); w = w * aspx; h = h * aspy; @@ -729,7 +721,7 @@ static int view_all_exec(bContext *C, wmOperator *op) zoomx = (float) width / (w + 2 * margin); zoomy = (float) height / (h + 2 * margin); - sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL); + sclip_zoom_set(C, MIN2(zoomx, zoomy), NULL); } else { if ((w >= width || h >= height) && (width > 0 && height > 0)) { @@ -737,10 +729,10 @@ static int view_all_exec(bContext *C, wmOperator *op) zoomy = (float) height / h; /* find the zoom value that will fit the image in the image space */ - sclip_zoom_set(sc, ar, 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)), NULL); + sclip_zoom_set(C, 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)), NULL); } else - sclip_zoom_set(sc, ar, 1.0f, NULL); + sclip_zoom_set(C, 1.0f, NULL); } sc->xof = sc->yof = 0.0f; @@ -775,7 +767,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op)) sc->xlockof = 0.0f; sc->ylockof = 0.0f; - ED_clip_view_selection(sc, ar, 1); + ED_clip_view_selection(C, ar, 1); ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; @@ -1031,7 +1023,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if ((clip->flag & MCLIP_USE_PROXY) == 0) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 3f8fd5966ec..d9c9f63e4a3 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -69,7 +69,7 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord), void (*segment_end)(void *userdata)) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int width, height, coord; BKE_movieclip_get_size(clip, &sc->user, &width, &height); @@ -128,7 +128,7 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, int selected_only, int in void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord), void (*segment_end)(void *userdata)) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -147,7 +147,7 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, int selected_only, int in void clip_graph_tracking_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata, void (*func)(void *userdata, MovieTrackingMarker *marker)) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -223,13 +223,14 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, } } -void clip_view_center_to_point(SpaceClip *sc, float x, float y) +void clip_view_center_to_point(const bContext *C, float x, float y) { + SpaceClip *sc = CTX_wm_space_clip(C); int width, height; float aspx, aspy; - ED_space_clip_size(sc, &width, &height); - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_aspect(sc, &aspx, &aspy); sc->xof = (x - 0.5f) * width * aspx; sc->yof = (y - 0.5f) * height * aspy; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 174b7fcb373..0a6a4af6960 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -227,7 +227,7 @@ static void clip_scopes_check_gpencil_change(ScrArea *sa) static void clip_stabilization_tag_refresh(ScrArea *sa) { SpaceClip *sc = (SpaceClip *) sa->spacedata.first; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (clip) { MovieTrackingStabilization *stab = &clip->tracking.stabilization; @@ -1008,13 +1008,14 @@ static void clip_refresh(const bContext *C, ScrArea *sa) /********************* main region ********************/ /* sets up the fields of the View2D from zoom and offset */ -static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) +static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) { - MovieClip *clip = ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); float x1, y1, w, h; int width, height, winx, winy; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); w = width; h = height; @@ -1074,12 +1075,55 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } +static void clip_main_area_draw_mask(const bContext *C, ARegion *ar) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + int x, y; + int width, height; + float zoomx, zoomy; + + /* frame image */ + float maxdim; + float xofs, yofs; + + /* find window pixel coordinates of origin */ + UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); + + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + + /* frame the image */ + maxdim = maxf(width, height); + if (width == height) { + xofs = yofs = 0; + } + else if (width < height) { + xofs = ((height - width) / -2.0f) * zoomx; + yofs = 0.0f; + } + else { /* (width > height) */ + xofs = 0.0f; + yofs = ((width - height) / -2.0f) * zoomy; + } + + /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ + glPushMatrix(); + glTranslatef(x + xofs, y + yofs, 0); + glScalef(maxdim * zoomx, maxdim * zoomy, 0); + glMultMatrixf(sc->stabmat); + + ED_mask_draw(C, sc->mask_draw_flag, sc->mask_draw_type); + + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + + glPopMatrix(); +} + static void clip_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ SpaceClip *sc = CTX_wm_space_clip(C); - Scene *scene = CTX_data_scene(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); /* if tracking is in progress, we should synchronize framenr from clipuser * so latest tracked frame would be shown */ @@ -1093,7 +1137,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) tmpibuf = ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL); } - if (ED_clip_view_selection(sc, ar, 0)) { + if (ED_clip_view_selection(C, ar, 0)) { sc->xof += sc->xlockof; sc->yof += sc->ylockof; } @@ -1107,51 +1151,12 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); /* data... */ - movieclip_main_area_set_view2d(sc, ar); + movieclip_main_area_set_view2d(C, ar); - clip_draw_main(sc, ar, scene); + clip_draw_main(C, ar); if (sc->mode == SC_MODE_MASKEDIT) { - int x, y; - int width, height; - float zoomx, zoomy, aspx, aspy; - - /* frame image */ - float maxdim; - float xofs, yofs; - - /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_aspect(sc, &aspx, &aspy); - - /* frame the image */ - maxdim = maxf(width, height); - if (width == height) { - xofs = yofs = 0; - } - else if (width < height) { - xofs = ((height - width) / -2.0f) * zoomx; - yofs = 0.0f; - } - else { /* (width > height) */ - xofs = 0.0f; - yofs = ((width - height) / -2.0f) * zoomy; - } - - /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ - glPushMatrix(); - glTranslatef(x + xofs, y + yofs, 0); - glScalef(maxdim * zoomx, maxdim * zoomy, 0); - glMultMatrixf(sc->stabmat); - - ED_mask_draw((bContext *)C, sc->mask_draw_flag, sc->mask_draw_type); - - ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - - glPopMatrix(); + clip_main_area_draw_mask(C, ar); } /* Grease Pencil */ @@ -1226,7 +1231,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; @@ -1289,7 +1294,7 @@ static void clip_channels_area_init(wmWindowManager *wm, ARegion *ar) static void clip_channels_area_draw(const bContext *C, ARegion *ar) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; View2DScrollers *scrollers; diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 8ca483c94d3..af2847492ad 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -81,16 +81,17 @@ /********************** add marker operator *********************/ -static void add_marker(SpaceClip *sc, float x, float y) +static void add_marker(const bContext *C, float x, float y) { - MovieClip *clip = ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; int width, height; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height); @@ -102,18 +103,18 @@ static void add_marker(SpaceClip *sc, float x, float y) static int add_marker_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); float pos[2]; int width, height; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (!width || !height) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", pos); - add_marker(sc, pos[0], pos[1]); + add_marker(C, pos[0], pos[1]); /* reset offset from locked position, so frame jumping wouldn't be so confusing */ sc->xlockof = 0; @@ -160,7 +161,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot) static int delete_track_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track = tracksbase->first, *next; @@ -201,10 +202,10 @@ void CLIP_OT_delete_track(wmOperatorType *ot) static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track = tracksbase->first, *next; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int has_selection = 0; while (track) { @@ -283,7 +284,7 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra int area, int corner, int action, int width, int height) { SlideMarkerData *data = MEM_callocN(sizeof(SlideMarkerData), "slide marker data"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); marker = BKE_tracking_marker_ensure(track, framenr); @@ -524,15 +525,15 @@ static void show_cursor(bContext *C) MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int *area_r, int *action_r, int *corner_r) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height; float co[2]; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int action = -1, area = 0, corner = -1; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (width == 0 || height == 0) return NULL; @@ -575,6 +576,9 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int ok = TRUE; } else { +#if 0 + /* TODO: disable for now, needs better approaches for visualization */ + if (mouse_on_corner(sc, marker, TRACK_AREA_PAT, co, 1, 12.0f, width, height)) { area = TRACK_AREA_PAT; action = SLIDE_ACTION_OFFSET; @@ -585,6 +589,7 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int action = SLIDE_ACTION_SIZE; ok = TRUE; } +#endif if (!ok && mouse_on_tilt(sc, marker, co, width, height)) { area = TRACK_AREA_PAT; action = SLIDE_ACTION_TILT_SIZE; @@ -621,10 +626,10 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) int width, height; float co[2]; void *customdata = NULL; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int area, action, corner; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (width == 0 || height == 0) return NULL; @@ -647,7 +652,7 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) if (slidedata) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; tracking->act_track = slidedata->track; @@ -946,7 +951,7 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip) int tot = 0; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); track = tracksbase->first; while (track) { @@ -990,7 +995,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit { ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int frames_limit = 0; clear_invisible_track_selection(sc, clip); @@ -1033,14 +1038,14 @@ static int track_markers_check_direction(int backwards, int curfra, int efra) static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backwards) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); MovieTrackingSettings *settings = &clip->tracking.settings; int frames_limit; track_init_markers(sc, clip, &frames_limit); - tmj->sfra = ED_space_clip_clip_framenr(sc); + tmj->sfra = ED_space_clip_get_clip_frame_number(sc); tmj->clip = clip; tmj->backwards = backwards; @@ -1157,10 +1162,10 @@ static void track_markers_freejob(void *tmv) static int track_markers_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); struct MovieTrackingContext *context; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int sfra = framenr, efra; int backwards = RNA_boolean_get(op->ptr, "backwards"); int sequence = RNA_boolean_get(op->ptr, "sequence"); @@ -1220,7 +1225,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve TrackMarkersJob *tmj; ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); wmJob *steve; int backwards = RNA_boolean_get(op->ptr, "backwards"); int sequence = RNA_boolean_get(op->ptr, "sequence"); @@ -1326,7 +1331,7 @@ typedef struct { static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op, char *error_msg, int max_error) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); MovieTracking *tracking = &clip->tracking; MovieTrackingSettings *settings = &clip->tracking.settings; @@ -1450,7 +1455,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even SolveCameraJob *scj; ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); wmJob *steve; @@ -1532,7 +1537,7 @@ void CLIP_OT_solve_camera(wmOperatorType *ot) static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); @@ -1580,12 +1585,12 @@ void CLIP_OT_clear_solution(wmOperatorType *ot) static int clear_track_path_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); int action = RNA_enum_get(op->ptr, "action"); int clear_active = RNA_boolean_get(op->ptr, "clear_active"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); if (clear_active) { track = BKE_tracking_track_get_active(&clip->tracking); @@ -1637,12 +1642,12 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot) static int disable_markers_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track = tracksbase->first; int action = RNA_enum_get(op->ptr, "action"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); while (track) { if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { @@ -1719,7 +1724,7 @@ static Object *get_orientation_object(bContext *C) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); Object *object = NULL; @@ -1743,7 +1748,7 @@ static int set_orientation_poll(bContext *C) if (sc) { Scene *scene = CTX_data_scene(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (clip) { MovieTracking *tracking = &clip->tracking; @@ -1764,7 +1769,7 @@ static int set_orientation_poll(bContext *C) static int count_selected_bundles(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; int tot = 0; @@ -1835,7 +1840,7 @@ static Object *object_solver_camera(Scene *scene, Object *ob) static int set_origin_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; MovieTrackingObject *tracking_object; @@ -2031,7 +2036,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb static int set_plane_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; @@ -2169,7 +2174,7 @@ void CLIP_OT_set_plane(wmOperatorType *ot) static int set_axis_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); MovieTrackingTrack *track; @@ -2241,7 +2246,7 @@ void CLIP_OT_set_axis(wmOperatorType *ot) static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); MovieTrackingTrack *track; @@ -2322,7 +2327,7 @@ static int set_scale_exec(bContext *C, wmOperator *op) static int set_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.dist); @@ -2357,7 +2362,7 @@ static int set_solution_scale_poll(bContext *C) SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (clip) { MovieTracking *tracking = &clip->tracking; @@ -2378,7 +2383,7 @@ static int set_solution_scale_exec(bContext *C, wmOperator *op) static int set_solution_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.object_distance); @@ -2411,7 +2416,7 @@ void CLIP_OT_set_solution_scale(wmOperatorType *ot) static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int width, height; BKE_movieclip_get_size(clip, &sc->user, &width, &height); @@ -2447,7 +2452,7 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot) static int hide_tracks_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); @@ -2506,7 +2511,7 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot) static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -2563,7 +2568,7 @@ static bGPDlayer *detect_get_layer(MovieClip *clip) static int detect_features_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int clip_flag = clip->flag & MCLIP_TIMECODE_FLAGS; ImBuf *ibuf = BKE_movieclip_get_ibuf_flag(clip, &sc->user, clip_flag, MOVIECLIP_CACHE_SKIP); MovieTracking *tracking = &clip->tracking; @@ -2574,7 +2579,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) int min_trackability = RNA_int_get(op->ptr, "min_trackability"); int min_distance = RNA_int_get(op->ptr, "min_distance"); int place_outside_layer = 0; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); bGPDlayer *layer = NULL; if (!ibuf) { @@ -2640,7 +2645,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int pos = RNA_enum_get(op->ptr, "position"); int delta; @@ -2665,7 +2670,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) } else { /* to to failed frame */ if (clip->tracking.reconstruction.flag & TRACKING_RECONSTRUCTED) { - int a = ED_space_clip_clip_framenr(sc); + int a = ED_space_clip_get_clip_frame_number(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); @@ -2732,7 +2737,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) static int join_tracks_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *act_track, *track, *next; @@ -2786,7 +2791,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot) static int lock_tracks_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track = tracksbase->first; @@ -2839,7 +2844,7 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot) static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track, *act_track = BKE_tracking_track_get_active(tracking); @@ -2886,7 +2891,7 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot) static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -2935,7 +2940,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot) static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingStabilization *stab = &tracking->stabilization; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); @@ -2995,7 +3000,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot) static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -3038,7 +3043,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); @@ -3168,7 +3173,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) static int clean_tracks_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track, *next, *act_track = BKE_tracking_track_get_active(tracking); @@ -3224,7 +3229,7 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "frames")) RNA_int_set(op->ptr, "frames", clip->tracking.settings.clean_frames); @@ -3273,7 +3278,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; BKE_tracking_object_add(tracking, "Object"); @@ -3303,7 +3308,7 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot) static int tracking_object_remove_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object; @@ -3341,7 +3346,7 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot) static int copy_tracks_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); @@ -3381,7 +3386,7 @@ static int paste_tracks_poll(bContext *C) static int paste_tracks_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 640af498c1f..0ebb84b3953 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -110,15 +110,16 @@ static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx return dist < MAX2(epsx, epsy); } -static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track) +static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *track) { - int framenr = ED_space_clip_clip_framenr(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); float pat_min[2], pat_max[2]; float epsx, epsy; int width, height; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); @@ -187,7 +188,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas { MovieTrackingTrack *track = NULL, *cur; float mindist = 0.0f; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); cur = tracksbase->first; while (cur) { @@ -226,7 +227,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas static int mouse_select(bContext *C, float co[2], int extend) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); @@ -235,7 +236,7 @@ static int mouse_select(bContext *C, float co[2], int extend) track = find_nearest_track(sc, tracksbase, co); if (track) { - int area = track_mouse_area(sc, co, track); + int area = track_mouse_area(C, co, track); if (!extend || !TRACK_VIEW_SELECTED(sc, track)) area = TRACK_AREA_ALL; @@ -288,7 +289,7 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) if (track) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); clip->tracking.act_track = track; @@ -332,14 +333,14 @@ void CLIP_OT_select(wmOperatorType *ot) static int border_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); rcti rect; rctf rectf; int change = FALSE, mode, extend; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); /* get rectangle from operator */ rect.xmin = RNA_int_get(op->ptr, "xmin"); @@ -412,15 +413,14 @@ void CLIP_OT_select_border(wmOperatorType *ot) static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select) { - ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); rcti rect; int change = FALSE; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); /* get rectangle from operator */ BLI_lasso_boundbox(&rect, mcords, moves); @@ -435,7 +435,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho float screen_co[2]; /* marker in screen coords */ - ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co); + ED_clip_point_stable_pos__reverse(C, marker->pos, screen_co); if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) @@ -519,14 +519,13 @@ static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], f static int circle_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); - ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); int x, y, radius, width, height, mode, change = FALSE; float zoomx, zoomy, offset[2], ellipse[2]; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); /* get operator properties */ x = RNA_int_get(op->ptr, "x"); @@ -536,8 +535,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) mode = RNA_int_get(op->ptr, "gesture_mode"); /* compute ellipse and position in unified coordinates */ - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; @@ -602,13 +601,13 @@ void CLIP_OT_select_circle(wmOperatorType *ot) static int select_all_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track = NULL; /* selected track */ MovieTrackingMarker *marker; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); int action = RNA_enum_get(op->ptr, "action"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int has_selection = FALSE; if (action == SEL_TOGGLE) { @@ -692,13 +691,13 @@ void CLIP_OT_select_all(wmOperatorType *ot) static int select_groped_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; MovieTrackingMarker *marker; MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); int group = RNA_enum_get(op->ptr, "group"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); track = tracksbase->first; while (track) { diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 10db1bb1f12..55e75992b89 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -71,7 +71,7 @@ #include "fsmenu.h" #include "filelist.h" -#include "file_intern.h" // own include +#include "file_intern.h" // own include /* button events */ enum { @@ -109,8 +109,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) { /* Button layout. */ const int max_x = ar->winx - 10; - const int line1_y = ar->winy - (IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN); - const int line2_y = line1_y - (IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN); + const int line1_y = ar->winy - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN); + const int line2_y = line1_y - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN); const int input_minw = 20; const int btn_h = UI_UNIT_Y; const int btn_fn_w = UI_UNIT_X; @@ -123,16 +123,16 @@ void file_draw_buttons(const bContext *C, ARegion *ar) int loadbutton; int fnumbuttons; int min_x = 10; - int chan_offs = 0; + int chan_offs = 0; int available_w = max_x - min_x; int line1_w = available_w; int line2_w = available_w; - uiBut* but; - uiBlock* block; - SpaceFile* sfile = CTX_wm_space_file(C); - FileSelectParams* params = ED_fileselect_get_params(sfile); - ARegion* artmp; + uiBut *but; + uiBlock *block; + SpaceFile *sfile = CTX_wm_space_file(C); + FileSelectParams *params = ED_fileselect_get_params(sfile); + ARegion *artmp; /* Initialize UI block. */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); @@ -140,7 +140,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiBlockSetHandleFunc(block, do_file_buttons, NULL); /* exception to make space for collapsed region icon */ - for (artmp=CTX_wm_area(C)->regionbase.first; artmp; artmp=artmp->next) { + for (artmp = CTX_wm_area(C)->regionbase.first; artmp; artmp = artmp->next) { if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) { chan_offs = 16; min_x += chan_offs; @@ -152,7 +152,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) loadbutton = UI_GetStringWidth(sfile->params->title) + btn_margin; if (loadbutton < btn_minw) { loadbutton = MAX2(btn_minw, - btn_margin + UI_GetStringWidth(params->title)); + btn_margin + UI_GetStringWidth(params->title)); } if (available_w <= loadbutton + separator + input_minw || params->title[0] == 0) { @@ -174,12 +174,12 @@ void file_draw_buttons(const bContext *C, ARegion *ar) /* Text input fields for directory and file. */ if (available_w > 0) { - int overwrite_alert= file_draw_check_exists(sfile); + int overwrite_alert = file_draw_check_exists(sfile); /* callbacks for operator check functions */ uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL); but = uiDefButTextO(block, TEX, "FILE_OT_directory", 0, "", - min_x, line1_y, line1_w-chan_offs, btn_h, + min_x, line1_y, line1_w - chan_offs, btn_h, params->dir, 0.0, (float)FILE_MAX, 0, 0, TIP_("File path")); uiButSetCompleteFunc(but, autocomplete_directory, NULL); @@ -187,9 +187,9 @@ void file_draw_buttons(const bContext *C, ARegion *ar) if ((params->flag & FILE_DIRSEL_ONLY) == 0) { but = uiDefBut(block, TEX, B_FS_FILENAME, "", - min_x, line2_y, line2_w-chan_offs, btn_h, + min_x, line2_y, line2_w - chan_offs, btn_h, params->file, 0.0, (float)FILE_MAXFILE, 0, 0, - TIP_(overwrite_alert ?N_("File name, overwrite existing") : N_("File name"))); + TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name"))); uiButSetCompleteFunc(but, autocomplete_file, NULL); uiButSetFlag(but, UI_BUT_NO_UTF8); uiButClearFlag(but, UI_BUT_UNDO); /* operator button above does this automatic */ @@ -246,8 +246,8 @@ static void draw_tile(int sx, int sy, int width, int height, int colorid, int sh static int get_file_icon(struct direntry *file) { if (file->type & S_IFDIR) { - if ( strcmp(file->relname, "..") == 0) { - return ICON_FILE_PARENT; + if (strcmp(file->relname, "..") == 0) { + return ICON_FILE_PARENT; } if (file->flags & BLENDERFILE) { return ICON_FILE_BLEND; @@ -283,7 +283,7 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, /*float alpha=1.0f;*/ x = sx; - y = sy-height; + y = sy - height; /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ @@ -292,9 +292,9 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, } -static void file_draw_string(int sx, int sy, const char* string, float width, int height, short align) +static void file_draw_string(int sx, int sy, const char *string, float width, int height, short align) { - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiFontStyle fs = style->widgetlabel; rcti rect; char fname[FILE_MAXFILE]; @@ -306,7 +306,7 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in /* no text clipping needed, uiStyleFontDraw does it but is a bit too strict (for buttons it works) */ rect.xmin = sx; - rect.xmax = (int)(sx + ceil(width+4.0f)); + rect.xmax = (int)(sx + ceil(width + 4.0f)); rect.ymin = sy - height; rect.ymax = sy; @@ -315,12 +315,12 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in void file_calc_previews(const bContext *C, ARegion *ar) { - SpaceFile *sfile= CTX_wm_space_file(C); - View2D *v2d= &ar->v2d; + SpaceFile *sfile = CTX_wm_space_file(C); + View2D *v2d = &ar->v2d; ED_fileselect_init_layout(sfile, ar); /* +SCROLL_HEIGHT is bad hack to work around issue in UI_view2d_totRect_set */ - UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height+V2D_SCROLL_HEIGHT); + UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height + V2D_SCROLL_HEIGHT); } static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, short dropshadow) @@ -337,13 +337,13 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) { if (imb->x > imb->y) { scaledx = (float)layout->prv_w; - scaledy = ( (float)imb->y/(float)imb->x )*layout->prv_w; - scale = scaledx/imb->x; + scaledy = ( (float)imb->y / (float)imb->x) * layout->prv_w; + scale = scaledx / imb->x; } else { scaledy = (float)layout->prv_h; - scaledx = ( (float)imb->x/(float)imb->y )*layout->prv_h; - scale = scaledy/imb->y; + scaledx = ( (float)imb->x / (float)imb->y) * layout->prv_h; + scale = scaledy / imb->y; } } else { @@ -353,8 +353,8 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int } ex = (int)scaledx; ey = (int)scaledy; - fx = ((float)layout->prv_w - (float)ex)/2.0f; - fy = ((float)layout->prv_h - (float)ey)/2.0f; + fx = ((float)layout->prv_w - (float)ex) / 2.0f; + fy = ((float)layout->prv_h - (float)ey) / 2.0f; dx = (fx + 0.5f + layout->prv_border_x); dy = (fy + 0.5f - layout->prv_border_y); xco = sx + (int)dx; @@ -389,17 +389,17 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) { - char newname[FILE_MAX+12]; - char orgname[FILE_MAX+12]; - char filename[FILE_MAX+12]; - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - ARegion* ar = CTX_wm_region(C); + char newname[FILE_MAX + 12]; + char orgname[FILE_MAX + 12]; + char filename[FILE_MAX + 12]; + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); + ARegion *ar = CTX_wm_region(C); BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname); BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename)); BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename); - if ( strcmp(orgname, newname) != 0 ) { + if (strcmp(orgname, newname) != 0) { if (!BLI_exists(newname)) { BLI_rename(orgname, newname); /* to make sure we show what is on disk */ @@ -417,11 +417,11 @@ static void draw_background(FileLayout *layout, View2D *v2d) int sy; /* alternating flat shade background */ - for (i=0; (i <= layout->rows); i+=2) { - sy = (int)v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y; + for (i = 0; (i <= layout->rows); i += 2) { + sy = (int)v2d->cur.ymax - i * (layout->tile_h + 2 * layout->tile_border_y) - layout->tile_border_y; UI_ThemeColorShade(TH_BACK, -7); - glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy+layout->tile_h+2*layout->tile_border_y)); + glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y)); } } @@ -433,10 +433,10 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) /* vertical column dividers */ sx = (int)v2d->tot.xmin; while (sx < v2d->cur.xmax) { - sx += (layout->tile_w+2*layout->tile_border_x); + sx += (layout->tile_w + 2 * layout->tile_border_x); UI_ThemeColorShade(TH_BACK, 30); - sdrawline(sx+1, (short)(v2d->cur.ymax - layout->tile_border_y), sx+1, (short)v2d->cur.ymin); + sdrawline(sx + 1, (short)(v2d->cur.ymax - layout->tile_border_y), sx + 1, (short)v2d->cur.ymin); UI_ThemeColorShade(TH_BACK, -30); sdrawline(sx, (short)(v2d->cur.ymax - layout->tile_border_y), sx, (short)v2d->cur.ymin); } @@ -444,11 +444,11 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) void file_draw_list(const bContext *C, ARegion *ar) { - SpaceFile *sfile= CTX_wm_space_file(C); - FileSelectParams* params = ED_fileselect_get_params(sfile); - FileLayout* layout= ED_fileselect_get_layout(sfile, ar); - View2D *v2d= &ar->v2d; - struct FileList* files = sfile->files; + SpaceFile *sfile = CTX_wm_space_file(C); + FileSelectParams *params = ED_fileselect_get_params(sfile); + FileLayout *layout = ED_fileselect_get_layout(sfile, ar); + View2D *v2d = &ar->v2d; + struct FileList *files = sfile->files; struct direntry *file; ImBuf *imb; uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); @@ -472,7 +472,7 @@ void file_draw_list(const bContext *C, ARegion *ar) } offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax); - if (offset<0) offset=0; + if (offset < 0) offset = 0; numfiles_layout = ED_fileselect_layout_numfiles(layout, ar); @@ -484,14 +484,14 @@ void file_draw_list(const bContext *C, ARegion *ar) numfiles_layout += layout->columns; } - textwidth =( FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME]; - textheight = (int)(layout->textheight*3.0/2.0 + 0.5); + textwidth = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME]; + textheight = (int)(layout->textheight * 3.0 / 2.0 + 0.5); - align = ( FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT; + align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT; - for (i = offset; (i < numfiles) && (i<offset+numfiles_layout); i++) { + for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { ED_fileselect_layout_tilepos(layout, i, &sx, &sy); - sx += (int)(v2d->tot.xmin+2.0f); + sx += (int)(v2d->tot.xmin + 2.0f); sy = (int)(v2d->tot.ymax - sy); file = filelist_file(files, i); @@ -503,12 +503,12 @@ void file_draw_list(const bContext *C, ARegion *ar) if ((params->active_file == i) || (file->selflag & HILITED_FILE) || (file->selflag & SELECTED_FILE)) { int colorid = (file->selflag & SELECTED_FILE) ? TH_HILITE : TH_BACK; int shade = (params->active_file == i) || (file->selflag & HILITED_FILE) ? 20 : 0; - draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid, shade); + draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade); } } uiSetRoundBox(UI_CNR_NONE); - if ( FILE_IMGDISPLAY == params->display ) { + if (FILE_IMGDISPLAY == params->display) { is_icon = 0; imb = filelist_getimage(files, i); if (!imb) { @@ -519,26 +519,26 @@ void file_draw_list(const bContext *C, ARegion *ar) file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE)); } else { - file_draw_icon(block, file->path, sx, sy-(UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE); + file_draw_icon(block, file->path, sx, sy - (UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE); sx += ICON_DEFAULT_WIDTH_SCALE + 4; } UI_ThemeColor4(TH_TEXT); if (file->selflag & EDITING_FILE) { - uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy-layout->tile_h-3, - textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); + uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 3, + textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); uiButSetRenameFunc(but, renamebutton_cb, file); uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */ uiButClearFlag(but, UI_BUT_UNDO); - if ( 0 == uiButActiveOnly(C, block, but)) { + if (0 == uiButActiveOnly(C, block, but)) { file->selflag &= ~EDITING_FILE; } } if (!(file->selflag & EDITING_FILE)) { int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy; - file_draw_string(sx+1, tpos, file->relname, (float)textwidth, textheight, align); + file_draw_string(sx + 1, tpos, file->relname, (float)textwidth, textheight, align); } if (params->display == FILE_SHORTDISPLAY) { diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index d3598ffd4e7..3ad6614d356 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -41,12 +41,12 @@ struct SpaceFile; struct ARegion *file_buttons_region(struct ScrArea *sa); /* file_draw.c */ -#define TILE_BORDER_X (UI_UNIT_X/4) -#define TILE_BORDER_Y (UI_UNIT_Y/4) +#define TILE_BORDER_X (UI_UNIT_X / 4) +#define TILE_BORDER_Y (UI_UNIT_Y / 4) /* ui geometry */ -#define IMASEL_BUTTONS_HEIGHT (UI_UNIT_Y*2) -#define IMASEL_BUTTONS_MARGIN (UI_UNIT_Y/6) +#define IMASEL_BUTTONS_HEIGHT (UI_UNIT_Y * 2) +#define IMASEL_BUTTONS_MARGIN (UI_UNIT_Y / 6) void file_draw_buttons(const bContext *C, ARegion *ar); void file_calc_previews(const bContext *C, ARegion *ar); @@ -98,12 +98,12 @@ void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op); /* filesel.c */ -float file_shorten_string(char* string, float w, int front); -float file_string_width(const char* str); +float file_shorten_string(char *string, float w, int front); +float file_string_width(const char *str); float file_font_pointsize(void); void file_change_dir(bContext *C, int checkdir); -int file_select_match(struct SpaceFile *sfile, const char *pattern); +int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file); void autocomplete_directory(struct bContext *C, char *str, void *arg_v); void autocomplete_file(struct bContext *C, char *str, void *arg_v); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 4bb5a21cb3d..0cf3586e659 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -65,17 +65,17 @@ #include <ctype.h> /* for events */ -#define NOTACTIVEFILE 0 -#define ACTIVATE 1 -#define INACTIVATE 2 +#define NOTACTIVEFILE 0 +#define ACTIVATE 1 +#define INACTIVATE 2 /* ---------- FILE SELECTION ------------ */ -static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion* ar, const rcti* rect) +static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion *ar, const rcti *rect) { FileSelection sel; float fxmin, fymin, fxmax, fymax; - View2D* v2d = &ar->v2d; + View2D *v2d = &ar->v2d; rcti rect_view; UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin, &fxmin, &fymin); @@ -88,11 +88,11 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion* ar, return sel; } -static void file_deselect_all(SpaceFile* sfile, unsigned int flag) +static void file_deselect_all(SpaceFile *sfile, unsigned int flag) { FileSelection sel; sel.first = 0; - sel.last = filelist_numfiles(sfile->files)-1; + sel.last = filelist_numfiles(sfile->files) - 1; filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL); } @@ -103,10 +103,10 @@ typedef enum FileSelect { FILE_SELECT_FILE = 2 } FileSelect; -static void clamp_to_filelist(int numfiles, FileSelection* sel) +static void clamp_to_filelist(int numfiles, FileSelection *sel) { /* border select before the first file */ - if ( (sel->first < 0) && (sel->last >=0 ) ) { + if ( (sel->first < 0) && (sel->last >= 0) ) { sel->first = 0; } /* don't select if everything is outside filelist */ @@ -117,67 +117,67 @@ static void clamp_to_filelist(int numfiles, FileSelection* sel) /* fix if last file invalid */ if ( (sel->first > 0) && (sel->last < 0) ) - sel->last = numfiles-1; + sel->last = numfiles - 1; /* clamp */ if ( (sel->first >= numfiles) ) { - sel->first = numfiles-1; + sel->first = numfiles - 1; } if ( (sel->last >= numfiles) ) { - sel->last = numfiles-1; + sel->last = numfiles - 1; } } -static FileSelection file_selection_get(bContext* C, const rcti* rect, short fill) +static FileSelection file_selection_get(bContext *C, const rcti *rect, short fill) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); int numfiles = filelist_numfiles(sfile->files); FileSelection sel; sel = find_file_mouse_rect(sfile, ar, rect); - if ( !((sel.first == -1) && (sel.last == -1)) ) { + if (!((sel.first == -1) && (sel.last == -1)) ) { clamp_to_filelist(numfiles, &sel); } /* if desired, fill the selection up from the last selected file to the current one */ if (fill && (sel.last >= 0) && (sel.last < numfiles) ) { - int f= sel.last; + int f = sel.last; while (f >= 0) { - if ( filelist_is_selected(sfile->files, f, CHECK_ALL) ) + if (filelist_is_selected(sfile->files, f, CHECK_ALL) ) break; f--; } if (f >= 0) { - sel.first = f+1; + sel.first = f + 1; } } return sel; } -static FileSelect file_select_do(bContext* C, int selected_idx) +static FileSelect file_select_do(bContext *C, int selected_idx) { FileSelect retval = FILE_SELECT_NOTHING; - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); int numfiles = filelist_numfiles(sfile->files); - struct direntry* file; + struct direntry *file; /* make the selected file active */ - if ( (selected_idx >= 0) && - (selected_idx < numfiles) && - (file= filelist_file(sfile->files, selected_idx))) + if ((selected_idx >= 0) && + (selected_idx < numfiles) && + (file = filelist_file(sfile->files, selected_idx))) { params->active_file = selected_idx; if (S_ISDIR(file->type)) { /* the path is too long and we are not going up! */ - if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX ) { + if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) { // XXX error("Path too long, cannot enter this directory"); } else { - if (strcmp(file->relname, "..")==0) { + if (strcmp(file->relname, "..") == 0) { /* avoids /../../ */ BLI_parent_dir(params->dir); } @@ -202,12 +202,12 @@ static FileSelect file_select_do(bContext* C, int selected_idx) } -static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, short fill) +static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, short fill) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelect retval = FILE_SELECT_NOTHING; - FileSelection sel= file_selection_get(C, rect, fill); /* get the selection */ - const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; + FileSelection sel = file_selection_get(C, rect, fill); /* get the selection */ + const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; /* flag the files as selected in the filelist */ filelist_select(sfile->files, &sel, select, SELECTED_FILE, check_type); @@ -231,15 +231,15 @@ static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); FileSelection sel; rcti rect; int result; - result= WM_border_select_modal(C, op, event); + result = WM_border_select_modal(C, op, event); if (result == OPERATOR_RUNNING_MODAL) { @@ -254,7 +254,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) if ( (sel.first != params->sel_first) || (sel.last != params->sel_last) ) { file_deselect_all(sfile, HILITED_FILE); filelist_select(sfile->files, &sel, FILE_SEL_ADD, HILITED_FILE, CHECK_ALL); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } params->sel_first = sel.first; params->sel_last = sel.last; @@ -263,7 +263,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) params->active_file = -1; params->sel_first = params->sel_last = -1; file_deselect_all(sfile, HILITED_FILE); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } return result; @@ -271,11 +271,11 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) static int file_border_select_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); rcti rect; FileSelect ret; - int extend= RNA_boolean_get(op->ptr, "extend"); - short select= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); + int extend = RNA_boolean_get(op->ptr, "extend"); + short select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); @@ -283,7 +283,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); if (!extend) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); file_deselect_all(sfile, SELECTED_FILE); } @@ -292,10 +292,10 @@ static int file_border_select_exec(bContext *C, wmOperator *op) ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, 0); if (FILE_SELECT_DIR == ret) { - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } else if (FILE_SELECT_FILE == ret) { - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } return OPERATOR_FINISHED; } @@ -320,8 +320,8 @@ void FILE_OT_select_border(wmOperatorType *ot) static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelect ret; rcti rect; int extend = RNA_boolean_get(op->ptr, "extend"); @@ -341,12 +341,12 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill); if (FILE_SELECT_DIR == ret) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); else if (FILE_SELECT_FILE == ret) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); WM_event_add_mousemove(C); /* for directory changes */ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); return OPERATOR_FINISHED; } @@ -369,18 +369,18 @@ void FILE_OT_select(wmOperatorType *ot) static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelection sel; int numfiles = filelist_numfiles(sfile->files); int i; int is_selected = 0; sel.first = 0; - sel.last = numfiles-1; + sel.last = numfiles - 1; /* Is any file selected ? */ - for ( i=0; i < numfiles; ++i) { + for (i = 0; i < numfiles; ++i) { if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { is_selected = 1; break; @@ -391,7 +391,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, SELECTED_FILE, CHECK_ALL); } else { - const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; + const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; filelist_select(sfile->files, &sel, FILE_SEL_ADD, SELECTED_FILE, check_type); } ED_area_tag_redraw(sa); @@ -418,18 +418,18 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) static int bookmark_select_exec(bContext *C, wmOperator *op) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (RNA_struct_find_property(op->ptr, "dir")) { char entry[256]; - FileSelectParams* params = sfile->params; + FileSelectParams *params = sfile->params; RNA_string_get(op->ptr, "dir", entry); BLI_strncpy(params->dir, entry, sizeof(params->dir)); BLI_cleanup_dir(G.main->name, params->dir); file_change_dir(C, 1); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } return OPERATOR_FINISHED; @@ -451,10 +451,10 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); - struct FSMenu* fsmenu = fsmenu_get(); - struct FileSelectParams* params= ED_fileselect_get_params(sfile); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = CTX_wm_space_file(C); + struct FSMenu *fsmenu = fsmenu_get(); + struct FileSelectParams *params = ED_fileselect_get_params(sfile); if (params->dir[0] != '\0') { char name[FILE_MAX]; @@ -482,13 +482,13 @@ void FILE_OT_bookmark_add(wmOperatorType *ot) static int bookmark_delete_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); - struct FSMenu* fsmenu = fsmenu_get(); + ScrArea *sa = CTX_wm_area(C); + struct FSMenu *fsmenu = fsmenu_get(); int nentries = fsmenu_get_nentries(fsmenu, FS_CATEGORY_BOOKMARKS); if (RNA_struct_find_property(op->ptr, "index")) { int index = RNA_int_get(op->ptr, "index"); - if ( (index >-1) && (index < nentries)) { + if ( (index > -1) && (index < nentries)) { char name[FILE_MAX]; fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index); @@ -517,16 +517,16 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { - View2D* v2d = &ar->v2d; - FileSelectParams* params; + View2D *v2d = &ar->v2d; + FileSelectParams *params; int numfiles, origfile; - if (sfile==NULL || sfile->files==NULL) return 0; + if (sfile == NULL || sfile->files == NULL) return 0; numfiles = filelist_numfiles(sfile->files); params = ED_fileselect_get_params(sfile); - origfile= params->active_file; + origfile = params->active_file; mx -= ar->winrct.xmin; my -= ar->winrct.ymin; @@ -540,20 +540,20 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) active_file = ED_fileselect_layout_offset(sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy)); if ((active_file >= 0) && (active_file < numfiles)) - params->active_file=active_file; + params->active_file = active_file; else - params->active_file= -1; + params->active_file = -1; } else - params->active_file= -1; + params->active_file = -1; return (params->active_file != origfile); } static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (!file_hilight_set(sfile, ar, event->x, event->y)) return OPERATOR_CANCELLED; @@ -577,7 +577,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot) int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; sfile->op = NULL; @@ -590,9 +590,9 @@ int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_operator_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); - if (!sfile || !sfile->op) poll= 0; + if (!sfile || !sfile->op) poll = 0; return poll; } @@ -634,30 +634,45 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) * they may be already set. */ { PointerRNA itemptr; - PropertyRNA *prop_files= RNA_struct_find_property(op->ptr, "files"); - PropertyRNA *prop_dirs= RNA_struct_find_property(op->ptr, "dirs"); + PropertyRNA *prop_files = RNA_struct_find_property(op->ptr, "files"); + PropertyRNA *prop_dirs = RNA_struct_find_property(op->ptr, "dirs"); int i, numfiles = filelist_numfiles(sfile->files); if (prop_files) { + int num_files = 0; RNA_property_collection_clear(op->ptr, prop_files); - for (i=0; i<numfiles; i++) { + for (i = 0; i < numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_FILES)) { - struct direntry *file= filelist_file(sfile->files, i); + struct direntry *file = filelist_file(sfile->files, i); RNA_property_collection_add(op->ptr, prop_files, &itemptr); RNA_string_set(&itemptr, "name", file->relname); + num_files++; } } + /* make sure the file specified in the filename button is added even if no files selected */ + if (0 == num_files) { + RNA_property_collection_add(op->ptr, prop_files, &itemptr); + RNA_string_set(&itemptr, "name", sfile->params->file); + } } if (prop_dirs) { + int num_dirs = 0; RNA_property_collection_clear(op->ptr, prop_dirs); - for (i=0; i<numfiles; i++) { + for (i = 0; i < numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) { - struct direntry *file= filelist_file(sfile->files, i); + struct direntry *file = filelist_file(sfile->files, i); RNA_property_collection_add(op->ptr, prop_dirs, &itemptr); RNA_string_set(&itemptr, "name", file->relname); + num_dirs++; } } + + /* make sure the directory specified in the button is added even if no directory selected */ + if (0 == num_dirs) { + RNA_property_collection_add(op->ptr, prop_dirs, &itemptr); + RNA_string_set(&itemptr, "name", sfile->params->dir); + } } @@ -669,16 +684,16 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) PropertyRNA *prop; /* If neither of the above are set, split the filepath back */ - if ((prop= RNA_struct_find_property(op->ptr, "filepath"))) { + if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { char filepath[FILE_MAX]; RNA_property_string_get(op->ptr, prop, filepath); BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); } else { - if ((prop= RNA_struct_find_property(op->ptr, "filename"))) { + if ((prop = RNA_struct_find_property(op->ptr, "filename"))) { RNA_property_string_get(op->ptr, prop, sfile->params->file); } - if ((prop= RNA_struct_find_property(op->ptr, "directory"))) { + if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { RNA_property_string_get(op->ptr, prop, sfile->params->dir); } } @@ -692,8 +707,8 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; if (op) { /* fail on reload */ if (op->type->check) { char filepath[FILE_MAX]; @@ -730,20 +745,20 @@ int file_draw_check_exists(SpaceFile *sfile) /* sends events now, so things get handled on windowqueue level */ int file_exec(bContext *C, wmOperator *exec_op) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); char filepath[FILE_MAX]; if (sfile->op) { - wmOperator *op= sfile->op; + wmOperator *op = sfile->op; /* when used as a macro, for doubleclick, * to prevent closing when doubleclicking on .. item */ if (RNA_boolean_get(exec_op->ptr, "need_active")) { - int i, active=0; + int i, active = 0; - for (i=0; i<filelist_numfiles(sfile->files); i++) { + for (i = 0; i < filelist_numfiles(sfile->files); i++) { if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { - active=1; + active = 1; break; } } @@ -788,14 +803,14 @@ void FILE_OT_execute(struct wmOperatorType *ot) int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (BLI_has_parent(sfile->params->dir)) { BLI_parent_dir(sfile->params->dir); BLI_cleanup_dir(G.main->name, sfile->params->dir); file_change_dir(C, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } } @@ -819,15 +834,15 @@ void FILE_OT_parent(struct wmOperatorType *ot) static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); - struct FSMenu* fsmenu = fsmenu_get(); + SpaceFile *sfile = CTX_wm_space_file(C); + struct FSMenu *fsmenu = fsmenu_get(); ED_fileselect_clear(C, sfile); /* refresh system directory menu */ fsmenu_refresh_system_category(fsmenu); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; @@ -847,7 +862,7 @@ void FILE_OT_previous(struct wmOperatorType *ot) int file_previous_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (!sfile->folders_next) @@ -859,7 +874,7 @@ int file_previous_exec(bContext *C, wmOperator *UNUSED(unused)) file_change_dir(C, 1); } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -878,7 +893,7 @@ void FILE_OT_next(struct wmOperatorType *ot) int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (!sfile->folders_next) sfile->folders_next = folderlist_new(); @@ -891,7 +906,7 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) file_change_dir(C, 1); } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -901,31 +916,31 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { ScrArea *sa = CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); - ARegion *ar, *oldar= CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); + ARegion *ar, *oldar = CTX_wm_region(C); int offset; int numfiles, numfiles_layout; int edit_idx = 0; int i; /* escape if not our timer */ - if (sfile->smoothscroll_timer==NULL || sfile->smoothscroll_timer!=event->customdata) + if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) return OPERATOR_PASS_THROUGH; numfiles = filelist_numfiles(sfile->files); /* check if we are editing a name */ - for (i=0; i < numfiles; ++i) { + for (i = 0; i < numfiles; ++i) { if (filelist_is_selected(sfile->files, i, CHECK_ALL) ) { - edit_idx=i; + edit_idx = i; break; } } /* if we are not editing, we are done */ - if (0==edit_idx) { + if (0 == edit_idx) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_PASS_THROUGH; } @@ -933,21 +948,21 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (!ar || ar->regiontype != RGN_TYPE_WINDOW) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_PASS_THROUGH; } offset = ED_fileselect_layout_offset(sfile->layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax); - if (offset<0) offset=0; + if (offset < 0) offset = 0; /* scroll offset is the first file in the row/column we are editing in */ if (sfile->scroll_offset == 0) { if (sfile->layout->flag & FILE_LAYOUT_HOR) { - sfile->scroll_offset = (edit_idx/sfile->layout->rows)*sfile->layout->rows; + sfile->scroll_offset = (edit_idx / sfile->layout->rows) * sfile->layout->rows; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->rows; } else { - sfile->scroll_offset = (edit_idx/sfile->layout->columns)*sfile->layout->columns; + sfile->scroll_offset = (edit_idx / sfile->layout->columns) * sfile->layout->columns; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns; } } @@ -957,7 +972,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent /* check if we have reached our final scroll position */ if ( (sfile->scroll_offset >= offset) && (sfile->scroll_offset < offset + numfiles_layout) ) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_FINISHED; } @@ -1011,7 +1026,7 @@ void FILE_OT_smoothscroll(wmOperatorType *ot) /* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created. * The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name. */ -static int new_folder_path(const char* parent, char *folder, char *name) +static int new_folder_path(const char *parent, char *folder, char *name) { int i = 1; int len = 0; @@ -1021,22 +1036,22 @@ static int new_folder_path(const char* parent, char *folder, char *name) /* check whether folder with the name already exists, in this case * add number to the name. Check length of generated name to avoid * crazy case of huge number of folders each named 'New Folder (x)' */ - while (BLI_exists(folder) && (len<FILE_MAXFILE)) { + while (BLI_exists(folder) && (len < FILE_MAXFILE)) { len = BLI_snprintf(name, FILE_MAXFILE, "New Folder(%d)", i); BLI_join_dirfile(folder, FILE_MAX, parent, name); /* XXX, not real length */ i++; } - return (len<FILE_MAXFILE); + return (len < FILE_MAXFILE); } int file_directory_new_exec(bContext *C, wmOperator *op) { char name[FILE_MAXFILE]; char path[FILE_MAX]; - int generate_name= 1; + int generate_name = 1; - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (!sfile->params) { BKE_report(op->reports, RPT_WARNING, "No parent directory given"); @@ -1047,7 +1062,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op) if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", path); - if (path[0] != '\0') generate_name= 0; + if (path[0] != '\0') generate_name = 0; } if (generate_name) { @@ -1070,12 +1085,12 @@ int file_directory_new_exec(bContext *C, wmOperator *op) BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); /* set timer to smoothly view newly generated file */ - sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0/1000.0); /* max 30 frs/sec */ - sfile->scroll_offset=0; + sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */ + sfile->scroll_offset = 0; /* reload dir to make sure we're seeing what's in the directory */ ED_fileselect_clear(C, sfile); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -1100,7 +1115,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) static void file_expand_directory(bContext *C) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { /* TODO, what about // when relbase isn't valid? */ @@ -1108,8 +1123,8 @@ static void file_expand_directory(bContext *C) BLI_path_abs(sfile->params->dir, G.main->name); } else if (sfile->params->dir[0] == '~') { - char tmpstr[sizeof(sfile->params->dir)-1]; - BLI_strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr)); + char tmpstr[sizeof(sfile->params->dir) - 1]; + BLI_strncpy(tmpstr, sfile->params->dir + 1, sizeof(tmpstr)); BLI_join_dirfile(sfile->params->dir, sizeof(sfile->params->dir), BLI_getDefaultDocumentFolder(), tmpstr); } @@ -1125,12 +1140,12 @@ static void file_expand_directory(bContext *C) } /* change "C:" --> "C:\", [#28102] */ else if ( (isalpha(sfile->params->dir[0]) && - (sfile->params->dir[1] == ':')) && + (sfile->params->dir[1] == ':')) && (sfile->params->dir[2] == '\0') - ) { - sfile->params->dir[2]= '\\'; - sfile->params->dir[3]= '\0'; + ) { + sfile->params->dir[2] = '\\'; + sfile->params->dir[3] = '\0'; } #endif } @@ -1138,14 +1153,14 @@ static void file_expand_directory(bContext *C) static int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { file_expand_directory(C); if (!BLI_exists(sfile->params->dir)) { return WM_operator_confirm_message(C, op, "Create new directory?"); - } + } return file_directory_exec(C, op); } @@ -1157,7 +1172,7 @@ static int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { file_expand_directory(C); @@ -1177,23 +1192,27 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) BLI_add_slash(sfile->params->dir); file_change_dir(C, 1); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); - } - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); + } return OPERATOR_FINISHED; } int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); - + SpaceFile *sfile = CTX_wm_space_file(C); + char matched_file[FILE_MAX]; if (sfile->params) { - if (file_select_match(sfile, sfile->params->file)) { + matched_file[0] = '\0'; + if (file_select_match(sfile, sfile->params->file, matched_file)) { + /* int i, numfiles = filelist_numfiles(sfile->files); */ /* XXX UNUSED */ sfile->params->file[0] = '\0'; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + /* replace the pattern (or filename that the user typed in, with the first selected file of the match */ + BLI_strncpy(sfile->params->file, matched_file, sizeof(sfile->params->file)); + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } - } + } return OPERATOR_FINISHED; } @@ -1203,8 +1222,8 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_directory_poll(bContext *C) { /* sfile->files can be NULL on file load */ - SpaceFile *sfile= CTX_wm_space_file(C); - return ED_operator_file_active(C) && (sfile->files==NULL || filelist_lib(sfile->files)==NULL); + SpaceFile *sfile = CTX_wm_space_file(C); + return ED_operator_file_active(C) && (sfile->files == NULL || filelist_lib(sfile->files) == NULL); } void FILE_OT_directory(struct wmOperatorType *ot) @@ -1234,12 +1253,12 @@ void FILE_OT_refresh(struct wmOperatorType *ot) static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { sfile->params->flag ^= FILE_HIDE_DOT; ED_fileselect_clear(C, sfile); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } return OPERATOR_FINISHED; @@ -1262,23 +1281,23 @@ struct ARegion *file_buttons_region(struct ScrArea *sa) { ARegion *ar, *arnew; - for (ar= sa->regionbase.first; ar; ar= ar->next) - if (ar->regiontype==RGN_TYPE_CHANNELS) + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar->regiontype == RGN_TYPE_CHANNELS) return ar; /* add subdiv level; after header */ - for (ar= sa->regionbase.first; ar; ar= ar->next) - if (ar->regiontype==RGN_TYPE_HEADER) + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar->regiontype == RGN_TYPE_HEADER) break; /* is error! */ - if (ar==NULL) return NULL; + if (ar == NULL) return NULL; - arnew= MEM_callocN(sizeof(ARegion), "buttons for file panels"); + arnew = MEM_callocN(sizeof(ARegion), "buttons for file panels"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_CHANNELS; - arnew->alignment= RGN_ALIGN_LEFT; + arnew->regiontype = RGN_TYPE_CHANNELS; + arnew->alignment = RGN_ALIGN_LEFT; arnew->flag = RGN_FLAG_HIDDEN; @@ -1287,8 +1306,8 @@ struct ARegion *file_buttons_region(struct ScrArea *sa) static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= file_buttons_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = file_buttons_region(sa); if (ar) ED_region_toggle_hidden(C, ar); @@ -1311,8 +1330,8 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) static int file_filenum_exec(bContext *C, wmOperator *op) { - SpaceFile *sfile= CTX_wm_space_file(C); - ScrArea *sa= CTX_wm_area(C); + SpaceFile *sfile = CTX_wm_space_file(C); + ScrArea *sa = CTX_wm_area(C); int inc = RNA_int_get(op->ptr, "increment"); if (sfile->params && (inc != 0)) { @@ -1343,17 +1362,17 @@ void FILE_OT_filenum(struct wmOperatorType *ot) static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); if (sfile->params) { int idx = sfile->params->active_file; int numfiles = filelist_numfiles(sfile->files); - if ( (0<=idx) && (idx<numfiles) ) { - struct direntry *file= filelist_file(sfile->files, idx); + if ( (0 <= idx) && (idx < numfiles) ) { + struct direntry *file = filelist_file(sfile->files, idx); filelist_select_file(sfile->files, idx, FILE_SEL_ADD, EDITING_FILE, CHECK_ALL); BLI_strncpy(sfile->params->renameedit, file->relname, FILE_MAXFILE); - sfile->params->renamefile[0]= '\0'; + sfile->params->renamefile[0] = '\0'; } ED_area_tag_redraw(sa); } @@ -1365,19 +1384,19 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) static int file_rename_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile && sfile->params) { if (sfile->params->active_file < 0) { - poll= 0; + poll = 0; } else { char dir[FILE_MAX], group[FILE_MAX]; - if (filelist_islibrary(sfile->files, dir, group)) poll= 0; + if (filelist_islibrary(sfile->files, dir, group)) poll = 0; } } else - poll= 0; + poll = 0; return poll; } @@ -1397,22 +1416,22 @@ void FILE_OT_rename(struct wmOperatorType *ot) static int file_delete_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); - struct direntry* file; + SpaceFile *sfile = CTX_wm_space_file(C); + struct direntry *file; if (sfile && sfile->params) { if (sfile->params->active_file < 0) { - poll= 0; + poll = 0; } else { char dir[FILE_MAX], group[FILE_MAX]; - if (filelist_islibrary(sfile->files, dir, group)) poll= 0; + if (filelist_islibrary(sfile->files, dir, group)) poll = 0; file = filelist_file(sfile->files, sfile->params->active_file); - if (file && S_ISDIR(file->type)) poll= 0; + if (file && S_ISDIR(file->type)) poll = 0; } } else - poll= 0; + poll = 0; return poll; } @@ -1420,15 +1439,15 @@ static int file_delete_poll(bContext *C) int file_delete_exec(bContext *C, wmOperator *UNUSED(op)) { char str[FILE_MAX]; - SpaceFile *sfile= CTX_wm_space_file(C); - struct direntry* file; + SpaceFile *sfile = CTX_wm_space_file(C); + struct direntry *file; file = filelist_file(sfile->files, sfile->params->active_file); BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relname); BLI_delete(str, 0, 0); ED_fileselect_clear(C, sfile); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index a17a7edbd80..51bd660e126 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -59,7 +59,7 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v)) { PointerRNA ptr; - char *entry= (char*)arg_entry; + char *entry = (char *)arg_entry; WM_operator_properties_create(&ptr, "FILE_OT_select_bookmark"); RNA_string_set(&ptr, "dir", entry); @@ -69,15 +69,15 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v)) static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete, int reverse) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); uiBlock *block; uiBut *but; uiLayout *box, *col; - struct FSMenu* fsmenu = fsmenu_get(); + struct FSMenu *fsmenu = fsmenu_get(); int i, i_iter, nentries = fsmenu_get_nentries(fsmenu, category); /* reset each time */ - *nr= -1; + *nr = -1; /* hide if no entries */ if (nentries == 0) @@ -85,24 +85,24 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat /* layout */ uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT); - block= uiLayoutGetBlock(pa->layout); - box= uiLayoutBox(pa->layout); - col= uiLayoutColumn(box, 1); + block = uiLayoutGetBlock(pa->layout); + box = uiLayoutBox(pa->layout); + col = uiLayoutColumn(box, TRUE); - for (i_iter=0; i_iter< nentries;++i_iter) { + for (i_iter = 0; i_iter < nentries; ++i_iter) { char dir[FILE_MAX]; char temp[FILE_MAX]; - uiLayout* layout = uiLayoutRow(col, 0); + uiLayout *layout = uiLayoutRow(col, FALSE); char *entry; - i= reverse ? nentries-(i_iter+1) : i_iter; + i = reverse ? nentries - (i_iter + 1) : i_iter; entry = fsmenu_get_entry(fsmenu, category, i); /* set this list item as active if we have a match */ if (sfile->params) { if (BLI_path_cmp(sfile->params->dir, entry) == 0) { - *nr= i; + *nr = i; } } @@ -118,7 +118,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat /* create list item */ but = uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, nr, 0, i, 0, 0, entry); uiButSetFunc(but, file_panel_cb, entry, NULL); - uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT); + uiButSetFlag(but, UI_ICON_LEFT | UI_TEXT_LEFT); /* create delete button */ if (allow_delete && fsmenu_can_save(fsmenu, category, i)) { @@ -131,7 +131,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat static void file_panel_system(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0); @@ -139,11 +139,11 @@ static void file_panel_system(const bContext *C, Panel *pa) static void file_panel_bookmarks(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); uiLayout *row; if (sfile) { - row= uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add"); uiItemL(row, NULL, ICON_NONE); @@ -153,10 +153,10 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa) static void file_panel_recent(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) { - if ( !(U.uiflag & USER_HIDE_RECENT) ) { + if (!(U.uiflag & USER_HIDE_RECENT) ) { file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0, 1); } } @@ -165,31 +165,31 @@ static void file_panel_recent(const bContext *C, Panel *pa) static int file_panel_operator_poll(const bContext *C, PanelType *UNUSED(pt)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); return (sfile && sfile->op); } static void file_panel_operator_header(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; BLI_strncpy(pa->drawname, RNA_struct_ui_name(op->type->srna), sizeof(pa->drawname)); } static int file_panel_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { - const char *prop_id= RNA_property_identifier(prop); - return !( strcmp(prop_id, "filepath") == 0 || - strcmp(prop_id, "directory") == 0 || - strcmp(prop_id, "filename") == 0 - ); + const char *prop_id = RNA_property_identifier(prop); + return !(strcmp(prop_id, "filepath") == 0 || + strcmp(prop_id, "directory") == 0 || + strcmp(prop_id, "filename") == 0 + ); } static void file_panel_operator(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; // int empty= 1, flag; uiBlockSetFunc(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL); @@ -203,30 +203,30 @@ void file_panels_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype file system directories"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file system directories"); strcpy(pt->idname, "FILE_PT_system"); strcpy(pt->label, N_("System")); - pt->draw= file_panel_system; + pt->draw = file_panel_system; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file bookmarks"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file bookmarks"); strcpy(pt->idname, "FILE_PT_bookmarks"); strcpy(pt->label, N_("Bookmarks")); - pt->draw= file_panel_bookmarks; + pt->draw = file_panel_bookmarks; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file recent directories"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file recent directories"); strcpy(pt->idname, "FILE_PT_recent"); strcpy(pt->label, N_("Recent")); - pt->draw= file_panel_recent; + pt->draw = file_panel_recent; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file operator properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file operator properties"); strcpy(pt->idname, "FILE_PT_operator"); strcpy(pt->label, N_("Operator")); - pt->poll= file_panel_operator_poll; - pt->draw_header= file_panel_operator_header; - pt->draw= file_panel_operator; + pt->poll = file_panel_operator_poll; + pt->draw_header = file_panel_operator_header; + pt->draw = file_panel_operator; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index afd04697e5e..6d2c8657f0b 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -98,7 +98,7 @@ typedef struct ThumbnailJob { ListBase loadimages; short *stop; short *do_update; - struct FileList* filelist; + struct FileList *filelist; ReportList reports; } ThumbnailJob; @@ -119,7 +119,7 @@ typedef struct FileList { short hide_parent; void (*readf)(struct FileList *); - int (*filterf)(struct direntry* file, const char* dir, unsigned int filter, short hide_dot); + int (*filterf)(struct direntry *file, const char *dir, unsigned int filter, short hide_dot); } FileList; @@ -145,25 +145,25 @@ typedef struct FolderList { #define SPECIAL_IMG_LOADING 10 #define SPECIAL_IMG_MAX SPECIAL_IMG_LOADING + 1 -static ImBuf* gSpecialFileImages[SPECIAL_IMG_MAX]; +static ImBuf *gSpecialFileImages[SPECIAL_IMG_MAX]; /* ******************* SORT ******************* */ static int compare_name(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -172,28 +172,28 @@ static int compare_name(const void *a1, const void *a2) if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if ( strcmp(entry1->relname, ".")==0 ) return (-1); - if ( strcmp(entry2->relname, ".")==0 ) return (1); - if ( strcmp(entry1->relname, "..")==0 ) return (-1); - if ( strcmp(entry2->relname, "..")==0 ) return (1); + if (strcmp(entry1->relname, ".") == 0) return (-1); + if (strcmp(entry2->relname, ".") == 0) return (1); + if (strcmp(entry1->relname, "..") == 0) return (-1); + if (strcmp(entry2->relname, "..") == 0) return (1); return (BLI_natstrcmp(entry1->relname, entry2->relname)); } static int compare_date(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -202,31 +202,31 @@ static int compare_date(const void *a1, const void *a2) if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if ( strcmp(entry1->relname, ".")==0 ) return (-1); - if ( strcmp(entry2->relname, ".")==0 ) return (1); - if ( strcmp(entry1->relname, "..")==0 ) return (-1); - if ( strcmp(entry2->relname, "..")==0 ) return (1); + if (strcmp(entry1->relname, ".") == 0) return (-1); + if (strcmp(entry2->relname, ".") == 0) return (1); + if (strcmp(entry1->relname, "..") == 0) return (-1); + if (strcmp(entry2->relname, "..") == 0) return (1); - if ( entry1->s.st_mtime < entry2->s.st_mtime) return 1; - if ( entry1->s.st_mtime > entry2->s.st_mtime) return -1; + if (entry1->s.st_mtime < entry2->s.st_mtime) return 1; + if (entry1->s.st_mtime > entry2->s.st_mtime) return -1; else return BLI_natstrcmp(entry1->relname, entry2->relname); } static int compare_size(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -235,39 +235,39 @@ static int compare_size(const void *a1, const void *a2) if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if ( strcmp(entry1->relname, ".")==0 ) return (-1); - if ( strcmp(entry2->relname, ".")==0 ) return (1); - if ( strcmp(entry1->relname, "..")==0 ) return (-1); - if ( strcmp(entry2->relname, "..")==0 ) return (1); + if (strcmp(entry1->relname, ".") == 0) return (-1); + if (strcmp(entry2->relname, ".") == 0) return (1); + if (strcmp(entry1->relname, "..") == 0) return (-1); + if (strcmp(entry2->relname, "..") == 0) return (1); - if ( entry1->s.st_size < entry2->s.st_size) return 1; - if ( entry1->s.st_size > entry2->s.st_size) return -1; + if (entry1->s.st_size < entry2->s.st_size) return 1; + if (entry1->s.st_size > entry2->s.st_size) return -1; else return BLI_natstrcmp(entry1->relname, entry2->relname); } static int compare_extension(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; const char *sufix1, *sufix2; - const char *nil=""; + const char *nil = ""; - if (!(sufix1= strstr (entry1->relname, ".blend.gz"))) - sufix1= strrchr (entry1->relname, '.'); - if (!(sufix2= strstr (entry2->relname, ".blend.gz"))) - sufix2= strrchr (entry2->relname, '.'); - if (!sufix1) sufix1= nil; - if (!sufix2) sufix2= nil; + if (!(sufix1 = strstr(entry1->relname, ".blend.gz"))) + sufix1 = strrchr(entry1->relname, '.'); + if (!(sufix2 = strstr(entry2->relname, ".blend.gz"))) + sufix2 = strrchr(entry2->relname, '.'); + if (!sufix1) sufix1 = nil; + if (!sufix2) sufix2 = nil; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -276,46 +276,46 @@ static int compare_extension(const void *a1, const void *a2) if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if ( strcmp(entry1->relname, ".")==0 ) return (-1); - if ( strcmp(entry2->relname, ".")==0 ) return (1); - if ( strcmp(entry1->relname, "..")==0 ) return (-1); - if ( strcmp(entry2->relname, "..")==0 ) return (1); + if (strcmp(entry1->relname, ".") == 0) return (-1); + if (strcmp(entry2->relname, ".") == 0) return (1); + if (strcmp(entry1->relname, "..") == 0) return (-1); + if (strcmp(entry2->relname, "..") == 0) return (1); return (BLI_strcasecmp(sufix1, sufix2)); } -static int is_hidden_file(const char* filename, short hide_dot) +static int is_hidden_file(const char *filename, short hide_dot) { - int is_hidden=0; + int is_hidden = 0; if (hide_dot) { - if (filename[0]=='.' && filename[1]!='.' && filename[1]!=0) { - is_hidden=1; /* ignore .file */ + if (filename[0] == '.' && filename[1] != '.' && filename[1] != 0) { + is_hidden = 1; /* ignore .file */ } else if (((filename[0] == '.') && (filename[1] == 0) )) { - is_hidden=1; /* ignore . */ + is_hidden = 1; /* ignore . */ } else { - int len=strlen(filename); - if ( (len>0) && (filename[len-1]=='~') ) { - is_hidden=1; /* ignore file~ */ + int len = strlen(filename); + if ( (len > 0) && (filename[len - 1] == '~') ) { + is_hidden = 1; /* ignore file~ */ } } } else { if (((filename[0] == '.') && (filename[1] == 0) )) { - is_hidden=1; /* ignore . */ + is_hidden = 1; /* ignore . */ } } return is_hidden; } -static int is_filtered_file(struct direntry* file, const char* UNUSED(dir), unsigned int filter, short hide_dot) +static int is_filtered_file(struct direntry *file, const char *UNUSED(dir), unsigned int filter, short hide_dot) { - int is_filtered=0; + int is_filtered = 0; if (filter) { if (file->flags & filter) { - is_filtered=1; + is_filtered = 1; } else if (file->type & S_IFDIR) { if (filter & FOLDERFILE) { @@ -329,9 +329,9 @@ static int is_filtered_file(struct direntry* file, const char* UNUSED(dir), unsi return is_filtered && !is_hidden_file(file->relname, hide_dot); } -static int is_filtered_lib(struct direntry* file, const char* dir, unsigned int filter, short hide_dot) +static int is_filtered_lib(struct direntry *file, const char *dir, unsigned int filter, short hide_dot) { - int is_filtered=0; + int is_filtered = 0; char tdir[FILE_MAX], tgroup[GROUP_MAX]; if (BLO_is_a_library(dir, tdir, tgroup)) { is_filtered = !is_hidden_file(file->relname, hide_dot); @@ -342,12 +342,12 @@ static int is_filtered_lib(struct direntry* file, const char* dir, unsigned int return is_filtered; } -static int is_filtered_main(struct direntry* file, const char* UNUSED(dir), unsigned int UNUSED(filter), short hide_dot) +static int is_filtered_main(struct direntry *file, const char *UNUSED(dir), unsigned int UNUSED(filter), short hide_dot) { return !is_hidden_file(file->relname, hide_dot); } -void filelist_filter(FileList* filelist) +void filelist_filter(FileList *filelist) { int num_filtered = 0; int i, j; @@ -358,7 +358,7 @@ void filelist_filter(FileList* filelist) // How many files are left after filter ? for (i = 0; i < filelist->numfiles; ++i) { struct direntry *file = &filelist->filelist[i]; - if ( filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { + if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { num_filtered++; } } @@ -367,12 +367,12 @@ void filelist_filter(FileList* filelist) MEM_freeN(filelist->fidx); filelist->fidx = NULL; } - filelist->fidx = (int *)MEM_callocN(num_filtered*sizeof(int), "filteridx"); + filelist->fidx = (int *)MEM_callocN(num_filtered * sizeof(int), "filteridx"); filelist->numfiltered = num_filtered; - for (i = 0, j=0; i < filelist->numfiles; ++i) { + for (i = 0, j = 0; i < filelist->numfiles; ++i) { struct direntry *file = &filelist->filelist[i]; - if ( filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { + if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { filelist->fidx[j++] = i; } } @@ -386,16 +386,16 @@ void filelist_init_icons(void) #ifdef WITH_HEADLESS bbuf = NULL; #else - bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_prvicons, datatoc_prvicons_size, IB_rect, "<splash>"); + bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons, datatoc_prvicons_size, IB_rect, "<splash>"); #endif if (bbuf) { - for (y=0; y<SPECIAL_IMG_ROWS; y++) { - for (x=0; x<SPECIAL_IMG_COLS; x++) { - int tile = SPECIAL_IMG_COLS*y + x; + for (y = 0; y < SPECIAL_IMG_ROWS; y++) { + for (x = 0; x < SPECIAL_IMG_COLS; x++) { + int tile = SPECIAL_IMG_COLS * y + x; if (tile < SPECIAL_IMG_MAX) { ibuf = IMB_allocImBuf(SPECIAL_IMG_SIZE, SPECIAL_IMG_SIZE, 32, IB_rect); - for (k=0; k<SPECIAL_IMG_SIZE; k++) { - memcpy(&ibuf->rect[k*SPECIAL_IMG_SIZE], &bbuf->rect[(k+y*SPECIAL_IMG_SIZE)*SPECIAL_IMG_SIZE*SPECIAL_IMG_COLS+x*SPECIAL_IMG_SIZE], SPECIAL_IMG_SIZE*sizeof(int)); + for (k = 0; k < SPECIAL_IMG_SIZE; k++) { + memcpy(&ibuf->rect[k * SPECIAL_IMG_SIZE], &bbuf->rect[(k + y * SPECIAL_IMG_SIZE) * SPECIAL_IMG_SIZE * SPECIAL_IMG_COLS + x * SPECIAL_IMG_SIZE], SPECIAL_IMG_SIZE * sizeof(int)); } gSpecialFileImages[tile] = ibuf; } @@ -408,20 +408,20 @@ void filelist_init_icons(void) void filelist_free_icons(void) { int i; - for (i=0; i < SPECIAL_IMG_MAX; ++i) { + for (i = 0; i < SPECIAL_IMG_MAX; ++i) { IMB_freeImBuf(gSpecialFileImages[i]); gSpecialFileImages[i] = NULL; } } //-----------------FOLDERLIST (previous/next) --------------// -struct ListBase* folderlist_new(void) +ListBase *folderlist_new(void) { - ListBase* p = MEM_callocN(sizeof(ListBase), "folderlist" ); + ListBase *p = MEM_callocN(sizeof(ListBase), "folderlist"); return p; } -void folderlist_popdir(struct ListBase* folderlist, char *dir) +void folderlist_popdir(struct ListBase *folderlist, char *dir) { const char *prev_dir; struct FolderList *folder; @@ -441,21 +441,21 @@ void folderlist_popdir(struct ListBase* folderlist, char *dir) // delete the folder next or use setdir directly before PREVIOUS OP } -void folderlist_pushdir(ListBase* folderlist, const char *dir) +void folderlist_pushdir(ListBase *folderlist, const char *dir) { struct FolderList *folder, *previous_folder; previous_folder = folderlist->last; // check if already exists if (previous_folder && previous_folder->foldername) { - if (BLI_path_cmp(previous_folder->foldername, dir)==0) { + if (BLI_path_cmp(previous_folder->foldername, dir) == 0) { return; } } // create next folder element - folder = (FolderList*)MEM_mallocN(sizeof(FolderList), "FolderList"); - folder->foldername = (char*)MEM_mallocN(sizeof(char)*(strlen(dir)+1), "foldername"); + folder = (FolderList *)MEM_mallocN(sizeof(FolderList), "FolderList"); + folder->foldername = (char *)MEM_mallocN(sizeof(char) * (strlen(dir) + 1), "foldername"); folder->foldername[0] = '\0'; BLI_strncpy(folder->foldername, dir, FILE_MAXDIR); @@ -474,7 +474,7 @@ int folderlist_clear_next(struct SpaceFile *sfile) // if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next folder = sfile->folders_prev->last; - if ((!folder) ||(BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) + if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) return 0; // eventually clear flist->folders_next @@ -482,27 +482,27 @@ int folderlist_clear_next(struct SpaceFile *sfile) } /* not listbase itself */ -void folderlist_free(ListBase* folderlist) +void folderlist_free(ListBase *folderlist) { if (folderlist) { FolderList *folder; - for (folder= folderlist->first; folder; folder= folder->next) + for (folder = folderlist->first; folder; folder = folder->next) MEM_freeN(folder->foldername); BLI_freelistN(folderlist); } } -ListBase *folderlist_duplicate(ListBase* folderlist) +ListBase *folderlist_duplicate(ListBase *folderlist) { if (folderlist) { - ListBase *folderlistn= MEM_callocN(sizeof(ListBase), "copy folderlist"); + ListBase *folderlistn = MEM_callocN(sizeof(ListBase), "copy folderlist"); FolderList *folder; BLI_duplicatelist(folderlistn, folderlist); - for (folder= folderlistn->first; folder; folder= folder->next) { - folder->foldername= MEM_dupallocN(folder->foldername); + for (folder = folderlistn->first; folder; folder = folder->next) { + folder->foldername = MEM_dupallocN(folder->foldername); } return folderlistn; } @@ -510,14 +510,14 @@ ListBase *folderlist_duplicate(ListBase* folderlist) } -static void filelist_read_main(struct FileList* filelist); -static void filelist_read_library(struct FileList* filelist); -static void filelist_read_dir(struct FileList* filelist); +static void filelist_read_main(struct FileList *filelist); +static void filelist_read_library(struct FileList *filelist); +static void filelist_read_dir(struct FileList *filelist); //------------------FILELIST------------------------// -struct FileList* filelist_new(short type) +FileList *filelist_new(short type) { - FileList* p = MEM_callocN(sizeof(FileList), "filelist" ); + FileList *p = MEM_callocN(sizeof(FileList), "filelist"); switch (type) { case FILE_MAIN: p->readf = filelist_read_main; @@ -536,7 +536,7 @@ struct FileList* filelist_new(short type) } -void filelist_free(struct FileList* filelist) +void filelist_free(struct FileList *filelist) { int i; @@ -570,51 +570,51 @@ void filelist_free(struct FileList* filelist) filelist->filelist = NULL; filelist->filter = 0; filelist->filter_glob[0] = '\0'; - filelist->numfiltered =0; - filelist->hide_dot =0; + filelist->numfiltered = 0; + filelist->hide_dot = 0; } -void filelist_freelib(struct FileList* filelist) +void filelist_freelib(struct FileList *filelist) { if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= NULL; + filelist->libfiledata = NULL; } -struct BlendHandle *filelist_lib(struct FileList* filelist) +BlendHandle *filelist_lib(struct FileList *filelist) { return filelist->libfiledata; } -int filelist_numfiles(struct FileList* filelist) +int filelist_numfiles(struct FileList *filelist) { return filelist->numfiltered; } -const char * filelist_dir(struct FileList* filelist) +const char *filelist_dir(struct FileList *filelist) { return filelist->dir; } -void filelist_setdir(struct FileList* filelist, const char *dir) +void filelist_setdir(struct FileList *filelist, const char *dir) { BLI_strncpy(filelist->dir, dir, sizeof(filelist->dir)); } -void filelist_imgsize(struct FileList* filelist, short w, short h) +void filelist_imgsize(struct FileList *filelist, short w, short h) { filelist->prv_w = w; filelist->prv_h = h; } -short filelist_changed(struct FileList* filelist) +short filelist_changed(struct FileList *filelist) { return filelist->changed; } -struct ImBuf * filelist_getimage(struct FileList* filelist, int index) +ImBuf *filelist_getimage(struct FileList *filelist, int index) { - ImBuf* ibuf = NULL; + ImBuf *ibuf = NULL; int fidx = 0; if ( (index < 0) || (index >= filelist->numfiltered) ) { return NULL; @@ -625,10 +625,10 @@ struct ImBuf * filelist_getimage(struct FileList* filelist, int index) return ibuf; } -struct ImBuf * filelist_geticon(struct FileList* filelist, int index) +ImBuf *filelist_geticon(struct FileList *filelist, int index) { - ImBuf* ibuf= NULL; - struct direntry *file= NULL; + ImBuf *ibuf = NULL; + struct direntry *file = NULL; int fidx = 0; if ( (index < 0) || (index >= filelist->numfiltered) ) { return NULL; @@ -636,7 +636,7 @@ struct ImBuf * filelist_geticon(struct FileList* filelist, int index) fidx = filelist->fidx[index]; file = &filelist->filelist[fidx]; if (file->type & S_IFDIR) { - if ( strcmp(filelist->filelist[fidx].relname, "..") == 0) { + if (strcmp(filelist->filelist[fidx].relname, "..") == 0) { ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT]; } else if (strcmp(filelist->filelist[fidx].relname, ".") == 0) { @@ -675,7 +675,7 @@ struct ImBuf * filelist_geticon(struct FileList* filelist, int index) return ibuf; } -struct direntry * filelist_file(struct FileList* filelist, int index) +struct direntry *filelist_file(struct FileList *filelist, int index) { int fidx = 0; @@ -687,7 +687,7 @@ struct direntry * filelist_file(struct FileList* filelist, int index) return &filelist->filelist[fidx]; } -int filelist_find(struct FileList* filelist, const char *filename) +int filelist_find(struct FileList *filelist, const char *filename) { int index = -1; int i; @@ -698,7 +698,7 @@ int filelist_find(struct FileList* filelist, const char *filename) for (i = 0; i < filelist->numfiles; ++i) { - if ( strcmp(filelist->filelist[i].relname, filename) == 0) { /* not dealing with user input so don't need BLI_path_cmp */ + if (strcmp(filelist->filelist[i].relname, filename) == 0) { /* not dealing with user input so don't need BLI_path_cmp */ index = i; break; } @@ -713,17 +713,17 @@ int filelist_find(struct FileList* filelist, const char *filename) return fidx; } -void filelist_hidedot(struct FileList* filelist, short hide) +void filelist_hidedot(struct FileList *filelist, short hide) { filelist->hide_dot = hide; } -void filelist_setfilter(struct FileList* filelist, unsigned int filter) +void filelist_setfilter(struct FileList *filelist, unsigned int filter) { filelist->filter = filter; } -void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob) +void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob) { BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob)); } @@ -731,23 +731,23 @@ void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob static int file_is_blend_backup(const char *str) { short a, b; - int retval= 0; + int retval = 0; - a= strlen(str); - b= 7; + a = strlen(str); + b = 7; - if (a==0 || b>=a); + if (a == 0 || b >= a) ; else { char *loc; - if (a > b+1) + if (a > b + 1) b++; /* allow .blend1 .blend2 .blend32 */ - loc= BLI_strcasestr(str+a-b, ".blend"); + loc = BLI_strcasestr(str + a - b, ".blend"); if (loc) - retval= 1; + retval = 1; } return (retval); @@ -801,37 +801,37 @@ static int file_extension_type(const char *relname) int ED_file_extension_icon(const char *relname) { - int type= file_extension_type(relname); + int type = file_extension_type(relname); - if (type == BLENDERFILE || type==BLENDERFILE_BACKUP) + if (type == BLENDERFILE || type == BLENDERFILE_BACKUP) return ICON_FILE_BLEND; - else if (type == IMAGEFILE) + else if (type == IMAGEFILE) return ICON_FILE_IMAGE; - else if (type == MOVIEFILE) + else if (type == MOVIEFILE) return ICON_FILE_MOVIE; - else if (type == PYSCRIPTFILE) + else if (type == PYSCRIPTFILE) return ICON_FILE_SCRIPT; - else if (type == SOUNDFILE) + else if (type == SOUNDFILE) return ICON_FILE_SOUND; - else if (type == FTFONTFILE) + else if (type == FTFONTFILE) return ICON_FILE_FONT; - else if (type == BTXFILE) + else if (type == BTXFILE) return ICON_FILE_BLANK; - else if (type == COLLADAFILE) + else if (type == COLLADAFILE) return ICON_FILE_BLANK; return ICON_FILE_BLANK; } -static void filelist_setfiletypes(struct FileList* filelist) +static void filelist_setfiletypes(struct FileList *filelist) { struct direntry *file; int num; - file= filelist->filelist; + file = filelist->filelist; - for (num=0; num<filelist->numfiles; num++, file++) { - file->type= file->s.st_mode; /* restore the mess below */ + for (num = 0; num < filelist->numfiles; num++, file++) { + file->type = file->s.st_mode; /* restore the mess below */ /* Don't check extensions for directories */ if (file->type & S_IFDIR) { @@ -842,21 +842,21 @@ static void filelist_setfiletypes(struct FileList* filelist) if (filelist->filter_glob && BLI_testextensie_glob(file->relname, filelist->filter_glob)) { - file->flags= OPERATORFILE; + file->flags = OPERATORFILE; } } } -static void filelist_read_dir(struct FileList* filelist) +static void filelist_read_dir(struct FileList *filelist) { - char wdir[FILE_MAX]= ""; + char wdir[FILE_MAX] = ""; if (!filelist) return; filelist->fidx = NULL; filelist->filelist = NULL; - BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ + BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ BLI_cleanup_dir(G.main->name, filelist->dir); filelist->numfiles = BLI_dir_contents(filelist->dir, &(filelist->filelist)); @@ -866,13 +866,13 @@ static void filelist_read_dir(struct FileList* filelist) filelist_filter(filelist); } -static void filelist_read_main(struct FileList* filelist) +static void filelist_read_main(struct FileList *filelist) { if (!filelist) return; filelist_from_main(filelist); } -static void filelist_read_library(struct FileList* filelist) +static void filelist_read_library(struct FileList *filelist) { if (!filelist) return; BLI_cleanup_dir(G.main->name, filelist->dir); @@ -884,7 +884,7 @@ static void filelist_read_library(struct FileList* filelist) BLI_make_exist(filelist->dir); filelist_read_dir(filelist); file = filelist->filelist; - for (num=0; num<filelist->numfiles; num++, file++) { + for (num = 0; num < filelist->numfiles; num++, file++) { if (BLO_has_bfile_extension(file->relname)) { char name[FILE_MAX]; @@ -900,26 +900,26 @@ static void filelist_read_library(struct FileList* filelist) } } -void filelist_readdir(struct FileList* filelist) +void filelist_readdir(struct FileList *filelist) { filelist->readf(filelist); } -int filelist_empty(struct FileList* filelist) +int filelist_empty(struct FileList *filelist) { return filelist->filelist == NULL; } -void filelist_parent(struct FileList* filelist) +void filelist_parent(struct FileList *filelist) { BLI_parent_dir(filelist->dir); BLI_make_exist(filelist->dir); filelist_readdir(filelist); } -void filelist_select_file(struct FileList* filelist, int index, FileSelType select, unsigned int flag, FileCheckType check) +void filelist_select_file(struct FileList *filelist, int index, FileSelType select, unsigned int flag, FileCheckType check) { - struct direntry* file = filelist_file(filelist, index); + struct direntry *file = filelist_file(filelist, index); if (file != NULL) { int check_ok = 0; switch (check) { @@ -950,7 +950,7 @@ void filelist_select_file(struct FileList* filelist, int index, FileSelType sele } } -void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType select, unsigned int flag, FileCheckType check) +void filelist_select(struct FileList *filelist, FileSelection *sel, FileSelType select, unsigned int flag, FileCheckType check) { /* select all valid files between first and last indicated */ if ( (sel->first >= 0) && (sel->first < filelist->numfiltered) && (sel->last >= 0) && (sel->last < filelist->numfiltered) ) { @@ -961,9 +961,9 @@ void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType } } -int filelist_is_selected(struct FileList* filelist, int index, FileCheckType check) +int filelist_is_selected(struct FileList *filelist, int index, FileCheckType check) { - struct direntry* file = filelist_file(filelist, index); + struct direntry *file = filelist_file(filelist, index); if (!file) { return 0; } @@ -978,27 +978,27 @@ int filelist_is_selected(struct FileList* filelist, int index, FileCheckType che } } -void filelist_sort(struct FileList* filelist, short sort) +void filelist_sort(struct FileList *filelist, short sort) { switch (sort) { - case FILE_SORT_ALPHA: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name); - break; - case FILE_SORT_TIME: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_date); - break; - case FILE_SORT_SIZE: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_size); - break; - case FILE_SORT_EXTENSION: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_extension); + case FILE_SORT_ALPHA: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name); + break; + case FILE_SORT_TIME: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_date); + break; + case FILE_SORT_SIZE: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_size); + break; + case FILE_SORT_EXTENSION: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_extension); } filelist_filter(filelist); } -int filelist_islibrary(struct FileList* filelist, char* dir, char* group) +int filelist_islibrary(struct FileList *filelist, char *dir, char *group) { return BLO_is_a_library(filelist->dir, dir, group); } @@ -1009,27 +1009,27 @@ static int groupname_to_code(const char *group) char *lslash; BLI_strncpy(buf, group, sizeof(buf)); - lslash= BLI_last_slash(buf); + lslash = BLI_last_slash(buf); if (lslash) - lslash[0]= '\0'; + lslash[0] = '\0'; return BKE_idcode_from_name(buf); } -void filelist_from_library(struct FileList* filelist) +void filelist_from_library(struct FileList *filelist) { LinkNode *l, *names, *previews; - struct ImBuf* ima; + struct ImBuf *ima; int ok, i, nprevs, nnames, idcode; char filename[FILE_MAX]; char dir[FILE_MAX], group[GROUP_MAX]; /* name test */ - ok= filelist_islibrary(filelist, dir, group); + ok = filelist_islibrary(filelist, dir, group); if (!ok) { /* free */ if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= NULL; + filelist->libfiledata = NULL; return; } @@ -1038,40 +1038,40 @@ void filelist_from_library(struct FileList* filelist) /* there we go */ /* for the time being only read filedata when libfiledata==0 */ if (filelist->libfiledata == NULL) { - filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); + filelist->libfiledata = BLO_blendhandle_from_file(dir, NULL); if (filelist->libfiledata == NULL) return; } - idcode= groupname_to_code(group); + idcode = groupname_to_code(group); /* memory for strings is passed into filelist[i].relname * and freed in freefilelist */ if (idcode) { - previews= BLO_blendhandle_get_previews(filelist->libfiledata, idcode, &nprevs); - names= BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames); + previews = BLO_blendhandle_get_previews(filelist->libfiledata, idcode, &nprevs); + names = BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames); /* ugh, no rewind, need to reopen */ BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); + filelist->libfiledata = BLO_blendhandle_from_file(dir, NULL); } else { - previews= NULL; - nprevs= 0; - names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata); - nnames= BLI_linklist_length(names); + previews = NULL; + nprevs = 0; + names = BLO_blendhandle_get_linkable_groups(filelist->libfiledata); + nnames = BLI_linklist_length(names); } - filelist->numfiles= nnames + 1; - filelist->filelist= malloc(filelist->numfiles * sizeof(*filelist->filelist)); + filelist->numfiles = nnames + 1; + filelist->filelist = malloc(filelist->numfiles * sizeof(*filelist->filelist)); memset(filelist->filelist, 0, filelist->numfiles * sizeof(*filelist->filelist)); - filelist->filelist[0].relname= BLI_strdup(".."); + filelist->filelist[0].relname = BLI_strdup(".."); filelist->filelist[0].type |= S_IFDIR; - for (i=0, l= names; i<nnames; i++, l= l->next) { - char *blockname= l->link; + for (i = 0, l = names; i < nnames; i++, l = l->next) { + char *blockname = l->link; - filelist->filelist[i + 1].relname= BLI_strdup(blockname); + filelist->filelist[i + 1].relname = BLI_strdup(blockname); if (idcode) { filelist->filelist[i + 1].type |= S_IFREG; } @@ -1084,8 +1084,8 @@ void filelist_from_library(struct FileList* filelist) printf("filelist_from_library: error, found %d items, %d previews\n", nnames, nprevs); } else if (previews) { - for (i=0, l= previews; i<nnames; i++, l= l->next) { - PreviewImage *img= l->link; + for (i = 0, l = previews; i < nnames; i++, l = l->next) { + PreviewImage *img = l->link; if (img) { unsigned int w = img->w[ICON_SIZE_PREVIEW]; @@ -1095,7 +1095,7 @@ void filelist_from_library(struct FileList* filelist) /* first allocate imbuf for copying preview into it */ if (w > 0 && h > 0 && rect) { ima = IMB_allocImBuf(w, h, 32, IB_rect); - memcpy(ima->rect, rect, w*h*sizeof(unsigned int)); + memcpy(ima->rect, rect, w * h * sizeof(unsigned int)); filelist->filelist[i + 1].image = ima; filelist->filelist[i + 1].flags = IMAGEFILE; } @@ -1108,13 +1108,13 @@ void filelist_from_library(struct FileList* filelist) filelist_sort(filelist, FILE_SORT_ALPHA); - BLI_strncpy(G.main->name, filename, sizeof(filename)); // prevent G.main->name to change + BLI_strncpy(G.main->name, filename, sizeof(filename)); /* prevent G.main->name to change */ filelist->filter = 0; filelist_filter(filelist); } -void filelist_hideparent(struct FileList* filelist, short hide) +void filelist_hideparent(struct FileList *filelist, short hide) { filelist->hide_parent = hide; } @@ -1128,110 +1128,110 @@ void filelist_from_main(struct FileList *filelist) // filelist->type = FILE_MAIN; // XXXXX TODO: add modes to filebrowser - if (filelist->dir[0]=='/') filelist->dir[0]= 0; + if (filelist->dir[0] == '/') filelist->dir[0] = 0; if (filelist->dir[0]) { - idcode= groupname_to_code(filelist->dir); - if (idcode==0) filelist->dir[0]= 0; + idcode = groupname_to_code(filelist->dir); + if (idcode == 0) filelist->dir[0] = 0; } - if ( filelist->dir[0]==0) { + if (filelist->dir[0] == 0) { /* make directories */ - filelist->numfiles= 25; - filelist->filelist= (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)); + filelist->numfiles = 25; + filelist->filelist = (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)); - for (a=0; a<filelist->numfiles; a++) { + for (a = 0; a < filelist->numfiles; a++) { memset(&(filelist->filelist[a]), 0, sizeof(struct direntry)); filelist->filelist[a].type |= S_IFDIR; } - filelist->filelist[0].relname= BLI_strdup(".."); - filelist->filelist[2].relname= BLI_strdup("Scene"); - filelist->filelist[3].relname= BLI_strdup("Object"); - filelist->filelist[4].relname= BLI_strdup("Mesh"); - filelist->filelist[5].relname= BLI_strdup("Curve"); - filelist->filelist[6].relname= BLI_strdup("Metaball"); - filelist->filelist[7].relname= BLI_strdup("Material"); - filelist->filelist[8].relname= BLI_strdup("Texture"); - filelist->filelist[9].relname= BLI_strdup("Image"); - filelist->filelist[10].relname= BLI_strdup("Ika"); - filelist->filelist[11].relname= BLI_strdup("Wave"); - filelist->filelist[12].relname= BLI_strdup("Lattice"); - filelist->filelist[13].relname= BLI_strdup("Lamp"); - filelist->filelist[14].relname= BLI_strdup("Camera"); - filelist->filelist[15].relname= BLI_strdup("Ipo"); - filelist->filelist[16].relname= BLI_strdup("World"); - filelist->filelist[17].relname= BLI_strdup("Screen"); - filelist->filelist[18].relname= BLI_strdup("VFont"); - filelist->filelist[19].relname= BLI_strdup("Text"); - filelist->filelist[20].relname= BLI_strdup("Armature"); - filelist->filelist[21].relname= BLI_strdup("Action"); - filelist->filelist[22].relname= BLI_strdup("NodeTree"); - filelist->filelist[23].relname= BLI_strdup("Speaker"); + filelist->filelist[0].relname = BLI_strdup(".."); + filelist->filelist[2].relname = BLI_strdup("Scene"); + filelist->filelist[3].relname = BLI_strdup("Object"); + filelist->filelist[4].relname = BLI_strdup("Mesh"); + filelist->filelist[5].relname = BLI_strdup("Curve"); + filelist->filelist[6].relname = BLI_strdup("Metaball"); + filelist->filelist[7].relname = BLI_strdup("Material"); + filelist->filelist[8].relname = BLI_strdup("Texture"); + filelist->filelist[9].relname = BLI_strdup("Image"); + filelist->filelist[10].relname = BLI_strdup("Ika"); + filelist->filelist[11].relname = BLI_strdup("Wave"); + filelist->filelist[12].relname = BLI_strdup("Lattice"); + filelist->filelist[13].relname = BLI_strdup("Lamp"); + filelist->filelist[14].relname = BLI_strdup("Camera"); + filelist->filelist[15].relname = BLI_strdup("Ipo"); + filelist->filelist[16].relname = BLI_strdup("World"); + filelist->filelist[17].relname = BLI_strdup("Screen"); + filelist->filelist[18].relname = BLI_strdup("VFont"); + filelist->filelist[19].relname = BLI_strdup("Text"); + filelist->filelist[20].relname = BLI_strdup("Armature"); + filelist->filelist[21].relname = BLI_strdup("Action"); + filelist->filelist[22].relname = BLI_strdup("NodeTree"); + filelist->filelist[23].relname = BLI_strdup("Speaker"); filelist->filelist[24].relname= BLI_strdup("FreestyleLineStyle"); filelist_sort(filelist, FILE_SORT_ALPHA); } else { /* make files */ - idcode= groupname_to_code(filelist->dir); + idcode = groupname_to_code(filelist->dir); - lb= which_libbase(G.main, idcode ); + lb = which_libbase(G.main, idcode); if (lb == NULL) return; - id= lb->first; - filelist->numfiles= 0; + id = lb->first; + filelist->numfiles = 0; while (id) { if (!filelist->hide_dot || id->name[2] != '.') { filelist->numfiles++; } - id= id->next; + id = id->next; } /* XXXXX TODO: if databrowse F4 or append/link filelist->hide_parent has to be set */ - if (!filelist->hide_parent) filelist->numfiles+= 1; - filelist->filelist= filelist->numfiles > 0 ? (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)) : NULL; + if (!filelist->hide_parent) filelist->numfiles += 1; + filelist->filelist = filelist->numfiles > 0 ? (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)) : NULL; files = filelist->filelist; if (!filelist->hide_parent) { memset(&(filelist->filelist[0]), 0, sizeof(struct direntry)); - filelist->filelist[0].relname= BLI_strdup(".."); + filelist->filelist[0].relname = BLI_strdup(".."); filelist->filelist[0].type |= S_IFDIR; files++; } - id= lb->first; - totlib= totbl= 0; + id = lb->first; + totlib = totbl = 0; while (id) { ok = 1; if (ok) { if (!filelist->hide_dot || id->name[2] != '.') { memset(files, 0, sizeof(struct direntry)); - if (id->lib==NULL) - files->relname= BLI_strdup(id->name+2); + if (id->lib == NULL) + files->relname = BLI_strdup(id->name + 2); else { - files->relname= MEM_mallocN(FILE_MAX+32, "filename for lib"); - sprintf(files->relname, "%s | %s", id->lib->name, id->name+2); + files->relname = MEM_mallocN(FILE_MAX + 32, "filename for lib"); + sprintf(files->relname, "%s | %s", id->lib->name, id->name + 2); } files->type |= S_IFREG; -#if 0 // XXXXX TODO show the selection status of the objects +#if 0 // XXXXX TODO show the selection status of the objects if (!filelist->has_func) { /* F4 DATA BROWSE */ - if (idcode==ID_OB) { + if (idcode == ID_OB) { if ( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE; } - else if (idcode==ID_SCE) { + else if (idcode == ID_SCE) { if ( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE; } } #endif - files->nr= totbl+1; - files->poin= id; - fake= id->flag & LIB_FAKEUSER; + files->nr = totbl + 1; + files->poin = id; + fake = id->flag & LIB_FAKEUSER; if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) { files->flags |= IMAGEFILE; } @@ -1241,7 +1241,7 @@ void filelist_from_main(struct FileList *filelist) else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us); if (id->lib) { - if (totlib==0) firstlib= files; + if (totlib == 0) firstlib = files; totlib++; } @@ -1250,11 +1250,11 @@ void filelist_from_main(struct FileList *filelist) totbl++; } - id= id->next; + id = id->next; } /* only qsort of library blocks */ - if (totlib>1) { + if (totlib > 1) { qsort(firstlib, totlib, sizeof(struct direntry), compare_name); } } @@ -1264,10 +1264,10 @@ void filelist_from_main(struct FileList *filelist) static void thumbnail_joblist_free(ThumbnailJob *tj) { - FileImage* limg = tj->loadimages.first; + FileImage *limg = tj->loadimages.first; /* free the images not yet copied to the filelist -> these will get freed with the filelist */ - for ( ; limg; limg= limg->next) { + for (; limg; limg = limg->next) { if ((limg->img) && (!limg->done)) { IMB_freeImBuf(limg->img); } @@ -1277,26 +1277,26 @@ static void thumbnail_joblist_free(ThumbnailJob *tj) static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float *UNUSED(progress)) { - ThumbnailJob *tj= tjv; - FileImage* limg = tj->loadimages.first; + ThumbnailJob *tj = tjv; + FileImage *limg = tj->loadimages.first; - tj->stop= stop; - tj->do_update= do_update; + tj->stop = stop; + tj->do_update = do_update; - while ( (*stop==0) && (limg) ) { - if ( limg->flags & IMAGEFILE ) { + while ( (*stop == 0) && (limg) ) { + if (limg->flags & IMAGEFILE) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_IMAGE); } - else if ( limg->flags & BLENDERFILE ) { + else if (limg->flags & BLENDERFILE) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_BLEND); } - else if ( limg->flags & MOVIEFILE ) { + else if (limg->flags & MOVIEFILE) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_MOVIE); if (!limg->img) { - /* remember that file can't be loaded via IMB_open_anim */ - limg->flags &= ~MOVIEFILE; - limg->flags |= MOVIEFILE_ICON; - } + /* remember that file can't be loaded via IMB_open_anim */ + limg->flags &= ~MOVIEFILE; + limg->flags |= MOVIEFILE_ICON; + } } *do_update = TRUE; PIL_sleep_ms(10); @@ -1306,10 +1306,10 @@ static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float static void thumbnails_update(void *tjv) { - ThumbnailJob *tj= tjv; + ThumbnailJob *tj = tjv; if (tj->filelist && tj->filelist->filelist) { - FileImage* limg = tj->loadimages.first; + FileImage *limg = tj->loadimages.first; while (limg) { if (!limg->done && limg->img) { tj->filelist->filelist[limg->index].image = limg->img; @@ -1327,28 +1327,28 @@ static void thumbnails_update(void *tjv) static void thumbnails_free(void *tjv) { - ThumbnailJob *tj= tjv; + ThumbnailJob *tj = tjv; thumbnail_joblist_free(tj); MEM_freeN(tj); } -void thumbnails_start(struct FileList* filelist, const struct bContext* C) +void thumbnails_start(struct FileList *filelist, const struct bContext *C) { wmJob *steve; ThumbnailJob *tj; int idx; /* prepare job data */ - tj= MEM_callocN(sizeof(ThumbnailJob), "thumbnails\n"); + tj = MEM_callocN(sizeof(ThumbnailJob), "thumbnails\n"); tj->filelist = filelist; - for (idx = 0; idx < filelist->numfiles;idx++) { + for (idx = 0; idx < filelist->numfiles; idx++) { if (!filelist->filelist[idx].image) { - if ( (filelist->filelist[idx].flags & (IMAGEFILE|MOVIEFILE|BLENDERFILE)) ) { - FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); + if ( (filelist->filelist[idx].flags & (IMAGEFILE | MOVIEFILE | BLENDERFILE)) ) { + FileImage *limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); BLI_strncpy(limg->path, filelist->filelist[idx].path, FILE_MAX); - limg->index= idx; - limg->flags= filelist->filelist[idx].flags; + limg->index = idx; + limg->flags = filelist->filelist[idx].flags; BLI_addtail(&tj->loadimages, limg); } } @@ -1357,7 +1357,7 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C) BKE_reports_init(&tj->reports, RPT_PRINT); /* setup job */ - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", 0); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", 0); WM_jobs_customdata(steve, tj, thumbnails_free); WM_jobs_timer(steve, 0.5, NC_WINDOW, NC_WINDOW); WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update, NULL); @@ -1366,12 +1366,12 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C) WM_jobs_start(CTX_wm_manager(C), steve); } -void thumbnails_stop(struct FileList* filelist, const struct bContext* C) +void thumbnails_stop(struct FileList *filelist, const struct bContext *C) { WM_jobs_kill(CTX_wm_manager(C), filelist, NULL); } -int thumbnails_running(struct FileList* filelist, const struct bContext* C) +int thumbnails_running(struct FileList *filelist, const struct bContext *C) { return WM_jobs_test(CTX_wm_manager(C), filelist); } diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index 7a37c5fb3c5..32a31c51229 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -49,8 +49,8 @@ struct FileSelection; typedef enum FileSelType { FILE_SEL_REMOVE = 0, - FILE_SEL_ADD = 1, - FILE_SEL_TOGGLE = 2 + FILE_SEL_ADD = 1, + FILE_SEL_TOGGLE = 2 } FileSelType; typedef enum FileCheckType { @@ -59,49 +59,49 @@ typedef enum FileCheckType { CHECK_ALL = 3 } FileCheckType; -struct FileList * filelist_new(short type); -void filelist_init_icons(void); -void filelist_free_icons(void); -int filelist_find(struct FileList* filelist, const char *file); -void filelist_free(struct FileList* filelist); -void filelist_sort(struct FileList* filelist, short sort); -int filelist_numfiles(struct FileList* filelist); -const char * filelist_dir(struct FileList* filelist); -void filelist_setdir(struct FileList* filelist, const char *dir); -struct direntry * filelist_file(struct FileList* filelist, int index); -void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType select, unsigned int flag, FileCheckType check); -void filelist_select_file(struct FileList* filelist, int index, FileSelType select, unsigned int flag, FileCheckType check); -int filelist_is_selected(struct FileList* filelist, int index, FileCheckType check); -void filelist_hidedot(struct FileList* filelist, short hide); -void filelist_setfilter(struct FileList* filelist, unsigned int filter); -void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob); -void filelist_filter(struct FileList* filelist); -void filelist_imgsize(struct FileList* filelist, short w, short h); -struct ImBuf * filelist_getimage(struct FileList* filelist, int index); -struct ImBuf * filelist_geticon(struct FileList* filelist, int index); -short filelist_changed(struct FileList* filelist); -void filelist_readdir(struct FileList* filelist); +struct FileList * filelist_new(short type); +void filelist_init_icons(void); +void filelist_free_icons(void); +int filelist_find(struct FileList *filelist, const char *file); +void filelist_free(struct FileList *filelist); +void filelist_sort(struct FileList *filelist, short sort); +int filelist_numfiles(struct FileList *filelist); +const char * filelist_dir(struct FileList *filelist); +void filelist_setdir(struct FileList *filelist, const char *dir); +struct direntry * filelist_file(struct FileList *filelist, int index); +void filelist_select(struct FileList *filelist, FileSelection *sel, FileSelType select, unsigned int flag, FileCheckType check); +void filelist_select_file(struct FileList *filelist, int index, FileSelType select, unsigned int flag, FileCheckType check); +int filelist_is_selected(struct FileList *filelist, int index, FileCheckType check); +void filelist_hidedot(struct FileList *filelist, short hide); +void filelist_setfilter(struct FileList *filelist, unsigned int filter); +void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob); +void filelist_filter(struct FileList *filelist); +void filelist_imgsize(struct FileList *filelist, short w, short h); +struct ImBuf * filelist_getimage(struct FileList *filelist, int index); +struct ImBuf * filelist_geticon(struct FileList *filelist, int index); +short filelist_changed(struct FileList *filelist); +void filelist_readdir(struct FileList *filelist); -int filelist_empty(struct FileList* filelist); -void filelist_parent(struct FileList* filelist); +int filelist_empty(struct FileList *filelist); +void filelist_parent(struct FileList *filelist); -struct BlendHandle *filelist_lib(struct FileList* filelist); -int filelist_islibrary (struct FileList* filelist, char* dir, char* group); -void filelist_from_main(struct FileList* filelist); -void filelist_from_library(struct FileList* filelist); -void filelist_freelib(struct FileList* filelist); -void filelist_hideparent(struct FileList* filelist, short hide); +struct BlendHandle *filelist_lib(struct FileList *filelist); +int filelist_islibrary(struct FileList *filelist, char *dir, char *group); +void filelist_from_main(struct FileList *filelist); +void filelist_from_library(struct FileList *filelist); +void filelist_freelib(struct FileList *filelist); +void filelist_hideparent(struct FileList *filelist, short hide); -struct ListBase * folderlist_new(void); -void folderlist_free(struct ListBase* folderlist); -struct ListBase * folderlist_duplicate(ListBase* folderlist); -void folderlist_popdir(struct ListBase* folderlist, char *dir); -void folderlist_pushdir(struct ListBase* folderlist, const char *dir); -int folderlist_clear_next(struct SpaceFile* sfile); +struct ListBase * folderlist_new(void); +void folderlist_free(struct ListBase *folderlist); +struct ListBase * folderlist_duplicate(ListBase *folderlist); +void folderlist_popdir(struct ListBase *folderlist, char *dir); +void folderlist_pushdir(struct ListBase *folderlist, const char *dir); +int folderlist_clear_next(struct SpaceFile *sfile); -void thumbnails_stop(struct FileList* filelist, const struct bContext* C); -void thumbnails_start(struct FileList* filelist, const struct bContext* C); -int thumbnails_running(struct FileList* filelist, const struct bContext* C); +void thumbnails_stop(struct FileList *filelist, const struct bContext *C); +void thumbnails_start(struct FileList *filelist, const struct bContext *C); +int thumbnails_running(struct FileList *filelist, const struct bContext *C); #ifdef __cplusplus } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index b0818d40e53..adb3e7acca5 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -86,7 +86,7 @@ # include <fnmatch.h> #endif -FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile) +FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile) { if (!sfile->params) { ED_fileselect_set_params(sfile); @@ -101,7 +101,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* create new parameters if necessary */ if (!sfile->params) { - sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); + sfile->params = MEM_callocN(sizeof(FileSelectParams), "fileselparams"); /* set path to most recently opened .blend */ BLI_split_dirfile(G.main->name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); sfile->params->filter_glob[0] = '\0'; @@ -111,11 +111,11 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* set the parameters from the operator, if it exists */ if (op) { - const short is_files= (RNA_struct_find_property(op->ptr, "files") != NULL); - const short is_filepath= (RNA_struct_find_property(op->ptr, "filepath") != NULL); - const short is_filename= (RNA_struct_find_property(op->ptr, "filename") != NULL); - const short is_directory= (RNA_struct_find_property(op->ptr, "directory") != NULL); - const short is_relative_path= (RNA_struct_find_property(op->ptr, "relative_path") != NULL); + const short is_files = (RNA_struct_find_property(op->ptr, "files") != NULL); + const short is_filepath = (RNA_struct_find_property(op->ptr, "filepath") != NULL); + const short is_filename = (RNA_struct_find_property(op->ptr, "filename") != NULL); + const short is_directory = (RNA_struct_find_property(op->ptr, "directory") != NULL); + const short is_relative_path = (RNA_struct_find_property(op->ptr, "relative_path") != NULL); BLI_strncpy(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title)); @@ -129,7 +129,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) RNA_string_get(op->ptr, "filepath", name); if (params->type == FILE_LOADLIB) { BLI_strncpy(params->dir, name, sizeof(params->dir)); - sfile->params->file[0]= '\0'; + sfile->params->file[0] = '\0'; } else { BLI_split_dirfile(name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); @@ -138,7 +138,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) else { if (is_directory && RNA_struct_property_is_set(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", params->dir); - sfile->params->file[0]= '\0'; + sfile->params->file[0] = '\0'; } if (is_filename && RNA_struct_property_is_set(op->ptr, "filename")) { @@ -151,7 +151,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) BLI_path_abs(params->dir, G.main->name); } - if (is_directory==TRUE && is_filename==FALSE && is_filepath==FALSE && is_files==FALSE) { + if (is_directory == TRUE && is_filename == FALSE && is_filepath == FALSE && is_files == FALSE) { params->flag |= FILE_DIRSEL_ONLY; } else { @@ -183,7 +183,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->filter |= RNA_boolean_get(op->ptr, "filter_collada") ? COLLADAFILE : 0; if (RNA_struct_find_property(op->ptr, "filter_glob")) { RNA_string_get(op->ptr, "filter_glob", params->filter_glob); - params->filter |= (OPERATORFILE|FOLDERFILE); + params->filter |= (OPERATORFILE | FOLDERFILE); } else { params->filter_glob[0] = '\0'; @@ -213,17 +213,17 @@ short ED_fileselect_set_params(SpaceFile *sfile) } if (RNA_struct_find_property(op->ptr, "display_type")) - params->display= RNA_enum_get(op->ptr, "display_type"); + params->display = RNA_enum_get(op->ptr, "display_type"); - if (params->display==FILE_DEFAULTDISPLAY) { + if (params->display == FILE_DEFAULTDISPLAY) { if (U.uiflag & USER_SHOW_THUMBNAILS) { - if (params->filter & (IMAGEFILE|MOVIEFILE)) - params->display= FILE_IMGDISPLAY; + if (params->filter & (IMAGEFILE | MOVIEFILE)) + params->display = FILE_IMGDISPLAY; else - params->display= FILE_SHORTDISPLAY; + params->display = FILE_SHORTDISPLAY; } else { - params->display= FILE_SHORTDISPLAY; + params->display = FILE_SHORTDISPLAY; } } @@ -252,7 +252,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* switching thumbnails needs to recalc layout [#28809] */ if (sfile->layout) { - sfile->layout->dirty= TRUE; + sfile->layout->dirty = TRUE; } return 1; @@ -265,28 +265,28 @@ void ED_fileselect_reset_params(SpaceFile *sfile) sfile->params->title[0] = '\0'; } -int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) +int ED_fileselect_layout_numfiles(FileLayout *layout, struct ARegion *ar) { int numfiles; if (layout->flag & FILE_LAYOUT_HOR) { - int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x); + int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2 * layout->tile_border_x); numfiles = (int)((float)width / (float)layout->tile_w + 0.5f); - return numfiles*layout->rows; + return numfiles * layout->rows; } else { - int height = (int)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y); - numfiles = (int)((float)height/(float)layout->tile_h + 0.5f); - return numfiles*layout->columns; + int height = (int)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2 * layout->tile_border_y); + numfiles = (int)((float)height / (float)layout->tile_h + 0.5f); + return numfiles * layout->columns; } } static int is_inside(int x, int y, int cols, int rows) { - return ( (x >= 0) && (x<cols) && (y>=0) && (y<rows) ); + return ( (x >= 0) && (x < cols) && (y >= 0) && (y < rows) ); } -FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* rect) +FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *rect) { int colmin, colmax, rowmin, rowmax; FileSelection sel; @@ -295,43 +295,43 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* r if (layout == NULL) return sel; - colmin = (rect->xmin)/(layout->tile_w + 2*layout->tile_border_x); - rowmin = (rect->ymin)/(layout->tile_h + 2*layout->tile_border_y); - colmax = (rect->xmax)/(layout->tile_w + 2*layout->tile_border_x); - rowmax = (rect->ymax)/(layout->tile_h + 2*layout->tile_border_y); + colmin = (rect->xmin) / (layout->tile_w + 2 * layout->tile_border_x); + rowmin = (rect->ymin) / (layout->tile_h + 2 * layout->tile_border_y); + colmax = (rect->xmax) / (layout->tile_w + 2 * layout->tile_border_x); + rowmax = (rect->ymax) / (layout->tile_h + 2 * layout->tile_border_y); if (is_inside(colmin, rowmin, layout->columns, layout->rows) || is_inside(colmax, rowmax, layout->columns, layout->rows) ) { - CLAMP(colmin, 0, layout->columns-1); - CLAMP(rowmin, 0, layout->rows-1); - CLAMP(colmax, 0, layout->columns-1); - CLAMP(rowmax, 0, layout->rows-1); + CLAMP(colmin, 0, layout->columns - 1); + CLAMP(rowmin, 0, layout->rows - 1); + CLAMP(colmax, 0, layout->columns - 1); + CLAMP(rowmax, 0, layout->rows - 1); } - if ((colmin > layout->columns-1) || (rowmin > layout->rows-1)) { + if ((colmin > layout->columns - 1) || (rowmin > layout->rows - 1)) { sel.first = -1; } else { if (layout->flag & FILE_LAYOUT_HOR) - sel.first = layout->rows*colmin + rowmin; + sel.first = layout->rows * colmin + rowmin; else - sel.first = colmin + layout->columns*rowmin; + sel.first = colmin + layout->columns * rowmin; } - if ((colmax > layout->columns-1) || (rowmax > layout->rows-1)) { + if ((colmax > layout->columns - 1) || (rowmax > layout->rows - 1)) { sel.last = -1; } else { if (layout->flag & FILE_LAYOUT_HOR) - sel.last = layout->rows*colmax + rowmax; + sel.last = layout->rows * colmax + rowmax; else - sel.last = colmax + layout->columns*rowmax; + sel.last = colmax + layout->columns * rowmax; } return sel; } -int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) +int ED_fileselect_layout_offset(FileLayout *layout, int x, int y) { int offsetx, offsety; int active_file; @@ -339,35 +339,35 @@ int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) if (layout == NULL) return -1; - offsetx = (x)/(layout->tile_w + 2*layout->tile_border_x); - offsety = (y)/(layout->tile_h + 2*layout->tile_border_y); + offsetx = (x) / (layout->tile_w + 2 * layout->tile_border_x); + offsety = (y) / (layout->tile_h + 2 * layout->tile_border_y); if (offsetx > layout->columns - 1) return -1; if (offsety > layout->rows - 1) return -1; if (layout->flag & FILE_LAYOUT_HOR) - active_file = layout->rows*offsetx + offsety; + active_file = layout->rows * offsetx + offsety; else - active_file = offsetx + layout->columns*offsety; + active_file = offsetx + layout->columns * offsety; return active_file; } -void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y) +void ED_fileselect_layout_tilepos(FileLayout *layout, int tile, int *x, int *y) { if (layout->flag == FILE_LAYOUT_HOR) { - *x = layout->tile_border_x + (tile/layout->rows)*(layout->tile_w+2*layout->tile_border_x); - *y = layout->tile_border_y + (tile%layout->rows)*(layout->tile_h+2*layout->tile_border_y); + *x = layout->tile_border_x + (tile / layout->rows) * (layout->tile_w + 2 * layout->tile_border_x); + *y = layout->tile_border_y + (tile % layout->rows) * (layout->tile_h + 2 * layout->tile_border_y); } else { - *x = layout->tile_border_x + ((tile)%layout->columns)*(layout->tile_w+2*layout->tile_border_x); - *y = layout->tile_border_y + ((tile)/layout->columns)*(layout->tile_h+2*layout->tile_border_y); + *x = layout->tile_border_x + ((tile) % layout->columns) * (layout->tile_w + 2 * layout->tile_border_x); + *y = layout->tile_border_y + ((tile) / layout->columns) * (layout->tile_h + 2 * layout->tile_border_y); } } /* Shorten a string to a given width w. * If front is set, shorten from the front, * otherwise shorten from the end. */ -float file_shorten_string(char* string, float w, int front) +float file_shorten_string(char *string, float w, int front) { char temp[FILE_MAX]; short shortened = 0; @@ -384,23 +384,23 @@ float file_shorten_string(char* string, float w, int front) char *s = string; BLI_strncpy(temp, "...", 4); pad = file_string_width(temp); - while ((*s) && (sw+pad>w)) { + while ((*s) && (sw + pad > w)) { s++; sw = file_string_width(s); shortened = 1; } if (shortened) { int slen = strlen(s); - BLI_strncpy(temp+3, s, slen+1); - temp[slen+4] = '\0'; - BLI_strncpy(string, temp, slen+4); + BLI_strncpy(temp + 3, s, slen + 1); + temp[slen + 4] = '\0'; + BLI_strncpy(string, temp, slen + 4); } } else { char *s = string; - while (sw>w) { + while (sw > w) { int slen = strlen(string); - string[slen-1] = '\0'; + string[slen - 1] = '\0'; sw = file_string_width(s); shortened = 1; } @@ -408,7 +408,7 @@ float file_shorten_string(char* string, float w, int front) if (shortened) { int slen = strlen(string); if (slen > 3) { - BLI_strncpy(string+slen-3, "...", 4); + BLI_strncpy(string + slen - 3, "...", 4); } } } @@ -416,9 +416,9 @@ float file_shorten_string(char* string, float w, int front) return sw; } -float file_string_width(const char* str) +float file_string_width(const char *str) { - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); return BLF_width(style->widget.uifont_id, str); } @@ -428,28 +428,28 @@ float file_font_pointsize(void) #if 0 float s; char tmp[2] = "X"; - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); s = BLF_height(style->widget.uifont_id, tmp); return style->widget.points; #else - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); return style->widget.points * UI_DPI_FAC; #endif } -static void column_widths(struct FileList* files, struct FileLayout* layout) +static void column_widths(struct FileList *files, struct FileLayout *layout) { int i; int numfiles = filelist_numfiles(files); - for (i=0; i<MAX_FILE_COLUMN; ++i) { + for (i = 0; i < MAX_FILE_COLUMN; ++i) { layout->column_widths[i] = 0; } - for (i=0; (i < numfiles); ++i) { - struct direntry* file = filelist_file(files, i); + for (i = 0; (i < numfiles); ++i) { + struct direntry *file = filelist_file(files, i); if (file) { float len; len = file_string_width(file->relname); @@ -475,8 +475,8 @@ static void column_widths(struct FileList* files, struct FileLayout* layout) void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) { FileSelectParams *params = ED_fileselect_get_params(sfile); - FileLayout *layout= NULL; - View2D *v2d= &ar->v2d; + FileLayout *layout = NULL; + View2D *v2d = &ar->v2d; int maxlen = 0; int numfiles; int textheight; @@ -501,17 +501,17 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_border_y = 6; layout->prv_border_x = 6; layout->prv_border_y = 6; - layout->tile_w = layout->prv_w + 2*layout->prv_border_x; - layout->tile_h = layout->prv_h + 2*layout->prv_border_y + textheight; - layout->width= (int)(v2d->cur.xmax - v2d->cur.xmin - 2*layout->tile_border_x); - layout->columns= layout->width / (layout->tile_w + 2*layout->tile_border_x); + layout->tile_w = layout->prv_w + 2 * layout->prv_border_x; + layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight; + layout->width = (int)(v2d->cur.xmax - v2d->cur.xmin - 2 * layout->tile_border_x); + layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x); if (layout->columns > 0) - layout->rows= numfiles/layout->columns + 1; // XXX dirty, modulo is zero + layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero else { layout->columns = 1; - layout->rows= numfiles + 1; // XXX dirty, modulo is zero + layout->rows = numfiles + 1; // XXX dirty, modulo is zero } - layout->height= sfile->layout->rows*(layout->tile_h+2*layout->tile_border_y) + layout->tile_border_y*2; + layout->height = sfile->layout->rows * (layout->tile_h + 2 * layout->tile_border_y) + layout->tile_border_y * 2; layout->flag = FILE_LAYOUT_VER; } else { @@ -521,45 +521,45 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_border_y = 2; layout->prv_border_x = 0; layout->prv_border_y = 0; - layout->tile_h = textheight*3/2; - layout->height= (int)(v2d->cur.ymax - v2d->cur.ymin - 2*layout->tile_border_y); - layout->rows = layout->height / (layout->tile_h + 2*layout->tile_border_y); + layout->tile_h = textheight * 3 / 2; + layout->height = (int)(v2d->cur.ymax - v2d->cur.ymin - 2 * layout->tile_border_y); + layout->rows = layout->height / (layout->tile_h + 2 * layout->tile_border_y); column_widths(sfile->files, layout); if (params->display == FILE_SHORTDISPLAY) { maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + - (int)layout->column_widths[COLUMN_NAME] + 12 + - (int)layout->column_widths[COLUMN_SIZE] + 12; + (int)layout->column_widths[COLUMN_NAME] + 12 + + (int)layout->column_widths[COLUMN_SIZE] + 12; } else { maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + - (int)layout->column_widths[COLUMN_NAME] + 12 + + (int)layout->column_widths[COLUMN_NAME] + 12 + #ifndef WIN32 - (int)layout->column_widths[COLUMN_MODE1] + 12 + - (int)layout->column_widths[COLUMN_MODE2] + 12 + - (int)layout->column_widths[COLUMN_MODE3] + 12 + - (int)layout->column_widths[COLUMN_OWNER] + 12 + + (int)layout->column_widths[COLUMN_MODE1] + 12 + + (int)layout->column_widths[COLUMN_MODE2] + 12 + + (int)layout->column_widths[COLUMN_MODE3] + 12 + + (int)layout->column_widths[COLUMN_OWNER] + 12 + #endif - (int)layout->column_widths[COLUMN_DATE] + 12 + - (int)layout->column_widths[COLUMN_TIME] + 12 + - (int)layout->column_widths[COLUMN_SIZE] + 12; + (int)layout->column_widths[COLUMN_DATE] + 12 + + (int)layout->column_widths[COLUMN_TIME] + 12 + + (int)layout->column_widths[COLUMN_SIZE] + 12; } layout->tile_w = maxlen; if (layout->rows > 0) - layout->columns = numfiles/layout->rows + 1; // XXX dirty, modulo is zero + layout->columns = numfiles / layout->rows + 1; // XXX dirty, modulo is zero else { layout->rows = 1; layout->columns = numfiles + 1; // XXX dirty, modulo is zero } - layout->width = sfile->layout->columns * (layout->tile_w + 2*layout->tile_border_x) + layout->tile_border_x*2; + layout->width = sfile->layout->columns * (layout->tile_w + 2 * layout->tile_border_x) + layout->tile_border_x * 2; layout->flag = FILE_LAYOUT_HOR; } - layout->dirty= FALSE; + layout->dirty = FALSE; } -FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar) +FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar) { if (!sfile->layout) { ED_fileselect_init_layout(sfile, ar); @@ -569,13 +569,13 @@ FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar void file_change_dir(bContext *C, int checkdir) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { ED_fileselect_clear(C, sfile); - if (checkdir && BLI_is_dir(sfile->params->dir)==0) { + if (checkdir && BLI_is_dir(sfile->params->dir) == 0) { BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), sizeof(sfile->params->dir)); /* could return but just refresh the current dir */ } @@ -589,28 +589,34 @@ void file_change_dir(bContext *C, int checkdir) } } -int file_select_match(struct SpaceFile *sfile, const char *pattern) +int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file) { int match = 0; - if (strchr(pattern, '*') || strchr(pattern, '?') || strchr(pattern, '[')) { - int i; - struct direntry *file; - int n = filelist_numfiles(sfile->files); - - for (i = 0; i < n; i++) { - file = filelist_file(sfile->files, i); - if (fnmatch(pattern, file->relname, 0) == 0) { - file->selflag |= SELECTED_FILE; - match = 1; + + int i; + struct direntry *file; + int n = filelist_numfiles(sfile->files); + + /* select any file that matches the pattern, this includes exact match + * if the user selects a single file by entering the filename + */ + for (i = 0; i < n; i++) { + file = filelist_file(sfile->files, i); + if (fnmatch(pattern, file->relname, 0) == 0) { + file->selflag |= SELECTED_FILE; + if (!match) { + BLI_strncpy(matched_file, file->relname, FILE_MAX); } + match = 1; } } + return match; } void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); /* search if str matches the beginning of name */ if (str[0] && sfile->files) { @@ -624,10 +630,10 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) dir = opendir(dirname); if (dir) { - AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); + AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); while ((de = readdir(dir)) != NULL) { - if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) { + if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0) { /* pass */ } else { @@ -658,16 +664,16 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) void autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); /* search if str matches the beginning of name */ if (str[0] && sfile->files) { - AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); + AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); int nentries = filelist_numfiles(sfile->files); int i; - for (i= 0; i<nentries; ++i) { - struct direntry* file = filelist_file(sfile->files, i); + for (i = 0; i < nentries; ++i) { + struct direntry *file = filelist_file(sfile->files, i); if (file && S_ISREG(file->type)) { autocomplete_do_name(autocpl, file->relname); } @@ -686,7 +692,7 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile) } sfile->params->active_file = -1; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) @@ -703,7 +709,7 @@ void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) if (sfile->files) { ED_fileselect_clear(C, sfile); MEM_freeN(sfile->files); - sfile->files= NULL; + sfile->files = NULL; } } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 6d2381e64d5..0366043aaa0 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -449,9 +449,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction | - kLSSharedFileListDoNotMountVolumes, - &cfURL, NULL); + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, + &cfURL, NULL); if (err != noErr) continue; diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index e5b3d54ac9f..d7576d71933 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -45,42 +45,42 @@ typedef enum FSMenuCategory { struct FSMenu; -struct FSMenu* fsmenu_get (void); +struct FSMenu *fsmenu_get(void); - /** Returns the number of entries in the Fileselect Menu */ -int fsmenu_get_nentries (struct FSMenu* fsmenu, FSMenuCategory category); +/** Returns the number of entries in the Fileselect Menu */ +int fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category); - /** Returns the fsmenu entry at \a index (or NULL if a bad index) - * or a separator. - */ -char* fsmenu_get_entry (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Returns the fsmenu entry at \a index (or NULL if a bad index) + * or a separator. + */ +char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** Inserts a new fsmenu entry with the given \a path. - * Duplicate entries are not added. - * \param sorted Should entry be inserted in sorted order? - */ -void fsmenu_insert_entry (struct FSMenu* fsmenu, FSMenuCategory category, const char *path, int sorted, short save); +/** Inserts a new fsmenu entry with the given \a path. + * Duplicate entries are not added. + * \param sorted Should entry be inserted in sorted order? + */ +void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save); - /** Return whether the entry was created by the user and can be saved and deleted */ -short fsmenu_can_save (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Return whether the entry was created by the user and can be saved and deleted */ +short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** Removes the fsmenu entry at the given \a index. */ -void fsmenu_remove_entry (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Removes the fsmenu entry at the given \a index. */ +void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** saves the 'bookmarks' to the specified file */ -void fsmenu_write_file (struct FSMenu* fsmenu, const char *filename); +/** saves the 'bookmarks' to the specified file */ +void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename); - /** reads the 'bookmarks' from the specified file */ -void fsmenu_read_bookmarks (struct FSMenu* fsmenu, const char *filename); +/** reads the 'bookmarks' from the specified file */ +void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename); - /** adds system specific directories */ -void fsmenu_read_system (struct FSMenu* fsmenu, int read_bookmarks); +/** adds system specific directories */ +void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks); - /** Free's all the memory associated with the fsmenu */ -void fsmenu_free (struct FSMenu* fsmenu); +/** Free's all the memory associated with the fsmenu */ +void fsmenu_free(struct FSMenu *fsmenu); - /** Refresh system directory menu */ -void fsmenu_refresh_system_category (struct FSMenu* fsmenu); +/** Refresh system directory menu */ +void fsmenu_refresh_system_category(struct FSMenu *fsmenu); #endif diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index a90daa7e1e9..79979603f54 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -63,7 +63,7 @@ #include "UI_view2d.h" -#include "file_intern.h" // own include +#include "file_intern.h" // own include #include "fsmenu.h" #include "filelist.h" @@ -74,36 +74,36 @@ static SpaceLink *file_new(const bContext *UNUSED(C)) ARegion *ar; SpaceFile *sfile; - sfile= MEM_callocN(sizeof(SpaceFile), "initfile"); - sfile->spacetype= SPACE_FILE; + sfile = MEM_callocN(sizeof(SpaceFile), "initfile"); + sfile->spacetype = SPACE_FILE; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for file"); + ar = MEM_callocN(sizeof(ARegion), "header for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_TOP; /* channel list region */ - ar= MEM_callocN(sizeof(ARegion), "channel area for file"); + ar = MEM_callocN(sizeof(ARegion), "channel area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; /* ui list region */ - ar= MEM_callocN(sizeof(ARegion), "ui area for file"); + ar = MEM_callocN(sizeof(ARegion), "ui area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_TOP; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for file"); + ar = MEM_callocN(sizeof(ARegion), "main area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keeptot= V2D_KEEPTOT_STRICT; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; return (SpaceLink *)sfile; } @@ -111,31 +111,31 @@ static SpaceLink *file_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void file_free(SpaceLink *sl) { - SpaceFile *sfile= (SpaceFile *) sl; + SpaceFile *sfile = (SpaceFile *) sl; if (sfile->files) { // XXXXX would need to do thumbnails_stop here, but no context available filelist_freelib(sfile->files); filelist_free(sfile->files); MEM_freeN(sfile->files); - sfile->files= NULL; + sfile->files = NULL; } if (sfile->folders_prev) { folderlist_free(sfile->folders_prev); MEM_freeN(sfile->folders_prev); - sfile->folders_prev= NULL; + sfile->folders_prev = NULL; } if (sfile->folders_next) { folderlist_free(sfile->folders_next); MEM_freeN(sfile->folders_next); - sfile->folders_next= NULL; + sfile->folders_next = NULL; } if (sfile->params) { MEM_freeN(sfile->params); - sfile->params= NULL; + sfile->params = NULL; } if (sfile->layout) { @@ -148,27 +148,27 @@ static void file_free(SpaceLink *sl) /* spacetype; init callback, area size changes, screen set, etc */ static void file_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceFile *sfile= (SpaceFile*)sa->spacedata.first; + SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; //printf("file_init\n"); /* refresh system directory list */ fsmenu_refresh_system_category(fsmenu_get()); - if (sfile->layout) sfile->layout->dirty= TRUE; + if (sfile->layout) sfile->layout->dirty = TRUE; } static SpaceLink *file_duplicate(SpaceLink *sl) { - SpaceFile *sfileo= (SpaceFile*)sl; - SpaceFile *sfilen= MEM_dupallocN(sl); + SpaceFile *sfileo = (SpaceFile *)sl; + SpaceFile *sfilen = MEM_dupallocN(sl); /* clear or remove stuff from old */ sfilen->op = NULL; /* file window doesn't own operators */ if (sfileo->params) { sfilen->files = filelist_new(sfileo->params->type); - sfilen->params= MEM_dupallocN(sfileo->params); + sfilen->params = MEM_dupallocN(sfileo->params); filelist_setdir(sfilen->files, sfilen->params->dir); } @@ -179,14 +179,14 @@ static SpaceLink *file_duplicate(SpaceLink *sl) sfilen->folders_next = folderlist_duplicate(sfileo->folders_next); if (sfileo->layout) { - sfilen->layout= MEM_dupallocN(sfileo->layout); + sfilen->layout = MEM_dupallocN(sfileo->layout); } return (SpaceLink *)sfilen; } static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); if (!sfile->folders_prev) @@ -203,7 +203,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (filelist_empty(sfile->files)) { thumbnails_stop(sfile->files, C); filelist_readdir(sfile->files); - if (params->sort!=FILE_SORT_NONE) { + if (params->sort != FILE_SORT_NONE) { filelist_sort(sfile->files, params->sort); } BLI_strncpy(params->dir, filelist_dir(sfile->files), FILE_MAX); @@ -212,7 +212,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) } } else { - if (params->sort!=FILE_SORT_NONE) { + if (params->sort != FILE_SORT_NONE) { thumbnails_stop(sfile->files, C); filelist_sort(sfile->files, params->sort); if (params->display == FILE_IMGDISPLAY) { @@ -237,7 +237,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (params->renamefile[0] != '\0') { int idx = filelist_find(sfile->files, params->renamefile); if (idx >= 0) { - struct direntry *file= filelist_file(sfile->files, idx); + struct direntry *file = filelist_file(sfile->files, idx); if (file) { file->selflag |= EDITING_FILE; } @@ -245,7 +245,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) BLI_strncpy(sfile->params->renameedit, sfile->params->renamefile, sizeof(sfile->params->renameedit)); params->renamefile[0] = '\0'; } - if (sfile->layout) sfile->layout->dirty= TRUE; + if (sfile->layout) sfile->layout->dirty = TRUE; } @@ -307,11 +307,11 @@ static void file_main_area_listener(ARegion *ar, wmNotifier *wmn) static void file_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); - FileLayout *layout=NULL; + FileLayout *layout = NULL; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; float col[3]; @@ -355,7 +355,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) /* on first read, find active file */ if (params->active_file == -1) { - wmEvent *event= CTX_wm_window(C)->eventstate; + wmEvent *event = CTX_wm_window(C)->eventstate; file_hilight_set(sfile, ar, event->x, event->y); } @@ -365,7 +365,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); @@ -553,58 +553,58 @@ static void file_ui_area_listener(ARegion *ar, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_file(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype file"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file"); ARegionType *art; - st->spaceid= SPACE_FILE; + st->spaceid = SPACE_FILE; strncpy(st->name, "File", BKE_ST_MAXNAME); - st->new= file_new; - st->free= file_free; - st->init= file_init; - st->duplicate= file_duplicate; - st->refresh= file_refresh; - st->listener= file_listener; - st->operatortypes= file_operatortypes; - st->keymap= file_keymap; + st->new = file_new; + st->free = file_free; + st->init = file_init; + st->duplicate = file_duplicate; + st->refresh = file_refresh; + st->listener = file_listener; + st->operatortypes = file_operatortypes; + st->keymap = file_keymap; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_WINDOW; - art->init= file_main_area_init; - art->draw= file_main_area_draw; - art->listener= file_main_area_listener; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->init = file_main_area_init; + art->draw = file_main_area_draw; + art->listener = file_main_area_listener; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; - art->init= file_header_area_init; - art->draw= file_header_area_draw; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; + art->init = file_header_area_init; + art->draw = file_header_area_draw; // art->listener= file_header_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: ui */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_UI; - art->prefsizey= 60; - art->keymapflag= ED_KEYMAP_UI; - art->listener= file_ui_area_listener; - art->init= file_ui_area_init; - art->draw= file_ui_area_draw; + art->prefsizey = 60; + art->keymapflag = ED_KEYMAP_UI; + art->listener = file_ui_area_listener; + art->init = file_ui_area_init; + art->draw = file_ui_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: channels (directories) */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex= 240; - art->keymapflag= ED_KEYMAP_UI; - art->listener= file_channel_area_listener; - art->init= file_channel_area_init; - art->draw= file_channel_area_draw; + art->prefsizex = 240; + art->keymapflag = ED_KEYMAP_UI; + art->listener = file_channel_area_listener; + art->init = file_channel_area_init; + art->draw = file_channel_area_draw; BLI_addhead(&st->regiontypes, art); file_panels_register(art); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index ddcd46ba817..efe62eaf495 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -142,19 +142,19 @@ static void graph_panel_view(const bContext *C, Panel *pa) RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); /* 2D-Cursor */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); - row = uiLayoutSplit(sub, 0.7, 1); + row = uiLayoutSplit(sub, 0.7f, TRUE); uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); - row = uiLayoutSplit(sub, 0.7, 1); + row = uiLayoutSplit(sub, 0.7f, TRUE); uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE); } @@ -183,24 +183,24 @@ static void graph_panel_properties(const bContext *C, Panel *pa) /* user-friendly 'name' for F-Curve */ /* TODO: only show the path if this is invalid? */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); icon = getname_anim_fcurve(name, ale->id, fcu); uiItemL(col, name, icon); /* RNA-Path Editing - only really should be enabled when things aren't working */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0); uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA); uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE); /* color settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Display Color:"), ICON_NONE); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM)); uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); @@ -307,7 +307,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) } /* interpolation */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); /* numerical coordinate editing @@ -315,7 +315,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) * and unit conversion magic that cannot be achieved using a purely RNA-approach */ // XXX: - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* keyframe itself */ { uiItemL(col, IFACE_("Key:"), ICON_NONE); @@ -469,7 +469,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* Target ID */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:")); /* Target Property */ @@ -480,7 +480,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa /* get pointer for resolving the property selected */ RNA_id_pointer_create(dtar->id, &root_ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* rna path */ uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, IFACE_("Path")); } @@ -501,7 +501,7 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:")); if (dtar->id && ob1->pose) { @@ -511,7 +511,7 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar * uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); } - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:")); if (dtar2->id && ob2->pose) { @@ -537,7 +537,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:")); if (dtar->id && ob1->pose) { @@ -549,7 +549,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:")); if (dtar2->id && ob2->pose) { @@ -574,7 +574,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* properties */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:")); if (dtar->id && ob->pose) { @@ -584,7 +584,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); } - sub = uiLayoutColumn(layout, 1); + sub = uiLayoutColumn(layout, TRUE); uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); } @@ -612,7 +612,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL); /* general actions - management */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22, NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); @@ -625,7 +625,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* driver-level settings - type, expressions, and errors */ RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); block = uiLayoutGetBlock(col); uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); @@ -644,13 +644,13 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR); } - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); /* debug setting */ uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); /* value of driver */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { - uiLayout *row = uiLayoutRow(col, 1); + uiLayout *row = uiLayoutRow(col, TRUE); char valBuf[32]; uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); @@ -660,7 +660,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) } /* add driver variables */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver")); @@ -672,14 +672,14 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiLayout *box, *row; /* sub-layout column for this variable's settings */ - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); /* header panel */ box = uiLayoutBox(col); /* first row context info for driver */ RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); /* variable name */ uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); @@ -692,7 +692,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiBlockSetEmboss(block, UI_EMBOSS); /* variable type */ - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); /* variable type settings */ @@ -718,7 +718,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) char valBuf[32]; box = uiLayoutBox(col); - row = uiLayoutRow(box, 1); + row = uiLayoutRow(box, TRUE); uiItemL(row, IFACE_("Value:"), ICON_NONE); BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); @@ -760,7 +760,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) /* 'add modifier' button at top of panel */ { - row = uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a 'add modifier' operator @@ -768,14 +768,14 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) 10, 0, 150, 20, TIP_("Adds a new F-Curve Modifier for the active F-Curve")); /* copy/paste (as sub-row)*/ - row = uiLayoutRow(row, 1); + row = uiLayoutRow(row, TRUE); uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); } /* draw each modifier */ for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm); } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 332a2ecada4..aa596b8b635 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -512,7 +512,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image int wmenu1, wmenu2, wmenu3, layer; char *strp; - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); /* layer menu is 1/3 larger than pass */ wmenu1 = (2 * w) / 5; @@ -552,7 +552,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, uiBut *but; const float dpi_fac = UI_DPI_FAC; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (rr == NULL || iuser == NULL) return; @@ -693,13 +693,13 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); - row = uiLayoutRow(row, 0); + row = uiLayoutRow(row, FALSE); uiLayoutSetEnabled(row, ima->packedfile == NULL); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); @@ -733,26 +733,26 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (compact == 0) { /* background image view doesnt need these */ uiItemS(layout); - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* XXX Why only display fields_per_frame only for video image types? * And why allow fields for non-video image types at all??? */ if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - uiLayout *subsplit = uiLayoutSplit(col, 0, 0); - uiLayout *subcol = uiLayoutColumn(subsplit, 0); + uiLayout *subsplit = uiLayoutSplit(col, 0.0f, FALSE); + uiLayout *subcol = uiLayoutColumn(subsplit, FALSE); uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE); - subcol = uiLayoutColumn(subsplit, 0); + subcol = uiLayoutColumn(subsplit, FALSE); uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE); } else uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(row, &imaptr, "use_color_unpremultiply", 0, NULL, ICON_NONE); } @@ -761,24 +761,24 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); BLI_snprintf(str, sizeof(str), IFACE_("(%d) Frames"), iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); uiItemR(col, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemO(col, NULL, ICON_NONE, "IMAGE_OT_match_movie_length"); uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } else if (ima->source == IMA_SRC_GENERATED) { - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); @@ -804,12 +804,12 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiLayout *col, *row, *split, *sub; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); - split = uiLayoutSplit(col, 0.5f, 0); + split = uiLayoutSplit(col, 0.5f, FALSE); uiItemR(split, imfptr, "file_format", 0, "", ICON_NONE); - sub = uiLayoutRow(split, 0); + sub = uiLayoutRow(split, FALSE); uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); /* only display depth setting if multiple depths can be used */ @@ -821,7 +821,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) R_IMF_CHAN_DEPTH_24, R_IMF_CHAN_DEPTH_32)) == 0) { - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -837,7 +837,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE); } - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); if (BKE_imtype_supports_zbuf(imf->imtype)) { uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE); } @@ -847,7 +847,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) } if (imf->imtype == R_IMF_IMTYPE_JP2) { - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE); uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 7e67e737cc2..3dc1fbd738f 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1926,6 +1926,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) if (ibuf == NULL) { ED_space_image_release_buffer(sima, lock); + info->draw = 0; return; } @@ -2018,8 +2019,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) } #endif } - else + else { info->draw = 0; + } ED_space_image_release_buffer(sima, lock); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 32e6f588e27..59e47363a22 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -550,7 +550,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) /* fast switch to render slots */ for (i = 0; i < MAX2(IMA_MAX_RENDER_SLOT, 9); i++) { - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY+i, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY + i, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slot"); RNA_int_set(kmi->ptr, "value", i); } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 0eec61f599e..08842698214 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3197,8 +3197,8 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo uiLayout *box, *row, *sub; bSensor *sens= (bSensor *)ptr->data; - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3210,13 +3210,13 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo uiItemL(row, sens->name, ICON_NONE); } - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_sensors_active_states") && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3228,19 +3228,19 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) { uiLayout *box, *split, *sub, *row; - box= uiLayoutBox(layout); - split = uiLayoutSplit(box, 0.45, 0); + box = uiLayoutBox(layout); + split = uiLayoutSplit(box, 0.45f, FALSE); - row= uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_pulse_true_level", 0, "", ICON_DOTSUP); uiItemR(row, ptr, "use_pulse_false_level", 0, "", ICON_DOTSDOWN); - sub=uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, (RNA_boolean_get(ptr, "use_pulse_true_level") || RNA_boolean_get(ptr, "use_pulse_false_level"))); uiItemR(sub, ptr, "frequency", 0, "Freq", ICON_NONE); - row= uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -3282,7 +3282,7 @@ static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr) if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, as->posechannel, &pchan_ptr)) uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE); } - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "test_type", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "test_type") != SENS_ARM_STATE_CHANGED) uiItemR(row, ptr, "value", 0, NULL, ICON_NONE); @@ -3295,8 +3295,8 @@ static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr, bContext *C RNA_main_pointer_create(CTX_data_main(C), &main_ptr); - split = uiLayoutSplit(layout, 0.3, 0); - row = uiLayoutRow(split, 1); + split = uiLayoutSplit(layout, 0.3f, FALSE); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_pulse", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_material", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -3314,7 +3314,7 @@ static void draw_sensor_delay(uiLayout *layout, PointerRNA *ptr) { uiLayout *row; - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "delay", 0, NULL, ICON_NONE); uiItemR(row, ptr, "duration", 0, NULL, ICON_NONE); @@ -3332,17 +3332,17 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) case SENS_JOY_BUTTON: uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "button_number", 0, NULL, ICON_NONE); break; case SENS_JOY_AXIS: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "axis_number", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "axis_direction", 0, NULL, ICON_NONE); break; @@ -3350,12 +3350,12 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "hat_number", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "hat_direction", 0, NULL, ICON_NONE); break; case SENS_JOY_AXIS_SINGLE: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "single_axis_number", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE); break; @@ -3368,21 +3368,21 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) PointerRNA settings_ptr; uiLayout *row, *col; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, "Key:", ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE); uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_all_keys", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemL(row, "First Modifier:", ICON_NONE); uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemL(row, "Second Modifier:", ICON_NONE); uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NONE); @@ -3407,7 +3407,7 @@ static void draw_sensor_near(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE); uiItemR(row, ptr, "reset_distance", 0, NULL, ICON_NONE); } @@ -3425,7 +3425,7 @@ static void draw_sensor_property(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "evaluation_type")) { case SENS_PROP_INTERVAL: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "value_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "value_max", 0, NULL, ICON_NONE); break; @@ -3447,7 +3447,7 @@ static void draw_sensor_radar(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "axis", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "angle", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE); } @@ -3463,7 +3463,7 @@ static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C) PointerRNA main_ptr; RNA_main_pointer_create(CTX_data_main(C), &main_ptr); - split= uiLayoutSplit(layout, 0.3, 0); + split = uiLayoutSplit(layout, 0.3f, FALSE); uiItemR(split, ptr, "ray_type", 0, "", ICON_NONE); switch (RNA_enum_get(ptr, "ray_type")) { case SENS_RAY_PROPERTY: @@ -3474,9 +3474,9 @@ static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C) break; } - split= uiLayoutSplit(layout, 0.3, 0); + split = uiLayoutSplit(layout, 0.3, FALSE); uiItemR(split, ptr, "axis", 0, "", ICON_NONE); - row= uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "range", 0, NULL, ICON_NONE); uiItemR(row, ptr, "use_x_ray", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); } @@ -3555,8 +3555,8 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i char state[3]; BLI_snprintf(state, sizeof(state), "%d", RNA_int_get(ptr, "states")); - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3574,7 +3574,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i uiItemR(row, ptr, "use_priority", 0, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3590,13 +3590,13 @@ static void draw_controller_python(uiLayout *layout, PointerRNA *ptr) { uiLayout *split, *sub; - split = uiLayoutSplit(layout, 0.3, 1); + split = uiLayoutSplit(layout, 0.3, TRUE); uiItemR(split, ptr, "mode", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "mode") == CONT_PY_SCRIPT) { uiItemR(split, ptr, "text", 0, "", ICON_NONE); } else { - sub = uiLayoutSplit(split, 0.8, 0); + sub = uiLayoutSplit(split, 0.8f, FALSE); uiItemR(sub, ptr, "module", 0, "", ICON_NONE); uiItemR(sub, ptr, "use_debug", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); } @@ -3646,8 +3646,8 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * uiLayout *box, *row, *sub; bActuator *act= (bActuator *)ptr->data; - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3659,13 +3659,13 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * uiItemL(row, act->name, ICON_NONE); } - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_actuators_active_states") && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3680,22 +3680,22 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "play_mode", 0, "", ICON_NONE); - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemR(sub, ptr, "use_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(sub, ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutColumn(sub, 0); + row = uiLayoutColumn(sub, FALSE); uiLayoutSetActive(row, (RNA_boolean_get(ptr, "use_additive") || RNA_boolean_get(ptr, "use_force"))); uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "action", 0, "", ICON_NONE); uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if ((RNA_enum_get(ptr, "play_mode") == ACT_ACTION_FROM_PROP)) uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); @@ -3706,11 +3706,11 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "apply_to_children", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE); uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE); uiItemR(row, ptr, "layer_weight", 0, NULL, ICON_NONE); @@ -3798,11 +3798,11 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) uiLayout *row; uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "height", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "max", 0, NULL, ICON_NONE); @@ -3821,7 +3821,7 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext case ACT_CONST_TYPE_LOC: uiItemR(layout, ptr, "limit", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "limit_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "limit_max", 0, NULL, ICON_NONE); @@ -3829,36 +3829,36 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext break; case ACT_CONST_TYPE_DIST: - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8, FALSE); uiItemR(split, ptr, "direction", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 1); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, TRUE); uiItemL(col, "Range:", ICON_NONE); uiItemR(col, ptr, "range", 0, "", ICON_NONE); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemR(col, ptr, "use_force_distance", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_force_distance") == TRUE); uiItemR(sub, ptr, "distance", 0, "", ICON_NONE); uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15f, FALSE); uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (RNA_boolean_get(ptr, "use_material_detect")) uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA); else uiItemR(split, ptr, "property", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); break; @@ -3866,43 +3866,43 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext case ACT_CONST_TYPE_ORI: uiItemR(layout, ptr, "direction_axis_pos", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 1); + row=uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 0); + row=uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "rotation_max", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 1); + row=uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "angle_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "angle_max", 0, NULL, ICON_NONE); break; case ACT_CONST_TYPE_FH: - split=uiLayoutSplit(layout, 0.75, 0); - row= uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.75, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "fh_damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "fh_height", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_fh_paralel_axis", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "direction_axis", 0, NULL, ICON_NONE); - split = uiLayoutSplit(row, 0.9, 0); + split = uiLayoutSplit(row, 0.9f, FALSE); uiItemR(split, ptr, "fh_force", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_fh_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (RNA_boolean_get(ptr, "use_material_detect")) uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA); else uiItemR(split, ptr, "property", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); break; @@ -3917,17 +3917,17 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "mode")) { case ACT_EDOB_ADD_OBJECT: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "object", 0, NULL, ICON_NONE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "angular_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; @@ -3938,16 +3938,16 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) uiItemL(layout, "Mode only available for mesh objects", ICON_NONE); break; } - split = uiLayoutSplit(layout, 0.6, 0); + split = uiLayoutSplit(layout, 0.6, FALSE); uiItemR(split, ptr, "mesh", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "use_replace_display_mesh", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_replace_physics_mesh", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; case ACT_EDOB_TRACK_TO: - split = uiLayoutSplit(layout, 0.5, 0); + split = uiLayoutSplit(layout, 0.5, FALSE); uiItemR(split, ptr, "track_object", 0, NULL, ICON_NONE); - sub = uiLayoutSplit(split, 0.7, 0); + sub = uiLayoutSplit(split, 0.7f, FALSE); uiItemR(sub, ptr, "time", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "use_3d_tracking", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; @@ -3974,8 +3974,8 @@ static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "glsl_shader", 0, NULL, ICON_NONE); break; case ACT_2DFILTER_MOTIONBLUR: - split=uiLayoutSplit(layout, 0.75, 1); - row= uiLayoutRow(split, 0); + split=uiLayoutSplit(layout, 0.75f, TRUE); + row = uiLayoutRow(split, FALSE); uiLayoutSetActive(row, RNA_boolean_get(ptr, "use_motion_blur") == TRUE); uiItemR(row, ptr, "motion_blur_factor", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_motion_blur", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -4007,7 +4007,7 @@ static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr, bContext *C uiItemPointerR(layout, ptr, "to_property", &main_ptr, "objects", NULL, ICON_OBJECT_DATA); uiItemR(layout, ptr, "subject", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "body_type", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "body_type") == ACT_MESG_MESG) @@ -4031,37 +4031,37 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "mode")) { case ACT_OBJECT_NORMAL: - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "offset_location", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_location", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (ELEM3(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) { uiItemL(layout, "Dynamic Object Settings:", ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "force", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "torque", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_torque", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_add_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "angular_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -4071,29 +4071,29 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) case ACT_OBJECT_SERVO: uiItemR(layout, ptr, "reference_object", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_x", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_x") == TRUE); uiItemR(sub, ptr, "force_max_x", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_x", 0, NULL, ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_y", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_y") == TRUE); uiItemR(sub, ptr, "force_max_y", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_y", 0, NULL, ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_z", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_z") == TRUE); uiItemR(sub, ptr, "force_max_z", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_z", 0, NULL, ICON_NONE); @@ -4102,7 +4102,7 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) //Layout designers willing to help on that, please compare with 2.49 ui // (since the old code is going to be deleted ... soon) - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "proportional_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "integral_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "derivate_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -4119,9 +4119,9 @@ static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr) if (RNA_enum_get(ptr, "mode") == ACT_PARENT_SET) { uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "use_compound", 0, NULL, ICON_NONE); - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_compound") == TRUE); uiItemR(sub, ptr, "use_ghost", 0, NULL, ICON_NONE); } @@ -4152,15 +4152,15 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE); break; case ACT_PROP_COPY: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "object", 0, NULL, ICON_NONE); if (ob_from) { RNA_pointer_create((ID *)ob_from, &RNA_GameObjectSettings, ob_from, &obj_settings_ptr); uiItemPointerR(row, ptr, "object_property", &obj_settings_ptr, "properties", NULL, ICON_NONE); } else { - sub= uiLayoutRow(row, 0); - uiLayoutSetActive(sub, 0); + sub = uiLayoutRow(row, FALSE); + uiLayoutSetActive(sub, FALSE); uiItemR(sub, ptr, "object_property", 0, NULL, ICON_NONE); } break; @@ -4176,15 +4176,15 @@ static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr) ob = (Object *)ptr->id.data; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "seed", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distribution", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); switch (RNA_enum_get(ptr, "distribution")) { case ACT_RANDOM_BOOL_CONST: @@ -4261,12 +4261,12 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "mode", 0, "", ICON_NONE); uiItemR(row, ptr, "action", 0, "", ICON_NONE); uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if ((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); @@ -4275,11 +4275,11 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "frame_end", 0, NULL, ICON_NONE); } - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE); uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemPointerR(row, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR @@ -4298,28 +4298,28 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) } uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "volume", 0, NULL, ICON_NONE); uiItemR(row, ptr, "pitch", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_sound_3d", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_sound_3d") == TRUE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gain_3d_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "gain_3d_max", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "distance_3d_reference", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distance_3d_max", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "rolloff_factor_3d", 0, NULL, ICON_NONE); uiItemR(row, ptr, "cone_outer_gain_3d", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "cone_outer_angle_3d", 0, NULL, ICON_NONE); uiItemR(row, ptr, "cone_inner_angle_3d", 0, NULL, ICON_NONE); } @@ -4331,7 +4331,7 @@ static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) PointerRNA settings_ptr; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - split = uiLayoutSplit(layout, 0.35, 0); + split = uiLayoutSplit(layout, 0.35, FALSE); uiItemR(split, ptr, "operation", 0, NULL, ICON_NONE); uiTemplateLayers(split, ptr, "states", &settings_ptr, "used_states", 0); @@ -4340,7 +4340,7 @@ static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_visibility(uiLayout *layout, PointerRNA *ptr) { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "use_visible", 0, NULL, ICON_NONE); uiItemR(row, ptr, "use_occlusion", 0, NULL, ICON_NONE); @@ -4356,32 +4356,32 @@ static void draw_actuator_steering(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "target", 0, NULL, 0); uiItemR(layout, ptr, "navmesh", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "distance", 0, NULL, 0); uiItemR(row, ptr, "velocity", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "acceleration", 0, NULL, 0); uiItemR(row, ptr, "turn_speed", 0, NULL, 0); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "facing", 0, NULL, 0); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "facing_axis", 0, NULL, 0); if (!RNA_boolean_get(ptr, "facing")) { - uiLayoutSetActive(col, 0); + uiLayoutSetActive(col, FALSE); } - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "normal_up", 0, NULL, 0); if (!RNA_pointer_get(ptr, "navmesh").data) { - uiLayoutSetActive(col, 0); + uiLayoutSetActive(col, FALSE); } - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "self_terminated", 0, NULL, 0); if (RNA_enum_get(ptr, "mode")==ACT_STEERING_PATHFOLLOWING) { uiItemR(row, ptr, "update_period", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); } uiItemR(row, ptr, "show_visualization", 0, NULL, 0); } @@ -4522,7 +4522,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 420; yco= 170; width= 300; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4545,32 +4545,32 @@ static void logic_buttons_new(bContext *C, ARegion *ar) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - split= uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE); if (RNA_boolean_get(&settings_ptr, "show_state_panel")) { - box= uiLayoutBox(layout); - split= uiLayoutSplit(box, 0.2, 0); + box = uiLayoutBox(layout); + split = uiLayoutSplit(box, 0.2f, FALSE); - col= uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemL(col, "Visible", ICON_NONE); uiItemL(col, "Initial", ICON_NONE); - subsplit= uiLayoutSplit(split, 0.85, 0); - col= uiLayoutColumn(subsplit, 0); - row= uiLayoutRow(col, 0); + subsplit = uiLayoutSplit(split, 0.85f, FALSE); + col = uiLayoutColumn(subsplit, FALSE); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&settings_ptr, "use_all_states") == FALSE); uiTemplateLayers(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0); - row= uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiTemplateLayers(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0); - col= uiLayoutColumn(subsplit, 0); + col = uiLayoutColumn(subsplit, FALSE); uiItemR(col, &settings_ptr, "use_all_states", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(col, &settings_ptr, "show_debug_state", 0, "", ICON_NONE); } @@ -4589,18 +4589,18 @@ static void logic_buttons_new(bContext *C, ARegion *ar) continue; /* use two nested splits to align inlinks/links properly */ - split = uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); /* put inlink button to the left */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, ""); - //col = uiLayoutColumn(split, 1); + //col = uiLayoutColumn(split, TRUE); /* nested split for middle and right columns */ - subsplit = uiLayoutSplit(split, 0.95, 0); + subsplit = uiLayoutSplit(split, 0.95f, FALSE); - col = uiLayoutColumn(subsplit, 1); + col = uiLayoutColumn(subsplit, TRUE); uiLayoutSetContextPointer(col, "controller", &ptr); /* should make UI template for controller header.. function will do for now */ @@ -4612,7 +4612,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* put link button to the right */ - col = uiLayoutColumn(subsplit, 0); + col = uiLayoutColumn(subsplit, FALSE); uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); @@ -4625,7 +4625,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 10; yco= 170; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4643,7 +4643,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* only draw the sensor common header if "use_visible" */ if ((ob->scavisflag & OB_VIS_SENS) == 0) continue; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE); @@ -4667,8 +4667,8 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* make as visible, for move operator */ sens->flag |= SENS_VISIBLE; - split = uiLayoutSplit(layout, 0.95, 0); - col = uiLayoutColumn(split, 1); + split = uiLayoutSplit(layout, 0.95f, FALSE); + col = uiLayoutColumn(split, TRUE); uiLayoutSetContextPointer(col, "sensor", &ptr); /* should make UI template for sensor header.. function will do for now */ @@ -4678,7 +4678,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) draw_brick_sensor(col, &ptr, C); /* put link button to the right */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* use old-school uiButtons for links for now */ but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); @@ -4691,7 +4691,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 800; yco= 170; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4709,7 +4709,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* only draw the actuator common header if "use_visible" */ if ( (ob->scavisflag & OB_VIS_ACT) == 0) continue; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE); @@ -4734,13 +4734,13 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* make as visible, for move operator */ act->flag |= ACT_VISIBLE; - split = uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); /* put inlink button to the left */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, ""); - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiLayoutSetContextPointer(col, "actuator", &ptr); /* should make UI template for actuator header.. function will do for now */ diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index be60e47ac8f..9b0e342505b 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -253,19 +253,19 @@ static void nla_panel_animdata(const bContext *C, Panel *pa) /* Active Action Properties ------------------------------------- */ /* action */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators /* extrapolation */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); /* blending */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); /* influence */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); } @@ -285,7 +285,7 @@ static void nla_panel_track(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Info - Active NLA-Context:Track ---------------------- */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA); } @@ -306,12 +306,12 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* strip type */ - row = uiLayoutColumn(layout, 1); + row = uiLayoutColumn(layout, TRUE); uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon? uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE); /* strip extents */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiItemL(column, "Strip Extents:", ICON_NONE); uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); @@ -325,27 +325,27 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* only show if allowed to... */ if (showEvalProps) { /* extrapolation */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); /* blending */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); /* blend in/out + autoblending * - blend in/out can only be set when autoblending is off */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence") == FALSE); uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? - sub = uiLayoutColumn(column, 1); + sub = uiLayoutColumn(column, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend") == FALSE); uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); /* settings */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); uiItemL(column, "Playback Settings:", ICON_NONE); uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); @@ -371,19 +371,19 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* action pointer */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION); /* action extents */ // XXX custom names were used here (to avoid the prefixes)... probably not necessary in future? - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiItemL(column, "Action Extents:", ICON_NONE); uiItemR(column, &strip_ptr, "action_frame_start", 0, "Start Frame", ICON_NONE); uiItemR(column, &strip_ptr, "action_frame_end", 0, "End Frame", ICON_NONE); uiItemO(column, NULL, ICON_NONE, "NLA_OT_action_sync_length"); /* action usage */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time") == FALSE); uiItemL(column, "Playback Settings:", ICON_NONE); uiItemR(column, &strip_ptr, "scale", 0, NULL, ICON_NONE); @@ -405,19 +405,19 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); - sub = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, TRUE); + sub = uiLayoutRow(col, FALSE); uiItemR(sub, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE); - sub = uiLayoutRow(col, 0); + sub = uiLayoutRow(col, FALSE); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_time")); uiItemR(sub, &strip_ptr, "strip_time", 0, NULL, ICON_NONE); } @@ -441,7 +441,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) /* 'add modifier' button at top of panel */ { - row = uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a temporary 'add modifier' operator @@ -450,14 +450,14 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) TIP_("Adds a new F-Modifier for the active NLA Strip")); /* copy/paste (as sub-row)*/ - row = uiLayoutRow(row, 1); + row = uiLayoutRow(row, TRUE); uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy"); uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); } /* draw each modifier */ for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 8aa56823baf..22017a2d8b9 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -140,7 +140,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); - layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), 0); + layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), FALSE); uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE); @@ -291,7 +291,7 @@ static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr prop = RNA_struct_find_property(ptr, "outputs"); RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiTemplateColorWheel(col, &sockptr, "default_value", 1, 0, 0, 0); uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE); } @@ -302,7 +302,7 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA bNodeTree *ntree = (bNodeTree *)ptr->id.data; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE); if (ntree->type == NTREE_COMPOSIT) uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA); @@ -325,7 +325,7 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE); uiItemR(row, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); } @@ -340,25 +340,30 @@ static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0); } -static float *_sample_col = NULL; // bad bad, 2.5 will do better? -#if 0 -static void node_curvemap_sample(float *col) +static float _sample_col[4]; // bad bad, 2.5 will do better? +#define SAMPLE_FLT_ISNONE FLT_MAX +void ED_node_sample_set(const float col[4]) { - _sample_col = col; + if (col) { + copy_v4_v4(_sample_col, col); + } + else { + copy_v4_fl(_sample_col, SAMPLE_FLT_ISNONE); + } } -#endif static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { bNode *node = ptr->data; CurveMapping *cumap = node->storage; - if (_sample_col) { + if (_sample_col[0] != SAMPLE_FLT_ISNONE) { cumap->flag |= CUMA_DRAW_SAMPLE; copy_v3_v3(cumap->sample, _sample_col); } - else + else { cumap->flag &= ~CUMA_DRAW_SAMPLE; + } uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0); } @@ -1002,7 +1007,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN glDisable(GL_BLEND); /* outline active and selected emphasis */ - if (node->flag & (NODE_ACTIVE | SELECT) ) { + if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1105,7 +1110,7 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* XXX only kept for debugging * selection state is indicated by socket outline below! */ - #if 0 +#if 0 /* body */ uiSetRoundBox(15); UI_ThemeColor4(TH_NODE); @@ -1116,18 +1121,18 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* outline active and selected emphasis */ if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); - glEnable( GL_LINE_SMOOTH ); + glEnable(GL_LINE_SMOOTH); /* using different shades of TH_TEXT_HI for the empasis, like triangle */ - if( node->flag & NODE_ACTIVE ) + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); else UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); - glDisable( GL_LINE_SMOOTH ); + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - #endif +#endif /* only draw input socket. as they all are placed on the same position. * highlight also if node itself is selected, since we don't display the node body separately! @@ -1194,10 +1199,10 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap uiLayout *col; int source; - if(!imaptr->data) + if (!imaptr->data) return; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, imaptr, "source", 0, "", ICON_NONE); @@ -1214,7 +1219,7 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap } if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, iuserptr, "frame_duration", 0, NULL, ICON_NONE); uiItemR(col, iuserptr, "frame_start", 0, NULL, ICON_NONE); uiItemR(col, iuserptr, "frame_offset", 0, NULL, ICON_NONE); @@ -1222,7 +1227,7 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap uiItemR(col, iuserptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); } - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER) uiItemR(col, iuserptr, "layer", 0, NULL, ICON_NONE); @@ -1238,7 +1243,7 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA if (!node->id) return; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE); uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE); @@ -1249,22 +1254,22 @@ static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), Poin uiLayout *row; uiItemL(layout, IFACE_("Location:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "translation", 0, "", ICON_NONE); uiItemL(layout, IFACE_("Rotation:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "rotation", 0, "", ICON_NONE); uiItemL(layout, IFACE_("Scale:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "scale", 0, "", ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE); uiItemR(row, ptr, "min", 0, "", ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE); uiItemR(row, ptr, "max", 0, "", ICON_NONE); } @@ -1279,7 +1284,7 @@ static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA PointerRNA obptr = CTX_data_pointer_get(C, "active_object"); uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); @@ -1471,8 +1476,8 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point if (!node->id) return; - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "layer", 0, "", ICON_NONE); prop = RNA_struct_find_property(ptr, "layer"); @@ -1494,7 +1499,7 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point { uiLayout *col, *row; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "filter_type", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "filter_type") != R_FILTER_FAST_GAUSS) { @@ -1506,15 +1511,15 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point if (RNA_boolean_get(ptr, "use_relative")) { uiItemL(col, IFACE_("Aspect Correction"), 0); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, 0); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE); } else { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "size_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "size_y", 0, IFACE_("Y"), ICON_NONE); } @@ -1527,14 +1532,14 @@ static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), Poin uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Center:"), ICON_NONE); uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE); uiItemS(layout); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); @@ -1548,7 +1553,7 @@ static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED( { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE); uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE); @@ -1558,29 +1563,26 @@ static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *sub, *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE); uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE); uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_gamma_correction", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer") == TRUE); uiItemR(col, ptr, "f_stop", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); - uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_preview")); - uiItemR(sub, ptr, "samples", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer") == FALSE); uiItemR(sub, ptr, "z_scale", 0, NULL, ICON_NONE); } @@ -1620,7 +1622,7 @@ static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "tonemap_type") == 0) { uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1639,10 +1641,10 @@ static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), P { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_projector", 0, NULL, ICON_NONE); - col = uiLayoutColumn(col, 0); + col = uiLayoutColumn(col, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector") == FALSE); uiItemR(col, ptr, "use_jitter", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_fit", 0, NULL, ICON_NONE); @@ -1652,11 +1654,11 @@ static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE); uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Speed:"), ICON_NONE); uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE); uiItemR(col, ptr, "speed_max", 0, IFACE_("Max"), ICON_NONE); @@ -1681,7 +1683,7 @@ static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), Point uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); if (RNA_boolean_get(ptr, "relative")) { uiItemR(col, ptr, "rel_min_x", 0, IFACE_("Left"), ICON_NONE); uiItemR(col, ptr, "rel_max_x", 0, IFACE_("Right"), ICON_NONE); @@ -1700,8 +1702,8 @@ static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C) { uiLayout *row, *col; - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE); } @@ -1710,7 +1712,7 @@ static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUS { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Inner Edge:"), ICON_NONE); uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE); @@ -1722,19 +1724,19 @@ static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), { uiLayout *sub, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE); uiItemR(col, ptr, "size", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min")); uiItemR(sub, ptr, "min", 0, "", ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max")); uiItemR(sub, ptr, "max", 0, "", ICON_NONE); } @@ -1743,7 +1745,7 @@ static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE); } @@ -1752,7 +1754,7 @@ static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), P { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE); } @@ -1761,7 +1763,7 @@ static void node_composit_buts_hue_sat(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1771,8 +1773,13 @@ static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C) { uiItemR(layout, ptr, "type", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE); - if (RNA_enum_get(ptr, "type") == CMP_NODE_DILATEERODE_DISTANCE_THRESH) { - uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE); + switch (RNA_enum_get(ptr, "type")) { + case CMP_NODE_DILATEERODE_DISTANCE_THRESH: + uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE); + break; + case CMP_NODE_DILATEERODE_DISTANCE_FEATHER: + uiItemR(layout, ptr, "falloff", 0, NULL, ICON_NONE); + break; } } @@ -1780,7 +1787,7 @@ static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -1789,10 +1796,10 @@ static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED { uiLayout *col, *row; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1804,15 +1811,15 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C) uiLayout *row, *col; uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "limit_method") == 0) { uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -1829,11 +1836,11 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */ uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/ @@ -1843,7 +1850,7 @@ static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C) { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1854,20 +1861,20 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED( uiLayout *col, *row; uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Key Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "limit_method") == 0) { uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -1879,7 +1886,7 @@ static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -1892,7 +1899,7 @@ static void node_composit_buts_map_uv(uiLayout *layout, bContext *UNUSED(C), Poi static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "index", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "use_smooth_mask", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); } /* draw function for file output node sockets, displays only sub-path and format, no value button */ @@ -1907,7 +1914,7 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y + NODE_DY, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); imfptr = RNA_pointer_get(&nodeptr, "format"); imtype = RNA_enum_get(&imfptr, "file_format"); @@ -1976,7 +1983,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */ active_input_ptr.id.data = ptr->id.data; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&op_ptr, "direction", 1); op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); @@ -1985,30 +1992,30 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C if (active_input_ptr.data) { if (multilayer) { uiLayout *row, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Layer:"), 0); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "name", 0, "", 0); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); } else { uiLayout *row, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("File Path:"), 0); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "path", 0, "", 0); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); /* format details for individual files */ imfptr = RNA_pointer_get(&active_input_ptr, "format"); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Format:"), 0); uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, 0); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE); uiTemplateImageSettings(col, &imfptr); } @@ -2037,7 +2044,7 @@ static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), Poi { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE); uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE); } @@ -2060,39 +2067,39 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C if (RNA_enum_get(ptr, "correction_method") == 0) { - split = uiLayoutSplit(layout, 0, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "lift", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "gamma", 1, 1, 1, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "gain", 1, 1, 1, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE); } else { - split = uiLayoutSplit(layout, 0, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "offset", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "power", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "power", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "slope", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE); } @@ -2127,6 +2134,17 @@ static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUS static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { + bNode *node = ptr->data; + CurveMapping *cumap = node->storage; + + if (_sample_col[0] != SAMPLE_FLT_ISNONE) { + cumap->flag |= CUMA_DRAW_SAMPLE; + copy_v3_v3(cumap->sample, _sample_col); + } + else { + cumap->flag &= ~CUMA_DRAW_SAMPLE; + } + uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0); } @@ -2173,12 +2191,12 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, "", 0); uiItemL(row, IFACE_("Saturation"), 0); uiItemL(row, IFACE_("Contrast"), 0); @@ -2186,7 +2204,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemL(row, IFACE_("Gain"), 0); uiItemL(row, IFACE_("Lift"), 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Master"), 0); uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2194,7 +2212,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Highlights"), 0); uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2202,7 +2220,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Midtones"), 0); uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2210,7 +2228,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Shadows"), 0); uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2218,7 +2236,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "midtones_start", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -2227,7 +2245,7 @@ static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *U { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE); @@ -2262,7 +2280,7 @@ static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *U uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "midtones_start", 0, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_end", 0, NULL, ICON_NONE); } @@ -2276,11 +2294,11 @@ static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "x", 0, NULL, ICON_NONE); uiItemR(row, ptr, "y", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2403,10 +2421,10 @@ void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "x", 0, NULL, ICON_NONE); uiItemR(row, ptr, "y", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2420,7 +2438,7 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "tile_order") == 0) { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE); uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE); } @@ -2429,7 +2447,8 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL); - uiItemR(layout, ptr, "smooth_mask", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE); } @@ -2446,7 +2465,7 @@ static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, Point RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA); } } @@ -2675,11 +2694,11 @@ static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), Poin { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE); uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE); uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE); } @@ -2694,23 +2713,23 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); switch (tex->type) { case TEX_BLEND: uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; case TEX_MARBLE: - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; @@ -2719,9 +2738,9 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe break; case TEX_STUCCI: - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); break; @@ -2729,18 +2748,18 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe case TEX_WOOD: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, !(RNA_enum_get(&tex_ptr, "wood_type") == TEX_BAND || RNA_enum_get(&tex_ptr, "wood_type") == TEX_RING)); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; case TEX_CLOUDS: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE); break; diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index f2ec2289ad1..bc4c391720a 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -100,7 +100,7 @@ static void active_node_panel(const bContext *C, Panel *pa) //else RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); - layout = uiLayoutColumn(pa->layout, 0); + layout = uiLayoutColumn(pa->layout, FALSE); uiLayoutSetContextPointer(layout, "node", &ptr); /* draw this node's name, etc. */ @@ -113,17 +113,17 @@ static void active_node_panel(const bContext *C, Panel *pa) uiItemS(layout); uiItemS(layout); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemM(col, (bContext *)C, "NODE_MT_node_color_presets", NULL, 0); uiItemR(col, &ptr, "use_custom_color", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); - sub = uiLayoutRow(col, 0); + sub = uiLayoutRow(col, FALSE); if (!(node->flag & NODE_CUSTOM_COLOR)) uiLayoutSetEnabled(sub, 0); uiItemR(sub, &ptr, "color", 0, "", 0); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemO(col, "", ICON_ZOOMIN, "node.node_color_preset_add"); opptr = uiItemFullO(col, "node.node_color_preset_add", "", ICON_ZOOMOUT, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_boolean_set(&opptr, "remove_active", 1); @@ -164,7 +164,7 @@ static void node_sockets_panel(const bContext *C, Panel *pa) for (sock=node->inputs.first; sock; sock=sock->next) { BLI_snprintf(name, sizeof(name), "%s:", sock->name); - split = uiLayoutSplit(layout, 0.35f, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); uiItemL(split, name, ICON_NONE); uiTemplateNodeLink(split, ntree, node, sock); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 81e375f26bc..48f772e8008 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -120,7 +120,7 @@ typedef struct CompoJob { /* called by compo, only to check job 'stop' value */ static int compo_breakjob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; return *(cj->stop); } @@ -128,14 +128,14 @@ static int compo_breakjob(void *cjv) /* called by compo, wmJob sends notifier */ static void compo_redrawjob(void *cjv, char *UNUSED(str)) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; *(cj->do_update) = TRUE; } static void compo_freejob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; if (cj->localtree) { ntreeLocalMerge(cj->localtree, cj->ntree); @@ -147,22 +147,22 @@ static void compo_freejob(void *cjv) * sliding buttons doesn't frustrate */ static void compo_initjob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; - cj->localtree= ntreeLocalize(cj->ntree); + cj->localtree = ntreeLocalize(cj->ntree); } /* called before redraw notifiers, it moves finished previews over */ static void compo_updatejob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; ntreeLocalSync(cj->localtree, cj->ntree); } static void compo_progressjob(void *cjv, float progress) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; *(cj->progress) = progress; } @@ -171,49 +171,49 @@ static void compo_progressjob(void *cjv, float progress) /* only this runs inside thread */ static void compo_startjob(void *cjv, short *stop, short *do_update, float *progress) { - CompoJob *cj= cjv; - bNodeTree *ntree= cj->localtree; + CompoJob *cj = cjv; + bNodeTree *ntree = cj->localtree; if (cj->scene->use_nodes == FALSE) return; - cj->stop= stop; - cj->do_update= do_update; - cj->progress= progress; - - ntree->test_break= compo_breakjob; - ntree->tbh= cj; - ntree->stats_draw= compo_redrawjob; - ntree->sdh= cj; - ntree->progress= compo_progressjob; - ntree->prh= cj; + cj->stop = stop; + cj->do_update = do_update; + cj->progress = progress; + + ntree->test_break = compo_breakjob; + ntree->tbh = cj; + ntree->stats_draw = compo_redrawjob; + ntree->sdh = cj; + ntree->progress = compo_progressjob; + ntree->prh = cj; // XXX BIF_store_spare(); - ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */ + ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */ - ntree->test_break= NULL; - ntree->stats_draw= NULL; - ntree->progress= NULL; + ntree->test_break = NULL; + ntree->stats_draw = NULL; + ntree->progress = NULL; } void snode_composite_job(const bContext *C, ScrArea *sa) { - SpaceNode *snode= sa->spacedata.first; + SpaceNode *snode = sa->spacedata.first; wmJob *steve; CompoJob *cj; - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Compositing", WM_JOB_EXCL_RENDER|WM_JOB_PROGRESS); - cj= MEM_callocN(sizeof(CompoJob), "compo job"); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS); + cj = MEM_callocN(sizeof(CompoJob), "compo job"); /* customdata for preview thread */ - cj->scene= CTX_data_scene(C); - cj->ntree= snode->nodetree; + cj->scene = CTX_data_scene(C); + cj->ntree = snode->nodetree; /* setup job */ WM_jobs_customdata(steve, cj, compo_freejob); - WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE|ND_COMPO_RESULT); + WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE | ND_COMPO_RESULT); WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob, NULL); WM_jobs_start(CTX_wm_manager(C), steve); @@ -225,9 +225,9 @@ void snode_composite_job(const bContext *C, ScrArea *sa) /* operator poll callback */ static int composite_node_active(bContext *C) { - if ( ED_operator_node_active(C)) { - SpaceNode *snode= CTX_wm_space_node(C); - if (snode->treetype==NTREE_COMPOSIT) + if (ED_operator_node_active(C)) { + SpaceNode *snode = CTX_wm_space_node(C); + if (snode->treetype == NTREE_COMPOSIT) return 1; } return 0; @@ -239,7 +239,7 @@ static bNode *editnode_get_active(bNodeTree *ntree) bNode *node; /* check for edited group */ - for (node= ntree->nodes.first; node; node= node->next) + for (node = ntree->nodes.first; node; node = node->next) if (nodeGroupEditGet(node)) break; if (node) @@ -255,9 +255,9 @@ static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) if (ntree == lookup) return 1; - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) if (node->type == NODE_GROUP && node->id) - if (has_nodetree((bNodeTree*)node->id, lookup)) + if (has_nodetree((bNodeTree *)node->id, lookup)) return 1; return 0; @@ -274,8 +274,8 @@ void snode_dag_update(bContext *C, SpaceNode *snode) Main *bmain = CTX_data_main(C); /* for groups, update all ID's using this */ - if (snode->edittree!=snode->nodetree) { - bNodeTreeType *tti= ntreeGetType(snode->edittree->type); + if (snode->edittree != snode->nodetree) { + bNodeTreeType *tti = ntreeGetType(snode->edittree->type); tti->foreach_nodetree(bmain, snode->edittree, snode_dag_update_group); } @@ -284,14 +284,14 @@ void snode_dag_update(bContext *C, SpaceNode *snode) void snode_notify(bContext *C, SpaceNode *snode) { - WM_event_add_notifier(C, NC_NODE|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL); - if (snode->treetype==NTREE_SHADER) - WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id); - else if (snode->treetype==NTREE_COMPOSIT) - WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id); - else if (snode->treetype==NTREE_TEXTURE) - WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); + if (snode->treetype == NTREE_SHADER) + WM_event_add_notifier(C, NC_MATERIAL | ND_NODES, snode->id); + else if (snode->treetype == NTREE_COMPOSIT) + WM_event_add_notifier(C, NC_SCENE | ND_NODES, snode->id); + else if (snode->treetype == NTREE_TEXTURE) + WM_event_add_notifier(C, NC_TEXTURE | ND_NODES, snode->id); } bNode *node_tree_get_editgroup(bNodeTree *nodetree) @@ -299,7 +299,7 @@ bNode *node_tree_get_editgroup(bNodeTree *nodetree) bNode *gnode; /* get the groupnode */ - for (gnode= nodetree->nodes.first; gnode; gnode= gnode->next) + for (gnode = nodetree->nodes.first; gnode; gnode = gnode->next) if (nodeGroupEditGet(gnode)) break; return gnode; @@ -316,11 +316,11 @@ void ED_node_shader_default(Scene *scene, ID *id) int output_type, shader_type; float color[3], strength = 1.0f; - ntree= ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); + ntree = ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); switch (GS(id->name)) { case ID_MA: { - Material *ma= (Material*)id; + Material *ma = (Material *)id; ma->nodetree = ntree; if (BKE_scene_use_new_shading_nodes(scene)) { @@ -333,22 +333,22 @@ void ED_node_shader_default(Scene *scene, ID *id) } copy_v3_v3(color, &ma->r); - strength= 0.0f; + strength = 0.0f; break; } case ID_WO: { - World *wo= (World*)id; + World *wo = (World *)id; wo->nodetree = ntree; output_type = SH_NODE_OUTPUT_WORLD; shader_type = SH_NODE_BACKGROUND; copy_v3_v3(color, &wo->horr); - strength= 1.0f; + strength = 1.0f; break; } case ID_LA: { - Lamp *la= (Lamp*)id; + Lamp *la = (Lamp *)id; la->nodetree = ntree; output_type = SH_NODE_OUTPUT_LAMP; @@ -356,9 +356,9 @@ void ED_node_shader_default(Scene *scene, ID *id) copy_v3_v3(color, &la->r); if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) - strength= 100.0f; + strength = 100.0f; else - strength= 1.0f; + strength = 1.0f; break; } default: @@ -367,27 +367,27 @@ void ED_node_shader_default(Scene *scene, ID *id) } ntemp.type = output_type; - out= nodeAddNode(ntree, &ntemp); - out->locx= 300.0f; out->locy= 300.0f; + out = nodeAddNode(ntree, &ntemp); + out->locx = 300.0f; out->locy = 300.0f; ntemp.type = shader_type; - in= nodeAddNode(ntree, &ntemp); - in->locx= 10.0f; in->locy= 300.0f; + in = nodeAddNode(ntree, &ntemp); + in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(ntree, in); /* only a link from color to color */ - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(ntree, in, fromsock, out, tosock); /* default values */ if (BKE_scene_use_new_shading_nodes(scene)) { - sock= in->inputs.first; - copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color); + sock = in->inputs.first; + copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, color); if (strength != 0.0f) { - sock= in->inputs.last; - ((bNodeSocketValueFloat*)sock->default_value)->value= strength; + sock = in->inputs.last; + ((bNodeSocketValueFloat *)sock->default_value)->value = strength; } } @@ -409,28 +409,28 @@ void ED_node_composit_default(Scene *sce) return; } - sce->nodetree= ntreeAddTree("Compositing Nodetree", NTREE_COMPOSIT, 0); + sce->nodetree = ntreeAddTree("Compositing Nodetree", NTREE_COMPOSIT, 0); sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; sce->nodetree->render_quality = NTREE_QUALITY_HIGH; ntemp.type = CMP_NODE_COMPOSITE; - out= nodeAddNode(sce->nodetree, &ntemp); - out->locx= 300.0f; out->locy= 400.0f; - out->id= &sce->id; + out = nodeAddNode(sce->nodetree, &ntemp); + out->locx = 300.0f; out->locy = 400.0f; + out->id = &sce->id; id_us_plus(out->id); ntemp.type = CMP_NODE_R_LAYERS; - in= nodeAddNode(sce->nodetree, &ntemp); - in->locx= 10.0f; in->locy= 400.0f; - in->id= &sce->id; + in = nodeAddNode(sce->nodetree, &ntemp); + in->locx = 10.0f; in->locy = 400.0f; + in->id = &sce->id; id_us_plus(in->id); nodeSetActive(sce->nodetree, in); /* links from color to color */ - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(sce->nodetree, in, fromsock, out, tosock); ntreeUpdateTree(sce->nodetree); @@ -453,19 +453,19 @@ void ED_node_texture_default(Tex *tx) return; } - tx->nodetree= ntreeAddTree("Texture Nodetree", NTREE_TEXTURE, 0); + tx->nodetree = ntreeAddTree("Texture Nodetree", NTREE_TEXTURE, 0); ntemp.type = TEX_NODE_OUTPUT; - out= nodeAddNode(tx->nodetree, &ntemp); - out->locx= 300.0f; out->locy= 300.0f; + out = nodeAddNode(tx->nodetree, &ntemp); + out->locx = 300.0f; out->locy = 300.0f; ntemp.type = TEX_NODE_CHECKER; - in= nodeAddNode(tx->nodetree, &ntemp); - in->locx= 10.0f; in->locy= 300.0f; + in = nodeAddNode(tx->nodetree, &ntemp); + in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(tx->nodetree, in); - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(tx->nodetree, in, fromsock, out, tosock); ntreeUpdateTree(tx->nodetree); @@ -475,128 +475,128 @@ void ED_node_texture_default(Tex *tx) void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype) { if (id) { - bNode *node= NULL; - short idtype= GS(id->name); + bNode *node = NULL; + short idtype = GS(id->name); if (idtype == ID_NT) { - *ntree= (bNodeTree*)id; - if (treetype) *treetype= (*ntree)->type; + *ntree = (bNodeTree *)id; + if (treetype) *treetype = (*ntree)->type; } else if (idtype == ID_MA) { - *ntree= ((Material*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((Material *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_LA) { - *ntree= ((Lamp*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((Lamp *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_WO) { - *ntree= ((World*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((World *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_SCE) { - *ntree= ((Scene*)id)->nodetree; - if (treetype) *treetype= NTREE_COMPOSIT; + *ntree = ((Scene *)id)->nodetree; + if (treetype) *treetype = NTREE_COMPOSIT; } else if (idtype == ID_TE) { - *ntree= ((Tex*)id)->nodetree; - if (treetype) *treetype= NTREE_TEXTURE; + *ntree = ((Tex *)id)->nodetree; + if (treetype) *treetype = NTREE_TEXTURE; } else { - if (treetype) *treetype= 0; + if (treetype) *treetype = 0; return; } /* find editable group */ if (edittree) { if (*ntree) - for (node= (*ntree)->nodes.first; node; node= node->next) + for (node = (*ntree)->nodes.first; node; node = node->next) if (nodeGroupEditGet(node)) break; if (node && node->id) - *edittree= (bNodeTree *)node->id; + *edittree = (bNodeTree *)node->id; else - *edittree= *ntree; + *edittree = *ntree; } } else { - *ntree= NULL; - *edittree= NULL; - if (treetype) *treetype= 0; + *ntree = NULL; + *edittree = NULL; + if (treetype) *treetype = 0; } } /* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */ void snode_set_context(SpaceNode *snode, Scene *scene) { - Object *ob= OBACT; + Object *ob = OBACT; - snode->id= snode->from= NULL; + snode->id = snode->from = NULL; - if (snode->treetype==NTREE_SHADER) { + if (snode->treetype == NTREE_SHADER) { /* need active object, or we allow pinning... */ if (snode->shaderfrom == SNODE_SHADER_OBJECT) { if (ob) { if (ob->type == OB_LAMP) { - snode->from= &ob->id; - snode->id= ob->data; + snode->from = &ob->id; + snode->id = ob->data; } else { - Material *ma= give_current_material(ob, ob->actcol); + Material *ma = give_current_material(ob, ob->actcol); if (ma) { - snode->from= &ob->id; - snode->id= &ma->id; + snode->from = &ob->id; + snode->id = &ma->id; } } } } else { /* SNODE_SHADER_WORLD */ if (scene->world) { - snode->from= NULL; - snode->id= &scene->world->id; + snode->from = NULL; + snode->id = &scene->world->id; } } } - else if (snode->treetype==NTREE_COMPOSIT) { - snode->id= &scene->id; + else if (snode->treetype == NTREE_COMPOSIT) { + snode->id = &scene->id; /* update output sockets based on available layers */ ntreeCompositForceHidden(scene->nodetree, scene); } - else if (snode->treetype==NTREE_TEXTURE) { - Tex *tx= NULL; + else if (snode->treetype == NTREE_TEXTURE) { + Tex *tx = NULL; - if (snode->texfrom==SNODE_TEX_OBJECT) { + if (snode->texfrom == SNODE_TEX_OBJECT) { if (ob) { - tx= give_current_object_texture(ob); + tx = give_current_object_texture(ob); if (ob->type == OB_LAMP) - snode->from= (ID*)ob->data; + snode->from = (ID *)ob->data; else - snode->from= (ID*)give_current_material(ob, ob->actcol); + snode->from = (ID *)give_current_material(ob, ob->actcol); /* from is not set fully for material nodes, should be ID + Node then */ - snode->id= &tx->id; + snode->id = &tx->id; } } - else if (snode->texfrom==SNODE_TEX_WORLD) { - tx= give_current_world_texture(scene->world); - snode->from= (ID *)scene->world; - snode->id= &tx->id; + else if (snode->texfrom == SNODE_TEX_WORLD) { + tx = give_current_world_texture(scene->world); + snode->from = (ID *)scene->world; + snode->id = &tx->id; } else { - struct Brush *brush= NULL; + struct Brush *brush = NULL; if (ob && (ob->mode & OB_MODE_SCULPT)) - brush= paint_brush(&scene->toolsettings->sculpt->paint); + brush = paint_brush(&scene->toolsettings->sculpt->paint); else - brush= paint_brush(&scene->toolsettings->imapaint.paint); + brush = paint_brush(&scene->toolsettings->imapaint.paint); if (brush) { - snode->from= (ID *)brush; - tx= give_current_brush_texture(brush); - snode->id= &tx->id; + snode->from = (ID *)brush; + tx = give_current_brush_texture(brush); + snode->id = &tx->id; } } } @@ -618,7 +618,7 @@ static void snode_update(SpaceNode *snode, bNode *node) nodeUpdate(snode->edittree, node); /* if inside group, tag entire group */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) nodeUpdateID(snode->nodetree, gnode->id); } @@ -629,24 +629,24 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) nodeSetActive(ntree, node); - if (node->type!=NODE_GROUP) { - int was_output= (node->flag & NODE_DO_OUTPUT); + if (node->type != NODE_GROUP) { + int was_output = (node->flag & NODE_DO_OUTPUT); /* tree specific activate calls */ - if (ntree->type==NTREE_SHADER) { + if (ntree->type == NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ if (node->id && ELEM3(GS(node->id->name), ID_MA, ID_LA, ID_WO)) nodeClearActiveID(ntree, ID_TE); - if (node->type==SH_NODE_OUTPUT) { + if (node->type == SH_NODE_OUTPUT) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( tnode->type==SH_NODE_OUTPUT) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (tnode->type == SH_NODE_OUTPUT) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - if (was_output==0) + if (was_output == 0) ED_node_generic_update(bmain, ntree, node); } @@ -654,49 +654,49 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) { Material *ma; - for (ma=bmain->mat.first; ma; ma=ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->nodetree && ma->use_nodes && has_nodetree(ma->nodetree, ntree)) GPU_material_free(ma); WM_main_add_notifier(NC_IMAGE, NULL); } - WM_main_add_notifier(NC_MATERIAL|ND_NODES, node->id); + WM_main_add_notifier(NC_MATERIAL | ND_NODES, node->id); } - else if (ntree->type==NTREE_COMPOSIT) { + else if (ntree->type == NTREE_COMPOSIT) { /* make active viewer, currently only 1 supported... */ - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - if (was_output==0) + if (was_output == 0) ED_node_generic_update(bmain, ntree, node); /* addnode() doesnt link this yet... */ - node->id= (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } - else if (node->type==CMP_NODE_R_LAYERS) { + else if (node->type == CMP_NODE_R_LAYERS) { Scene *scene; - for (scene=bmain->scene.first; scene; scene=scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->nodetree && scene->use_nodes && has_nodetree(scene->nodetree, ntree)) { - if (node->id==NULL || node->id==(ID *)scene) { - scene->r.actlay= node->custom1; + if (node->id == NULL || node->id == (ID *)scene) { + scene->r.actlay = node->custom1; } } } } - else if (node->type==CMP_NODE_COMPOSITE) { - if (was_output==0) { + else if (node->type == CMP_NODE_COMPOSITE) { + if (was_output == 0) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( tnode->type==CMP_NODE_COMPOSITE) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (tnode->type == CMP_NODE_COMPOSITE) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; @@ -704,11 +704,11 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) } } } - else if (ntree->type==NTREE_TEXTURE) { + else if (ntree->type == NTREE_TEXTURE) { // XXX #if 0 if (node->id) - ; // XXX BIF_preview_changed(-1); + ; // XXX BIF_preview_changed(-1); // allqueue(REDRAWBUTSSHADING, 1); // allqueue(REDRAWIPO, 0); #endif @@ -745,7 +745,7 @@ static void edit_node_properties(wmOperatorType *ot) static int edit_node_invoke_properties(bContext *C, wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "node")) { - bNode *node= CTX_data_pointer_get_type(C, "node", &RNA_Node).data; + bNode *node = CTX_data_pointer_get_type(C, "node", &RNA_Node).data; if (!node) return 0; else @@ -764,7 +764,7 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op) static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **rnode, bNodeSocket **rsock, int *rin_out) { bNode *node; - bNodeSocket *sock=NULL; + bNodeSocket *sock = NULL; char nodename[MAX_NAME]; int sockindex; int in_out; @@ -776,8 +776,8 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r sockindex = RNA_int_get(op->ptr, "socket"); switch (in_out) { - case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; - case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; + case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; + case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; } if (rnode) @@ -796,25 +796,25 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode) bNode *node; /* make sure nothing has group editing on */ - for (node=snode->nodetree->nodes.first; node; node=node->next) + for (node = snode->nodetree->nodes.first; node; node = node->next) nodeGroupEditClear(node); - if (gnode==NULL) { + if (gnode == NULL) { /* with NULL argument we do a toggle */ - if (snode->edittree==snode->nodetree) - gnode= nodeGetActive(snode->nodetree); + if (snode->edittree == snode->nodetree) + gnode = nodeGetActive(snode->nodetree); } if (gnode) { snode->edittree = nodeGroupEditSet(gnode, 1); /* deselect all other nodes, so we can also do grabbing of entire subtree */ - for (node= snode->nodetree->nodes.first; node; node= node->next) + for (node = snode->nodetree->nodes.first; node; node = node->next) node_deselect(node); node_select(gnode); } else - snode->edittree= snode->nodetree; + snode->edittree = snode->nodetree; } static int node_group_edit_exec(bContext *C, wmOperator *UNUSED(op)) @@ -823,14 +823,14 @@ static int node_group_edit_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(C); - if (snode->nodetree==snode->edittree) { + if (snode->nodetree == snode->edittree) { bNode *gnode = nodeGetActive(snode->edittree); snode_make_group_editable(snode, gnode); } else snode_make_group_editable(snode, NULL); - WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL); return OPERATOR_FINISHED; } @@ -841,9 +841,9 @@ static int node_group_edit_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e bNode *gnode; /* XXX callback? */ - if (snode->nodetree==snode->edittree) { + if (snode->nodetree == snode->edittree) { gnode = nodeGetActive(snode->edittree); - if (gnode && gnode->id && GS(gnode->id->name)==ID_NT && gnode->id->lib) { + if (gnode && gnode->id && GS(gnode->id->name) == ID_NT && gnode->id->lib) { uiPupMenuOkee(C, op->type->idname, "Make group local?"); return OPERATOR_CANCELLED; } @@ -865,7 +865,7 @@ void NODE_OT_group_edit(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Add Group Socket operator ************* */ @@ -873,10 +873,10 @@ void NODE_OT_group_edit(wmOperatorType *ot) static int node_group_socket_add_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int in_out= -1; - char name[MAX_NAME]= ""; - int type= SOCK_FLOAT; - bNodeTree *ngroup= snode->edittree; + int in_out = -1; + char name[MAX_NAME] = ""; + int type = SOCK_FLOAT; + bNodeTree *ngroup = snode->edittree; /* bNodeSocket *sock; */ /* UNUSED */ ED_preview_kill_jobs(C); @@ -914,7 +914,7 @@ void NODE_OT_group_socket_add(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Group socket name"); @@ -926,9 +926,9 @@ void NODE_OT_group_socket_add(wmOperatorType *ot) static int node_group_socket_remove_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock; ED_preview_kill_jobs(C); @@ -943,7 +943,7 @@ static int node_group_socket_remove_exec(bContext *C, wmOperator *op) else return OPERATOR_CANCELLED; - sock = (bNodeSocket*)BLI_findlink(in_out==SOCK_IN ? &ngroup->inputs : &ngroup->outputs, index); + sock = (bNodeSocket *)BLI_findlink(in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs, index); if (sock) { node_group_remove_socket(ngroup, sock, in_out); ntreeUpdateTree(ngroup); @@ -966,7 +966,7 @@ void NODE_OT_group_socket_remove(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -977,9 +977,9 @@ void NODE_OT_group_socket_remove(wmOperatorType *ot) static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock, *prev; ED_preview_kill_jobs(C); @@ -995,8 +995,8 @@ static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* swap */ - if (in_out==SOCK_IN) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->inputs, index); + if (in_out == SOCK_IN) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->inputs, index); prev = sock->prev; /* can't move up the first socket */ if (!prev) @@ -1006,8 +1006,8 @@ static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) ngroup->update |= NTREE_UPDATE_GROUP_IN; } - else if (in_out==SOCK_OUT) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->outputs, index); + else if (in_out == SOCK_OUT) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->outputs, index); prev = sock->prev; /* can't move up the first socket */ if (!prev) @@ -1036,7 +1036,7 @@ void NODE_OT_group_socket_move_up(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -1047,9 +1047,9 @@ void NODE_OT_group_socket_move_up(wmOperatorType *ot) static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock, *next; ED_preview_kill_jobs(C); @@ -1065,8 +1065,8 @@ static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* swap */ - if (in_out==SOCK_IN) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->inputs, index); + if (in_out == SOCK_IN) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->inputs, index); next = sock->next; /* can't move down the last socket */ if (!next) @@ -1076,8 +1076,8 @@ static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) ngroup->update |= NTREE_UPDATE_GROUP_IN; } - else if (in_out==SOCK_OUT) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->outputs, index); + else if (in_out == SOCK_OUT) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->outputs, index); next = sock->next; /* can't move down the last socket */ if (!next) @@ -1106,7 +1106,7 @@ void NODE_OT_group_socket_move_down(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -1122,22 +1122,22 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) bNodeTree *ngroup, *wgroup; ListBase anim_basepaths = {NULL, NULL}; - ngroup= (bNodeTree *)gnode->id; - if (ngroup==NULL) return 0; + ngroup = (bNodeTree *)gnode->id; + if (ngroup == NULL) return 0; /* clear new pointers, set in copytree */ - for (node= ntree->nodes.first; node; node= node->next) - node->new_node= NULL; + for (node = ntree->nodes.first; node; node = node->next) + node->new_node = NULL; /* wgroup is a temporary copy of the NodeTree we're merging in * - all of wgroup's nodes are transferred across to their new home * - ngroup (i.e. the source NodeTree) is left unscathed */ - wgroup= ntreeCopyTree(ngroup); + wgroup = ntreeCopyTree(ngroup); /* add the nodes into the ntree */ - for (node= wgroup->nodes.first; node; node= nextn) { - nextn= node->next; + for (node = wgroup->nodes.first; node; node = nextn) { + nextn = node->next; /* keep track of this node's RNA "base" path (the part of the path identifying the node) * if the old nodetree has animation data which potentially covers this node @@ -1164,10 +1164,10 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } /* restore external links to and from the gnode */ - for (link= ntree->links.first; link; link= link->next) { - if (link->fromnode==gnode) { + for (link = ntree->links.first; link; link = link->next) { + if (link->fromnode == gnode) { if (link->fromsock->groupsock) { - bNodeSocket *gsock= link->fromsock->groupsock; + bNodeSocket *gsock = link->fromsock->groupsock; if (gsock->link) { if (gsock->link->fromnode) { /* NB: using the new internal copies here! the groupsock pointer still maps to the old tree */ @@ -1176,7 +1176,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } else { /* group output directly maps to group input */ - bNodeSocket *insock= node_group_find_input(gnode, gsock->link->fromsock); + bNodeSocket *insock = node_group_find_input(gnode, gsock->link->fromsock); if (insock->link) { link->fromnode = insock->link->fromnode; link->fromsock = insock->link->fromsock; @@ -1191,20 +1191,20 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } } /* remove internal output links, these are not used anymore */ - for (link=wgroup->links.first; link; link= linkn) { + for (link = wgroup->links.first; link; link = linkn) { linkn = link->next; if (!link->tonode) nodeRemLink(wgroup, link); } /* restore links from internal nodes */ - for (link= wgroup->links.first; link; link= link->next) { + for (link = wgroup->links.first; link; link = link->next) { /* indicates link to group input */ if (!link->fromnode) { /* NB: can't use find_group_node_input here, * because gnode sockets still point to the old tree! */ bNodeSocket *insock; - for (insock= gnode->inputs.first; insock; insock= insock->next) + for (insock = gnode->inputs.first; insock; insock = insock->next) if (insock->groupsock->new_sock == link->fromsock) break; if (insock->link) { @@ -1220,8 +1220,8 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } /* add internal links to the ntree */ - for (link= wgroup->links.first; link; link= linkn) { - linkn= link->next; + for (link = wgroup->links.first; link; link = linkn) { + linkn = link->next; BLI_remlink(&wgroup->links, link); BLI_addtail(&ntree->links, link); } @@ -1229,7 +1229,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* and copy across the animation, * note that the animation data's action can be NULL here */ if (wgroup->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; bAction *waction; /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */ @@ -1271,15 +1271,15 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); /* are we inside of a group? */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) snode_make_group_editable(snode, NULL); - gnode= nodeGetActive(snode->edittree); - if (gnode==NULL) + gnode = nodeGetActive(snode->edittree); + if (gnode == NULL) return OPERATOR_CANCELLED; - if (gnode->type!=NODE_GROUP) { + if (gnode->type != NODE_GROUP) { BKE_report(op->reports, RPT_WARNING, "Not a group"); return OPERATOR_CANCELLED; } @@ -1309,7 +1309,7 @@ void NODE_OT_group_ungroup(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Separate operator ********************** */ @@ -1322,19 +1322,19 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make bNodeTree *ngroup; ListBase anim_basepaths = {NULL, NULL}; - ngroup= (bNodeTree *)gnode->id; - if (ngroup==NULL) return 0; + ngroup = (bNodeTree *)gnode->id; + if (ngroup == NULL) return 0; /* deselect all nodes in the target tree */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node_deselect(node); /* clear new pointers, set in nodeCopyNode */ - for (node= ngroup->nodes.first; node; node= node->next) - node->new_node= NULL; + for (node = ngroup->nodes.first; node; node = node->next) + node->new_node = NULL; /* add selected nodes into the ntree */ - for (node= ngroup->nodes.first; node; node= node_next) { + for (node = ngroup->nodes.first; node; node = node_next) { node_next = node->next; if (!(node->flag & NODE_SELECT)) continue; @@ -1375,7 +1375,7 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make } /* add internal links to the ntree */ - for (link= ngroup->links.first; link; link= link_next) { + for (link = ngroup->links.first; link; link = link_next) { int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT)); int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT)); link_next = link->next; @@ -1400,7 +1400,7 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make /* and copy across the animation, * note that the animation data's action can be NULL here */ if (ngroup->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; /* now perform the moving */ BKE_animdata_separate_by_basepath(&ngroup->id, &ntree->id, &anim_basepaths); @@ -1428,7 +1428,7 @@ typedef enum eNodeGroupSeparateType { /* Operator Property */ EnumPropertyItem node_group_separate_types[] = { - {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, + {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, {NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"}, {0, NULL, 0, NULL, NULL} }; @@ -1442,25 +1442,25 @@ static int node_group_separate_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); /* are we inside of a group? */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (!gnode) { BKE_report(op->reports, RPT_WARNING, "Not inside node group"); return OPERATOR_CANCELLED; } switch (type) { - case NODE_GS_COPY: - if (!node_group_separate_selected(snode->nodetree, gnode, 1)) { - BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); - return OPERATOR_CANCELLED; - } - break; - case NODE_GS_MOVE: - if (!node_group_separate_selected(snode->nodetree, gnode, 0)) { - BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); - return OPERATOR_CANCELLED; - } - break; + case NODE_GS_COPY: + if (!node_group_separate_selected(snode->nodetree, gnode, 1)) { + BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); + return OPERATOR_CANCELLED; + } + break; + case NODE_GS_MOVE: + if (!node_group_separate_selected(snode->nodetree, gnode, 0)) { + BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); + return OPERATOR_CANCELLED; + } + break; } /* switch to parent tree */ @@ -1501,7 +1501,7 @@ void NODE_OT_group_separate(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", ""); } @@ -1513,7 +1513,7 @@ static bNode *visible_node(SpaceNode *snode, rctf *rct) { bNode *node; - for (node=snode->edittree->nodes.last; node; node=node->prev) { + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (BLI_isect_rctf(&node->totr, rct, NULL)) break; } @@ -1529,17 +1529,17 @@ typedef struct NodeViewMove { static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - NodeViewMove *nvm= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + NodeViewMove *nvm = op->customdata; switch (event->type) { case MOUSEMOVE: - snode->xof -= (nvm->mvalo[0]-event->mval[0]); - snode->yof -= (nvm->mvalo[1]-event->mval[1]); - nvm->mvalo[0]= event->mval[0]; - nvm->mvalo[1]= event->mval[1]; + snode->xof -= (nvm->mvalo[0] - event->mval[0]); + snode->yof -= (nvm->mvalo[1] - event->mval[1]); + nvm->mvalo[0] = event->mval[0]; + nvm->mvalo[1] = event->mval[1]; /* prevent dragging image outside of the window and losing it! */ CLAMP(snode->xof, nvm->xmin, nvm->xmax); @@ -1554,9 +1554,9 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTMOUSE: MEM_freeN(nvm); - op->customdata= NULL; + op->customdata = NULL; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE, NULL); return OPERATOR_FINISHED; } @@ -1566,30 +1566,30 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); NodeViewMove *nvm; Image *ima; ImBuf *ibuf; - int pad= 10; + int pad = 10; void *lock; - ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); - ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf == NULL) { BKE_image_release_ibuf(ima, lock); return OPERATOR_CANCELLED; } - nvm= MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct"); - op->customdata= nvm; - nvm->mvalo[0]= event->mval[0]; - nvm->mvalo[1]= event->mval[1]; + nvm = MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct"); + op->customdata = nvm; + nvm->mvalo[0] = event->mval[0]; + nvm->mvalo[1] = event->mval[1]; - nvm->xmin = -(ar->winx/2) - ibuf->x/2 + pad; - nvm->xmax = ar->winx/2 + ibuf->x/2 - pad; - nvm->ymin = -(ar->winy/2) - ibuf->y/2 + pad; - nvm->ymax = ar->winy/2 + ibuf->y/2 - pad; + nvm->xmin = -(ar->winx / 2) - ibuf->x / 2 + pad; + nvm->xmax = ar->winx / 2 + ibuf->x / 2 - pad; + nvm->ymin = -(ar->winy / 2) - ibuf->y / 2 + pad; + nvm->ymax = ar->winy / 2 + ibuf->y / 2 - pad; BKE_image_release_ibuf(ima, lock); @@ -1602,7 +1602,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) static int snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; return OPERATOR_CANCELLED; } @@ -1621,14 +1621,14 @@ void NODE_OT_backimage_move(wmOperatorType *ot) ot->cancel = snode_bg_viewmove_cancel; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; } static int backimage_zoom(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - float fac= RNA_float_get(op->ptr, "factor"); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + float fac = RNA_float_get(op->ptr, "factor"); snode->zoom *= fac; ED_region_tag_redraw(ar); @@ -1674,28 +1674,32 @@ typedef struct ImageSampleInfo { static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) { Scene *scene = CTX_data_scene(C); - ImageSampleInfo *info= arg_info; + ImageSampleInfo *info = arg_info; - ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, - info->x, info->y, info->col, info->colf, - NULL, NULL /* zbuf - unused for nodes */ - ); + if (info->draw) { + ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, + info->x, info->y, info->col, info->colf, + NULL, NULL /* zbuf - unused for nodes */ + ); + } } static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - ImageSampleInfo *info= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + ImageSampleInfo *info = op->customdata; void *lock; Image *ima; ImBuf *ibuf; float fx, fy, bufx, bufy; - ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); - ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - if (!ibuf) + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + if (!ibuf) { + info->draw = 0; return; + } if (!ibuf->rect) { if (info->color_manage) @@ -1708,46 +1712,50 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) /* map the mouse coords to the backdrop image space */ bufx = ibuf->x * snode->zoom; bufy = ibuf->y * snode->zoom; - fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f); - fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f); + fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f); + fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f); - if (fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { + if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { float *fp; char *cp; - int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); + int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); - CLAMP(x, 0, ibuf->x-1); - CLAMP(y, 0, ibuf->y-1); + CLAMP(x, 0, ibuf->x - 1); + CLAMP(y, 0, ibuf->y - 1); - info->x= x; - info->y= y; - info->draw= 1; - info->channels= ibuf->channels; + info->x = x; + info->y = y; + info->draw = 1; + info->channels = ibuf->channels; if (ibuf->rect) { - cp= (char *)(ibuf->rect + y*ibuf->x + x); + cp = (char *)(ibuf->rect + y * ibuf->x + x); - info->col[0]= cp[0]; - info->col[1]= cp[1]; - info->col[2]= cp[2]; - info->col[3]= cp[3]; + info->col[0] = cp[0]; + info->col[1] = cp[1]; + info->col[2] = cp[2]; + info->col[3] = cp[3]; - info->colf[0]= (float)cp[0]/255.0f; - info->colf[1]= (float)cp[1]/255.0f; - info->colf[2]= (float)cp[2]/255.0f; - info->colf[3]= (float)cp[3]/255.0f; + info->colf[0] = (float)cp[0] / 255.0f; + info->colf[1] = (float)cp[1] / 255.0f; + info->colf[2] = (float)cp[2] / 255.0f; + info->colf[3] = (float)cp[3] / 255.0f; } if (ibuf->rect_float) { - fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); + fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - info->colf[0]= fp[0]; - info->colf[1]= fp[1]; - info->colf[2]= fp[2]; - info->colf[3]= fp[3]; + info->colf[0] = fp[0]; + info->colf[1] = fp[1]; + info->colf[2] = fp[2]; + info->colf[3] = fp[3]; } + + ED_node_sample_set(info->colf); + } + else { + info->draw = 0; + ED_node_sample_set(NULL); } - else - info->draw= 0; BKE_image_release_ibuf(ima, lock); @@ -1756,8 +1764,9 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) static void sample_exit(bContext *C, wmOperator *op) { - ImageSampleInfo *info= op->customdata; + ImageSampleInfo *info = op->customdata; + ED_node_sample_set(NULL); ED_region_draw_cb_exit(info->art, info->draw_handle); ED_area_tag_redraw(CTX_wm_area(C)); MEM_freeN(info); @@ -1765,17 +1774,17 @@ static void sample_exit(bContext *C, wmOperator *op) static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); ImageSampleInfo *info; - if (snode->treetype!=NTREE_COMPOSIT || !(snode->flag & SNODE_BACKDRAW)) + if (snode->treetype != NTREE_COMPOSIT || !(snode->flag & SNODE_BACKDRAW)) return OPERATOR_CANCELLED; - info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); - info->art= ar->type; + info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); + info->art = ar->type; info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL); - op->customdata= info; + op->customdata = info; sample_apply(C, op, event); @@ -1837,20 +1846,20 @@ static void node_resize_init(bContext *C, wmOperator *op, wmEvent *UNUSED(event) { SpaceNode *snode = CTX_wm_space_node(C); - NodeSizeWidget *nsw= MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); + NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); - op->customdata= nsw; - nsw->mxstart= snode->mx; - nsw->mystart= snode->my; + op->customdata = nsw; + nsw->mxstart = snode->mx; + nsw->mystart = snode->my; /* store old */ - nsw->oldlocx= node->locx; - nsw->oldlocy= node->locy; - nsw->oldoffsetx= node->offsetx; - nsw->oldoffsety= node->offsety; - nsw->oldwidth= node->width; - nsw->oldheight= node->height; - nsw->oldminiwidth= node->miniwidth; + nsw->oldlocx = node->locx; + nsw->oldlocy = node->locy; + nsw->oldoffsetx = node->offsetx; + nsw->oldoffsety = node->offsety; + nsw->oldwidth = node->width; + nsw->oldheight = node->height; + nsw->oldminiwidth = node->miniwidth; nsw->directions = dir; WM_cursor_modal(CTX_wm_window(C), node_get_resize_cursor(dir)); @@ -1863,15 +1872,15 @@ static void node_resize_exit(bContext *C, wmOperator *op, int UNUSED(cancel)) WM_cursor_restore(CTX_wm_window(C)); MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNode *node= editnode_get_active(snode->edittree); - NodeSizeWidget *nsw= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNode *node = editnode_get_active(snode->edittree); + NodeSizeWidget *nsw = op->customdata; float mx, my, dx, dy; switch (event->type) { @@ -1886,46 +1895,46 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) float widthmin = 0.0f; float widthmax = 100.0f; if (nsw->directions & NODE_RESIZE_RIGHT) { - node->miniwidth= nsw->oldminiwidth + dx; + node->miniwidth = nsw->oldminiwidth + dx; CLAMP(node->miniwidth, widthmin, widthmax); } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + nsw->oldminiwidth; - node->locx= nsw->oldlocx + dx; + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); - node->miniwidth= locmax - node->locx; + node->miniwidth = locmax - node->locx; } } else { - float widthmin = UI_DPI_FAC*node->typeinfo->minwidth; - float widthmax = UI_DPI_FAC*node->typeinfo->maxwidth; + float widthmin = UI_DPI_FAC * node->typeinfo->minwidth; + float widthmax = UI_DPI_FAC * node->typeinfo->maxwidth; if (nsw->directions & NODE_RESIZE_RIGHT) { - node->width= nsw->oldwidth + dx; + node->width = nsw->oldwidth + dx; CLAMP(node->width, widthmin, widthmax); } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + nsw->oldwidth; - node->locx= nsw->oldlocx + dx; + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); - node->width= locmax - node->locx; + node->width = locmax - node->locx; } } /* height works the other way round ... */ { - float heightmin = UI_DPI_FAC*node->typeinfo->minheight; - float heightmax = UI_DPI_FAC*node->typeinfo->maxheight; + float heightmin = UI_DPI_FAC * node->typeinfo->minheight; + float heightmax = UI_DPI_FAC * node->typeinfo->maxheight; if (nsw->directions & NODE_RESIZE_TOP) { float locmin = nsw->oldlocy - nsw->oldheight; - node->locy= nsw->oldlocy + dy; + node->locy = nsw->oldlocy + dy; CLAMP(node->locy, locmin + heightmin, locmin + heightmax); - node->height= node->locy - locmin; + node->height = node->locy - locmin; } if (nsw->directions & NODE_RESIZE_BOTTOM) { - node->height= nsw->oldheight - dy; + node->height = nsw->oldheight - dy; CLAMP(node->height, heightmin, heightmax); } } @@ -1934,20 +1943,20 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) if (node->type == NODE_FRAME) { /* keep the offset symmetric around center point */ if (nsw->directions & NODE_RESIZE_LEFT) { - node->locx = nsw->oldlocx + 0.5f*dx; - node->offsetx = nsw->oldoffsetx + 0.5f*dx; + node->locx = nsw->oldlocx + 0.5f * dx; + node->offsetx = nsw->oldoffsetx + 0.5f * dx; } if (nsw->directions & NODE_RESIZE_RIGHT) { - node->locx = nsw->oldlocx + 0.5f*dx; - node->offsetx = nsw->oldoffsetx - 0.5f*dx; + node->locx = nsw->oldlocx + 0.5f * dx; + node->offsetx = nsw->oldoffsetx - 0.5f * dx; } if (nsw->directions & NODE_RESIZE_TOP) { - node->locy = nsw->oldlocy + 0.5f*dy; - node->offsety = nsw->oldoffsety + 0.5f*dy; + node->locy = nsw->oldlocy + 0.5f * dy; + node->offsety = nsw->oldoffsety + 0.5f * dy; } if (nsw->directions & NODE_RESIZE_BOTTOM) { - node->locy = nsw->oldlocy + 0.5f*dy; - node->offsety = nsw->oldoffsety - 0.5f*dy; + node->locy = nsw->oldlocy + 0.5f * dy; + node->offsety = nsw->oldoffsety - 0.5f * dy; } } } @@ -1971,9 +1980,9 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNode *node= editnode_get_active(snode->edittree); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNode *node = editnode_get_active(snode->edittree); int dir; if (node) { @@ -1986,7 +1995,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } static int node_resize_cancel(bContext *C, wmOperator *op) @@ -2020,10 +2029,10 @@ int node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; - for (sock= node->inputs.first; sock; sock= sock->next) + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; - for (sock= node->outputs.first; sock; sock= sock->next) + for (sock = node->outputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; return 0; @@ -2033,20 +2042,20 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set) { bNodeSocket *sock; - if (set==0) { - for (sock= node->inputs.first; sock; sock= sock->next) + if (set == 0) { + for (sock = node->inputs.first; sock; sock = sock->next) sock->flag &= ~SOCK_HIDDEN; - for (sock= node->outputs.first; sock; sock= sock->next) + for (sock = node->outputs.first; sock; sock = sock->next) sock->flag &= ~SOCK_HIDDEN; } else { /* hide unused sockets */ - for (sock= node->inputs.first; sock; sock= sock->next) { - if (sock->link==NULL) + for (sock = node->inputs.first; sock; sock = sock->next) { + if (sock->link == NULL) sock->flag |= SOCK_HIDDEN; } - for (sock= node->outputs.first; sock; sock= sock->next) { - if (nodeCountSocketLinks(snode->edittree, sock)==0) + for (sock = node->outputs.first; sock; sock = sock->next) { + if (nodeCountSocketLinks(snode->edittree, sock) == 0) sock->flag |= SOCK_HIDDEN; } } @@ -2060,20 +2069,20 @@ static int node_link_viewer(const bContext *C, bNode *tonode) bNodeSocket *sock; /* context check */ - if (tonode==NULL || tonode->outputs.first==NULL) + if (tonode == NULL || tonode->outputs.first == NULL) return OPERATOR_CANCELLED; - if ( ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) return OPERATOR_CANCELLED; /* get viewer */ - for (node= snode->edittree->nodes.first; node; node= node->next) - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + for (node = snode->edittree->nodes.first; node; node = node->next) + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) if (node->flag & NODE_DO_OUTPUT) break; /* no viewer, we make one active */ - if (node==NULL) { - for (node= snode->edittree->nodes.first; node; node= node->next) { - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (node == NULL) { + for (node = snode->edittree->nodes.first; node; node = node->next) { + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { node->flag |= NODE_DO_OUTPUT; break; } @@ -2085,17 +2094,17 @@ static int node_link_viewer(const bContext *C, bNode *tonode) /* try to find an already connected socket to cycle to the next */ if (node) { link = NULL; - for (link= snode->edittree->links.first; link; link= link->next) - if (link->tonode==node && link->fromnode==tonode) - if (link->tosock==node->inputs.first) + for (link = snode->edittree->links.first; link; link = link->next) + if (link->tonode == node && link->fromnode == tonode) + if (link->tosock == node->inputs.first) break; if (link) { /* unlink existing connection */ - sock= link->fromsock; + sock = link->fromsock; nodeRemLink(snode->edittree, link); /* find a socket after the previously connected socket */ - for (sock=sock->next; sock; sock= sock->next) + for (sock = sock->next; sock; sock = sock->next) if (!nodeSocketIsHidden(sock)) break; } @@ -2103,7 +2112,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode) /* find a socket starting from the first socket */ if (!sock) { - for (sock= tonode->outputs.first; sock; sock= sock->next) + for (sock = tonode->outputs.first; sock; sock = sock->next) if (!nodeSocketIsHidden(sock)) break; } @@ -2125,17 +2134,17 @@ static int node_link_viewer(const bContext *C, bNode *tonode) } else { /* get link to viewer */ - for (link= snode->edittree->links.first; link; link= link->next) - if (link->tonode==node && link->tosock==node->inputs.first) + for (link = snode->edittree->links.first; link; link = link->next) + if (link->tonode == node && link->tosock == node->inputs.first) break; } - if (link==NULL) { + if (link == NULL) { nodeAddLink(snode->edittree, tonode, sock, node, node->inputs.first); } else { - link->fromnode= tonode; - link->fromsock= sock; + link->fromnode = tonode; + link->fromsock = sock; /* make sure the dependency sorting is updated */ snode->edittree->update |= NTREE_UPDATE_LINKS; } @@ -2149,10 +2158,10 @@ static int node_link_viewer(const bContext *C, bNode *tonode) static int node_active_link_viewer(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - node= editnode_get_active(snode->edittree); + node = editnode_get_active(snode->edittree); if (!node) return OPERATOR_CANCELLED; @@ -2181,31 +2190,31 @@ void NODE_OT_link_viewer(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* return 0, nothing done */ -static int UNUSED_FUNCTION(node_mouse_groupheader)(SpaceNode *snode) +static int UNUSED_FUNCTION(node_mouse_groupheader) (SpaceNode * snode) { bNode *gnode; - float mx=0, my=0; + float mx = 0, my = 0; // XXX int mval[2]; - gnode= node_tree_get_editgroup(snode->nodetree); - if (gnode==NULL) return 0; + gnode = node_tree_get_editgroup(snode->nodetree); + if (gnode == NULL) return 0; // XXX getmouseco_areawin(mval); // XXX areamouseco_to_ipoco(G.v2d, mval, &mx, &my); /* click in header or outside? */ - if (BLI_in_rctf(&gnode->totr, mx, my)==0) { - rctf rect= gnode->totr; + if (BLI_in_rctf(&gnode->totr, mx, my) == 0) { + rctf rect = gnode->totr; rect.ymax += NODE_DY; - if (BLI_in_rctf(&rect, mx, my)==0) - snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ + if (BLI_in_rctf(&rect, mx, my) == 0) + snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ // else // XXX transform_nodes(snode->nodetree, 'g', "Move group"); @@ -2222,36 +2231,36 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so bNodeSocket *sock; rctf rect; - *nodep= NULL; - *sockp= NULL; + *nodep = NULL; + *sockp = NULL; /* check if we click in a socket */ - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { - rect.xmin = snode->mx - (NODE_SOCKSIZE+4); - rect.ymin = snode->my - (NODE_SOCKSIZE+4); - rect.xmax = snode->mx + (NODE_SOCKSIZE+4); - rect.ymax = snode->my + (NODE_SOCKSIZE+4); + rect.xmin = snode->mx - (NODE_SOCKSIZE + 4); + rect.ymin = snode->my - (NODE_SOCKSIZE + 4); + rect.xmax = snode->mx + (NODE_SOCKSIZE + 4); + rect.ymax = snode->my + (NODE_SOCKSIZE + 4); if (!(node->flag & NODE_HIDDEN)) { /* extra padding inside and out - allow dragging on the text areas too */ if (in_out == SOCK_IN) { rect.xmax += NODE_SOCKSIZE; - rect.xmin -= NODE_SOCKSIZE*4; + rect.xmin -= NODE_SOCKSIZE * 4; } else if (in_out == SOCK_OUT) { - rect.xmax += NODE_SOCKSIZE*4; + rect.xmax += NODE_SOCKSIZE * 4; rect.xmin -= NODE_SOCKSIZE; } } if (in_out & SOCK_IN) { - for (sock= node->inputs.first; sock; sock= sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { - *nodep= node; - *sockp= sock; + *nodep = node; + *sockp = sock; return 1; } } @@ -2259,12 +2268,12 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so } } if (in_out & SOCK_OUT) { - for (sock= node->outputs.first; sock; sock= sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { - *nodep= node; - *sockp= sock; + *nodep = node; + *sockp = sock; return 1; } } @@ -2277,22 +2286,22 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so * NB: using ngroup->outputs as input sockets and vice versa here! */ if (in_out & SOCK_IN) { - for (sock= snode->edittree->outputs.first; sock; sock= sock->next) { + for (sock = snode->edittree->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { - *nodep= NULL; /* NULL node pointer indicates group socket */ - *sockp= sock; + *nodep = NULL; /* NULL node pointer indicates group socket */ + *sockp = sock; return 1; } } } } if (in_out & SOCK_OUT) { - for (sock= snode->edittree->inputs.first; sock; sock= sock->next) { + for (sock = snode->edittree->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { - *nodep= NULL; /* NULL node pointer indicates group socket */ - *sockp= sock; + *nodep = NULL; /* NULL node pointer indicates group socket */ + *sockp = sock; return 1; } } @@ -2304,7 +2313,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so static int outside_group_rect(SpaceNode *snode) { - bNode *gnode= node_tree_get_editgroup(snode->nodetree); + bNode *gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) { return (snode->mx < gnode->totr.xmin || snode->mx >= gnode->totr.xmax || @@ -2351,7 +2360,7 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke bNodeSocket *sock; /* first look for selected output */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; @@ -2360,19 +2369,19 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke } /* try to find a socket with a matching name */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; /* check for same types */ if (sock->type == sock_target->type) { - if (strcmp(sock->name, sock_target->name)==0) + if (strcmp(sock->name, sock_target->name) == 0) return sock; } } /* otherwise settle for the first available socket of the right type */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; @@ -2391,16 +2400,16 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, int replace) { bNodeSocket *sock; - int socktype, maxtype=0; + int socktype, maxtype = 0; int a = 0; - for (sock=node->inputs.first; sock; sock=sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { maxtype = MAX2(sock->type, maxtype); } /* find sockets of higher 'types' first (i.e. image) */ - for (socktype=maxtype; socktype >= 0; socktype--) { - for (sock=node->inputs.first; sock; sock=sock->next) { + for (socktype = maxtype; socktype >= 0; socktype--) { + for (sock = node->inputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, replace)) { a++; @@ -2447,9 +2456,9 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list"); bNodeListItem *nli; bNode *node; - int i, numlinks=0; + int i, numlinks = 0; - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) { nli = MEM_mallocN(sizeof(bNodeListItem), "temporary node list item"); nli->node = node; @@ -2460,7 +2469,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* sort nodes left to right */ BLI_sortlist(nodelist, sort_nodes_locx); - for (nli=nodelist->first; nli; nli=nli->next) { + for (nli = nodelist->first; nli; nli = nli->next) { bNode *node_fr, *node_to; bNodeSocket *sock_fr, *sock_to; int has_selected_inputs = 0; @@ -2471,7 +2480,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) node_to = nli->next->node; /* if there are selected sockets, connect those */ - for (sock_to = node_to->inputs.first; sock_to; sock_to=sock_to->next) { + for (sock_to = node_to->inputs.first; sock_to; sock_to = sock_to->next) { if (sock_to->flag & SELECT) { has_selected_inputs = 1; @@ -2492,7 +2501,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* no selected inputs, connect by finding suitable match */ int num_inputs = BLI_countlist(&node_to->inputs); - for (i=0; i<num_inputs; i++) { + for (i = 0; i < num_inputs; i++) { /* find the best guess input socket */ sock_to = best_socket_input(ntree, node_to, i, replace); @@ -2523,7 +2532,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* can be called from menus too, but they should do own undopush and redraws */ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate *ntemp, float locx, float locy) { - bNode *node= NULL, *gnode; + bNode *node = NULL, *gnode; node_deselect_all(snode); @@ -2531,11 +2540,11 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate /* generics */ if (node) { - node->locx= locx; - node->locy= locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node + node->locx = locx; + node->locy = locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node node_select(node); - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) { node->locx -= gnode->locx; node->locy -= gnode->locy; @@ -2544,7 +2553,7 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate ntreeUpdateTree(snode->edittree); ED_node_set_active(bmain, snode->edittree, node); - if (snode->nodetree->type==NTREE_COMPOSIT) { + if (snode->nodetree->type == NTREE_COMPOSIT) { if (ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) { node->id = &scene->id; } @@ -2561,7 +2570,7 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate snode_update(snode, node); } - if (snode->nodetree->type==NTREE_TEXTURE) { + if (snode->nodetree->type == NTREE_TEXTURE) { ntreeTexCheckCyclics(snode->edittree); } @@ -2577,7 +2586,7 @@ static void node_duplicate_reparent_recursive(bNode *node) node->flag |= NODE_TEST; /* find first selected parent */ - for (parent=node->parent; parent; parent=parent->parent) { + for (parent = node->parent; parent; parent = parent->parent) { if (parent->flag & SELECT) { if (!(parent->flag & NODE_TEST)) node_duplicate_reparent_recursive(parent); @@ -2593,8 +2602,8 @@ static void node_duplicate_reparent_recursive(bNode *node) static int node_duplicate_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeTree *ntree= snode->edittree; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeTree *ntree = snode->edittree; bNode *node, *newnode, *lastnode; bNodeLink *link, *newlink, *lastlink; int keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs"); @@ -2602,7 +2611,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); lastnode = ntree->nodes.last; - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { newnode = nodeCopyNode(ntree, node); @@ -2616,7 +2625,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new nodes again! */ - if (node==lastnode) + if (node == lastnode) break; } @@ -2624,7 +2633,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) * NB: this depends on correct node->new_node and sock->new_sock pointers from above copy! */ lastlink = ntree->links.last; - for (link=ntree->links.first; link; link=link->next) { + for (link = ntree->links.first; link; link = link->next) { /* This creates new links between copied nodes. * If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)! */ @@ -2649,25 +2658,25 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new links again! */ - if (link==lastlink) + if (link == lastlink) break; } /* clear flags for recursive depth-first iteration */ - for (node= ntree->nodes.first; node; node= node->next) + for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; /* reparent copied nodes */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) node_duplicate_reparent_recursive(node); /* only has to check old nodes */ - if (node==lastnode) + if (node == lastnode) break; } /* deselect old nodes, select the copies instead */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { /* has been set during copy above */ newnode = node->new_node; @@ -2678,7 +2687,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new nodes again! */ - if (node==lastnode) + if (node == lastnode) break; } @@ -2702,7 +2711,7 @@ void NODE_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes"); } @@ -2716,21 +2725,21 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL if (tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) { - for (tlink= snode->edittree->links.first; tlink; tlink= tlink->next) { - if (link!=tlink && tlink->tosock==link->tosock) + for (tlink = snode->edittree->links.first; tlink; tlink = tlink->next) { + if (link != tlink && tlink->tosock == link->tosock) break; } if (tlink) { /* try to move the existing link to the next available socket */ if (tlink->tonode) { /* is there a free input socket with the target type? */ - for (sock= tlink->tonode->inputs.first; sock; sock= sock->next) { - if (sock->type==tlink->tosock->type) + for (sock = tlink->tonode->inputs.first; sock; sock = sock->next) { + if (sock->type == tlink->tosock->type) if (nodeCountSocketLinks(snode->edittree, sock) < sock->limit) break; } if (sock) { - tlink->tosock= sock; + tlink->tosock = sock; sock->flag &= ~SOCK_HIDDEN; } else { @@ -2749,12 +2758,12 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL /* in_out = starting socket */ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNodeLinkDrag *nldrag= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNodeLinkDrag *nldrag = op->customdata; bNodeTree *ntree = snode->edittree; bNode *tnode; - bNodeSocket *tsock= NULL; + bNodeSocket *tsock = NULL; bNodeLink *link; LinkData *linkdata; int in_out; @@ -2762,14 +2771,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) in_out = nldrag->in_out; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); switch (event->type) { case MOUSEMOVE: - if (in_out==SOCK_OUT) { + if (in_out == SOCK_OUT) { if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_IN)) { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; /* skip if this is already the target socket */ @@ -2792,14 +2801,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { int do_update = FALSE; - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->tonode || link->tosock) { BLI_remlink(&ntree->links, link); link->prev = link->next = NULL; - link->tonode= NULL; - link->tosock= NULL; + link->tonode = NULL; + link->tosock = NULL; ntree->update |= NTREE_UPDATE_LINKS; do_update = TRUE; @@ -2812,7 +2821,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_OUT)) { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; /* skip if this is already the target socket */ @@ -2835,14 +2844,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { int do_update = FALSE; - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->fromnode || link->fromsock) { BLI_remlink(&ntree->links, link); link->prev = link->next = NULL; - link->fromnode= NULL; - link->fromsock= NULL; + link->fromnode = NULL; + link->fromsock = NULL; ntree->update |= NTREE_UPDATE_LINKS; do_update = TRUE; @@ -2860,7 +2869,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->tosock && link->fromsock) { @@ -2869,7 +2878,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) snode_update(snode, link->tonode); /* we might need to remove a link */ - if (in_out==SOCK_OUT) + if (in_out == SOCK_OUT) node_remove_extra_links(snode, link->tosock, link); /* when linking to group outputs, update the socket type */ @@ -2930,16 +2939,16 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) /* output indicated? */ if (node_find_indicated_socket(snode, &node, &sock, SOCK_OUT)) { - nldrag= MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); + nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); num_links = nodeCountSocketLinks(snode->edittree, sock); if (num_links > 0 && (num_links >= sock->limit || detach)) { /* dragged links are fixed on input side */ nldrag->in_out = SOCK_IN; /* detach current links and store them in the operator data */ - for (link= snode->edittree->links.first; link; link= link_next) { + for (link = snode->edittree->links.first; link; link = link_next) { link_next = link->next; - if (link->fromsock==sock) { + if (link->fromsock == sock) { linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data"); linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link"); *oplink = *link; @@ -2962,16 +2971,16 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) } /* or an input? */ else if (node_find_indicated_socket(snode, &node, &sock, SOCK_IN)) { - nldrag= MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); + nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); num_links = nodeCountSocketLinks(snode->edittree, sock); if (num_links > 0 && (num_links >= sock->limit || detach)) { /* dragged links are fixed on output side */ nldrag->in_out = SOCK_OUT; /* detach current links and store them in the operator data */ - for (link= snode->edittree->links.first; link; link= link_next) { + for (link = snode->edittree->links.first; link; link = link_next) { link_next = link->next; - if (link->tosock==sock) { + if (link->tosock == sock) { linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data"); linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link"); *oplink = *link; @@ -3002,20 +3011,20 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); bNodeLinkDrag *nldrag; int detach = RNA_boolean_get(op->ptr, "detach"); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); ED_preview_kill_jobs(C); nldrag = node_link_init(snode, detach); if (nldrag) { - op->customdata= nldrag; + op->customdata = nldrag; BLI_addtail(&snode->linkdrag, nldrag); /* add modal handler */ @@ -3024,13 +3033,13 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } else - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } static int node_link_cancel(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeLinkDrag *nldrag= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeLinkDrag *nldrag = op->customdata; BLI_remlink(&snode->linkdrag, nldrag); @@ -3055,7 +3064,7 @@ void NODE_OT_link(wmOperatorType *ot) ot->cancel = node_link_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_boolean(ot->srna, "detach", FALSE, "Detach", "Detach and redirect existing links"); } @@ -3065,7 +3074,7 @@ void NODE_OT_link(wmOperatorType *ot) /* makes a link between selected output and input sockets */ static int node_make_link_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); int replace = RNA_boolean_get(op->ptr, "replace"); ED_preview_kill_jobs(C); @@ -3095,7 +3104,7 @@ void NODE_OT_link_make(wmOperatorType *ot) ot->poll = ED_operator_node_active; // XXX we need a special poll which checks that there are selected input/output sockets /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "replace", 0, "Replace", "Replace socket connections with the new links"); } @@ -3104,16 +3113,16 @@ void NODE_OT_link_make(wmOperatorType *ot) #define LINK_RESOL 12 static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int tot, float result[2]) { - float coord_array[LINK_RESOL+1][2]; + float coord_array[LINK_RESOL + 1][2]; int i, b; if (node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { - for (i=0; i<tot-1; i++) - for (b=0; b<LINK_RESOL; b++) - if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) { - result[0] = (mcoords[i][0]+mcoords[i+1][0])/2.0f; - result[1] = (mcoords[i][1]+mcoords[i+1][1])/2.0f; + for (i = 0; i < tot - 1; i++) + for (b = 0; b < LINK_RESOL; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) { + result[0] = (mcoords[i][0] + mcoords[i + 1][0]) / 2.0f; + result[1] = (mcoords[i][1] + mcoords[i + 1][1]) / 2.0f; return 1; } } @@ -3122,29 +3131,30 @@ static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int static int add_reroute_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); float mcoords[256][2]; - int i= 0; + int i = 0; - RNA_BEGIN(op->ptr, itemptr, "path") { + RNA_BEGIN(op->ptr, itemptr, "path") + { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); UI_view2d_region_to_view(&ar->v2d, (short)loc[0], (short)loc[1], - &mcoords[i][0], &mcoords[i][1]); + &mcoords[i][0], &mcoords[i][1]); i++; - if (i>= 256) break; + if (i >= 256) break; } RNA_END; - if (i>1) { + if (i > 1) { bNodeLink *link; float insertPoint[2]; ED_preview_kill_jobs(C); - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (add_reroute_intersect_check(link, mcoords, i, insertPoint)) { bNodeTemplate ntemp; bNode *rerouteNode; @@ -3171,27 +3181,27 @@ static int add_reroute_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } void NODE_OT_add_reroute(wmOperatorType *ot) { PropertyRNA *prop; - ot->name= "Add reroute"; - ot->idname= "NODE_OT_add_reroute"; + ot->name = "Add reroute"; + ot->idname = "NODE_OT_add_reroute"; - ot->invoke= WM_gesture_lines_invoke; - ot->modal= WM_gesture_lines_modal; - ot->exec= add_reroute_exec; - ot->cancel= WM_gesture_lines_cancel; + ot->invoke = WM_gesture_lines_invoke; + ot->modal = WM_gesture_lines_modal; + ot->exec = add_reroute_exec; + ot->cancel = WM_gesture_lines_cancel; - ot->poll= ED_operator_node_active; + ot->poll = ED_operator_node_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); /* internal */ RNA_def_int(ot->srna, "cursor", BC_CROSSCURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); @@ -3201,14 +3211,14 @@ void NODE_OT_add_reroute(wmOperatorType *ot) /* ********************** Cut Link operator ***************** */ static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) { - float coord_array[LINK_RESOL+1][2]; + float coord_array[LINK_RESOL + 1][2]; int i, b; if (node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { - for (i=0; i<tot-1; i++) - for (b=0; b<LINK_RESOL; b++) - if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) + for (i = 0; i < tot - 1; i++) + for (b = 0; b < LINK_RESOL; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) return 1; } return 0; @@ -3216,30 +3226,30 @@ static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) static int cut_links_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); float mcoords[256][2]; - int i= 0; + int i = 0; - RNA_BEGIN (op->ptr, itemptr, "path") + RNA_BEGIN(op->ptr, itemptr, "path") { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); UI_view2d_region_to_view(&ar->v2d, (int)loc[0], (int)loc[1], - &mcoords[i][0], &mcoords[i][1]); + &mcoords[i][0], &mcoords[i][1]); i++; - if (i>= 256) break; + if (i >= 256) break; } RNA_END; - if (i>1) { + if (i > 1) { bNodeLink *link, *next; ED_preview_kill_jobs(C); - for (link= snode->edittree->links.first; link; link= next) { - next= link->next; + for (link = snode->edittree->links.first; link; link = next) { + next = link->next; if (cut_links_intersect(link, mcoords, i)) { snode_update(snode, link->tonode); @@ -3254,7 +3264,7 @@ static int cut_links_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } void NODE_OT_links_cut(wmOperatorType *ot) @@ -3273,9 +3283,9 @@ void NODE_OT_links_cut(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); /* internal */ RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); @@ -3285,13 +3295,13 @@ void NODE_OT_links_cut(wmOperatorType *ot) static int detach_links_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeTree *ntree= snode->edittree; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeTree *ntree = snode->edittree; bNode *node; ED_preview_kill_jobs(C); - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { nodeInternalRelink(ntree, node); } @@ -3315,7 +3325,7 @@ void NODE_OT_links_detach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************* automatic node insert on dragging ******************* */ @@ -3324,25 +3334,25 @@ void NODE_OT_links_detach(wmOperatorType *ot) static bNodeSocket *socket_best_match(ListBase *sockets) { bNodeSocket *sock; - int type, maxtype=0; + int type, maxtype = 0; /* find type range */ - for (sock=sockets->first; sock; sock=sock->next) + for (sock = sockets->first; sock; sock = sock->next) maxtype = MAX2(sock->type, maxtype); /* try all types, starting from 'highest' (i.e. colors, vectors, values) */ - for (type=maxtype; type >= 0; --type) { - for (sock= sockets->first; sock; sock= sock->next) { - if (!nodeSocketIsHidden(sock) && type==sock->type) { + for (type = maxtype; type >= 0; --type) { + for (sock = sockets->first; sock; sock = sock->next) { + if (!nodeSocketIsHidden(sock) && type == sock->type) { return sock; } } } /* no visible sockets, unhide first of highest type */ - for (type=maxtype; type >= 0; --type) { - for (sock= sockets->first; sock; sock= sock->next) { - if (type==sock->type) { + for (type = maxtype; type >= 0; --type) { + for (sock = sockets->first; sock; sock = sock->next) { + if (type == sock->type) { sock->flag &= ~SOCK_HIDDEN; return sock; } @@ -3355,31 +3365,31 @@ static bNodeSocket *socket_best_match(ListBase *sockets) /* prevent duplicate testing code below */ static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) { - SpaceNode *snode= sa?sa->spacedata.first:NULL; + SpaceNode *snode = sa ? sa->spacedata.first : NULL; bNode *node; bNodeLink *link; /* no unlucky accidents */ - if (sa==NULL || sa->spacetype!=SPACE_NODE) return NULL; + if (sa == NULL || sa->spacetype != SPACE_NODE) return NULL; - *select= NULL; + *select = NULL; - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { if (*select) break; else - *select= node; + *select = node; } } /* only one selected */ - if (node || *select==NULL) return NULL; + if (node || *select == NULL) return NULL; /* correct node */ - if ((*select)->inputs.first==NULL || (*select)->outputs.first==NULL) return NULL; + if ((*select)->inputs.first == NULL || (*select)->outputs.first == NULL) return NULL; /* test node for links */ - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (link->tonode == *select || link->fromnode == *select) return NULL; } @@ -3391,27 +3401,27 @@ static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) void ED_node_link_insert(ScrArea *sa) { bNode *node, *select; - SpaceNode *snode= ed_node_link_conditions(sa, &select); + SpaceNode *snode = ed_node_link_conditions(sa, &select); bNodeLink *link; bNodeSocket *sockto; - if (snode==NULL) return; + if (snode == NULL) return; /* get the link */ - for (link= snode->edittree->links.first; link; link=link->next) + for (link = snode->edittree->links.first; link; link = link->next) if (link->flag & NODE_LINKFLAG_HILITE) break; if (link) { - node= link->tonode; - sockto= link->tosock; + node = link->tonode; + sockto = link->tosock; - link->tonode= select; - link->tosock= socket_best_match(&select->inputs); + link->tonode = select; + link->tosock = socket_best_match(&select->inputs); link->flag &= ~NODE_LINKFLAG_HILITE; nodeAddLink(snode->edittree, select, socket_best_match(&select->outputs), node, sockto); - ntreeUpdateTree(snode->edittree); /* needed for pointers */ + ntreeUpdateTree(snode->edittree); /* needed for pointers */ snode_update(snode, select); ED_node_changed_update(snode->id, select); } @@ -3422,44 +3432,44 @@ void ED_node_link_insert(ScrArea *sa) void ED_node_link_intersect_test(ScrArea *sa, int test) { bNode *select; - SpaceNode *snode= ed_node_link_conditions(sa, &select); - bNodeLink *link, *selink=NULL; + SpaceNode *snode = ed_node_link_conditions(sa, &select); + bNodeLink *link, *selink = NULL; float mcoords[6][2]; - if (snode==NULL) return; + if (snode == NULL) return; /* clear flags */ - for (link= snode->edittree->links.first; link; link=link->next) + for (link = snode->edittree->links.first; link; link = link->next) link->flag &= ~NODE_LINKFLAG_HILITE; - if (test==0) return; + if (test == 0) return; /* okay, there's 1 node, without links, now intersect */ - mcoords[0][0]= select->totr.xmin; - mcoords[0][1]= select->totr.ymin; - mcoords[1][0]= select->totr.xmax; - mcoords[1][1]= select->totr.ymin; - mcoords[2][0]= select->totr.xmax; - mcoords[2][1]= select->totr.ymax; - mcoords[3][0]= select->totr.xmin; - mcoords[3][1]= select->totr.ymax; - mcoords[4][0]= select->totr.xmin; - mcoords[4][1]= select->totr.ymin; - mcoords[5][0]= select->totr.xmax; - mcoords[5][1]= select->totr.ymax; + mcoords[0][0] = select->totr.xmin; + mcoords[0][1] = select->totr.ymin; + mcoords[1][0] = select->totr.xmax; + mcoords[1][1] = select->totr.ymin; + mcoords[2][0] = select->totr.xmax; + mcoords[2][1] = select->totr.ymax; + mcoords[3][0] = select->totr.xmin; + mcoords[3][1] = select->totr.ymax; + mcoords[4][0] = select->totr.xmin; + mcoords[4][1] = select->totr.ymin; + mcoords[5][0] = select->totr.xmax; + mcoords[5][1] = select->totr.ymax; /* we only tag a single link for intersect now */ /* idea; use header dist when more? */ - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (cut_links_intersect(link, mcoords, 5)) { /* intersect code wants edges */ if (selink) break; - selink= link; + selink = link; } } - if (link==NULL && selink) + if (link == NULL && selink) selink->flag |= NODE_LINKFLAG_HILITE; } @@ -3471,20 +3481,20 @@ void ED_node_link_intersect_test(ScrArea *sa, int test) /* goes over all scenes, reads render layers */ static int node_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - SpaceNode *snode= CTX_wm_space_node(C); - Scene *curscene= CTX_data_scene(C), *scene; + Main *bmain = CTX_data_main(C); + SpaceNode *snode = CTX_wm_space_node(C); + Scene *curscene = CTX_data_scene(C), *scene; bNode *node; ED_preview_kill_jobs(C); /* first tag scenes unread */ - for (scene= bmain->scene.first; scene; scene= scene->id.next) + for (scene = bmain->scene.first; scene; scene = scene->id.next) scene->id.flag |= LIB_DOIT; - for (node= snode->edittree->nodes.first; node; node= node->next) { - if (node->type==CMP_NODE_R_LAYERS) { - ID *id= node->id; + for (node = snode->edittree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_R_LAYERS) { + ID *id = node->id; if (id->flag & LIB_DOIT) { RE_ReadRenderResult(curscene, (Scene *)id); ntreeCompositTagRender((Scene *)id); @@ -3516,10 +3526,10 @@ void NODE_OT_read_renderlayers(wmOperatorType *ot) static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - SpaceNode *snode= CTX_wm_space_node(C); - Scene *curscene= CTX_data_scene(C); - Render *re= RE_NewRender(curscene->id.name); + Main *bmain = CTX_data_main(C); + SpaceNode *snode = CTX_wm_space_node(C); + Scene *curscene = CTX_data_scene(C); + Render *re = RE_NewRender(curscene->id.name); WM_cursor_wait(1); RE_MergeFullSample(re, bmain, curscene, snode->nodetree); @@ -3527,7 +3537,7 @@ static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op)) /* note we are careful to send the right notifier, as otherwise the * compositor would reexecute and overwrite the full sample result */ - WM_event_add_notifier(C, NC_SCENE|ND_COMPO_RESULT, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_COMPO_RESULT, NULL); return OPERATOR_FINISHED; } @@ -3550,23 +3560,23 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *sce= CTX_data_scene(C); + Scene *sce = CTX_data_scene(C); bNode *node; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==(ID *)sce && node->need_exec) { + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == (ID *)sce && node->need_exec) { break; } } if (node) { - SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); if (srl) { PointerRNA op_ptr; WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); RNA_string_set(&op_ptr, "layer", srl->name); - RNA_string_set(&op_ptr, "scene", sce->id.name+2); + RNA_string_set(&op_ptr, "scene", sce->id.name + 2); /* to keep keypositions */ sce->r.scemode |= R_NO_FRAME_UPDATE; @@ -3607,35 +3617,35 @@ static int node_group_make_test(bNodeTree *ntree, bNode *gnode) int totnode = 0; /* is there something to group? also do some clearing */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; if (node->flag & NODE_SELECT) { /* no groups in groups */ - if (node->type==NODE_GROUP) + if (node->type == NODE_GROUP) return 0; totnode++; } node->done = 0; } - if (totnode==0) return 0; + if (totnode == 0) return 0; /* check if all connections are OK, no unselected node has both * inputs and outputs to a selection */ - for (link= ntree->links.first; link; link= link->next) { + for (link = ntree->links.first; link; link = link->next) { if (link->fromnode && link->tonode && link->fromnode->flag & NODE_SELECT && link->fromnode != gnode) link->tonode->done |= 1; if (link->fromnode && link->tonode && link->tonode->flag & NODE_SELECT && link->tonode != gnode) link->fromnode->done |= 2; } - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; - if ((node->flag & NODE_SELECT)==0) - if (node->done==3) + if ((node->flag & NODE_SELECT) == 0) + if (node->done == 3) break; } if (node) @@ -3648,7 +3658,7 @@ static void node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, { bNode *node; INIT_MINMAX2(min, max); - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; if (node->flag & NODE_SELECT) { @@ -3667,14 +3677,14 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) float min[2], max[2]; /* deselect all nodes in the target tree */ - for (node = ngroup->nodes.first; node; node=node->next) + for (node = ngroup->nodes.first; node; node = node->next) node_deselect(node); node_get_selected_minmax(ntree, gnode, min, max); /* move nodes over */ - for (node= ntree->nodes.first; node; node= nextn) { - nextn= node->next; + for (node = ntree->nodes.first; node; node = nextn) { + nextn = node->next; if (node == gnode) continue; if (node->flag & NODE_SELECT) { @@ -3700,14 +3710,14 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) BLI_remlink(&ntree->nodes, node); BLI_addtail(&ngroup->nodes, node); - node->locx-= 0.5f*(min[0]+max[0]); - node->locy-= 0.5f*(min[1]+max[1]); + node->locx -= 0.5f * (min[0] + max[0]); + node->locy -= 0.5f * (min[1] + max[1]); } } /* move animation data over */ if (ntree->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths); @@ -3724,10 +3734,10 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) ntreeFreeCache(ngroup); /* relink external sockets */ - for (link= ntree->links.first; link; link= linkn) { + for (link = ntree->links.first; link; link = linkn) { int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT) && link->fromnode != gnode); int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT) && link->tonode != gnode); - linkn= link->next; + linkn = link->next; if (gnode && ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode))) { /* remove all links to/from the gnode. @@ -3747,8 +3757,8 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) } else if (fromselect) { /* search for existing group node socket */ - for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next) - if (gsock->link && gsock->link->fromsock==link->fromsock) + for (gsock = ngroup->outputs.first; gsock; gsock = gsock->next) + if (gsock->link && gsock->link->fromsock == link->fromsock) break; if (!gsock) { gsock = node_group_expose_socket(ngroup, link->fromsock, SOCK_OUT); @@ -3779,14 +3789,14 @@ static bNode *node_group_make_from_selected(bNodeTree *ntree) node_get_selected_minmax(ntree, NULL, min, max); /* new nodetree */ - ngroup= ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP); + ngroup = ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP); /* make group node */ ntemp.type = NODE_GROUP; ntemp.ngroup = ngroup; - gnode= nodeAddNode(ntree, &ntemp); - gnode->locx= 0.5f*(min[0]+max[0]); - gnode->locy= 0.5f*(min[1]+max[1]); + gnode = nodeAddNode(ntree, &ntemp); + gnode->locx = 0.5f * (min[0] + max[0]); + gnode->locy = 0.5f * (min[1] + max[1]); node_group_make_insert_selected(ntree, gnode); @@ -3814,16 +3824,16 @@ static int node_group_make_exec(bContext *C, wmOperator *op) bNode *gnode; int type = RNA_enum_get(op->ptr, "type"); - if (snode->edittree!=snode->nodetree) { + if (snode->edittree != snode->nodetree) { BKE_report(op->reports, RPT_WARNING, "Can not add a new Group in a Group"); return OPERATOR_CANCELLED; } /* for time being... is too complex to handle */ - if (snode->treetype==NTREE_COMPOSIT) { - for (gnode=snode->nodetree->nodes.first; gnode; gnode= gnode->next) { + if (snode->treetype == NTREE_COMPOSIT) { + for (gnode = snode->nodetree->nodes.first; gnode; gnode = gnode->next) { if (gnode->flag & SELECT) - if (gnode->type==CMP_NODE_R_LAYERS) + if (gnode->type == CMP_NODE_R_LAYERS) break; } @@ -3836,29 +3846,29 @@ static int node_group_make_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); switch (type) { - case NODE_GM_NEW: - if (node_group_make_test(snode->nodetree, NULL)) { - gnode = node_group_make_from_selected(snode->nodetree); - } - else { - BKE_report(op->reports, RPT_WARNING, "Can not make Group"); - return OPERATOR_CANCELLED; - } - break; - case NODE_GM_INSERT: - gnode = nodeGetActive(snode->nodetree); - if (!gnode || gnode->type != NODE_GROUP) { - BKE_report(op->reports, RPT_WARNING, "No active Group node"); - return OPERATOR_CANCELLED; - } - if (node_group_make_test(snode->nodetree, gnode)) { - node_group_make_insert_selected(snode->nodetree, gnode); - } - else { - BKE_report(op->reports, RPT_WARNING, "Can not insert into Group"); - return OPERATOR_CANCELLED; - } - break; + case NODE_GM_NEW: + if (node_group_make_test(snode->nodetree, NULL)) { + gnode = node_group_make_from_selected(snode->nodetree); + } + else { + BKE_report(op->reports, RPT_WARNING, "Can not make Group"); + return OPERATOR_CANCELLED; + } + break; + case NODE_GM_INSERT: + gnode = nodeGetActive(snode->nodetree); + if (!gnode || gnode->type != NODE_GROUP) { + BKE_report(op->reports, RPT_WARNING, "No active Group node"); + return OPERATOR_CANCELLED; + } + if (node_group_make_test(snode->nodetree, gnode)) { + node_group_make_insert_selected(snode->nodetree, gnode); + } + else { + BKE_report(op->reports, RPT_WARNING, "Can not insert into Group"); + return OPERATOR_CANCELLED; + } + break; } if (gnode) { @@ -3909,7 +3919,7 @@ void NODE_OT_group_make(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", node_group_make_types, NODE_GM_NEW, "Type", ""); } @@ -3919,18 +3929,18 @@ void NODE_OT_group_make(wmOperatorType *ot) static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) { bNode *node; - int tot_eq= 0, tot_neq= 0; + int tot_eq = 0, tot_neq = 0; /* Toggles the flag on all selected nodes. * If the flag is set on all nodes it is unset. * If the flag is not set on all nodes, it is set. */ - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (toggle_flag== NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW)==0) + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; - if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) + if (toggle_flag == NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS) == 0) continue; if (node->flag & toggle_flag) @@ -3939,15 +3949,15 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) tot_neq++; } } - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (toggle_flag== NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW)==0) + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; - if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) + if (toggle_flag == NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS) == 0) continue; - if ( (tot_eq && tot_neq) || tot_eq==0) + if ( (tot_eq && tot_neq) || tot_eq == 0) node->flag |= toggle_flag; else node->flag &= ~toggle_flag; @@ -3957,7 +3967,7 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -3982,12 +3992,12 @@ void NODE_OT_hide_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -4014,12 +4024,12 @@ void NODE_OT_preview_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -4044,12 +4054,12 @@ void NODE_OT_options_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; int hidden; @@ -4061,16 +4071,16 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) /* Toggle for all selected nodes */ hidden = 0; - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { if (node_has_hidden_sockets(node)) { - hidden= 1; + hidden = 1; break; } } } - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { node_set_hidden_sockets(snode, node, !hidden); } @@ -4095,19 +4105,19 @@ void NODE_OT_hide_socket_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Mute operator *********************** */ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { /* Only allow muting of nodes having a mute func! */ if ((node->flag & SELECT) && node->typeinfo->internal_connect) { node->flag ^= NODE_MUTED; @@ -4133,20 +4143,20 @@ void NODE_OT_mute_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Delete operator ******************* */ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node, *next; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= next) { - next= node->next; + for (node = snode->edittree->nodes.first; node; node = next) { + next = node->next; if (node->flag & SELECT) { /* check id user here, nodeFreeNode is called for free dbase too */ if (node->id) @@ -4175,19 +4185,19 @@ void NODE_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Delete with reconnect ******************* */ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node, *next; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= next) { - next= node->next; + for (node = snode->edittree->nodes.first; node; node = next) { + next = node->next; if (node->flag & SELECT) { nodeInternalRelink(snode->edittree, node); @@ -4218,14 +4228,14 @@ void NODE_OT_delete_reconnect(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Show Cyclic Dependencies Operator ******************* */ static int node_show_cycles_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* this is just a wrapper around this call... */ ntreeUpdateTree(snode->nodetree); @@ -4246,18 +4256,18 @@ void NODE_OT_show_cyclic_dependencies(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Add File Node Operator ******************* */ static int node_add_file_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceNode *snode= CTX_wm_space_node(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - Image *ima= NULL; + Image *ima = NULL; bNodeTemplate ntemp; /* check input variables */ @@ -4265,9 +4275,9 @@ static int node_add_file_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - errno= 0; + errno = 0; - ima= BKE_image_load_exists(path); + ima = BKE_image_load_exists(path); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported image format"); @@ -4275,9 +4285,9 @@ static int node_add_file_exec(bContext *C, wmOperator *op) } } else if (RNA_struct_property_is_set(op->ptr, "name")) { - char name[MAX_ID_NAME-2]; + char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ima= (Image *)BKE_libblock_find_name(ID_IM, name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); @@ -4320,12 +4330,12 @@ static int node_add_file_exec(bContext *C, wmOperator *op) static int node_add_file_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceNode *snode= CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) return node_add_file_exec(C, op); @@ -4346,10 +4356,10 @@ void NODE_OT_add_file(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path - RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Datablock name to assign"); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Datablock name to assign"); } /********************** New node tree operator *********************/ @@ -4361,10 +4371,10 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) PointerRNA ptr, idptr; PropertyRNA *prop; int treetype; - char treename[MAX_ID_NAME-2] = "NodeTree"; + char treename[MAX_ID_NAME - 2] = "NodeTree"; /* retrieve state */ - snode= CTX_wm_space_node(C); + snode = CTX_wm_space_node(C); if (RNA_struct_property_is_set(op->ptr, "type")) treetype = RNA_enum_get(op->ptr, "type"); @@ -4391,7 +4401,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) RNA_property_update(C, &ptr, prop); } else if (snode) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); snode->nodetree = ntree; ED_node_tree_update(snode, scene); @@ -4412,18 +4422,18 @@ void NODE_OT_new_node_tree(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", nodetree_type_items, NTREE_COMPOSIT, "Tree Type", ""); - RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME-2, "Name", ""); + RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", ""); } /* ****************** File Output Add Socket ******************* */ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceNode *snode= CTX_wm_space_node(C); + Scene *scene = CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr; bNodeTree *ntree; bNode *node; @@ -4455,7 +4465,7 @@ void NODE_OT_output_file_add_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_string(ot->srna, "file_path", "Image", MAX_NAME, "File Path", "Sub-path of the output file"); } @@ -4464,7 +4474,7 @@ void NODE_OT_output_file_add_socket(wmOperatorType *ot) static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNodeTree *ntree; bNode *node; @@ -4494,14 +4504,14 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Multi File Output Move Socket ******************* */ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNode *node; NodeImageMultiFile *nimf; @@ -4519,7 +4529,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) direction = RNA_enum_get(op->ptr, "direction"); - if (direction==1) { + if (direction == 1) { bNodeSocket *before = sock->prev; if (!before) return OPERATOR_CANCELLED; @@ -4546,7 +4556,8 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) static EnumPropertyItem direction_items[] = { {1, "UP", 0, "Up", ""}, {2, "DOWN", 0, "Down", ""}, - { 0, NULL, 0, NULL, NULL }}; + { 0, NULL, 0, NULL, NULL } + }; /* identifiers */ ot->name = "Move File Node Socket"; @@ -4558,7 +4569,7 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "direction", direction_items, 2, "Direction", ""); } @@ -4577,7 +4588,7 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) if (!node) return OPERATOR_CANCELLED; - for (tnode=ntree->nodes.first; tnode; tnode=tnode->next) { + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->flag & NODE_SELECT && tnode != node) { if (node->flag & NODE_CUSTOM_COLOR) { tnode->flag |= NODE_CUSTOM_COLOR; @@ -4589,7 +4600,7 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4606,7 +4617,7 @@ void NODE_OT_node_copy_color(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Set Parent ******************* */ @@ -4619,7 +4630,7 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) if (!frame || frame->type != NODE_FRAME) return OPERATOR_CANCELLED; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == frame) continue; if (node->flag & NODE_SELECT) { @@ -4629,7 +4640,7 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4646,7 +4657,7 @@ void NODE_OT_parent_set(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Clear Parent ******************* */ @@ -4657,13 +4668,13 @@ static int node_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) bNodeTree *ntree = snode->edittree; bNode *node; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) { nodeDetachNode(node); } } - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4680,14 +4691,14 @@ void NODE_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Join Nodes ******************* */ /* tags for depth-first search */ -#define NODE_JOIN_DONE 1 -#define NODE_JOIN_IS_DESCENDANT 2 +#define NODE_JOIN_DONE 1 +#define NODE_JOIN_IS_DESCENDANT 2 static void node_join_attach_recursive(bNode *node, bNode *frame) { @@ -4727,7 +4738,7 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op)) bNodeTemplate ntemp; /* XXX save selection: node_add_node call below sets the new frame as single active+selected node */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) node->flag |= NODE_TEST; else @@ -4740,22 +4751,22 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op)) frame = node_add_node(snode, bmain, scene, &ntemp, 0.0f, 0.0f); /* reset tags */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->done = 0; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (!(node->done & NODE_JOIN_DONE)) node_join_attach_recursive(node, frame); } /* restore selection */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_TEST) node->flag |= NODE_SELECT; } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4772,7 +4783,7 @@ void NODE_OT_join(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Attach ******************* */ @@ -4784,7 +4795,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) bNode *frame; /* check nodes front to back */ - for (frame=ntree->nodes.last; frame; frame=frame->prev) { + for (frame = ntree->nodes.last; frame; frame = frame->prev) { /* skip selected, those are the nodes we want to attach */ if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) continue; @@ -4793,7 +4804,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } if (frame) { bNode *node, *parent; - for (node=ntree->nodes.last; node; node=node->prev) { + for (node = ntree->nodes.last; node; node = node->prev) { if (node->flag & NODE_SELECT) { if (node->parent == NULL) { /* attach all unparented nodes */ @@ -4801,7 +4812,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } else { /* attach nodes which share parent with the frame */ - for (parent=frame->parent; parent; parent=parent->parent) + for (parent = frame->parent; parent; parent = parent->parent) if (parent == node->parent) break; if (parent) { @@ -4814,15 +4825,15 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } static int node_attach_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceNode *snode= CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); @@ -4843,14 +4854,14 @@ void NODE_OT_attach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Detach ******************* */ /* tags for depth-first search */ -#define NODE_DETACH_DONE 1 -#define NODE_DETACH_IS_DESCENDANT 2 +#define NODE_DETACH_DONE 1 +#define NODE_DETACH_IS_DESCENDANT 2 static void node_detach_recursive(bNode *node) { @@ -4883,18 +4894,18 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op)) bNode *node; /* reset tags */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->done = 0; /* detach nodes recursively * relative order is preserved here! */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (!(node->done & NODE_DETACH_DONE)) node_detach_recursive(node); } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4911,5 +4922,5 @@ void NODE_OT_detach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 0d03df2298f..d4cfa2a3ba2 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -239,7 +239,7 @@ static void node_menu_add(const bContext *C, Menu *menu) bNodeTreeType *ntreetype= ntreeGetType(snode->treetype); if (!snode->nodetree) - uiLayoutSetActive(layout, 0); + uiLayoutSetActive(layout, FALSE); if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, layout, node_menu_add_foreach_cb); diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 97e64c4acdf..bf0e539efe7 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -358,7 +358,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) continue; if (first) { - column= uiLayoutColumn(layout, 0); + column = uiLayoutColumn(layout, FALSE); uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); @@ -415,7 +415,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) continue; if (first) { - column= uiLayoutColumn(layout, 0); + column = uiLayoutColumn(layout, FALSE); uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); @@ -470,7 +470,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ bNodeTreeType *ntreetype= ntreeGetType(arg->ntree->type); uiBlockSetCurLayout(block, layout); - split= uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); arg->bmain= bmain; arg->scene= scene; @@ -479,7 +479,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); - column= uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); uiBlockSetCurLayout(block, column); if (sock->link) { @@ -547,9 +547,9 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b if (node->typeinfo->uifunc) { if (node->type != NODE_GROUP) { - split = uiLayoutSplit(layout, 0.35f, 0); - col = uiLayoutColumn(split, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); + col = uiLayoutColumn(split, FALSE); + col = uiLayoutColumn(split, FALSE); node->typeinfo->uifunc(col, C, &nodeptr); } @@ -590,9 +590,9 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, BLI_snprintf(label, UI_MAX_NAME_STR, "%s%s:", label, IFACE_(input->name)); /* split in label and value */ - split = uiLayoutSplit(layout, 0.35f, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); if (depth > 0) { uiBlockSetEmboss(block, UI_EMBOSSN); @@ -615,7 +615,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bt->flag= UI_TEXT_LEFT; if (dependency_loop) { - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemL(row, IFACE_("Dependency Loop"), ICON_ERROR); } else if (lnode) { @@ -633,18 +633,18 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, /* input not linked, show value */ if (input->type != SOCK_SHADER && !(input->flag & SOCK_HIDE_VALUE)) { if (input->type == SOCK_VECTOR) { - row = uiLayoutRow(split, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(split, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, &inputptr, "default_value", 0, "", 0); } else { - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, &inputptr, "default_value", 0, "", 0); } } else - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiTemplateNodeLink(row, ntree, node, input); } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index f0ecaf3ab2c..2f5e32c61d1 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -202,26 +202,39 @@ static int group_restrict_flag(Group *gr, int flag) { GroupObject *gob; +#ifdef USE_GROUP_SELECT for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->restrictflag & flag) == 0) return 0; } - return 1; +#else + /* weak but fast */ + if ((gob = gr->gobject.first)) + if ((gob->ob->restrictflag & flag) == 0) + return 0; + return 1; +#endif } -#ifdef USE_GROUP_SELECT static int group_select_flag(Group *gr) { GroupObject *gob; +#ifdef USE_GROUP_SELECT for (gob = gr->gobject.first; gob; gob = gob->next) if ((gob->ob->flag & SELECT)) return 1; return 0; -} +#else + /* weak but fast */ + if ((gob = gr->gobject.first)) + if (gob->ob->flag & SELECT) + return 1; + return 0; #endif +} void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) { @@ -428,25 +441,15 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); -#ifndef USE_GROUP_SELECT - restrict_bool = FALSE; -#endif - -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); @@ -1289,7 +1292,6 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } else if (te->idcode == ID_GR) { -#ifdef USE_GROUP_SELECT Group *gr = (Group *)tselem->id; if (group_select_flag(gr)) { char col[4]; @@ -1299,7 +1301,6 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene active = 2; } -#endif } else if (te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index e48450e93bd..9148373cb2d 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -72,8 +72,11 @@ #include "sequencer_intern.h" -#define SEQ_LEFTHANDLE 1 -#define SEQ_RIGHTHANDLE 2 +#define SEQ_LEFTHANDLE 1 +#define SEQ_RIGHTHANDLE 2 + +#define SEQ_HANDLE_SIZE_MIN 7.0f +#define SEQ_HANDLE_SIZE_MAX 40.0f /* Note, Don't use SEQ_BEGIN/SEQ_END while drawing! @@ -325,13 +328,19 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, glDisable(GL_BLEND); } +/* clamp handles to defined size in pixel space */ +static float draw_seq_handle_size_get_clamped(Sequence *seq, const float pixelx) +{ + const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN; + const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX; + return CLAMPIS(seq->handsize, minhandle, maxhandle); +} + /* draw a handle, for each end of a sequence strip */ -static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short direction) +static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_clamped, const short direction) { float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect float x1, x2, y1, y2; - float handsize; - float minhandle, maxhandle; char numstr[32]; unsigned int whichsel = 0; @@ -340,31 +349,25 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - - /* clamp handles to defined size in pixel space */ - handsize = seq->handsize; - minhandle = 7; - maxhandle = 40; - CLAMP(handsize, minhandle * pixelx, maxhandle * pixelx); - + /* set up co-ordinates/dimensions for either left or right handle */ if (direction == SEQ_LEFTHANDLE) { rx1 = x1; - rx2 = x1 + handsize * 0.75f; + rx2 = x1 + handsize_clamped * 0.75f; - v1[0] = x1 + handsize / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); - v2[0] = x1 + handsize / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); - v3[0] = v2[0] + handsize / 4; v3[1] = (y1 + y2) / 2.0f; + v1[0] = x1 + handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); + v2[0] = x1 + handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); + v3[0] = v2[0] + handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f; whichsel = SEQ_LEFTSEL; } else if (direction == SEQ_RIGHTHANDLE) { - rx1 = x2 - handsize * 0.75f; + rx1 = x2 - handsize_clamped * 0.75f; rx2 = x2; - v1[0] = x2 - handsize / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); - v2[0] = x2 - handsize / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); - v3[0] = v2[0] - handsize / 4; v3[1] = (y1 + y2) / 2.0f; + v1[0] = x2 - handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); + v2[0] = x2 - handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); + v3[0] = v2[0] - handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f; whichsel = SEQ_RIGHTSEL; } @@ -404,7 +407,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire } else { BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1); - x1 = x2 - handsize * 0.75f; + x1 = x2 - handsize_clamped * 0.75f; y1 = y2 + 0.05f; } UI_view2d_text_cache_add(v2d, x1, y1, numstr, col); @@ -530,67 +533,67 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float name = give_seqname(seq); if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) { - BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_SCENE) { if (seq->scene) { if (seq->scene_camera) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s (%s)", - seq->len, name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d", + name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->scene->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->scene->id.name + 2, seq->len); } } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MOVIECLIP) { if (seq->clip && strcmp(name, seq->clip->id.name + 2) != 0) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->clip->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->clip->id.name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MASK) { if (seq->mask && strcmp(name, seq->mask->id.name + 2) != 0) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->mask->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->mask->id.name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MULTICAM) { - BLI_snprintf(str, sizeof(str), "Cam | %s: %d", + BLI_snprintf(str, sizeof(str), "Cam %s: %d", name, seq->multicam_source); } else if (seq->type == SEQ_TYPE_IMAGE) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", - seq->len, name, seq->strip->dir, seq->strip->stripdata->name); + BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", + name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } else if (seq->type & SEQ_TYPE_EFFECT) { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } else if (seq->type == SEQ_TYPE_SOUND_RAM) { if (seq->sound) - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->sound->name); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->sound->name, seq->len); else - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } else if (seq->type == SEQ_TYPE_MOVIE) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", - seq->len, name, seq->strip->dir, seq->strip->stripdata->name); + BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", + name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } if (seq->flag & SELECT) { @@ -679,6 +682,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline View2D *v2d = &ar->v2d; float x1, x2, y1, y2; unsigned char col[3], background_col[3], is_single_image; + const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx); /* we need to know if this is a single image/color or not for drawing */ is_single_image = (char)seq_single_check(seq); @@ -706,8 +710,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline if (!is_single_image) draw_seq_extensions(scene, ar, seq); - draw_seq_handle(v2d, seq, pixelx, SEQ_LEFTHANDLE); - draw_seq_handle(v2d, seq, pixelx, SEQ_RIGHTHANDLE); + draw_seq_handle(v2d, seq, handsize_clamped, SEQ_LEFTHANDLE); + draw_seq_handle(v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE); /* draw the strip outline */ x1 = seq->startdisp; @@ -766,8 +770,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline } /* calculate if seq is long enough to print a name */ - x1 = seq->startdisp + seq->handsize; - x2 = seq->enddisp - seq->handsize; + x1 = seq->startdisp + handsize_clamped; + x2 = seq->enddisp - handsize_clamped; /* info text on the strip */ if (x1 < v2d->cur.xmin) x1 = v2d->cur.xmin; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index c686f8440a9..bc8133cded6 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1570,16 +1570,6 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } -static int sequencer_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) -{ - sequencer_add_duplicate_exec(C, op); - - RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); - WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); - - return OPERATOR_FINISHED; -} - void SEQUENCER_OT_duplicate(wmOperatorType *ot) { /* identifiers */ @@ -1588,7 +1578,6 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot) ot->description = "Duplicate the selected strips"; /* api callbacks */ - ot->invoke = sequencer_add_duplicate_invoke; ot->exec = sequencer_add_duplicate_exec; ot->poll = ED_operator_sequencer_active; diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 79ecd9f7481..4a1c8f0c006 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -167,7 +167,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_offset_clear", OKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0); @@ -321,3 +321,13 @@ void sequencer_keymap(wmKeyConfig *keyconf) #endif } +void ED_operatormacros_sequencer(void) +{ + wmOperatorType *ot; + + ot = WM_operatortype_append_macro("SEQUENCER_OT_duplicate_move", "Duplicate Strips", + "Duplicate selected strips and move them", OPTYPE_UNDO | OPTYPE_REGISTER); + + WM_operatortype_macro_define(ot, "SEQUENCER_OT_duplicate"); + WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); +} diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 463a262c09c..8be5b644afb 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -825,7 +825,7 @@ typedef struct DrawCache { static void text_drawcache_init(SpaceText *st) { - DrawCache *drawcache = MEM_callocN(sizeof (DrawCache), "text draw cache"); + DrawCache *drawcache = MEM_callocN(sizeof(DrawCache), "text draw cache"); drawcache->winx = -1; drawcache->nlines = BLI_countlist(&st->text->lines); diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 43252111303..7d39a89a130 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -431,7 +431,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r } tend(); - // printf ( "Draw Time: %f\n",( float ) tval() ); + // printf ( "Draw Time: %f\n",(float) tval() ); if (tex_shadow) GPU_texture_unbind(tex_shadow); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 4a135f91d91..a9941dc326a 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -834,7 +834,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL); - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutAbsoluteBlock(col); uiBlockBeginAlign(block); @@ -865,7 +865,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) { uiLayout *split, *colsub; - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8f, FALSE); if (ptr->type == &RNA_PoseBone) { PointerRNA boneptr; @@ -875,19 +875,19 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) bone = boneptr.data; uiLayoutSetActive(split, !(bone->parent && bone->flag & BONE_CONNECTED)); } - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "location", 0, NULL, ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_location", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8f, FALSE); switch (RNA_enum_get(ptr, "rotation_mode")) { case ROT_MODE_QUAT: /* quaternion */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_quaternion", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE + UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -896,9 +896,9 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; case ROT_MODE_AXISANGLE: /* axis angle */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_axis_angle", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -907,19 +907,19 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; default: /* euler rotations */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_euler", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; } uiItemR(layout, ptr, "rotation_mode", 0, "", ICON_NONE); - split = uiLayoutSplit(layout, 0.8, 0); - colsub = uiLayoutColumn(split, 1); + split = uiLayoutSplit(layout, 0.8f, FALSE); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "scale", 0, NULL, ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_scale", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -948,7 +948,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &pchanptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); /* XXX: RNA buts show data in native types (i.e. quats, 4-component axis/angle, etc.) * but old-school UI shows in eulers always. Do we want to be able to still display in Eulers? @@ -972,7 +972,7 @@ static void v3d_editarmature_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&arm->id, &RNA_EditBone, ebone, &eboneptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &eboneptr, "head", 0, NULL, ICON_NONE); if (ebone->parent && ebone->flag & BONE_CONNECTED) { PointerRNA parptr = RNA_pointer_get(&eboneptr, "parent"); @@ -1002,7 +1002,7 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&mball->id, &RNA_MetaElement, mball->lastelem, &ptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &ptr, "co", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "radius", 0, NULL, ICON_NONE); @@ -1010,7 +1010,7 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) uiItemR(col, &ptr, "type", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); switch (RNA_enum_get(&ptr, "type")) { case MB_BALL: break; @@ -1081,8 +1081,8 @@ static void view3d_panel_object(const bContext *C, Panel *pa) block = uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); - col = uiLayoutColumn(pa->layout, 0); - /* row = uiLayoutRow(col, 0); */ /* UNUSED */ + col = uiLayoutColumn(pa->layout, FALSE); + /* row = uiLayoutRow(col, FALSE); */ /* UNUSED */ RNA_id_pointer_create(&ob->id, &obptr); if (ob == obedit) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fcb4f97bcbe..709de274b8b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -153,12 +153,14 @@ static void view3d_draw_clipping(RegionView3D *rv3d) BoundBox *bb = rv3d->clipbb; if (bb) { - static unsigned int clipping_index[6][4] = {{0, 1, 2, 3}, - {0, 4, 5, 1}, - {4, 7, 6, 5}, - {7, 3, 2, 6}, - {1, 5, 6, 2}, - {7, 4, 0, 3}}; + static unsigned int clipping_index[6][4] = { + {0, 1, 2, 3}, + {0, 4, 5, 1}, + {4, 7, 6, 5}, + {7, 3, 2, 6}, + {1, 5, 6, 2}, + {7, 4, 0, 3} + }; /* fill in zero alpha for rendering & re-projection [#31530] */ unsigned char col[4]; @@ -1587,6 +1589,11 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, * be dereferenced after usage. */ freeibuf = ibuf; } + else { + /* perhaps when loading future files... */ + BLI_assert(0); + copy_v2_fl(image_aspect, 1.0f); + } if (ibuf == NULL) continue; @@ -2835,7 +2842,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw cliprct.xmax = CLAMPIS(cliprct.xmax, ar->winrct.xmin, ar->winrct.xmax); cliprct.ymax = CLAMPIS(cliprct.ymax, ar->winrct.ymin, ar->winrct.ymax); - if(cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) { + if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) { glGetIntegerv(GL_SCISSOR_BOX, scissor); glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index d632314f3ca..cc3d2d383b8 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1669,7 +1669,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) if (rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom = RV3D_CAMZOOM_MAX; } else if (rv3d->dist > 0.001f * v3d->grid) { - view_zoom_mouseloc(ar, .83333f, mx, my); + view_zoom_mouseloc(ar, 0.83333f, mx, my); } } @@ -1921,7 +1921,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) view_dolly_mouseloc(ar, rv3d->ofs, mousevec, 1.2f); } else { - view_dolly_mouseloc(ar, rv3d->ofs, mousevec, .83333f); + view_dolly_mouseloc(ar, rv3d->ofs, mousevec, 0.83333f); } if (rv3d->viewlock & RV3D_BOXVIEW) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index a68caeb0719..eb202497260 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -451,7 +451,7 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C) BMEditMesh *em = BMEdit_FromObject(obedit); uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select - Shift-Click for multiple modes"); uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select - Shift-Click for multiple modes"); @@ -494,7 +494,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) v3d->modeselect = OB_MODE_OBJECT; } - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene), 0, 0, 126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_("Mode")); @@ -512,7 +512,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } else { - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } @@ -521,7 +521,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) else { const char *str_menu; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* pose/object only however we want to allow in weight paint mode too @@ -531,7 +531,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } /* Transform widget / manipulators */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); block = uiLayoutGetBlock(row); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index ff896a95941..ee1ead76f7c 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -211,12 +211,12 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) for (ct = st->toolshelf.first; ct; ct = ct->next) { if (0 == strncmp(context, ct->context, OP_MAX_TYPENAME)) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); uiItemFullO(col, ct->opname, NULL, ICON_NONE, NULL, WM_OP_INVOKE_REGION_WIN, 0); } } } - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &st->toolshelf, "Add Tool", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add Tool in shelf, gets saved in files"); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index d32206c4335..e97df15543f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -183,11 +183,11 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) r_vec[2] = 0.0f; if (t->options & CTX_MOVIECLIP) { - ED_space_clip_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); } else if (t->options & CTX_MASK) { /* TODO - NOT WORKING, this isnt so bad since its only display aspect */ - ED_space_clip_mask_aspect(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); } r_vec[0] *= aspx; @@ -254,9 +254,9 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) copy_v2_v2(v, vec); if (t->options & CTX_MOVIECLIP) - ED_space_clip_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); else if (t->options & CTX_MASK) - ED_space_clip_mask_aspect(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); v[0] /= aspx; v[1] /= aspy; @@ -317,13 +317,13 @@ void applyAspectRatio(TransInfo *t, float vec[2]) if (t->options & CTX_MOVIECLIP) { - ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); vec[0] /= aspx; vec[1] /= aspy; } else if (t->options & CTX_MASK) { - ED_space_clip_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); vec[0] /= aspx; vec[1] /= aspy; @@ -356,10 +356,10 @@ void removeAspectRatio(TransInfo *t, float vec[2]) float aspx = 1.0f, aspy = 1.0f; if (t->options & CTX_MOVIECLIP) { - ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); } else if (t->options & CTX_MASK) { - ED_space_clip_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); } vec[0] *= aspx; @@ -410,16 +410,16 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) else if (t->spacetype == SPACE_CLIP) { SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first; - if (ED_space_clip_show_trackedit(sc)) { - MovieClip *clip = ED_space_clip(sc); + if (ED_space_clip_check_show_trackedit(sc)) { + MovieClip *clip = ED_space_clip_get_clip(sc); /* objects could be parented to tracking data, so send this for viewport refresh */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); } - else if (ED_space_clip_show_maskedit(sc)) { - Mask *mask = ED_space_clip_mask(sc); + else if (ED_space_clip_check_show_maskedit(sc)) { + Mask *mask = ED_space_clip_get_mask(sc); WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index fbc59f4c2cb..e924ce15286 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5046,7 +5046,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if (t->spacetype == SPACE_CLIP) { if (t->options & CTX_MOVIECLIP) { SpaceClip *sc = t->sa->spacedata.first; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (t->scene->nodetree) { /* tracks can be used for stabilization nodes, @@ -5057,7 +5057,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } else if (t->options & CTX_MASK) { SpaceClip *sc = t->sa->spacedata.first; - Mask *mask = ED_space_clip_mask(sc); + Mask *mask = ED_space_clip_get_mask(sc); if (t->scene->nodetree) { /* tracks can be used for stabilization nodes, @@ -5653,7 +5653,7 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d, TransDataTracking *tdt, MovieTrackingTrack *track, float aspx, float aspy) { - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr); tdt->flag = marker->flag; @@ -5702,12 +5702,12 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) TransData *td; TransData2D *td2d; SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; MovieTrackingMarker *marker; TransDataTracking *tdt; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); float aspx, aspy; /* count */ @@ -5736,7 +5736,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) if (t->total == 0) return; - ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransTracking TransData"); td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransTracking TransData2D"); @@ -5830,7 +5830,7 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t) TransData *td; TransData2D *td2d; SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; MovieTrackingMarker *marker, *prev_marker; @@ -5908,7 +5908,7 @@ static void createTransTrackingData(bContext *C, TransInfo *t) { ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int width, height; t->total = 0; @@ -5931,11 +5931,11 @@ static void cancelTransTracking(TransInfo *t) { TransDataTracking *tdt = t->customData; SpaceClip *sc = t->sa->spacedata.first; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; MovieTrackingMarker *marker; - int a, framenr = ED_space_clip_clip_framenr(sc); + int a, framenr = ED_space_clip_get_clip_frame_number(sc); if (tdt->mode == transDataTracking_ModeTracks) { track = tracksbase->first; @@ -5992,7 +5992,7 @@ void flushTransTracking(TransInfo *t) int a; float aspx, aspy; - ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); if (t->state == TRANS_CANCEL) cancelTransTracking(t); @@ -6072,7 +6072,7 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, tdm->point = point; copy_m3_m3(tdm->vec, bezt->vec); - ED_space_clip_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); if (propmode || is_sel_point) { int i; @@ -6250,7 +6250,7 @@ void flushTransMasking(TransInfo *t) int a; float aspx, aspy, invx, invy; - ED_space_clip_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); invx = 1.0f / aspx; invy = 1.0f / aspy; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index b7857be5afb..9f335b4afe7 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -639,11 +639,11 @@ static void recalcData_spaceclip(TransInfo *t) { SpaceClip *sc = t->sa->spacedata.first; - if (ED_space_clip_show_trackedit(sc)) { - MovieClip *clip = ED_space_clip(sc); + if (ED_space_clip_check_show_trackedit(sc)) { + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = sc->user.framenr; + int framenr = ED_space_clip_get_clip_frame_number(sc); flushTransTracking(t); @@ -675,8 +675,8 @@ static void recalcData_spaceclip(TransInfo *t) DAG_id_tag_update(&clip->id, 0); } - else if (ED_space_clip_show_maskedit(sc)) { - Mask *mask = ED_space_clip_mask(sc); + else if (ED_space_clip_check_show_maskedit(sc)) { + Mask *mask = ED_space_clip_get_mask(sc); flushTransMasking(t); @@ -1128,9 +1128,9 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->view = &ar->v2d; t->around = sclip->around; - if (ED_space_clip_show_trackedit(sclip)) + if (ED_space_clip_check_show_trackedit(sclip)) t->options |= CTX_MOVIECLIP; - else if (ED_space_clip_show_maskedit(sclip)) + else if (ED_space_clip_check_show_maskedit(sclip)) t->options |= CTX_MASK; } else { diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 9ebd43cd0d1..90b67951614 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -221,7 +221,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) setlinestyle(0); cpack(0x0); fdrawline(-0.020 / w, 0, -0.1 / w, 0); - fdrawline(0.1 / w, 0, .020 / w, 0); + fdrawline(0.1 / w, 0, 0.020 / w, 0); fdrawline(0, -0.020 / h, 0, -0.1 / h); fdrawline(0, 0.1 / h, 0, 0.020 / h); diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 65d23641ab5..0c2bfff3b57 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -493,12 +493,13 @@ static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even if (totitem > 0) { uiPopupMenu *pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); uiLayout *layout = uiPupMenuLayout(pup); - uiLayout *split = uiLayoutSplit(layout, 0, 0), *column = NULL; + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = NULL; int i, c; for (c = 0, i = totitem - 1; i >= 0; i--, c++) { if ( (c % 20) == 0) - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); if (item[i].identifier) uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index a90f8253654..d52463cf406 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -467,7 +467,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* draw other uvs */ if (sima->flag & SI_DRAW_OTHER) { - Image *curimage = (activetf) ? activetf->tpage : NULL; + Image *curimage = (activetf) ? activetf->tpage : ima; draw_uvs_other(scene, obedit, curimage); } |