Mouse toggling pixel cells
This commit is contained in:
parent
eccc14a714
commit
2e05df8035
1 changed files with 7 additions and 9 deletions
|
|
@ -1,6 +1,5 @@
|
|||
pixelEditor = config \
|
||||
c = config;
|
||||
_ = debug! "pixEd config" c;
|
||||
|
||||
upArrow = state \ (
|
||||
newRow = max 0 (state.selectedRow - 1);
|
||||
|
|
@ -19,7 +18,6 @@ pixelEditor = config \
|
|||
{ state = state.{ selectedCol = newCol }, emit = [] });
|
||||
|
||||
toggleFocused = state \ (
|
||||
_ = debug! "Toggling" state;
|
||||
row = state.selectedRow;
|
||||
col = state.selectedCol;
|
||||
newMap = contains { x = col, y = row } state.map
|
||||
|
|
@ -37,13 +35,13 @@ pixelEditor = config \
|
|||
map = [], # loadMap from store
|
||||
pixelWidth = 5,
|
||||
pixelHeight = 7,
|
||||
zoomMultiplier = 5,
|
||||
cellSize = 30,
|
||||
selectedRow = 0,
|
||||
selectedCol = 0
|
||||
},
|
||||
|
||||
update = state event \ event
|
||||
# | Toggle pixel \ (\ toggleFocused)
|
||||
| ClickCell { x = x, y = y } \ toggleFocused state.{ selectedRow = y, selectedCol = x }
|
||||
| Key { key = " " } \ toggleFocused state
|
||||
| Key { key = "Enter" } \ toggleFocused state
|
||||
|
||||
|
|
@ -61,9 +59,6 @@ pixelEditor = config \
|
|||
view = state emit \
|
||||
# onToggle = path \ emit (Toggle path);
|
||||
|
||||
cellWidth = state.pixelWidth * state.zoomMultiplier;
|
||||
cellHeight = state.pixelHeight * state.zoomMultiplier;
|
||||
|
||||
grid = ui.column {
|
||||
children = map (rIdx \
|
||||
ui.row {
|
||||
|
|
@ -72,9 +67,12 @@ pixelEditor = config \
|
|||
color = (on |True\ "#000" |False\ "rgba(255,255,255,0.2)");
|
||||
|
||||
selected = and (rIdx == state.selectedRow) (cIdx == state.selectedCol);
|
||||
strokeColor = (selected | True \ "#f00" | False \ "transparent");
|
||||
strokeColor = (selected | True \ "#f00" | False \ "rgba(0,0,0,0.2)");
|
||||
|
||||
ui.rect { w = cellWidth, h = cellHeight, color = color, strokeWidth = 1, strokeColor = strokeColor }
|
||||
ui.clickable {
|
||||
onClick = \ _ = debug! "here" [rIdx, cIdx]; emit (ClickCell { x = cIdx, y = rIdx }),
|
||||
child = ui.rect { w = state.cellSize, h = state.cellSize, color = color, strokeWidth = 1, strokeColor = strokeColor }
|
||||
}
|
||||
) (range 0 state.pixelWidth)
|
||||
}
|
||||
) (range 0 state.pixelHeight)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue