[BrushGraph 4/7] Add Node UI core and simple fields#63
[BrushGraph 4/7] Add Node UI core and simple fields#63maxmmitchell wants to merge 15 commits intobrush-graph/3-viewmodelfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the UI layer for a node-based brush behavior editor, introducing specific field editors for various node types (BinaryOp, Constant, Damping, Integral, etc.) and the core visual components for nodes and ports. The feedback focuses on critical performance optimizations within the Jetpack Compose implementation, specifically regarding the use of remember to cache expensive operations like protobuf creation and the pre-calculation of values to avoid O(N^2) complexity during recomposition or high-frequency touch events. Additionally, there are suggestions to improve maintainability by replacing magic numbers with constants and removing unused state variables.
| ProtoBrushBehavior.Node.newBuilder() | ||
| .setToolTypeFilterNode( | ||
| ProtoBrushBehavior.ToolTypeFilterNode.newBuilder() | ||
| .setEnabledToolTypes(1 shl 3) // Stylus |
There was a problem hiding this comment.
I think this is OK, it's just for a default value and is in the proto, so very unlikely to change. We could always have a utility that treats the tooltypes as an enum and then handles the bitshifting under the hood when converting to proto, but maybe overkill. Regardless will be on a different PR since this file was moved to a follow-up PR.
7e7ae14 to
4b2402e
Compare
a4e196f to
e17146a
Compare
4b2402e to
6f34b89
Compare
e17146a to
cc0aecc
Compare
6f34b89 to
db4a7d4
Compare
cka-dev
left a comment
There was a problem hiding this comment.
Main feedback on this one is to make sure all UI composables have a modifier param,
| import kotlin.math.roundToInt | ||
|
|
||
| @Composable | ||
| fun BoxScope.NodePortDots( |
| import kotlin.math.roundToInt | ||
|
|
||
| @Composable | ||
| fun NodeWidget( |
| MaterialTheme.colorScheme.surfaceDim | ||
| } else if (isActiveSource || isPressed || isSelected || isInSelectedSet) { | ||
| MaterialTheme.colorScheme.primaryContainer | ||
| } else if (node.hasError) { |
There was a problem hiding this comment.
consider switching to when statement here.
| .border( | ||
| if (isActiveSource || isPressed || isSelected || isInSelectedSet) { | ||
| 2.dp | ||
| } else if (node.isDisabled) { |
cc0aecc to
8157b89
Compare
db4a7d4 to
3fc5d33
Compare
This PR adds the full Brush Designer screen accessible from Settings, including:
UI Components:
- BrushDesignerScreen with adaptive layout (compact/expanded)
- Three editor tabs: Tip Shape, Paint, and Behaviors
- NumericField with slider, ± buttons, and tap-to-edit dialog
- EditableListWidget for managing behaviors, nodes, and texture layers
- PreviewPane with live stroke rendering via DrawingSurface
- TipPreview for visual tip shape feedback
- MathCurvePreview for response curve visualization
- NodeEditors for Source, Damping, Target, ResponseCurve, BinaryOp, etc.
Features:
- Proto editing via BrushDesignerViewModel
- Import/Export .brush files (GZIP-compressed protobuf)
- Save to Palette (Room DB integration)
- Load from Brushes(both stock and custom brushes) or My Palette
- Standard and Advanced Dynamics presets
- Texture import with thumbnail preview
- Color picker for brush paint
3fc5d33 to
7fb1de6
Compare
8157b89 to
4f012bf
Compare
4f012bf to
4ebcb7e
Compare
Description
This is the fourth PR in the Brush Graph stack. It introduces the visual infrastructure for nodes on the canvas and the simpler field editors.
Details
NodeWidgetandPortDotNodeRegistrymaintains positons of nodes (useful for "Add node between functionality") and ports (necessary for splines snapping to ports and clean edge connection)DisplayTextat UI layer.Dependencies
brush-graph/3-viewmodel