svn merge ^/trunk/blender -r48011:48095

This commit is contained in:
Ove Murberg Henriksen 2012-06-19 19:37:59 +00:00
commit a953e4bbe3
82 changed files with 1784 additions and 1453 deletions

@ -143,23 +143,23 @@ void AUD_FFMPEGReader::init()
switch(m_codecCtx->sample_fmt)
{
case SAMPLE_FMT_U8:
case AV_SAMPLE_FMT_U8:
m_convert = AUD_convert_u8_float;
m_specs.format = AUD_FORMAT_U8;
break;
case SAMPLE_FMT_S16:
case AV_SAMPLE_FMT_S16:
m_convert = AUD_convert_s16_float;
m_specs.format = AUD_FORMAT_S16;
break;
case SAMPLE_FMT_S32:
case AV_SAMPLE_FMT_S32:
m_convert = AUD_convert_s32_float;
m_specs.format = AUD_FORMAT_S32;
break;
case SAMPLE_FMT_FLT:
case AV_SAMPLE_FMT_FLT:
m_convert = AUD_convert_copy<float>;
m_specs.format = AUD_FORMAT_FLOAT32;
break;
case SAMPLE_FMT_DBL:
case AV_SAMPLE_FMT_DBL:
m_convert = AUD_convert_double_float;
m_specs.format = AUD_FORMAT_FLOAT64;
break;
@ -189,7 +189,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(std::string filename) :
}
catch(AUD_Exception&)
{
av_close_input_file(m_formatCtx);
avformat_close_input(&m_formatCtx);
throw;
}
}
@ -227,7 +227,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer) :
}
catch(AUD_Exception&)
{
av_close_input_stream(m_formatCtx);
avformat_close_input(&m_formatCtx);
av_free(m_aviocontext);
throw;
}
@ -239,7 +239,7 @@ AUD_FFMPEGReader::~AUD_FFMPEGReader()
if(m_aviocontext)
{
av_close_input_stream(m_formatCtx);
avformat_close_input(&m_formatCtx);
av_free(m_aviocontext);
}
else

@ -133,23 +133,23 @@ AUD_FFMPEGWriter::AUD_FFMPEGWriter(std::string filename, AUD_DeviceSpecs specs,
{
case AUD_FORMAT_U8:
m_convert = AUD_convert_float_u8;
m_codecCtx->sample_fmt = SAMPLE_FMT_U8;
m_codecCtx->sample_fmt = AV_SAMPLE_FMT_U8;
break;
case AUD_FORMAT_S16:
m_convert = AUD_convert_float_s16;
m_codecCtx->sample_fmt = SAMPLE_FMT_S16;
m_codecCtx->sample_fmt = AV_SAMPLE_FMT_S16;
break;
case AUD_FORMAT_S32:
m_convert = AUD_convert_float_s32;
m_codecCtx->sample_fmt = SAMPLE_FMT_S32;
m_codecCtx->sample_fmt = AV_SAMPLE_FMT_S32;
break;
case AUD_FORMAT_FLOAT32:
m_convert = AUD_convert_copy<float>;
m_codecCtx->sample_fmt = SAMPLE_FMT_FLT;
m_codecCtx->sample_fmt = AV_SAMPLE_FMT_FLT;
break;
case AUD_FORMAT_FLOAT64:
m_convert = AUD_convert_float_double;
m_codecCtx->sample_fmt = SAMPLE_FMT_DBL;
m_codecCtx->sample_fmt = AV_SAMPLE_FMT_DBL;
break;
default:
AUD_THROW(AUD_ERROR_FFMPEG, format_error);

@ -40,7 +40,6 @@
#endif
#include <libswscale/swscale.h>
#include <libavcodec/opt.h>
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105))
#define FFMPEG_HAVE_AVIO 1
@ -76,6 +75,20 @@
#define FFMPEG_FFV1_ALPHA_SUPPORTED
#endif
#if ((LIBAVFORMAT_VERSION_MAJOR < 53) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR < 24)) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR < 24) && (LIBAVFORMAT_VERSION_MICRO < 2)))
#define avformat_close_input(x) av_close_input_file(*(x))
#endif
#if ((LIBAVFORMAT_VERSION_MAJOR > 53) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR > 32)) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR == 24) && (LIBAVFORMAT_VERSION_MICRO >= 100)))
void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
static inline
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
{
ff_update_cur_dts(s, ref_st, timestamp);
}
#endif
#ifndef FFMPEG_HAVE_AVIO
#define AVIO_FLAG_WRITE URL_WRONLY
#define avio_open url_fopen

@ -174,6 +174,7 @@ class QuickExplode(Operator):
if self.style == 'BLEND' and len(mesh_objects) != 2:
self.report({'ERROR'}, "Select two mesh objects")
self.style = 'EXPLODE'
return {'CANCELLED'}
elif not mesh_objects:
self.report({'ERROR'}, "Select at least one mesh object")
@ -241,10 +242,10 @@ class QuickExplode(Operator):
if obj == to_obj:
tex_slot.alpha_factor = -1.0
elem = tex.color_ramp.elements[1]
elem.color = mat.diffuse_color
else:
elem = tex.color_ramp.elements[0]
elem.color = mat.diffuse_color
# Keep already defined alpha!
elem.color[:3] = mat.diffuse_color
else:
tex_slot.use_map_color_diffuse = False

@ -841,7 +841,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
row = layout.row()
row.prop(part, "use_simplify_viewport")
sub = row.row()
sub.active = part.viewport == True
sub.active = part.use_simplify_viewport == True
sub.prop(part, "simplify_viewport")
elif part.render_type == 'OBJECT':

@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 263
#define BLENDER_SUBVERSION 11
#define BLENDER_SUBVERSION 12
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0

