[Bf-blender-cvs] [c846fa132d3] greasepencil-object: Add new Scale parameter to template_greasepencil_color
Antonio Vazquez
noreply at git.blender.org
Sun Jul 15 16:23:09 CEST 2018
Commit: c846fa132d35fab8a4348a7ef10b9c0868b88a68
Author: Antonio Vazquez
Date: Sun Jul 15 14:12:38 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBc846fa132d35fab8a4348a7ef10b9c0868b88a68
Add new Scale parameter to template_greasepencil_color
Now it's possible to define the size of the previews.
===================================================================
M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_templates.c
M source/blender/makesrna/intern/rna_ui_api.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 991ffe31b93..355ef446573 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -991,6 +991,7 @@ class _defs_gpencil_paint:
ob = context.active_object
nrow = 3
ncol = 8
+ scale = 0.7
if ob and ob.mode == 'GPENCIL_PAINT':
brush = context.active_gpencil_brush
gp_settings = brush.gpencil_settings
@@ -1005,7 +1006,7 @@ class _defs_gpencil_paint:
row.prop(gp_settings, "gpencil_fill_simplyfy_level", text="Simplify")
row = layout.row()
- row.template_greasepencil_color(gp_settings, "material", rows=nrow, cols=ncol)
+ row.template_greasepencil_color(gp_settings, "material", rows=nrow, cols=ncol, scale=scale)
row = layout.row(align=True)
row.prop(gp_settings, "gpencil_fill_draw_mode", text="")
@@ -1020,7 +1021,7 @@ class _defs_gpencil_paint:
row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
row = layout.row(align=True)
- row.template_greasepencil_color(gp_settings, "material", rows=nrow, cols=ncol)
+ row.template_greasepencil_color(gp_settings, "material", rows=nrow, cols=ncol, scale=scale)
@staticmethod
def generate_from_brushes(context):
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 5eadc24e273..232ecaeb756 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1054,7 +1054,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct Pointe
uiLayout *uiTemplateGpencilModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
void uiTemplateGpencilColorPreview(
uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
- int rows, int cols, int filter);
+ int rows, int cols, float scale, int filter);
uiLayout *uiTemplateShaderFx(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 566ce833770..0a7c14e31c1 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -166,7 +166,8 @@ static uiBlock *template_common_search_menu(
const bContext *C, ARegion *region,
uiButSearchFunc search_func, void *search_arg,
uiButHandleFunc handle_func, void *active_item,
- const int preview_rows, const int preview_cols)
+ const int preview_rows, const int preview_cols,
+ float scale)
{
static char search[256];
wmWindow *win = CTX_wm_window(C);
@@ -181,8 +182,8 @@ static uiBlock *template_common_search_menu(
/* preview thumbnails */
if (preview_rows > 0 && preview_cols > 0) {
- const int w = 4 * U.widget_unit * preview_cols;
- const int h = 5 * U.widget_unit * preview_rows;
+ const int w = 4 * U.widget_unit * preview_cols * scale;
+ const int h = 5 * U.widget_unit * preview_rows * scale;
/* fake button, it holds space for search items */
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL);
@@ -241,6 +242,7 @@ typedef struct TemplateID {
short filter;
int prv_rows, prv_cols;
bool preview;
+ float scale;
} TemplateID;
/* Search browse menu, assign */
@@ -386,7 +388,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
return template_common_search_menu(
C, ar, id_search_cb_p, &template_ui, template_ID_set_property_cb, active_item_ptr.data,
- template_ui.prv_rows, template_ui.prv_cols);
+ template_ui.prv_rows, template_ui.prv_cols, template_ui.scale);
}
/************************ ID Template ***************************/
@@ -634,7 +636,7 @@ static uiBut *template_id_def_new_but(
static void template_ID(
bContext *C, uiLayout *layout, TemplateID *template_ui, StructRNA *type, int flag,
- const char *newop, const char *openop, const char *unlinkop)
+ const char *newop, const char *openop, const char *unlinkop, float scale)
{
uiBut *but;
uiBlock *block;
@@ -864,7 +866,8 @@ static void ui_template_id(
uiLayout *layout, bContext *C,
PointerRNA *ptr, const char *propname,
const char *newop, const char *openop, const char *unlinkop,
- int flag, int prv_rows, int prv_cols, int filter, bool use_tabs)
+ int flag, int prv_rows, int prv_cols, int filter, bool use_tabs,
+ float scale)
{
TemplateID *template_ui;
PropertyRNA *prop;
@@ -883,6 +886,7 @@ static void ui_template_id(
template_ui->prop = prop;
template_ui->prv_rows = prv_rows;
template_ui->prv_cols = prv_cols;
+ template_ui->scale = scale;
if ((flag & UI_ID_PIN) == 0) {
template_ui->filter = filter;
@@ -911,7 +915,7 @@ static void ui_template_id(
}
else {
uiLayoutRow(layout, true);
- template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop);
+ template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop, scale);
}
}
@@ -926,7 +930,7 @@ void uiTemplateID(
layout, C, ptr, propname,
newop, openop, unlinkop,
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
- 0, 0, filter, false);
+ 0, 0, filter, false, 1.0f);
}
void uiTemplateIDBrowse(
@@ -937,7 +941,7 @@ void uiTemplateIDBrowse(
layout, C, ptr, propname,
newop, openop, unlinkop,
UI_ID_BROWSE | UI_ID_RENAME,
- 0, 0, filter, false);
+ 0, 0, filter, false, 1.0f);
}
void uiTemplateIDPreview(
@@ -948,18 +952,18 @@ void uiTemplateIDPreview(
layout, C, ptr, propname,
newop, openop, unlinkop,
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS,
- rows, cols, filter, false);
+ rows, cols, filter, false, 1.0f);
}
void uiTemplateGpencilColorPreview(
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname,
- int rows, int cols, int filter)
+ int rows, int cols, float scale, int filter)
{
ui_template_id(
layout, C, ptr, propname,
NULL, NULL, NULL,
UI_ID_BROWSE | UI_ID_PREVIEWS,
- rows, cols, filter, false);
+ rows, cols, filter, false, scale < 0.5f ? 0.5f : scale);
}
/**
@@ -975,7 +979,7 @@ void uiTemplateIDTabs(
layout, C, ptr, propname,
newop, openop, unlinkop,
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
- 0, 0, filter, true);
+ 0, 0, filter, true, 1.0f);
}
/************************ ID Chooser Template ***************************/
@@ -1072,7 +1076,7 @@ static uiBlock *template_search_menu(bContext *C, ARegion *region, void *arg_tem
return template_common_search_menu(
C, region, ui_rna_collection_search_cb, &template_search,
template_search_handle_cb, active_ptr.data,
- template_search.preview_rows, template_search.preview_cols);
+ template_search.preview_rows, template_search.preview_cols, 1.0f);
}
static void template_search_add_button_searchmenu(
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index a51962199c8..345a2aa72a4 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -852,6 +852,7 @@ void RNA_api_ui_layout(StructRNA *srna)
api_ui_item_rna_common(func);
RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX);
+ RNA_def_float(func, "scale", 1.0f, 0.5f, 1.5f, "Scale of the image thumbnails", "", 0, INT_MAX);
RNA_def_enum(func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL,
"", "Optionally limit the items which can be selected");
More information about the Bf-blender-cvs
mailing list