[Bf-blender-cvs] [5301ea7] asset-experiments: Address most points from first reviewing pass.

Bastien Montagne noreply at git.blender.org
Fri May 29 10:56:05 CEST 2015


Commit: 5301ea7b966f1348ea95f9beac4996ca68adcbdc
Author: Bastien Montagne
Date:   Fri May 29 10:12:19 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rB5301ea7b966f1348ea95f9beac4996ca68adcbdc

Address most points from first reviewing pass.

Nothing new here, just some cleanup and refactor.

===================================================================

M	source/blender/blenkernel/intern/idcode.c
M	source/blender/blenlib/intern/BLI_filelist.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/include/UI_interface_icons.h
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/editors/space_file/filelist.h

===================================================================

diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 92fe12c..54b2b85 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -180,64 +180,41 @@ const char *BKE_idcode_to_name_plural(int code)
  */
 int BKE_idcode_to_idfilter(const int idcode)
 {
+#define CASE_IDFILTER(_id) case ID_##_id: return FILTER_ID_##_id
+
 	switch (idcode) {
-		case ID_AC:
-			return FILTER_ID_AC;
-		case ID_AR:
-			return FILTER_ID_AR;
-		case ID_BR:
-			return FILTER_ID_BR;
-		case ID_CA:
-			return FILTER_ID_CA;
-		case ID_CU:
-			return FILTER_ID_CU;
-		case ID_GD:
-			return FILTER_ID_GD;
-		case ID_GR:
-			return FILTER_ID_GR;
-		case ID_IM:
-			return FILTER_ID_IM;
-		case ID_LA:
-			return FILTER_ID_LA;
-		case ID_LS:
-			return FILTER_ID_LS;
-		case ID_LT:
-			return FILTER_ID_LT;
-		case ID_MA:
-			return FILTER_ID_MA;
-		case ID_MB:
-			return FILTER_ID_MB;
-		case ID_MC:
-			return FILTER_ID_MC;
-		case ID_ME:
-			return FILTER_ID_ME;
-		case ID_MSK:
-			return FILTER_ID_MSK;
-		case ID_NT:
-			return FILTER_ID_NT;
-		case ID_OB:
-			return FILTER_ID_OB;
-		case ID_PAL:
-			return FILTER_ID_PAL;
-		case ID_PC:
-			return FILTER_ID_PC;
-		case ID_SCE:
-			return FILTER_ID_SCE;
-		case ID_SPK:
-			return FILTER_ID_SPK;
-		case ID_SO:
-			return FILTER_ID_SO;
-		case ID_TE:
-			return FILTER_ID_TE;
-		case ID_TXT:
-			return FILTER_ID_TXT;
-		case ID_VF:
-			return FILTER_ID_VF;
-		case ID_WO:
-			return FILTER_ID_WO;
+		CASE_IDFILTER(AC);
+		CASE_IDFILTER(AR);
+		CASE_IDFILTER(BR);
+		CASE_IDFILTER(CA);
+		CASE_IDFILTER(CU);
+		CASE_IDFILTER(GD);
+		CASE_IDFILTER(GR);
+		CASE_IDFILTER(IM);
+		CASE_IDFILTER(LA);
+		CASE_IDFILTER(LS);
+		CASE_IDFILTER(LT);
+		CASE_IDFILTER(MA);
+		CASE_IDFILTER(MB);
+		CASE_IDFILTER(MC);
+		CASE_IDFILTER(ME);
+		CASE_IDFILTER(MSK);
+		CASE_IDFILTER(NT);
+		CASE_IDFILTER(OB);
+		CASE_IDFILTER(PAL);
+		CASE_IDFILTER(PC);
+		CASE_IDFILTER(SCE);
+		CASE_IDFILTER(SPK);
+		CASE_IDFILTER(SO);
+		CASE_IDFILTER(TE);
+		CASE_IDFILTER(TXT);
+		CASE_IDFILTER(VF);
+		CASE_IDFILTER(WO);
 		default:
 			return 0;
 	}
+
+#undef CASE_IDFILTER
 }
 
 /**
@@ -245,64 +222,41 @@ int BKE_idcode_to_idfilter(const int idcode)
  */
 int BKE_idcode_from_idfilter(const int idfilter)
 {
+#define CASE_IDFILTER(_id) case FILTER_ID_##_id: return ID_##_id
+
 	switch (idfilter) {
-		case FILTER_ID_AC:
-			return ID_AC;
-		case FILTER_ID_AR:
-			return ID_AR;
-		case FILTER_ID_BR:
-			return ID_BR;
-		case FILTER_ID_CA:
-			return ID_CA;
-		case FILTER_ID_CU:
-			return ID_CU;
-		case FILTER_ID_GD:
-			return ID_GD;
-		case FILTER_ID_GR:
-			return ID_GR;
-		case FILTER_ID_IM:
-			return ID_IM;
-		case FILTER_ID_LA:
-			return ID_LA;
-		case FILTER_ID_LS:
-			return ID_LS;
-		case FILTER_ID_LT:
-			return ID_LT;
-		case FILTER_ID_MA:
-			return ID_MA;
-		case FILTER_ID_MB:
-			return ID_MB;
-		case FILTER_ID_MC:
-			return ID_MC;
-		case FILTER_ID_ME:
-			return ID_ME;
-		case FILTER_ID_MSK:
-			return ID_MSK;
-		case FILTER_ID_NT:
-			return ID_NT;
-		case FILTER_ID_OB:
-			return ID_OB;
-		case FILTER_ID_PAL:
-			return ID_PAL;
-		case FILTER_ID_PC:
-			return ID_PC;
-		case FILTER_ID_SCE:
-			return ID_SCE;
-		case FILTER_ID_SPK:
-			return ID_SPK;
-		case FILTER_ID_SO:
-			return ID_SO;
-		case FILTER_ID_TE:
-			return ID_TE;
-		case FILTER_ID_TXT:
-			return ID_TXT;
-		case FILTER_ID_VF:
-			return ID_VF;
-		case FILTER_ID_WO:
-			return ID_WO;
+		CASE_IDFILTER(AC);
+		CASE_IDFILTER(AR);
+		CASE_IDFILTER(BR);
+		CASE_IDFILTER(CA);
+		CASE_IDFILTER(CU);
+		CASE_IDFILTER(GD);
+		CASE_IDFILTER(GR);
+		CASE_IDFILTER(IM);
+		CASE_IDFILTER(LA);
+		CASE_IDFILTER(LS);
+		CASE_IDFILTER(LT);
+		CASE_IDFILTER(MA);
+		CASE_IDFILTER(MB);
+		CASE_IDFILTER(MC);
+		CASE_IDFILTER(ME);
+		CASE_IDFILTER(MSK);
+		CASE_IDFILTER(NT);
+		CASE_IDFILTER(OB);
+		CASE_IDFILTER(PAL);
+		CASE_IDFILTER(PC);
+		CASE_IDFILTER(SCE);
+		CASE_IDFILTER(SPK);
+		CASE_IDFILTER(SO);
+		CASE_IDFILTER(TE);
+		CASE_IDFILTER(TXT);
+		CASE_IDFILTER(VF);
+		CASE_IDFILTER(WO);
 		default:
 			return 0;
 	}
+
+#undef CASE_IDFILTER
 }
 
 /**
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index b1df197..b2bfc6f 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -252,7 +252,11 @@ void BLI_filelist_entry_size_to_string(
 	 */
 	size = (double)(st ? st->st_size : sz);
 
