Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.cc
| Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
| #include "GPU_state.h" | #include "GPU_state.h" | ||||
| #include "GPU_viewport.h" | #include "GPU_viewport.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "ED_gpencil.h" | #include "ED_gpencil.h" | ||||
| #include "ED_node.h" | #include "ED_node.h" | ||||
| #include "ED_screen.h" | |||||
| #include "ED_space_api.h" | #include "ED_space_api.h" | ||||
| #include "UI_interface.hh" | |||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "NOD_geometry_nodes_eval_log.hh" | #include "NOD_geometry_nodes_eval_log.hh" | ||||
| #include "NOD_node_declaration.hh" | #include "NOD_node_declaration.hh" | ||||
| ▲ Show 20 Lines • Show All 2,069 Lines • ▼ Show 20 Lines | if (node->flag & NODE_BACKGROUND) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); | bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); | ||||
| node_draw(C, region, snode, ntree, node, key); | node_draw(C, region, snode, ntree, node, key); | ||||
| } | } | ||||
| } | } | ||||
| /* Draw tree path info in lower left corner. */ | /* Draw the breadcrumb on the bottom of the editor. */ | ||||
| static void draw_tree_path(SpaceNode *snode) | static void draw_tree_path(const bContext &C, ARegion ®ion) | ||||
HooglyBoogly: Pass as a `Span`, which is just clearer about the intentions of this code. | |||||
Done Inline ActionsI know this is really small, but it's almost always best (or at least consistent) to use the imperative tense for comments like this, like it was before. i.e. Draw instead of Draws HooglyBoogly: I know this is really small, but it's almost always best (or at least consistent) to use the… | |||||
Done Inline ActionsSpan already implies that the data is const, so I don't think the extra const in front of Span is necessary. HooglyBoogly: `Span` already implies that the data is const, so I don't think the extra `const` in front of… | |||||
| { | { | ||||
| char info[256]; | using namespace blender; | ||||
| ED_node_tree_path_get_fixedbuf(snode, info, sizeof(info)); | GPU_matrix_push_projection(); | ||||
| wmOrtho2_region_pixelspace(®ion); | |||||
Done Inline ActionsIt seems unnecessarily complicated to set the rect's values here, but then only use them once later with changed values. It seems like the steps could be simplified here HooglyBoogly: It seems unnecessarily complicated to set the rect's values here, but then only use them once… | |||||
| UI_FontThemeColor(BLF_default(), TH_TEXT_HI); | const rcti *rect = ED_region_visible_rect(®ion); | ||||
| BLF_draw_default(1.5f * UI_UNIT_X, 1.5f * UI_UNIT_Y, 0.0f, info, sizeof(info)); | |||||
| const uiStyle *style = UI_style_get_dpi(); | |||||
| const float padding_x = 16 * UI_DPI_FAC; | |||||
| const int x = rect->xmin + padding_x; | |||||
| const int y = region.winy - UI_UNIT_Y * 0.6f; | |||||
| const int width = BLI_rcti_size_x(rect) - 2 * padding_x; | |||||
| uiBlock *block = UI_block_begin(&C, ®ion, __func__, UI_EMBOSS_NONE); | |||||
| uiLayout *layout = UI_block_layout( | |||||
| block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y, width, 1, 0, style); | |||||
| Vector<ui::ContextPathItem> context_path = ed::space_node::context_path_for_space_node(C); | |||||
| ui::template_breadcrumbs(*layout, context_path); | |||||
| UI_block_layout_resolve(block, nullptr, nullptr); | |||||
| UI_block_end(&C, block); | |||||
| UI_block_draw(&C, block); | |||||
| GPU_matrix_pop_projection(); | |||||
| } | } | ||||
Done Inline ActionsAs far as I know (and I quickly tested), these two lines aren't necessary. HooglyBoogly: As far as I know (and I quickly tested), these two lines aren't necessary. | |||||
| static void snode_setup_v2d(SpaceNode *snode, ARegion *region, const float center[2]) | static void snode_setup_v2d(SpaceNode *snode, ARegion *region, const float center[2]) | ||||
| { | { | ||||
| View2D *v2d = ®ion->v2d; | View2D *v2d = ®ion->v2d; | ||||
Done Inline Actionsfor (const int i : context_path.index_range()) { HooglyBoogly: `for (const int i : context_path.index_range()) {` | |||||
| /* Shift view to node tree center. */ | /* Shift view to node tree center. */ | ||||
Done Inline ActionsUse a reference to avoid a copy HooglyBoogly: Use a reference to avoid a copy | |||||
| UI_view2d_center_set(v2d, center[0], center[1]); | UI_view2d_center_set(v2d, center[0], center[1]); | ||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| /* Aspect + font, set each time. */ | /* Aspect + font, set each time. */ | ||||
| snode->runtime->aspect = BLI_rctf_size_x(&v2d->cur) / (float)region->winx; | snode->runtime->aspect = BLI_rctf_size_x(&v2d->cur) / (float)region->winx; | ||||
| // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); | // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | void node_draw_space(const bContext *C, ARegion *region) | ||||
| if (snode->treepath.last) { | if (snode->treepath.last) { | ||||
| if (snode->overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && snode->flag & SNODE_SHOW_GPENCIL) { | if (snode->overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && snode->flag & SNODE_SHOW_GPENCIL) { | ||||
| /* Draw grease-pencil (screen strokes, and also paint-buffer). */ | /* Draw grease-pencil (screen strokes, and also paint-buffer). */ | ||||
| ED_annotation_draw_view2d(C, false); | ED_annotation_draw_view2d(C, false); | ||||
| } | } | ||||
| } | } | ||||
| /* Tree path info. */ | /* Draw context path. */ | ||||
| draw_tree_path(snode); | if (snode->edittree) { | ||||
| draw_tree_path(*C, *region); | |||||
Done Inline ActionsNo need for blender:: prefix here HooglyBoogly: No need for `blender::` prefix here | |||||
| } | |||||
| /* Scrollers. */ | /* Scrollers. */ | ||||
| UI_view2d_scrollers_draw(v2d, nullptr); | UI_view2d_scrollers_draw(v2d, nullptr); | ||||
| } | } | ||||
Pass as a Span, which is just clearer about the intentions of this code.