@ -1627,7 +1627,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
int nextLvl = curLvl + 1;
int ptrIdx, cornerIdx, i;
int vertDataSize = ss->meshIFC.vertDataSize;
void *q = ss->q, *r = ss->r;
float *q = ss->q, *r = ss->r;
#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) {
@ -1642,11 +1642,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
for (x = 0; x < gridSize - 1; x++) {
int fx = 1 + 2 * x;
int fy = 1 + 2 * y;
void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0);
void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0);
void *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1);
void *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1);
void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0);
const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0);
const float *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1);
const float *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1);
float *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
VertDataAvg4(co, co0, co1, co2, co3, ss);
}
@ -1660,11 +1660,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
for (S = 0; S < f->numVerts; S++) {
for (x = 0; x < gridSize - 1; x++) {
int fx = x * 2 + 1;
void *co0 = FACE_getIECo(f, curLvl, S, x + 0);
void *co1 = FACE_getIECo(f, curLvl, S, x + 1);
void *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx);
void *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1);
void *co = FACE_getIECo(f, nextLvl, S, fx);
const float *co0 = FACE_getIECo(f, curLvl, S, x + 0);
const float *co1 = FACE_getIECo(f, curLvl, S, x + 1);
const float *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx);
const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1);
float *co = FACE_getIECo(f, nextLvl, S, fx);
VertDataAvg4(co, co0, co1, co2, co3, ss);
}
@ -1679,11 +1679,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
for (y = 0; y < gridSize - 1; y++) {
int fx = x * 2;
int fy = y * 2 + 1;
void *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0);
void *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1);
void *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy);
void *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy);
void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
const float *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0);
const float *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1);
const float *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy);
const float *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy);
float *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
VertDataAvg4(co, co0, co1, co2, co3, ss);
}
@ -1694,11 +1694,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
for (x = 0; x < gridSize - 1; x++) {
int fx = x * 2 + 1;
int fy = y * 2;
void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y);
void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y);
void *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1);
void *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1);
void *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y);
const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y);
const float *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1);
const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1);
float *co = FACE_getIFCo(f, nextLvl, S, fx, fy);
VertDataAvg4(co, co0, co1, co2, co3, ss);
}
@ -1718,9 +1718,9 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
if (_edge_isBoundary(e) || sharpness > 1.0f) {
for (x = 0; x < edgeSize - 1; x++) {
int fx = x * 2 + 1;
void *co0 = EDGE_getCo(e, curLvl, x + 0);
void *co1 = EDGE_getCo(e, curLvl, x + 1);
void *co = EDGE_getCo(e, nextLvl, fx);
const float *co0 = EDGE_getCo(e, curLvl, x + 0);
const float *co1 = EDGE_getCo(e, curLvl, x + 1);
float *co = EDGE_getCo(e, nextLvl, fx);
VertDataCopy(co, co0, ss);
VertDataAdd(co, co1, ss);
@ -1730,9 +1730,9 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
else {
for (x = 0; x < edgeSize - 1; x++) {
int fx = x * 2 + 1;
void *co0 = EDGE_getCo(e, curLvl, x + 0);
void *co1 = EDGE_getCo(e, curLvl, x + 1);
void *co = EDGE_getCo(e, nextLvl, fx);
const float *co0 = EDGE_getCo(e, curLvl, x + 0);
const float *co1 = EDGE_getCo(e, curLvl, x + 1);
float *co = EDGE_getCo(e, nextLvl, fx);
int numFaces = 0;
VertDataCopy(q, co0, ss);
@ -1766,8 +1766,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
*/
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
CCGVert *v = (CCGVert *) effectedV[ptrIdx];
void *co = VERT_getCo(v, curLvl);
void *nCo = VERT_getCo(v, nextLvl);
const float *co = VERT_getCo(v, curLvl);
float *nCo = VERT_getCo(v, nextLvl);
int sharpCount = 0, allSharp = 1;
float avgSharpness = 0.0;
int j, seam = VERT_seam(v), seamEdges = 0;
@ -1914,14 +1914,18 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
avgSharpness = 0;
}
if (_edge_isBoundary(e) && (!e->numFaces || sharpCount < 2)) {
if (_edge_isBoundary(e)) {
for (x = 1; x < edgeSize - 1; x++) {
int fx = x * 2;
void *co = EDGE_getCo(e, curLvl, x);
void *nCo = EDGE_getCo(e, nextLvl, fx);
const float *co = EDGE_getCo(e, curLvl, x);
float *nCo = EDGE_getCo(e, nextLvl, fx);
/* Average previous level's endpoints */
VertDataCopy(r, EDGE_getCo(e, curLvl, x - 1), ss);
VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1), ss);
VertDataMulN(r, 0.5f, ss);
/* nCo = nCo * 0.75 + r * 0.25 */
VertDataCopy(nCo, co, ss);
VertDataMulN(nCo, 0.75f, ss);
VertDataMulN(r, 0.25f, ss);
@ -1931,8 +1935,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
else {
for (x = 1; x < edgeSize - 1; x++) {
int fx = x * 2;
void *co = EDGE_getCo(e, curLvl, x);
void *nCo = EDGE_getCo(e, nextLvl, fx);
const float *co = EDGE_getCo(e, curLvl, x);
float *nCo = EDGE_getCo(e, nextLvl, fx);
int numFaces = 0;
VertDataZero(q, ss);
@ -1974,7 +1978,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
#pragma omp parallel private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT)
{
void *q, *r;
float *q, *r;
#pragma omp critical
{
@ -2018,8 +2022,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
for (y = 1; y < gridSize - 1; y++) {
int fx = x * 2;
int fy = y * 2;
void *co = FACE_getIFCo(f, curLvl, S, x, y);
void *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy);
const float *co = FACE_getIFCo(f, curLvl, S, x, y);
float *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy);
VertDataAvg4(q,
FACE_getIFCo(f, nextLvl, S, fx - 1, fy - 1),
@ -2049,8 +2053,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
*/
for (x = 1; x < gridSize - 1; x++) {
int fx = x * 2;
void *co = FACE_getIECo(f, curLvl, S, x);
void *nCo = FACE_getIECo(f, nextLvl, S, fx);
const float *co = FACE_getIECo(f, curLvl, S, x);
float *nCo = FACE_getIECo(f, nextLvl, S, fx);
VertDataAvg4(q,
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1),
@ -2106,7 +2110,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss);
VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss);
for (x = 1; x < gridSize - 1; x++) {
void *co = FACE_getIECo(f, nextLvl, S, x);
float *co = FACE_getIECo(f, nextLvl, S, x);
VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co, ss);
VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co, ss);
}

@ -463,7 +463,6 @@ static void movieclip_load_get_szie(MovieClip *clip)
clip->tracking.camera.principal[0] = ((float)width) / 2.0f;
clip->tracking.camera.principal[1] = ((float)height) / 2.0f;
clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width;
}
}
@ -518,6 +517,11 @@ MovieClip *BKE_movieclip_file_add(const char *name)
clip->source = MCLIP_SRC_SEQUENCE;
movieclip_load_get_szie(clip);
if (clip->lastsize[0]) {
int width = clip->lastsize[0];
clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width;
}
movieclip_calc_length(clip);

@ -96,7 +96,7 @@ Paint *paint_get_active_from_context(const bContext *C)
obact = sce->basact->object;
if (CTX_wm_space_image(C) != NULL) {
if (obact->mode == OB_MODE_EDIT) {
if (obact && obact->mode == OB_MODE_EDIT) {
if (ts->use_uv_sculpt)
return &ts->uvsculpt->paint;
else

@ -42,8 +42,8 @@
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/rational.h>
#include <libavutil/samplefmt.h>
#include <libswscale/swscale.h>
#include <libavcodec/opt.h>
#include "MEM_guardedalloc.h"
@ -615,7 +615,7 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
c->sample_rate = rd->ffcodecdata.audio_mixrate;
c->bit_rate = ffmpeg_audio_bitrate * 1000;
c->sample_fmt = SAMPLE_FMT_S16;
c->sample_fmt = AV_SAMPLE_FMT_S16;
c->channels = rd->ffcodecdata.audio_channels;
codec = avcodec_find_encoder(c->codec_id);
if (!codec) {
@ -657,11 +657,21 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
}
/* essential functions -- start, append, end */
static void ffmpeg_dict_set_int(AVDictionary **dict, const char *key, int value)
{
char buffer[32];
BLI_snprintf(buffer, sizeof(buffer), "%d", value);
av_dict_set(dict, key, buffer, 0);
}
static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, ReportList *reports)
{
/* Handle to the output file */
AVFormatContext *of;
AVOutputFormat *fmt;
AVDictionary *opts = NULL;
char name[256];
const char **exts;
@ -707,13 +717,14 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
of->oformat = fmt;
of->packet_size = rd->ffcodecdata.mux_packet_size;
if (ffmpeg_audio_codec != CODEC_ID_NONE) {
of->mux_rate = rd->ffcodecdata.mux_rate;
ffmpeg_dict_set_int(&opts, "muxrate", rd->ffcodecdata.mux_rate);
}
else {
of->mux_rate = 0;
av_dict_set(&opts, "muxrate", "0", 0);
}
of->preload = (int)(0.5 * AV_TIME_BASE);
ffmpeg_dict_set_int(&opts, "preload", (int)(0.5 * AV_TIME_BASE));
of->max_delay = (int)(0.7 * AV_TIME_BASE);
fmt->audio_codec = ffmpeg_audio_codec;
@ -776,6 +787,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
fmt->audio_codec = CODEC_ID_PCM_S16LE;
if (ffmpeg_audio_codec != CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000 && rd->ffcodecdata.audio_channels != 2) {
BKE_report(reports, RPT_ERROR, "FFMPEG only supports 48khz / stereo audio for DV!");
av_dict_free(&opts);
return 0;
}
}
@ -785,6 +797,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
printf("alloc video stream %p\n", video_stream);
if (!video_stream) {
BKE_report(reports, RPT_ERROR, "Error initializing video stream.");
av_dict_free(&opts);
return 0;
}
}
@ -793,27 +806,26 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of);
if (!audio_stream) {
BKE_report(reports, RPT_ERROR, "Error initializing audio stream.");
av_dict_free(&opts);
return 0;
}
}
if (av_set_parameters(of, NULL) < 0) {
BKE_report(reports, RPT_ERROR, "Error setting output parameters.");
return 0;
}
if (!(fmt->flags & AVFMT_NOFILE)) {
if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) {
BKE_report(reports, RPT_ERROR, "Could not open file for writing.");
av_dict_free(&opts);
return 0;
}
}
if (av_write_header(of) < 0) {
if (avformat_write_header(of, NULL) < 0) {
BKE_report(reports, RPT_ERROR, "Could not initialize streams. Probably unsupported codec combination.");
av_dict_free(&opts);
return 0;
}
outfile = of;
av_dump_format(of, 0, name, 1);
av_dict_free(&opts);
return 1;
}
@ -1194,7 +1206,7 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char
char name_[128];
char *name;
char *param;
IDProperty *prop;
IDProperty *prop = NULL;
avcodec_get_context_defaults(&c);
@ -1222,9 +1234,11 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char
}
if (param && o->type != FF_OPT_TYPE_CONST && o->unit) {
p = my_av_find_opt(&c, param, o->unit, 0, 0);
prop = BKE_ffmpeg_property_add(rd,
(char *) type, p - c.av_class->option,
o - c.av_class->option);
if (p) {
prop = BKE_ffmpeg_property_add(rd,
(char *) type, p - c.av_class->option,
o - c.av_class->option);
}
}
else {
prop = BKE_ffmpeg_property_add(rd,

@ -6787,17 +6787,24 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
node->storage = nimf;
/* split off filename from the old path, to be used as socket sub-path */
BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename));
BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path));
nimf->format = old_data->im_format;
/* looks like storage data can be messed up somehow, stupid check here */
if (old_data) {
/* split off filename from the old path, to be used as socket sub-path */
BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename));
BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path));
nimf->format = old_data->im_format;
}
else {
basepath[0] = '\0';
BLI_strncpy(filename, old_image->name, sizeof(filename));
}
/* if z buffer is saved, change the image type to multilayer exr.
* XXX this is slightly messy, Z buffer was ignored before for anything but EXR and IRIS ...
* i'm just assuming here that IRIZ means IRIS with z buffer ...
*/
if (ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) {
if (old_data && ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) {
char sockpath[FILE_MAX];
nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER;
@ -6832,7 +6839,8 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
nodeRemoveSocket(ntree, node, old_image);
nodeRemoveSocket(ntree, node, old_z);
MEM_freeN(old_data);
if (old_data)
MEM_freeN(old_data);
}
else if (node->type==CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) {
NodeImageMultiFile *nimf = node->storage;
@ -7773,6 +7781,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 12)) {
Material *ma;
for (ma = main->mat.first; ma; ma = ma->id.next)
if (ma->strand_widthfade == 2.0f)
ma->strand_widthfade = 0.0f;
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */

@ -67,7 +67,7 @@ typedef enum CompositorPriority {
// chunk size determination
#define COM_PREVIEW_SIZE 140.0f
//#define COM_OPENCL_ENABLED
#define COM_OPENCL_ENABLED
//#define COM_DEBUG
// workscheduler threading models

@ -208,7 +208,7 @@ void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel,
const int height = outputMemoryBuffer->getHeight();
int offsetx;
int offsety;
const int localSize = 32;
const int localSize = 128;
size_t size[2];
cl_int2 offset;

@ -37,24 +37,24 @@ BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
Object *camob = context->getScene()->camera;
// Object *camob = context->getScene()->camera;
if (this->getInputSocket(2)->isConnected()) {
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation();
converter->setfStop(this->getbNode()->custom3);
converter->setCameraObject(camob);
operation->setMaxBlur((int)this->getbNode()->custom4);
operation->setQuality(context->getQuality());
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), 2, graph);
addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2));
graph->addOperation(operation);
graph->addOperation(converter);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
}
else {
// if (this->getInputSocket(2)->isConnected()) {
// VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
// ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation();
// converter->setfStop(this->getbNode()->custom3);
// converter->setCameraObject(camob);
// operation->setMaxBlur((int)this->getbNode()->custom4);
// operation->setQuality(context->getQuality());
// this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
// this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
// this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), 2, graph);
// addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2));
// graph->addOperation(operation);
// graph->addOperation(converter);
// this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
// }
// else {
BokehBlurOperation *operation = new BokehBlurOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
@ -63,5 +63,5 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex
operation->setQuality(context->getQuality());
graph->addOperation(operation);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
}
// }
}