-	if (size > 1024.0 * 1024.0 * 1024.0) {
+	if (size > 1024.0 * 1024.0 * 1024.0 * 1024.0) {
+		size /= (1024.0 * 1024.0 * 1024.0 * 1024.0);
+		fmt = compact ? "%.0f T" : "%.2f TiB";
+	}
+	else if (size > 1024.0 * 1024.0 * 1024.0) {
 		size /= (1024.0 * 1024.0 * 1024.0);
 		fmt = compact ? "%.0f G" : "%.2f GiB";
 	}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 5bcc7be..a5eac3e 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -603,8 +603,8 @@ static void write_previews(WriteData *wd, PreviewImage *prv)
 			prv->rect[1] = NULL;
 		}
 		writestruct(wd, DATA, "PreviewImage", 1, prv);
-		if (prv->rect[0]) writedata(wd, DATA, prv->w[0]*prv->h[0]*sizeof(unsigned int), prv->rect[0]);
-		if (prv->rect[1]) writedata(wd, DATA, prv->w[1]*prv->h[1]*sizeof(unsigned int), prv->rect[1]);
+		if (prv->rect[0]) writedata(wd, DATA, prv->w[0] * prv->h[0] * sizeof(unsigned int), prv->rect[0]);
+		if (prv->rect[1]) writedata(wd, DATA, prv->w[1] * prv->h[1] * sizeof(unsigned int), prv->rect[1]);
 
 		/* restore preview, we still want to keep it in memory even if not saved to file */
 		if (!(U.flag & USER_SAVE_PREVIEWS) ) {
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index e75a439..945ac1b 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -82,5 +82,6 @@ int UI_iconfile_get_index(const char *filename);
 struct PreviewImage *UI_icon_to_preview(int icon_id);
 
 int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, const bool big);
