MCPcopy Index your code
hub / github.com/JacquesLucke/code_autocomplete / draw_function_info_box

Method draw_function_info_box

modal_handler.py:339–401  ·  view source on GitHub ↗
(self, position, function, scale)

Source from the content-addressed store, hash-verified

337 draw_rectangle_border(outer_rectangle, thickness = 1, color = self.info_border_color)
338
339 def draw_function_info_box(self, position, function, scale):
340 text_size = 100 * scale
341 padding = 8 * scale
342 box_height = 200 * scale
343 line_height = 25 * scale
344
345 owner_label = Label()
346 owner_label.text = function.owner + "." + function.name + "(" + ", ".join(function.get_input_names()) + ")"
347 owner_label.color = self.text_color
348 owner_label.text_size = text_size
349 owner_label.max_lines = 1
350 owner_label.font_id = 1
351 owner_dimensions = owner_label.get_draw_dimensions()
352
353 return_label = Label()
354 return_names = function.get_output_names()
355 if len(return_names) == 0: return_label.text = " > None"
356 else: return_label.text = " > " + ", ".join(return_names)
357 return_label.color = self.text_color
358 return_label.text_size = text_size
359 return_label.max_lines = 1
360 return_label.font_id = 1
361 return_dimensions = return_label.get_draw_dimensions()
362
363 box_width = max(350 * scale, owner_dimensions[0], return_dimensions[0])
364
365 description_label = Label()
366 description_label.text = function.description
367 description_label.color = self.text_color
368 description_label.text_size = text_size
369 description_label.max_lines = 15
370 description_label.font_id = 0
371 description_label.line_height = line_height
372 description_label.width = box_width
373 description_line_amount = len(description_label.get_draw_lines())
374 description_dimensions = description_label.get_draw_dimensions()
375
376 box_width += 2 * padding
377 box_height = owner_dimensions[1] + \
378 return_dimensions[1] + \
379 description_dimensions[1] + \
380 2 * line_height
381
382
383 outer_rectangle = Rectangle(position[0], position[1], box_width, box_height)
384 draw_rectangle(outer_rectangle, color = self.info_background_color)
385
386 owner_position = [
387 outer_rectangle.left + padding,
388 outer_rectangle.top - padding - line_height / 4 * 3 ]
389 owner_label.draw(owner_position)
390
391 return_position = [
392 owner_position[0],
393 owner_position[1] - line_height ]
394 return_label.draw(return_position)
395
396 description_position = [

Callers 1

Calls 9

get_draw_dimensionsMethod · 0.95
get_draw_linesMethod · 0.95
drawMethod · 0.95
LabelClass · 0.85
RectangleClass · 0.85
draw_rectangleFunction · 0.85
draw_rectangle_borderFunction · 0.85
get_output_namesMethod · 0.80
get_input_namesMethod · 0.45

Tested by

no test coverage detected