Class: Wads::NodeWidget
Overview
A graphical representation of a node in a graph using a button-style, i.e a rectangular border with a text label. The choice to use this display class is dictated by the use_icons attribute of the current theme. Like images, the size of node widgets can be scaled.
Instance Attribute Summary collapse
-
#data_node ⇒ Object
Returns the value of attribute data_node.
Attributes inherited from Button
#action_code, #is_pressed, #label
Attributes inherited from Widget
#base_z, #children, #gui_theme, #height, #is_selected, #layout, #overlay_widget, #override_color, #text_input_fields, #visible, #width, #x, #y
Instance Method Summary collapse
- #get_text_widget ⇒ Object
-
#initialize(x, y, node, color = nil, initial_scale = 1, is_explorer = false) ⇒ NodeWidget
constructor
A new instance of NodeWidget.
- #is_background ⇒ Object
- #render ⇒ Object
- #set_scale(value, is_explorer = false) ⇒ Object
- #widget_z ⇒ Object
Methods inherited from Button
#handle_mouse_down, #handle_update, #set_action
Methods inherited from Widget
#add, #add_axis_lines, #add_button, #add_child, #add_delete_button, #add_document, #add_graph_display, #add_image, #add_multi_select_table, #add_overlay, #add_panel, #add_plot, #add_single_select_table, #add_table, #add_text, #border_color, #bottom_edge, #button_down, #button_up, #center_children, #center_x, #center_y, #clear_children, #contains_click, #debug, #disable_background, #disable_border, #draw, #draw_background, #draw_border, #enable_background, #enable_border, #error, #get_layout, #get_theme, #graphics_color, #handle_key_press, #handle_mouse_down, #handle_mouse_up, #handle_right_mouse, #handle_update, #info, #intercept_widget_event, #left_edge, #move_recursive_absolute, #move_recursive_delta, #overlaps_with, #relative_x, #relative_y, #relative_z_order, #remove_child, #remove_children, #remove_children_by_type, #right_edge, #selection_color, #set_absolute_position, #set_dimensions, #set_layout, #set_selected, #set_theme, #text_color, #top_edge, #unset_selected, #update, #uses_layout, #warn, #x_pixel_to_screen, #y_pixel_to_screen, #z_order
Constructor Details
#initialize(x, y, node, color = nil, initial_scale = 1, is_explorer = false) ⇒ NodeWidget
Returns a new instance of NodeWidget.
2827 2828 2829 2830 2831 2832 2833 2834 |
# File 'lib/wads/widgets.rb', line 2827 def initialize(x, y, node, color = nil, initial_scale = 1, is_explorer = false) super(x, y, node.name) @orig_width = @width @orig_height = @height @data_node = node @override_color = color set_scale(initial_scale, @is_explorer) end |
Instance Attribute Details
#data_node ⇒ Object
Returns the value of attribute data_node.
2825 2826 2827 |
# File 'lib/wads/widgets.rb', line 2825 def data_node @data_node end |
Instance Method Details
#get_text_widget ⇒ Object
2850 2851 2852 |
# File 'lib/wads/widgets.rb', line 2850 def nil end |
#is_background ⇒ Object
2836 2837 2838 |
# File 'lib/wads/widgets.rb', line 2836 def is_background @scale <= 1 and @is_explorer end |
#render ⇒ Object
2854 2855 2856 2857 2858 |
# File 'lib/wads/widgets.rb', line 2854 def render super draw_background(Z_ORDER_FOCAL_ELEMENTS) #draw_shadow(COLOR_GRAY) end |
#set_scale(value, is_explorer = false) ⇒ Object
2840 2841 2842 2843 2844 2845 2846 2847 2848 |
# File 'lib/wads/widgets.rb', line 2840 def set_scale(value, is_explorer = false) @scale = value @is_explorer = is_explorer if value < 1 value = 1 end @width = @orig_width * @scale.to_f debug("In regular node widget Setting scale of #{@label} to #{@scale}") end |
#widget_z ⇒ Object
2860 2861 2862 |
# File 'lib/wads/widgets.rb', line 2860 def Z_ORDER_TEXT end |