@ -91,11 +91,16 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
graph->addOperation(bokeh);
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
operation->setQuality(context->getQuality());
if (data->preview) {
operation->setQuality(COM_QUALITY_LOW);
} else {
operation->setQuality(context->getQuality());
}
operation->setMaxBlur(data->maxblur);
operation->setThreshold(data->bthresh);
addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1));
addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2));
addLink(graph, radiusOperation->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(3));
if (data->gamco) {
GammaCorrectOperation *correct = new GammaCorrectOperation();
GammaUncorrectOperation *inverse = new GammaUncorrectOperation();

@ -37,9 +37,11 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage;
if (!context->isRendering()) {
/* XXX TODO as in previous implementation?
* add dummy operations and exit, to prevent file writing on each compo update.
/* only output files when rendering a sequence -
* otherwise, it overwrites the output files just
* scrubbing through the timeline when the compositor updates.
*/
return;
}
if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) {

@ -85,6 +85,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
int i;
int width = this->getWidth();
int height = this->getHeight();
int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber);
if (this->trackingObject[0]) {
MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->trackingObject);
@ -102,7 +103,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
if (!sites_total)
return NULL;
BKE_movieclip_user_set_frame(&user, framenumber);
BKE_movieclip_user_set_frame(&user, clip_frame);
ibuf = BKE_movieclip_get_ibuf(movieClip, &user);
if (!ibuf)
@ -115,7 +116,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
i = 0;
while (track) {
VoronoiSite *site = &sites[i];
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenumber);
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE);
int j;
@ -182,8 +183,9 @@ void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsig
if (this->movieClip) {
MovieClipUser user = {0};
int width, height;
int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber);
BKE_movieclip_user_set_frame(&user, framenumber);
BKE_movieclip_user_set_frame(&user, clip_frame);
BKE_movieclip_get_size(this->movieClip, &user, &width, &height);
resolution[0] = width;