+int UI_idcode_icon_get(const int idcode);
 
 #endif /*  __UI_INTERFACE_ICONS_H__ */
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index bcb0b77..4116c0d 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1393,6 +1393,68 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big
 	return rnaicon;
 }
 
+int UI_idcode_icon_get(const int idcode)
+{
+	switch (idcode) {
+		case ID_AC:
+			return ICON_ANIM_DATA;
+		case ID_AR:
+			return ICON_ARMATURE_DATA;
+		case ID_BR:
+			return ICON_BRUSH_DATA;
+		case ID_CA:
+			return ICON_CAMERA_DATA;
+		case ID_CU:
+			return ICON_CURVE_DATA;
+		case ID_GD:
+			return ICON_GREASEPENCIL;
+		case ID_GR:
+			return ICON_GROUP;
+		case ID_IM:
+			return ICON_IMAGE_DATA;
+		case ID_LA:
+			return ICON_LAMP_DATA;
+		case ID_LS:
+			return ICON_LINE_DATA;
+		case ID_LT:
+			return ICON_LATTICE_DATA;
+		case ID_MA:
+			return ICON_MATERIAL_DATA;
+		case ID_MB:
+			return ICON_META_DATA;
+		case ID_MC:
+			return ICON_CLIP;
+		case ID_ME:
+			return ICON_MESH_DATA;
+		case ID_MSK:
+			return ICON_MOD_MASK;  /* TODO! this would need its own icon! */
+		case ID_NT:
+			return ICON_NODETREE;
+		case ID_OB:
+			return ICON_OBJECT_DATA;
+		case ID_PAL:
+			return ICON_COLOR;  /* TODO! this would need its own icon! */
+		case ID_PC:
+			return ICON_CURVE_BEZCURVE;  /* TODO! this would need its own icon! */
+		case ID_SCE:
+			return ICON_SCENE_DATA;
+		case ID_SPK:
+			return ICON_SPEAKER;
+		case ID_SO:
+			return ICON_SOUND;
+		case ID_TE:
+			return ICON_TEXTURE_DATA;
+		case ID_TXT:
+			return ICON_TEXT;
+		case ID_VF:
+			return ICON_FONT_DATA;
+		case ID_WO:
+			return ICON_WORLD_DATA;
+		default:
+			return ICON_NONE;
+	}
+}
+
 static void icon_draw_at_size(
         float x, float y, int icon_id, float aspect, float alpha,
         enum eIconSizes size, const bool nocreate)
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 7c2129a..170e870 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -261,6 +261,7 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon,
 	UI_but_func_tooltip_set(but, file_draw_tooltip_func, BLI_strdup(path));
 
 	if (drag) {
+		/* path is no more static, cannot give it directly to but... */
 		UI_but_drag_set_path(but, BLI_strdup(path), true);
 	}
 }
@@ -384,6 +385,7 @@ static void file_draw_preview(
 
 	/* dragregion */
 	if (drag) {
+		/* path is no more static, cannot give it directly to but... */
 		UI_but_drag_set_image(but, BLI_strdup(path), true, icon, imb, scale);
 	}
 
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 4c1f678..317a336 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -169,7 +169,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
 	SpaceFile *sfile = CTX_wm_space_file(C);
 	FileSelectParams *params = ED_fileselect_get_params(sfile);
 	int numfiles = filelist_numfiles(sfile->files);
-	FileDirEntry *file;
+	const FileDirEntry *file;
 
 	/* make the selected file active */
 	if ((selected_idx >= 0) &&
@@ -195,7 +195,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
 					BLI_parent_dir(params->dir);
 
 					if (params->recursion_level > 1) {
-						/* Disable 'dirtree' recursion when going up in tree! */
+						/* Disable 'dirtree' recursion when going up in tree. */
 						params->recursion_level = 1;
 						filelist_setrecursion(sfile->files, params->recursion_level);
 					}
@@ -276,7 +276,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent *
 
 			/* dont highlight readonly file (".." or ".") on border select */


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list