Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2013-09-05 17:03:03 +0400
committerTon Roosendaal <ton@blender.org>2013-09-05 17:03:03 +0400
commitdc8832ac92b3640f7dcb784086417da925c9e721 (patch)
tree439fc0393e8b2bbfefdb840e64264739df653297 /source/blender/makesrna/intern/rna_space.c
parent69b68ed867407538a9b231cabf3481cb1404b37f (diff)
Bugfix #35920
Adding a new node in Node Editor failed for "High DPI" (Only Mac retina now). - Py script for adding nodes was doing dpi magic, which it shouldn't. It has been replaced with a (temporary) API call to set the correct cursor location. (Thanks to Lukas T for helping here) - The SpaceNode->cursor[2] property now is *only* storing the coordinate in "adding new node space". Use of this has been removed from the code where possible, with as only exception the code to draw noodles while adding them. Special coder note: Nodes should respect the DPI value, and draw larger with larger buttons if you increase this size. The hack here is that this can only work nice if also the node positions are scaled accordingly. A better fix could be to check on scaling the node view itself for it. That then would also remove this Python API call that was added in this commit. However, that again might fight with how buttons layout code works now... needs some careful checking.
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r--source/blender/makesrna/intern/rna_space.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 29e20c1025e..54012122617 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -172,6 +172,7 @@ static EnumPropertyItem buttons_texture_context_items[] = {
#include "DNA_mask_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
#include "BLI_math.h"
@@ -197,6 +198,9 @@ static EnumPropertyItem buttons_texture_context_items[] = {
#include "IMB_imbuf_types.h"
+#include "UI_interface.h"
+#include "UI_view2d.h"
+
static StructRNA *rna_Space_refine(struct PointerRNA *ptr)
{
SpaceLink *space = (SpaceLink *)ptr->data;
@@ -1263,6 +1267,15 @@ static void rna_SpaceNodeEditor_show_backdrop_update(Main *UNUSED(bmain), Scene
WM_main_add_notifier(NC_SCENE | ND_NODES, NULL);
}
+static void rna_SpaceNodeEditor_cursor_location_from_region(SpaceNode *snode, bContext *C, int x, int y)
+{
+ ARegion *ar = CTX_wm_region(C);
+
+ UI_view2d_region_to_view(&ar->v2d, x, y, &snode->cursor[0], &snode->cursor[1]);
+ snode->cursor[0] /= UI_DPI_FAC;
+ snode->cursor[1] /= UI_DPI_FAC;
+}
+
static void rna_SpaceClipEditor_clip_set(PointerRNA *ptr, PointerRNA value)
{
SpaceClip *sc = (SpaceClip *)(ptr->data);
@@ -3301,7 +3314,8 @@ static void rna_def_space_node_path_api(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_space_node(BlenderRNA *brna)
{
StructRNA *srna;
- PropertyRNA *prop;
+ PropertyRNA *prop, *parm;
+ FunctionRNA *func;
static EnumPropertyItem texture_type_items[] = {
{SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object"},
@@ -3442,6 +3456,14 @@ static void rna_def_space_node(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "cursor");
RNA_def_property_ui_text(prop, "Cursor Location", "Location for adding new nodes");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
+
+ func = RNA_def_function(srna, "cursor_location_from_region", "rna_SpaceNodeEditor_cursor_location_from_region");
+ RNA_def_function_ui_description(func, "Set the cursor location using region coordinates");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "x", "Region x coordinate", -10000, 10000);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "y", "Region y coordinate", -10000, 10000);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
}
static void rna_def_space_logic(BlenderRNA *brna)