@ -47,9 +47,9 @@ void ScreenLensDistortionOperation::initExecution()
drg = 4.f * (kg - kr);
dgb = 4.f * (kb - kg);
kr4 = kr * 4;
kr4 = kr * 4.f;
kg4 = kg * 4.f;
kb4 *= kb * 4.f;
kb4 = kb * 4.f;
cx = 0.5f * (float)getWidth();
cy = 0.5f * (float)getHeight();

@ -31,15 +31,17 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image.
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE); // radius
this->addInputSocket(COM_DT_VALUE); // depth
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
this->inputProgram = NULL;
this->inputBokehProgram = NULL;
this->inputSizeProgram = NULL;
this->inputDepthProgram = NULL;
this->maxBlur = 32.0f;
this->threshold = 0.0f;
this->threshold = 1.0f;
}
@ -48,6 +50,7 @@ void VariableSizeBokehBlurOperation::initExecution()
this->inputProgram = getInputSocketReader(0);
this->inputBokehProgram = getInputSocketReader(1);
this->inputSizeProgram = getInputSocketReader(2);
this->inputDepthProgram = getInputSocketReader(3);
QualityStepHelper::initExecution(COM_QH_INCREASE);
}
@ -56,6 +59,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
float readColor[4];
float bokeh[4];
float tempSize[4];
float tempDepth[4];
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
@ -64,32 +68,35 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
int minx = x - maxBlur;
int maxx = x + maxBlur;
{
inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers);
inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers);
inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers);
color_accum[0] += readColor[0];
color_accum[1] += readColor[1];
color_accum[2] += readColor[2];
color_accum[3] += readColor[3];
add_v4_v4(color_accum, readColor);
add_v3_fl(multiplier_accum, 1.0f);
add_v4_fl(multiplier_accum, 1.0f);
float sizeCenter = tempSize[0];
float centerDepth = tempDepth[0]+threshold;
for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) {
for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) {
if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers);
inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
float size = tempSize[0];
// size += this->threshold;
float dx = nx - x;
float dy = ny - y;
if (nx == x && ny == y) {
/* pass */
}
else if (size >= fabsf(dx) && size >= fabsf(dy)) {
float u = 256 + dx * 256 / size;
float v = 256 + dy * 256 / size;
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers);
madd_v4_v4v4(color_accum, bokeh, readColor);
add_v4_v4(multiplier_accum, bokeh);
if (tempDepth[0] < centerDepth) {
if ((sizeCenter > threshold && size > threshold) || size <= threshold) {
float dx = nx - x;
float dy = ny - y;
if (nx == x && ny == y) {
}
else if (size >= fabsf(dx) && size >= fabsf(dy)) {
float u = 256 + dx * 256 / size;
float v = 256 + dy * 256 / size;
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers);
madd_v4_v4v4(color_accum, bokeh, readColor);
add_v4_v4(multiplier_accum, bokeh);
}
}
}
}
}
@ -132,6 +139,10 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu
if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) {
return true;
}
operation = getInputOperation(3);
if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
return true;
}
operation = getInputOperation(0);
if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
return true;

@ -32,6 +32,7 @@ private:
SocketReader *inputProgram;
SocketReader *inputBokehProgram;
SocketReader *inputSizeProgram;
SocketReader *inputDepthProgram;
public:
VariableSizeBokehBlurOperation();

@ -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)

@ -6,6 +6,7 @@ SConscript(['datafiles/SConscript',
'space_api/SConscript',
'util/SConscript',
'interface/SConscript',
'io/SConscript',
'animation/SConscript',
'armature/SConscript',
'mask/SConscript',

@ -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) {

@ -41,7 +41,7 @@ struct MovieClip;
struct SpaceClip;
struct wmEvent;
/* clip_editor.c */
/* ** clip_editor.c ** */
int ED_space_clip_poll(struct bContext *C);
int ED_space_clip_view_clip_poll(struct bContext *C);
@ -50,18 +50,16 @@ 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);
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);
int ED_space_clip_clip_framenr(struct SpaceClip *sc);
void ED_space_clip_get_zoom(struct SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy);
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);
void ED_space_clip_get_clip_size(struct SpaceClip *sc, int *width, int *height);
void ED_space_clip_get_clip_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
void ED_space_clip_get_clip_aspect_dimension_aware(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);
@ -69,21 +67,27 @@ struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2]
void ED_clip_update_frame(const struct Main *mainp, int cfra);
int ED_clip_view_selection(struct SpaceClip *sc, 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(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]);
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(SpaceClip *sc, ARegion *ar, 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_space_clip_get_mask_size(struct SpaceClip *sc, int *width, int *height);
void ED_space_clip_get_mask_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
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 */

@ -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}")

@ -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] )

