node/lib/metasm/metasm/gui/dasm_graph.rb
# check if the user clicked on the beginning/end of an arrow, if so focus on the other end
check if the user clicked on the beginning/end of an arrow, if so focus on the other end
check if the user clicked on the beginning / end of an arrow if so focus on the other end
def doubleclick_check_arrow(x, y)
		return if @margin*@zoom < 2
		x = view_x+x/@zoom
		y = view_y+y/@zoom
		sx = nil
		if bt = @shown_boxes.to_a.reverse.find { |b|
			y >= b.y+b.h-1 and y <= b.y+b.h-1+@margin+2 and
			sx = b.x+b.w/2 - b.to.length/2 * @margin/2 and
			x >= sx-@margin/2 and x <= sx+b.to.length*@margin/2	
		}
			idx = (x-sx+@margin/4).to_i / (@margin/2)
			idx = 0 if idx < 0
			idx = bt.to.length-1 if idx >= bt.to.length
			if bt.to[idx]
				if @parent_widget
					@caret_box, @caret_y = bt, bt[:line_address].length-1
					@parent_widget.focus_addr bt.to[idx][:line_address][0]
				else
					focus_xy(bt.to[idx].x, bt.to[idx].y)
				end
			end
			true
		elsif bf = @shown_boxes.to_a.reverse.find { |b|
			y >= b.y-@margin-2 and y <= b.y and
			sx = b.x+b.w/2 - b.from.length/2 * @margin/2 and
			x >= sx-@margin/2 and x <= sx+b.from.length*@margin/2
		}
			idx = (x-sx+@margin/4).to_i / (@margin/2)
			idx = 0 if idx < 0
			idx = bf.from.length-1 if idx >= bf.from.length
			if bf.from[idx]
				if @parent_widget
					@caret_box, @caret_y = bf, bf[:line_address].length-1
					@parent_widget.focus_addr bf.from[idx][:line_address][-1]
				else
					focus_xy(bt.from[idx].x, bt.from[idx].y)
				end
			end
			true
		end
	end
def doubleclick_check_arrow ( x , y ) return if @margin * @zoom < 2 x = view_x + x / @zoom y = view_y + y / @zoom sx = nil if bt = @shown_boxes . to_a . reverse . find { | b | y >= b . y + b . h - 1 and y <= b . y + b . h - 1 + @margin + 2 and sx = b . x + b . w / 2 - b . to . length / 2 * @margin / 2 and x >= sx - @margin / 2 and x <= sx + b . to . length * @margin / 2 } idx = ( x - sx + @margin / 4 ) . to_i / ( @margin / 2 ) idx = 0 if idx < 0 idx = bt . to . length - 1 if idx >= bt . to . length if bt . to [ idx ] if @parent_widget @caret_box , @caret_y = bt , bt [ :line_address ] . length - 1 @parent_widget . focus_addr bt . to [ idx ] [ :line_address ] [ 0 ] else focus_xy ( bt . to [ idx ] . x , bt . to [ idx ] . y ) end end true elsif bf = @shown_boxes . to_a . reverse . find { | b | y >= b . y - @margin - 2 and y <= b . y and sx = b . x + b . w / 2 - b . from . length / 2 * @margin / 2 and x >= sx - @margin / 2 and x <= sx + b . from . length * @margin / 2 } idx = ( x - sx + @margin / 4 ) . to_i / ( @margin / 2 ) idx = 0 if idx < 0 idx = bf . from . length - 1 if idx >= bf . from . length if bf . from [ idx ] if @parent_widget @caret_box , @caret_y = bf , bf [ :line_address ] . length - 1 @parent_widget . focus_addr bf . from [ idx ] [ :line_address ] [ - 1 ] else focus_xy ( bt . from [ idx ] . x , bt . from [ idx ] . y ) end end true end end
check if the user clicked on the beginning/end of an arrow, if so focus on the other end
check if the user clicked on the beginning / end of an arrow if so focus on the other end
# should be margin/4, but add a little comfort margin
x
y