UI: Drag and Drop Modifiers, Layout Updates
This patch implements the list panel system D7490 for modifiers. It also moves modifier drawing to a callback in ModifierTypeInfo in line with the extensible architecture refactoring goal T75724. This adds a PanelRegister callback and utilities for registering panels and subpanels. It also adds the callbacks for expansion saving and drag and drop reordering described in D7490. These utilities, callbacks, and other common UI elements shared between modifiers live in MOD_ui_common.c. Because modifier buttons are now in panels, we can make use of subpanels for organization. The UI layouts also use the single column layout style consistently used elsewhere in Blender. Additionally, the mode-setting buttons are aligned and ordered consistently with the outliner. However, the large number of UI changes in this patch may mean that additional polishing is required in master. Thanks to William Reynish (@billreynish) who did a fair amount of the layout work and to Julian Eisel (@Severin) for consistent help. Differential Revision: https://developer.blender.org/D7498
This commit is contained in:
@@ -30,9 +30,13 @@
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_effect.h"
|
||||
#include "BKE_lattice.h"
|
||||
#include "BKE_lib_query.h"
|
||||
@@ -40,11 +44,18 @@
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_pointcache.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "DEG_depsgraph_build.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "MOD_modifiertypes.h"
|
||||
#include "MOD_ui_common.h"
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
{
|
||||
@@ -546,6 +557,129 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *row;
|
||||
uiLayout *layout = panel->layout;
|
||||
int toggles_flag = UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE;
|
||||
|
||||
PointerRNA ptr;
|
||||
PointerRNA ob_ptr;
|
||||
modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
|
||||
|
||||
PointerRNA particle_obj_ptr = RNA_pointer_get(&ptr, "object");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
|
||||
if (!RNA_pointer_is_null(&particle_obj_ptr)) {
|
||||
uiItemPointerR(layout,
|
||||
&ptr,
|
||||
"particle_system",
|
||||
&particle_obj_ptr,
|
||||
"particle_systems",
|
||||
"Particle System",
|
||||
ICON_NONE);
|
||||
}
|
||||
else {
|
||||
uiItemR(layout, &ptr, "particle_system_index", 0, IFACE_("Particle System"), ICON_NONE);
|
||||
}
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
row = uiLayoutRowWithHeading(layout, true, IFACE_("Create Instances"));
|
||||
uiItemR(row, &ptr, "use_normal", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, &ptr, "use_children", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, &ptr, "use_size", toggles_flag, NULL, ICON_NONE);
|
||||
|
||||
row = uiLayoutRowWithHeading(layout, true, IFACE_("Show"));
|
||||
uiItemR(row, &ptr, "show_alive", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, &ptr, "show_dead", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, &ptr, "show_unborn", toggles_flag, NULL, ICON_NONE);
|
||||
|
||||
uiItemR(layout, &ptr, "particle_amount", 0, IFACE_("Amount"), ICON_NONE);
|
||||
uiItemR(layout, &ptr, "particle_offset", 0, IFACE_("Offset"), ICON_NONE);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
uiItemR(layout, &ptr, "space", 0, IFACE_("Coordinate Space"), ICON_NONE);
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemR(row, &ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void path_panel_draw_header(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiItemR(layout, &ptr, "use_path", 0, IFACE_("Create Along Paths"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void path_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
PointerRNA ob_ptr;
|
||||
modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiLayoutSetActive(layout, RNA_boolean_get(&ptr, "use_path"));
|
||||
|
||||
col = uiLayoutColumn(layout, true);
|
||||
uiItemR(col, &ptr, "position", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "random_position", UI_ITEM_R_SLIDER, IFACE_("Random"), ICON_NONE);
|
||||
col = uiLayoutColumn(layout, true);
|
||||
uiItemR(col, &ptr, "rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "random_rotation", UI_ITEM_R_SLIDER, IFACE_("Random"), ICON_NONE);
|
||||
|
||||
uiItemR(layout, &ptr, "use_preserve_shape", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void layers_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
PointerRNA ob_ptr;
|
||||
modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
|
||||
|
||||
PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemPointerR(layout,
|
||||
&ptr,
|
||||
"index_layer_name",
|
||||
&obj_data_ptr,
|
||||
"vertex_colors",
|
||||
IFACE_("Index"),
|
||||
ICON_NONE);
|
||||
uiItemPointerR(layout,
|
||||
&ptr,
|
||||
"value_layer_name",
|
||||
&obj_data_ptr,
|
||||
"vertex_colors",
|
||||
IFACE_("Value"),
|
||||
ICON_NONE);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = modifier_panel_register(
|
||||
region_type, eModifierType_ParticleInstance, panel_draw);
|
||||
modifier_subpanel_register(
|
||||
region_type, "paths", "", path_panel_draw_header, path_panel_draw, panel_type);
|
||||
modifier_subpanel_register(region_type, "layers", "Layers", NULL, layers_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_ParticleInstance = {
|
||||
/* name */ "ParticleInstance",
|
||||
/* structName */ "ParticleInstanceModifierData",
|
||||
@@ -576,4 +710,5 @@ ModifierTypeInfo modifierType_ParticleInstance = {
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user