@ -0,0 +1,281 @@
/*
* ***** 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 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");
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,
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, *sub, *split;
/* Export Options: */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, 0);
uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA);
row = uiLayoutRow(box, 0);
col = uiLayoutColumn(row, 0);
split = uiLayoutSplit(col, 0.5f, 0);
uiItemR(split, imfptr, "apply_modifiers", 0, NULL, ICON_NONE);
sub = uiLayoutRow(split, 0);
uiItemR(sub, imfptr, "export_mesh_type_selection", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE);
uiLayoutSetEnabled(sub, RNA_boolean_get(imfptr, "apply_modifiers"));
row = uiLayoutRow(box, 0);
uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, 0);
col = uiLayoutColumn(row, 0);
split = uiLayoutSplit(col, 0.1f, 0);
sub = uiLayoutRow(split, 0);
uiItemR(split, imfptr, "include_children", 0, NULL, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
row = uiLayoutRow(box, 0);
col = uiLayoutColumn(row, 0);
split = uiLayoutSplit(col, 0.1f, 0);
sub = uiLayoutRow(split, 0);
uiItemR(split, imfptr, "include_armatures", 0, NULL, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
// 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");
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, "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

@ -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

@ -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
}

@ -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

@ -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;

@ -441,10 +441,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);
}

@ -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);
@ -132,13 +132,13 @@ 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_mask_size(sc, width, height);
return;
}
else if (sa->spacetype == SPACE_SEQ) {
@ -154,12 +154,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_mask_aspect(sc, aspx, aspy);
}
else {
/* possible other spaces from which mask editing is available */
@ -168,7 +168,7 @@ 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);
@ -177,9 +177,9 @@ void ED_mask_pixelspace_factor(bContext *C, float *scalex, float *scaley)
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_clip_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_clip_aspect(sc, &aspx, &aspy);
*scalex = ((float)width * aspx) * zoomx;
*scaley = ((float)height * aspy) * zoomy;

@ -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,14 +97,14 @@ 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);

@ -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)
{

@ -595,8 +595,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_clip_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
width = height = MAX2(width, height);
ellipse[0] = width * zoomx / radius;

@ -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;
}

@ -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 ************************** */

@ -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;
}
}

@ -20,6 +20,7 @@
set(INC
../include
../io
../../blenkernel
../../blenlib
../../blenloader

@ -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'

@ -64,6 +64,8 @@
#include "ED_clip.h"
#include "ED_mask.h"
#include "io_ops.h"
/* only call once on startup, storage is global in BKE kernel listbase */
void ED_spacetypes_init(void)
{
@ -113,6 +115,7 @@ void ED_spacetypes_init(void)
ED_operatortypes_render();
ED_operatortypes_logic();
ED_operatortypes_mask();
ED_operatortypes_io();
UI_view2d_operatortypes();
UI_buttons_operatortypes();

@ -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;

@ -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;

@ -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;

@ -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,6 +837,9 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
glEnable(GL_LINE_STIPPLE);
glLineStipple(3, 0xaaaa);
#if 0
/* TODO: disable for now, needs better approach visualizing this */
glBegin(GL_LINE_LOOP);
glVertex2f(pat_min[0] - dx, pat_min[1] - dy);
glVertex2f(pat_max[0] + dx, pat_min[1] - dy);
@ -844,6 +847,13 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
glVertex2f(pat_min[0] - dx, pat_max[1] + dy);
glEnd();
/* 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);
@ -851,11 +861,6 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
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);
/* 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];
@ -1405,7 +1410,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene)
{
MovieClip *clip = ED_space_clip(sc);
MovieClip *clip = ED_space_clip_get_clip(sc);
ImBuf *ibuf;
int width, height;
float zoomx, zoomy;
@ -1414,8 +1419,8 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene)
if (!clip)
return;
ED_space_clip_size(sc, &width, &height);
ED_space_clip_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_clip_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
if (sc->flag & SC_SHOW_STABLE) {
float smat[4][4], ismat[4][4];
@ -1471,7 +1476,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;

@ -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;
@ -124,7 +124,7 @@ int ED_space_clip_maskedit_mask_poll(bContext *C)
/* ******** editing functions ******** */
void ED_space_clip_set(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip)
void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip)
{
MovieClip *old_clip;
@ -160,12 +160,12 @@ void ED_space_clip_set(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *c
WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip);
}
MovieClip *ED_space_clip(SpaceClip *sc)
MovieClip *ED_space_clip_get_clip(SpaceClip *sc)
{
return sc->clip;
}
Mask *ED_space_clip_mask(SpaceClip *sc)
Mask *ED_space_clip_get_mask(SpaceClip *sc)
{
return sc->mask;
}
@ -204,7 +204,7 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale
return NULL;
}
void ED_space_clip_size(SpaceClip *sc, int *width, int *height)
void ED_space_clip_get_clip_size(SpaceClip *sc, int *width, int *height)
{
if (!sc->clip) {
*width = *height = 0;
@ -214,7 +214,7 @@ 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_mask_size(SpaceClip *sc, int *width, int *height)
{
/* 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
@ -228,20 +228,20 @@ void ED_space_clip_mask_size(SpaceClip *sc, int *width, int *height)
} else {
float aspx, aspy;
ED_space_clip_size(sc, width, height);
ED_space_clip_aspect(sc, &aspx, &aspy);
ED_space_clip_get_clip_size(sc, width, height);
ED_space_clip_get_clip_aspect(sc, &aspx, &aspy);
*width *= aspx;
*height *= aspy;
}
}
void ED_space_clip_mask_aspect(SpaceClip *sc, float *aspx, float *aspy)
void ED_space_clip_get_mask_aspect(SpaceClip *sc, float *aspx, float *aspy)
{
int w, h;
ED_space_clip_aspect(sc, aspx, aspy);
ED_space_clip_size(sc, &w, &h);
ED_space_clip_get_clip_aspect(sc, aspx, aspy);
ED_space_clip_get_clip_size(sc, &w, &h);
/* now this is not accounted for! */
#if 0
@ -259,19 +259,19 @@ 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)
void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy)
{
int width, height;
ED_space_clip_size(sc, &width, &height);
ED_space_clip_get_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)
void ED_space_clip_get_clip_aspect(SpaceClip *sc, float *aspx, float *aspy)
{
MovieClip *clip = ED_space_clip(sc);
MovieClip *clip = ED_space_clip_get_clip(sc);
if (clip)
BKE_movieclip_aspect(clip, aspx, aspy);
@ -279,7 +279,7 @@ void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy)
*aspx = *aspy = 1.0f;
}
void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy)
void ED_space_clip_get_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy)
{
int w, h;
@ -290,8 +290,8 @@ 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_clip_aspect(sc, aspx, aspy);
ED_space_clip_get_clip_size(sc, &w, &h);
*aspx *= (float)w;
*aspy *= (float)h;
@ -330,23 +330,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)
int ED_space_clip_get_clip_frame_number(SpaceClip *sc)
{
MovieClip *clip = ED_space_clip(sc);
MovieClip *clip = ED_space_clip_get_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);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTrackingTrack *track;
int width, height, ok = FALSE;
ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
INIT_MINMAX2(min, max);
ED_space_clip_size(sc, &width, &height);
ED_space_clip_get_clip_size(sc, &width, &height);
track = tracksbase->first;
while (track) {
@ -388,7 +388,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit)
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_clip_size(sc, &frame_width, &frame_height);
if (frame_width == 0 || frame_height == 0)
return FALSE;
@ -408,7 +408,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_clip_aspect(sc, &aspx, &aspy);
width = ar->winrct.xmax - ar->winrct.xmin + 1;
height = ar->winrct.ymax - ar->winrct.ymin + 1;
@ -430,11 +430,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);
ED_space_clip_get_clip_size(sc, &width, &height);
r_co[0] *= width;
r_co[1] *= height * aspy;
@ -446,15 +446,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(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_clip_size(sc, &width, &height);
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy);
@ -469,7 +469,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};
@ -493,8 +493,8 @@ void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float c
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_clip_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_clip_point_undistorted_pos(sc, co, pos);
pos[2] = 0.0f;
@ -506,7 +506,7 @@ 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]);
}
@ -552,7 +552,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);
@ -657,7 +657,7 @@ void ED_space_clip_free_texture_buffer(SpaceClip *sc)
/* ******** masking editing related functions ******** */
int ED_space_clip_show_trackedit(SpaceClip *sc)
int ED_space_clip_check_show_trackedit(SpaceClip *sc)
{
if (sc) {
return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION);
@ -666,7 +666,7 @@ int ED_space_clip_show_trackedit(SpaceClip *sc)
return FALSE;
}
int ED_space_clip_show_maskedit(SpaceClip *sc)
int ED_space_clip_check_show_maskedit(SpaceClip *sc)
{
if (sc) {
return sc->mode == SC_MODE_MASKEDIT;

@ -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;

@ -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;

@ -78,7 +78,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_clip_size(sc, &width, &height);
width *= sc->zoom;
height *= sc->zoom;
@ -92,7 +92,7 @@ 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_clip_size(sc, &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;
@ -208,7 +208,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 +225,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));
@ -713,8 +713,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_clip_size(sc, &w, &h);
ED_space_clip_get_clip_aspect(sc, &aspx, &aspy);
w = w * aspx;
h = h * aspy;
@ -1031,7 +1031,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;

@ -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;
@ -228,8 +228,8 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y)
int width, height;
float aspx, aspy;
ED_space_clip_size(sc, &width, &height);
ED_space_clip_aspect(sc, &aspx, &aspy);
ED_space_clip_get_clip_size(sc, &width, &height);
ED_space_clip_get_clip_aspect(sc, &aspx, &aspy);
sc->xof = (x - 0.5f) * width * aspx;
sc->yof = (y - 0.5f) * height * aspy;

