diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-02-22 14:46:27 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-02-22 14:46:27 +0400 |
commit | 6f0cbba0d31b6b9b104df9f63652b40c40583cb3 (patch) | |
tree | cf68a8b7c983d959c69affc92b47043a972805a6 /source/blender/blenkernel/intern/node.c | |
parent | ca689e88aac0e33bf0fd9701f5c6174b5ff5f3fd (diff) |
Simple preset function for setting common node sizes based on enum instead of explicit numbers.
Most nodes use the default size now and don't need explicit function calls. Most remaining nodes can also use the preset variant instead of explicit size values, these are only needed for a few special nodes.
Thanks to Sebastian König for suggesting this and doing the monkey work of changing node definitions.
Diffstat (limited to 'source/blender/blenkernel/intern/node.c')
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 97bee320ecb..86fe47268d6 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2028,9 +2028,8 @@ void node_type_base(bNodeTreeType *ttype, bNodeType *ntype, int type, const char ntype->update_internal_links = ttype->update_internal_links; /* default size values */ - ntype->width = 140; - ntype->minwidth = 100; - ntype->maxwidth = 320; + node_type_size_preset(ntype, NODE_SIZE_DEFAULT); + ntype->height = 100; ntype->minheight = 30; ntype->maxheight = FLT_MAX; @@ -2062,6 +2061,21 @@ void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwid ntype->maxwidth = maxwidth; } +void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size) +{ + switch (size) { + case NODE_SIZE_DEFAULT: + node_type_size(ntype, 140, 100, 320); + break; + case NODE_SIZE_SMALL: + node_type_size(ntype, 100, 80, 320); + break; + case NODE_SIZE_LARGE: + node_type_size(ntype, 140, 120, 500); + break; + } +} + void node_type_storage(bNodeType *ntype, const char *storagename, void (*freestoragefunc)(struct bNode *), void (*copystoragefunc)(struct bNode *, struct bNode *)) { if (storagename) |