correct commit f3abc2cbf2
[?]
Jun 18, 2022, 5:52 AM
LYN3L74WRXZI4KNNIMNLPRFQ36RAGPWNE2O5AMB42H3CSTI6QM6QCDependencies
- [2]
B4YZWV6Sbugfix: checking if a point is on a manhattan line - [3]
KAUD3YIKtests: deleting points/shapes - [4]
AVFRVNFRbetter handle moving points - [5]
WTDKUACNrectangle and square shapes - [6]
6UZ2JNZEyet another key conflict - [7]
6LIPEQ5Imore robust transitions to temporary modes - [8]
JAXPXLEBset current_drawing_index with current_drawing - [9]
JFFUF5ALoverride mouse state lookups in tests - [10]
DRFE3B3Zmouse buttons are integers, not strings - [11]
LAW2O3NWextract variable Margin_left - [12]
YCDYGEZUinclude drawing index in a few places - [13]
VHQCNMARseveral more modules - [14]
RT6EV6OPdelegate update events to drawings - [15]
7SFHSB47rename - [16]
PX7DDEMOautosave slightly less aggressively - [17]
L6XA5EY2test: moving a point - [18]
XNFTJHC4split keyboard handling between Text and Drawing - [19]
Y4VYNEGFtest: autosave after name/move/delete of point - [*]
K2X6G75Zstart writing some tests for drawings - [*]
BLWAYPKVextract a module - [*]
6DE7RBZ6move mouse_released events to Drawing
Change contents
- edit in geom.lua at line 25
elseassert(false) - edit in drawing_tests.lua at line 424
check_nil(p2.name, 'F - test_move_point/baseline/p2:name') - edit in drawing_tests.lua at line 460
function test_move_point_on_manhattan_line()io.write('\ntest_move_point_on_manhattan_line')-- create a drawing with a manhattan lineFilename = 'foo'App.screen.init{width=Margin_left+300, height=300}Lines = load_array{'```lines', '```', ''}Line_width = 256 -- drawing coordinates 1:1 with pixelsCurrent_drawing_mode = 'manhattan'App.draw()App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+46, 1)local drawing = Lines[1]check_eq(#drawing.shapes, 1, 'F - test_move_point_on_manhattan_line/baseline/#shapes')check_eq(#drawing.points, 2, 'F - test_move_point_on_manhattan_line/baseline/#points')check_eq(drawing.shapes[1].mode, 'manhattan', 'F - test_move_point_on_manhattan_line/baseline/shape:1')App.draw()-- enter 'move' modeApp.run_after_keychord('C-u')check_eq(Current_drawing_mode, 'move', 'F - test_move_point_on_manhattan_line/mode:1')-- move pointApp.mouse_move(Margin_left+26, Margin_top+Drawing_padding_top+44)App.update(0.05)-- line is no longer manhattancheck_eq(drawing.shapes[1].mode, 'line', 'F - test_move_point_on_manhattan_line/baseline/shape:1')end - edit in drawing.lua at line 246
Drawing.relax_constraints(drawing, drawing.pending.target_point_index) - edit in drawing.lua at line 252
if drawing.mode == 'manhattan' thendrawing.mode = 'line'elseif drawing.mode == 'rectangle' or drawing.mode == 'square' thendrawing.mode = 'polygon'end - edit in drawing.lua at line 254
Drawing.relax_constraints(drawing, drawing.pending.target_point_index) - edit in drawing.lua at line 261[5.1052][23.54]
function Drawing.relax_constraints(drawing, p)for _,shape in ipairs(drawing.shapes) doif shape.mode == 'manhattan' thenif shape.p1 == p thenshape.mode = 'line'elseif shape.p2 == p thenshape.mode = 'line'endelseif shape.mode == 'rectangle' or shape.mode == 'square' thenfor _,v in ipairs(shape.vertices) doif v == p thenshape.mode = 'polygon'endendendendend - replacement in drawing.lua at line 492
local drawing_index,drawing,_,p = Drawing.select_point_at_mouse()local drawing_index,drawing,i,p = Drawing.select_point_at_mouse() - replacement in drawing.lua at line 498
drawing.pending = {mode=Current_drawing_mode, target_point=p}drawing.pending = {mode=Current_drawing_mode, target_point=p, target_point_index=i}