@ -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;
@ -1010,11 +1010,11 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
/* sets up the fields of the View2D from zoom and offset */
static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar)
{
MovieClip *clip = ED_space_clip(sc);
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_clip_size(sc, &width, &height);
w = width;
h = height;
@ -1079,7 +1079,7 @@ 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 */
@ -1123,9 +1123,9 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
/* 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);
ED_space_clip_get_clip_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ED_space_clip_get_clip_aspect(sc, &aspx, &aspy);
/* frame the image */
maxdim = maxf(width, height);
@ -1147,7 +1147,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
glScalef(maxdim * zoomx, maxdim * zoomy, 0);
glMultMatrixf(sc->stabmat);
ED_mask_draw((bContext *)C, sc->mask_draw_flag, sc->mask_draw_type);
ED_mask_draw(C, sc->mask_draw_flag, sc->mask_draw_type);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
@ -1226,7 +1226,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 +1289,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;

@ -83,14 +83,14 @@
static void add_marker(SpaceClip *sc, float x, float y)
{
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;
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_clip_size(sc, &width, &height);
track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height);
@ -102,11 +102,11 @@ 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_clip_size(sc, &width, &height);
if (!width || !height)
return OPERATOR_CANCELLED;
@ -160,7 +160,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 +201,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 +283,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 +524,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_clip_size(sc, &width, &height);
if (width == 0 || height == 0)
return NULL;
@ -575,6 +575,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 +588,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 +625,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_clip_size(sc, &width, &height);
if (width == 0 || height == 0)
return NULL;
@ -647,7 +651,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 +950,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 +994,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 +1037,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 +1161,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 +1224,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 +1330,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 +1454,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 +1536,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 +1584,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 +1641,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 +1723,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 +1747,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 +1768,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 +1839,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 +2035,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 +2173,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 +2245,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 +2326,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 +2361,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 +2382,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 +2415,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 +2451,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 +2510,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 +2567,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 +2578,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 +2644,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 +2669,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 +2736,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 +2790,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 +2843,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 +2890,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 +2939,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 +2999,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 +3042,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 +3172,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 +3228,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 +3277,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 +3307,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 +3345,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 +3385,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);

@ -112,13 +112,13 @@ static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx
static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track)
{
int framenr = ED_space_clip_clip_framenr(sc);
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_clip_size(sc, &width, &height);
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
@ -187,7 +187,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 +226,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);
@ -288,7 +288,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 +332,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");
@ -414,13 +414,13 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho
{
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);
@ -519,14 +519,14 @@ 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);
MovieClip *clip = ED_space_clip_get_clip(sc);
ARegion *ar = CTX_wm_region(C);
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 +536,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_clip_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
@ -602,13 +602,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 +692,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) {

@ -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) {

@ -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,8 +98,8 @@ 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);

@ -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,16 +634,16 @@ 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++;
@ -659,9 +659,9 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
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++;
@ -684,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);
}
}
@ -707,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];
@ -745,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;
}
}
@ -803,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);
}
}
@ -834,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;
@ -862,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)
@ -874,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;
}
@ -893,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();
@ -906,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;
}
@ -916,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;
}
@ -948,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;
}
}
@ -972,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;
}
@ -1026,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;
@ -1036,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");
@ -1062,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) {
@ -1085,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;
}
@ -1115,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? */
@ -1123,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);
}
@ -1140,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
}
@ -1153,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);
}
@ -1172,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);
@ -1192,28 +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) {
matched_file[0] = '\0';
if (file_select_match(sfile, sfile->params->file, matched_file)) {
int i, numfiles= filelist_numfiles(sfile->files);
/* int i, numfiles = filelist_numfiles(sfile->files); */ /* XXX UNUSED */
sfile->params->file[0] = '\0';
/* 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);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
}
}
}
return OPERATOR_FINISHED;
}
@ -1223,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)
@ -1254,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;
@ -1278,27 +1277,26 @@ void FILE_OT_hidedot(struct wmOperatorType *ot)
ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
}
struct ARegion *file_buttons_region(struct ScrArea *sa)
{
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;
@ -1307,8 +1305,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);
@ -1331,8 +1329,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)) {
@ -1363,17 +1361,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);
}
@ -1385,19 +1383,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;
}
@ -1417,22 +1415,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;
}
@ -1440,15 +1438,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;

@ -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, 1);
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, 0);
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, 0);
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);
}

File diff suppressed because it is too large Load Diff

@ -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
}

@ -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 */
}
@ -605,7 +605,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche
if (fnmatch(pattern, file->relname, 0) == 0) {
file->selflag |= SELECTED_FILE;
if (!match) {
BLI_strncpy(matched_file, file->relname, FILE_MAX );
BLI_strncpy(matched_file, file->relname, FILE_MAX);
}
match = 1;
}
@ -616,7 +616,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche
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) {
@ -630,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 {
@ -664,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);
}
@ -692,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)
@ -709,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;
}
}

@ -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;

@ -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

@ -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);

@ -1574,9 +1574,6 @@ static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), Po
col = uiLayoutColumn(layout, 0);
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);
uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE);

@ -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_clip_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_mask_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_clip_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_mask_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_clip_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_mask_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_clip_aspect_dimension_aware(sc, &aspx, &aspy);
}
else if (t->options & CTX_MASK) {
ED_space_clip_mask_aspect(sc, &aspx, &aspy);
ED_space_clip_get_mask_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);
}

@ -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_clip_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_clip_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_mask_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_mask_aspect(sc, &aspx, &aspy);
invx = 1.0f / aspx;
invy = 1.0f / aspy;

@ -639,8 +639,8 @@ 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;
@ -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 {

@ -445,7 +445,7 @@ static int startffmpeg(struct anim *anim)
int i, videoStream;
AVCodec *pCodec;
AVFormatContext *pFormatCtx;
AVFormatContext *pFormatCtx = NULL;
AVCodecContext *pCodecCtx;
int frs_num;
double frs_den;
@ -464,7 +464,7 @@ static int startffmpeg(struct anim *anim)
do_init_ffmpeg();
if (av_open_input_file(&pFormatCtx, anim->name, NULL, 0, NULL) != 0) {
if (avformat_open_input(&pFormatCtx, anim->name, NULL, NULL) != 0) {
return -1;
}

@ -531,13 +531,6 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg(
rv->c->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
if (av_set_parameters(rv->of, NULL) < 0) {
fprintf(stderr, "Couldn't set output parameters? "
"Proxy not built!\n");
av_free(rv->of);
return 0;
}
if (avio_open(&rv->of->pb, fname, AVIO_FLAG_WRITE) < 0) {
fprintf(stderr, "Couldn't open outputfile! "
"Proxy not built!\n");
@ -574,7 +567,12 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg(
NULL, NULL, NULL);
}
av_write_header(rv->of);
if (avformat_write_header(rv->of, NULL) < 0) {
fprintf(stderr, "Couldn't set output parameters? "
"Proxy not built!\n");
av_free(rv->of);
return 0;
}
return rv;
}
@ -737,7 +735,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim
memset(context->proxy_ctx, 0, sizeof(context->proxy_ctx));
memset(context->indexer, 0, sizeof(context->indexer));
if (av_open_input_file(&context->iFormatCtx, anim->name, NULL, 0, NULL) != 0) {
if (avformat_open_input(&context->iFormatCtx, anim->name, NULL, NULL) != 0) {
MEM_freeN(context);
return NULL;
}

@ -247,7 +247,7 @@ void do_init_ffmpeg(void)
static int isffmpeg(const char *filename)
{
AVFormatContext *pFormatCtx;
AVFormatContext *pFormatCtx = NULL;
unsigned int i;
int videoStream;
AVCodec *pCodec;
@ -268,7 +268,7 @@ static int isffmpeg(const char *filename)
return 0;
}
if (av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL) != 0) {
if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0) {
if (UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_open_input_file failed\n");
return 0;
}

@ -289,13 +289,15 @@ static void rna_def_movieclip(BlenderRNA *brna)
/* start_frame */
prop = RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "start_frame");
RNA_def_property_ui_text(prop, "Start Frame", "Global scene frame number at which this movie starts playing. Affects all data associated with a clip");
RNA_def_property_ui_text(prop, "Start Frame", "Global scene frame number at which this movie starts playing "
"(affects all data associated with a clip)");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
/* frame_offset */
prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "frame_offset");
RNA_def_property_ui_text(prop, "Frame Offset", "Offset of footage first frame relative to it's file name. Affects only how footage is loaing, not changes data associated with a clip");
RNA_def_property_ui_text(prop, "Frame Offset", "Offset of footage first frame relative to it's file name "
"(affects only how footage is loading, does not change data associated with a clip)");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
}

@ -2562,15 +2562,9 @@ static void def_cmp_defocus(StructRNA *srna)
prop = RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "preview", 1);
RNA_def_property_ui_text(prop, "Preview", "Enable sampling mode, useful for preview when using low samplecounts");
RNA_def_property_ui_text(prop, "Preview", "Enable low quality mode, useful for preview");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "samples");
RNA_def_property_range(prop, 16, 256);
RNA_def_property_ui_text(prop, "Samples", "Number of samples (16=grainy, higher=less noise)");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "use_zbuffer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "no_zbuf", 1);
RNA_def_property_ui_text(prop, "Use Z-Buffer",

@ -193,6 +193,16 @@ static void rna_def_area(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, 0, "rna_Area_type_update");
prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "totrct.xmin");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "X Position", "The window relative vertical location of the area");
prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "totrct.ymin");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Y Position", "The window relative horizontal location of the area");
prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "winx");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@ -230,6 +240,16 @@ static void rna_def_region(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Region Type", "Type of this region");
prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "winrct.xmin");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "X Position", "The window relative vertical location of the region");
prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "winrct.ymin");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Y Position", "The window relative horizontal location of the region");
prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "winx");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);

@ -1036,7 +1036,7 @@ static void rna_SpaceClipEditor_clip_set(PointerRNA *ptr, PointerRNA value)
SpaceClip *sc = (SpaceClip *)(ptr->data);
bScreen *screen = (bScreen *)ptr->id.data;
ED_space_clip_set(NULL, screen, sc, (MovieClip *)value.data);
ED_space_clip_set_clip(NULL, screen, sc, (MovieClip *)value.data);
}
static void rna_SpaceClipEditor_mask_set(PointerRNA *ptr, PointerRNA value)

