[Bf-blender-cvs] [04e4852a990] filebrowser_redesign: Cleanup: Rename column types to be less ambiguous
Julian Eisel
noreply at git.blender.org
Wed Aug 28 01:42:28 CEST 2019
Commit: 04e4852a9903dedab1f10d5f5830c5d3f8dbd742
Author: Julian Eisel
Date: Wed Aug 28 01:35:45 2019 +0200
Branches: filebrowser_redesign
https://developer.blender.org/rB04e4852a9903dedab1f10d5f5830c5d3f8dbd742
Cleanup: Rename column types to be less ambiguous
===================================================================
M source/blender/editors/include/ED_fileselect.h
M source/blender/editors/space_file/file_draw.c
M source/blender/editors/space_file/file_intern.h
M source/blender/editors/space_file/file_ops.c
M source/blender/editors/space_file/filesel.c
===================================================================
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index 57e35a26121..dc42237d804 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -34,16 +34,16 @@ struct wmWindowManager;
#define FILE_LAYOUT_HOR 1
#define FILE_LAYOUT_VER 2
-typedef enum FileListColumns {
+typedef enum FileAttributeColumnType {
COLUMN_NONE = -1,
COLUMN_NAME = 0,
COLUMN_DATETIME,
COLUMN_SIZE,
- COLUMN_MAX
-} FileListColumns;
+ ATTRIBUTE_COLUMN_MAX
+} FileAttributeColumnType;
-typedef struct FileDetailsColumn {
+typedef struct FileAttributeColumn {
/** UI name for this column */
const char *name;
@@ -53,12 +53,13 @@ typedef struct FileDetailsColumn {
/* Alignment of column texts, header text is always left aligned */
int text_align; /* eFontStyle_Align */
-} FileDetailsColumn;
+} FileAttributeColumn;
typedef struct FileLayout {
/* view settings - XXX - move into own struct */
int offset_top;
- int columnheader_h;
+ /* Height of the header for the different FileAttributeColumn's. */
+ int attribute_column_header_h;
int prv_w;
int prv_h;
int tile_w;
@@ -68,13 +69,17 @@ typedef struct FileLayout {
int prv_border_x;
int prv_border_y;
int rows;
- int columns;
+ /* Those are the major layout columns the files are distributed across, not to be confused with
+ * 'attribute_columns' array below. */
+ int flow_columns;
int width;
int height;
int flag;
int dirty;
int textheight;
- FileDetailsColumn details_columns[COLUMN_MAX];
+ /* The columns for each item (name, modification date/time, size). Not to be confused with the
+ * 'flow_columns' above. */
+ FileAttributeColumn attribute_columns[ATTRIBUTE_COLUMN_MAX];
/* When we change display size, we may have to update static strings like size of files... */
short curr_size;
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index c61d0e1e248..0083fc244d8 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -460,8 +460,11 @@ static void draw_columnheader_background(const FileLayout *layout, const View2D
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShade(TH_BACK, 11);
- immRectf(
- pos, v2d->cur.xmin, v2d->cur.ymax - layout->columnheader_h, v2d->cur.xmax, v2d->cur.ymax);
+ immRectf(pos,
+ v2d->cur.xmin,
+ v2d->cur.ymax - layout->attribute_column_header_h,
+ v2d->cur.xmax,
+ v2d->cur.ymax);
immUnbindProgram();
}
@@ -471,31 +474,33 @@ static void draw_columnheader_columns(const FileSelectParams *params,
const View2D *v2d,
const uchar text_col[4])
{
- const float divider_pad = 0.2 * layout->columnheader_h;
+ const float divider_pad = 0.2 * layout->attribute_column_header_h;
int sx = v2d->cur.xmin, sy = v2d->cur.ymax;
- for (FileListColumns column_type = 0; column_type < COLUMN_MAX; column_type++) {
- if (!file_column_type_enabled(params, column_type)) {
+ for (FileAttributeColumnType column_type = 0; column_type < ATTRIBUTE_COLUMN_MAX;
+ column_type++) {
+ if (!file_attribute_column_type_enabled(params, column_type)) {
continue;
}
- const FileDetailsColumn *column = &layout->details_columns[column_type];
+ const FileAttributeColumn *column = &layout->attribute_columns[column_type];
/* Active sort type triangle */
if (params->sort == column->sort_type) {
float tri_color[4];
rgba_uchar_to_float(tri_color, text_col);
- UI_draw_icon_tri(sx + column->width - (0.3f * U.widget_unit) - DETAILS_COLUMN_PADDING / 2.0f,
- sy + (0.1f * U.widget_unit) - (layout->columnheader_h / 2),
+ UI_draw_icon_tri(sx + column->width - (0.3f * U.widget_unit) -
+ ATTRIBUTE_COLUMN_PADDING / 2.0f,
+ sy + (0.1f * U.widget_unit) - (layout->attribute_column_header_h / 2),
(params->flag & FILE_SORT_INVERT) ? 't' : 'v',
tri_color);
}
- file_draw_string(sx + DETAILS_COLUMN_PADDING,
+ file_draw_string(sx + ATTRIBUTE_COLUMN_PADDING,
sy - layout->tile_border_y,
IFACE_(column->name),
- column->width - 2 * DETAILS_COLUMN_PADDING,
- layout->columnheader_h - layout->tile_border_y,
+ column->width - 2 * ATTRIBUTE_COLUMN_PADDING,
+ layout->attribute_column_header_h - layout->tile_border_y,
UI_STYLE_TEXT_LEFT,
text_col);
@@ -508,7 +513,7 @@ static void draw_columnheader_columns(const FileSelectParams *params,
immUniformThemeColorShade(TH_BACK, -10);
immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, sx - 1, sy - divider_pad);
- immVertex2f(pos, sx - 1, sy - layout->columnheader_h + divider_pad);
+ immVertex2f(pos, sx - 1, sy - layout->attribute_column_header_h + divider_pad);
immEnd();
immUnbindProgram();
}
@@ -524,8 +529,8 @@ static void draw_columnheader_columns(const FileSelectParams *params,
immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, v2d->cur.xmin, sy);
immVertex2f(pos, v2d->cur.xmax, sy);
- immVertex2f(pos, v2d->cur.xmin, sy - layout->columnheader_h);
- immVertex2f(pos, v2d->cur.xmax, sy - layout->columnheader_h);
+ immVertex2f(pos, v2d->cur.xmin, sy - layout->attribute_column_header_h);
+ immVertex2f(pos, v2d->cur.xmax, sy - layout->attribute_column_header_h);
immEnd();
immUnbindProgram();
}
@@ -534,7 +539,7 @@ static void draw_columnheader_columns(const FileSelectParams *params,
/**
* Updates the stat string stored in file->entry if necessary.
*/
-static const char *filelist_get_details_column_string(FileListColumns column,
+static const char *filelist_get_details_column_string(FileAttributeColumnType column,
const FileDirEntry *file,
const bool small_size,
const bool update_stat_strings)
@@ -588,15 +593,16 @@ static void draw_details_columns(const FileSelectParams *params,
const bool update_stat_strings = small_size != SMALL_SIZE_CHECK(layout->curr_size);
int sx = pos_x - layout->tile_border_x - (UI_UNIT_X * 0.1f), sy = pos_y;
- for (FileListColumns column_type = 0; column_type < COLUMN_MAX; column_type++) {
- const FileDetailsColumn *column = &layout->details_columns[column_type];
+ for (FileAttributeColumnType column_type = 0; column_type < ATTRIBUTE_COLUMN_MAX;
+ column_type++) {
+ const FileAttributeColumn *column = &layout->attribute_columns[column_type];
/* Name column is not a detail column (should already be drawn), always skip here. */
if (column_type == COLUMN_NAME) {
sx += column->width;
continue;
}
- if (!file_column_type_enabled(params, column_type)) {
+ if (!file_attribute_column_type_enabled(params, column_type)) {
continue;
}
@@ -604,10 +610,10 @@ static void draw_details_columns(const FileSelectParams *params,
column_type, file, small_size, update_stat_strings);
if (str) {
- file_draw_string(sx + DETAILS_COLUMN_PADDING,
+ file_draw_string(sx + ATTRIBUTE_COLUMN_PADDING,
sy - layout->tile_border_y,
IFACE_(str),
- column->width - 2 * DETAILS_COLUMN_PADDING,
+ column->width - 2 * ATTRIBUTE_COLUMN_PADDING,
layout->tile_h,
column->text_align,
text_col);
@@ -660,14 +666,14 @@ void file_draw_list(const bContext *C, ARegion *ar)
numfiles_layout += layout->rows;
}
else {
- numfiles_layout += layout->columns;
+ numfiles_layout += layout->flow_columns;
}
filelist_file_cache_slidingwindow_set(files, numfiles_layout);
textwidth = (FILE_IMGDISPLAY == params->display) ?
layout->tile_w :
- round_fl_to_int(layout->details_columns[COLUMN_NAME].width);
+ round_fl_to_int(layout->attribute_columns[COLUMN_NAME].width);
textheight = (int)(layout->textheight * 3.0 / 2.0 + 0.5);
align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT;
@@ -776,7 +782,8 @@ void file_draw_list(const bContext *C, ARegion *ar)
uiBut *but;
const short width = (params->display == FILE_IMGDISPLAY) ?
textwidth :
- layout->details_columns[COLUMN_NAME].width - DETAILS_COLUMN_PADDING;
+ layout->attribute_columns[COLUMN_NAME].width -
+ ATTRIBUTE_COLUMN_PADDING;
but = uiDefBut(block,
UI_BTYPE_TEXT,
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index 688f5494534..61f13098783 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -44,7 +44,7 @@ struct ARegion *file_tool_props_region(struct ScrArea *sa);
#define IMASEL_BUTTONS_HEIGHT (UI_UNIT_Y * 2)
#define IMASEL_BUTTONS_MARGIN (UI_UNIT_Y / 6)
-#define DETAILS_COLUMN_PADDING (0.5f * UI_UNIT_X)
+#define ATTRIBUTE_COLUMN_PADDING (0.5f * UI_UNIT_X)
#define SMALL_SIZE_CHECK(_size) ((_size) < 64) /* Related to FileSelectParams.thumbnail_size. */
@@ -116,15 +116,16 @@ void file_operator_to_sfile(bContext *C, struct SpaceFile *sfile, struct wmOpera
/* filesel.c */
void fileselect_file_set(SpaceFile *sfile, const int index);
-bool file_column_type_enabled(const FileSelectParams *params, FileListColumns column);
-bool file_column_header_is_inside(const struct View2D *v2d,
- const FileLayout *layout,
- int x,
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list