@ -30,6 +30,7 @@ set(INC
../blenlib
../blenloader
../editors/include
../editors/io
../gpu
../imbuf
../makesdna

@ -582,7 +582,10 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
wm->op_undo_depth--;
}
if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) && repeat == 0)
/* XXX Disabled the repeat check to address part 2 of #31840.
* Carefully checked all calls to wm_operator_exec and WM_operator_repeat, don't see any reason
* why this was needed, but worth to note it in case something turns bad. (mont29) */
if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)/* && repeat == 0 */)
wm_operator_reports(C, op, retval, FALSE);
if (retval & OPERATOR_FINISHED) {

@ -2134,236 +2134,6 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory");
}
/* XXX: move these collada operators to a more appropriate place */
#ifdef WITH_COLLADA
#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 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");
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,
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, *sub, *split;
/* Export Options: */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, 0);
uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA);
row = uiLayoutRow(box, 0);
col = uiLayoutColumn(row, 0);
split = uiLayoutSplit(col, 0.5f, 0);
uiItemR(split, imfptr, "apply_modifiers", 0, NULL, ICON_NONE);
sub = uiLayoutRow(split, 0);
uiItemR(sub, imfptr, "export_mesh_type_selection", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE);
uiLayoutSetEnabled(sub, RNA_boolean_get(imfptr, "apply_modifiers"));
row = uiLayoutRow(box, 0);
uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, 0);
col = uiLayoutColumn(row, 0);
split = uiLayoutSplit(col, 0.1f, 0);
sub = uiLayoutRow(split, 0);
uiItemR(split, imfptr, "include_children", 0, NULL, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
row = uiLayoutRow(box, 0);
col = uiLayoutColumn(row, 0);
split = uiLayoutSplit(col, 0.1f, 0);
sub = uiLayoutRow(split, 0);
uiItemR(split, imfptr, "include_armatures", 0, NULL, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
row = uiLayoutRow(box, 0);
uiItemR(row, imfptr, "deform_bones_only", 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);
row = uiLayoutRow(box, 0);
uiItemR(row, imfptr, "second_life", 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);
}
static 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 (Preview Resolution)");
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, "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;
}
static 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
/* *********************** */
static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
{
ot->name = "Toggle Fullscreen";
@ -3897,12 +3667,6 @@ void wm_operatortype_init(void)
#if defined(WIN32)
WM_operatortype_append(WM_OT_console_toggle);
#endif
#ifdef WITH_COLLADA
/* XXX: move these */
WM_operatortype_append(WM_OT_collada_export);
WM_operatortype_append(WM_OT_collada_import);
#endif
}
/* circleselect-like modal operators */

@ -227,7 +227,7 @@ struct ImBuf *ED_space_image_buffer(struct SpaceImage *sima) {return (struct ImB
void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSettings *settings) {}
void ED_screen_set_scene(struct bContext *C, struct Scene *scene) {}
void ED_space_clip_set(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip) {}
void ED_space_clip_set_clip(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip) {}
void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask){}
void ED_area_tag_redraw_regiontype(struct ScrArea *sa, int regiontype) {}

@ -824,6 +824,7 @@ endif()
bf_editor_animation
bf_editor_datafiles
bf_editor_mask
bf_editor_io
bf_render
bf_intern_opennl

@ -162,14 +162,14 @@ void VideoFFmpeg::initParams (short width, short height, float rate, bool image)
}
int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams)
int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams)
{
AVFormatContext *formatCtx;
AVFormatContext *formatCtx = NULL;
int i, videoStream;
AVCodec *codec;
AVCodecContext *codecCtx;
if (av_open_input_file(&formatCtx, filename, inputFormat, 0, formatParams)!=0)
if (avformat_open_input(&formatCtx, filename, inputFormat, formatParams)!=0)
return -1;
if (av_find_stream_info(formatCtx)<0)
@ -545,11 +545,7 @@ void VideoFFmpeg::openFile (char * filename)
// but it is really not desirable to seek on http file, so force streaming.
// It would be good to find this information from the context but there are no simple indication
!strncmp(filename, "http://", 7) ||
#ifdef FFMPEG_PB_IS_POINTER
(m_formatCtx->pb && m_formatCtx->pb->is_streamed)
#else
m_formatCtx->pb.is_streamed
#endif
(m_formatCtx->pb && !m_formatCtx->pb->seekable)
)
{
// the file is in fact a streaming source, treat as cam to prevent seeking
@ -586,14 +582,12 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
{
// open camera source
AVInputFormat *inputFormat;
AVFormatParameters formatParams;
AVRational frameRate;
AVDictionary *formatParams = NULL;
char filename[28], rateStr[20];
char *p;
do_init_ffmpeg();
memset(&formatParams, 0, sizeof(formatParams));
#ifdef WIN32
// video capture on windows only through Video For Windows driver
inputFormat = av_find_input_format("vfwcap");
@ -623,7 +617,13 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
sprintf(filename, "/dev/dv1394/%d", camIdx);
} else
{
inputFormat = av_find_input_format("video4linux");
const char *formats[] = {"video4linux2,v4l2", "video4linux2", "video4linux"};
int i, formatsCount = sizeof(formats) / sizeof(char*);
for (i = 0; i < formatsCount; i++) {
inputFormat = av_find_input_format(formats[i]);
if (inputFormat)
break;
}
sprintf(filename, "/dev/video%d", camIdx);
}
if (!inputFormat)
@ -637,20 +637,22 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
if ((p = strchr(filename, ':')) != 0)
*p = 0;
}
if (file && (p = strchr(file, ':')) != NULL)
formatParams.standard = p+1;
if (file && (p = strchr(file, ':')) != NULL) {
av_dict_set(&formatParams, "standard", p+1, 0);
}
#endif
//frame rate
if (m_captRate <= 0.f)
m_captRate = defFrameRate;
sprintf(rateStr, "%f", m_captRate);
av_parse_video_rate(&frameRate, rateStr);
// populate format parameters
// need to specify the time base = inverse of rate
formatParams.time_base.num = frameRate.den;
formatParams.time_base.den = frameRate.num;
formatParams.width = m_captWidth;
formatParams.height = m_captHeight;
av_dict_set(&formatParams, "framerate", rateStr, 0);
if (m_captWidth > 0 && m_captHeight > 0) {
char video_size[64];
BLI_snprintf(video_size, sizeof(video_size), "%dx%d", m_captWidth, m_captHeight);
av_dict_set(&formatParams, "video_size", video_size, 0);
}
if (openStream(filename, inputFormat, &formatParams) != 0)
return;
@ -665,6 +667,8 @@ void VideoFFmpeg::openCam (char * file, short camIdx)
// no need to thread if the system has a single core
m_isThreaded = true;
}
av_dict_free(&formatParams);
}
// play video

@ -46,10 +46,6 @@ extern "C" {
# define FFMPEG_CODEC_IS_POINTER 1
#endif
#if LIBAVFORMAT_VERSION_INT >= (52 << 16)
# define FFMPEG_PB_IS_POINTER 1
#endif
#ifdef FFMPEG_CODEC_IS_POINTER
static inline AVCodecContext* get_codec_from_stream(AVStream* stream)
{
@ -172,7 +168,7 @@ protected:
double actFrameRate (void) { return m_frameRate * m_baseFrameRate; }
/// common function to video file and capture
int openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams);
int openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams);
/// check if a frame is available and load it in pFrame, return true if a frame could be retrieved
AVFrame* grabFrame(long frame);