Top Level Namespace
- Includes:
- LibuiParadise::BaseModule
Defined Under Namespace
Modules: Fiddle, LibuiParadise Classes: FFTStream, FontExample
Constant Summary collapse
- UI =
LibUI
- VERSION =
'0.0.1'.freeze
- TITLE =
Michael Ende (1929-1995) The Neverending Story is a fantasy novel by German writer Michael Ende, The English version, translated by Ralph Manheim, was published in 1983.
'Michael Ende'
- MAIN_WINDOW =
Main Window
create_window('Try for automatic button press event after a delay', :default, HEIGHT, 1)
- HEIGHT =
#
HEIGHT
#
120
- X_OFF_LEFT =
20
- Y_OFF_TOP =
20
- X_OFF_RIGHT =
20
- Y_OFF_BOTTOM =
20
- POINT_RADIUS =
5
- BLUE =
#
BLUE
#
0x1E90FF
- WIDTH =
#
WIDTH
#
1000
- N_TIMES =
10
- REMOTE_URL =
#
'https://www.ghibli.jp/gallery/thumb-redturtle%03d.png'
- IMAGES =
#
IMAGES
#
[]
- FONT_FAMILY_TO_USE =
#
FONT_FAMILY_TO_USE
#
'Georgia'
- USE_THIS_FONT =
#
USE_THIS_FONT
#
'Hack'
Instance Method Summary collapse
-
#append_with_attribute(attr_str, what, attr1, attr2) ⇒ Object
# === append_with_attribute =========================================================================== #.
-
#callback_for_the_slider ⇒ Object
# === callback_for_the_slider =========================================================================== #.
-
#construct_graph(datapoints, width, height, should_extend) ⇒ Object
construct_graph.
- #do_call_this_method ⇒ Object
-
#draw_event(adp, attr_str, font_button, alignment) ⇒ Object
# === draw_event =========================================================================== #.
-
#graph_size(area_width, area_height) ⇒ Object
# === graph_size =========================================================================== #.
-
#make_attribute_string ⇒ Object
# === make_attribute_string =========================================================================== #.
-
#on_combobox_selected(area) ⇒ Object
# === on_combobox_selected =========================================================================== #.
-
#on_font_changed(area) ⇒ Object
# === on_font_changed =========================================================================== #.
- #point_locations(datapoints, width, height) ⇒ Object
-
#rbcallback(*args, &block) ⇒ Object
#.
-
#set_solid_brush(brush, color, alpha) ⇒ Object
set_solid_brush.
-
#the_button_was_clicked ⇒ Object
# === the_button_was_clicked =========================================================================== #.
Methods included from LibuiParadise::BaseModule
#abort_on_exception, #append_this_array_to_that_combobox, #area, #assumed_height?, #assumed_width?, #bold_button, #bold_label, #bold_text_left_aligned, #button, #chdir, #checkbox, #checked_checkbox, #close_properly, #colour_button, #colour_to_rgb, #combobox, #commandline_arguments?, #connect_skeleton, #copy, #copy_file, #create_directory, #create_grid, #create_skeleton_then_connect_skeleton, #create_table, #create_the_skeleton, #current_widget_pointer_type?, #delete_file, #do_quit, #editable_combobox, #entry, #error_msg, #esystem, #exit_from, #fancy_text, #font, #font_button, #free_table_model, #gtk3?, #hbox, #height?, #horizontal_separator, #image, #is_on_roebe?, #is_on_windows?, #label, #last_pointer?, #left_arrow?, #main_hash?, #main_then_quit, #menu, #message_box_error, #multiline_entry, #new_brush, #non_wrapping_multiline_entry, #parse_this_file_into_a_table, #password_entry, #quit_button, #radio_buttons, #register_this_fiddle_pointer_widget, #reset, #reset_the_internal_hash, #return_button_for_opening_a_local_file, #return_default_window, #return_pwd, #return_the_resolution_using_xrandr, #run, #run_main, #scrolling_area, #search_entry, #selected?, #set_commandline_arguments, #set_height, #set_main_window, #set_title, #set_width, #set_window, #sfancy, #sfile, #slider, #spinbox, #tab, #table, #text?, #text_layout, #title?, #title_width_height, #title_width_height_font, #try_to_parse_this_config_file, #try_to_use_this_font, #two_elements_hbox, #ui_draw_text_layout_params, #ui_font_descriptor, #ui_margined_main_window, #ui_msg_box, #ui_open_file, #ui_padded_grid, #ui_padded_hbox, #ui_padded_vbox, #ui_sync_connect, #ui_table_params_malloc, #ui_text_then_entry, #use_gtk3?, #use_gtk?, #use_libui?, #vbox, #vertical_separator, #width?, #window, #window?, #without_trailing_comment, #wrapper_new_progress_bar
Instance Method Details
#append_with_attribute(attr_str, what, attr1, attr2) ⇒ Object
#
append_with_attribute
#
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/libui_paradise/examples/simple/003_fancy_text_example.rb', line 38 def append_with_attribute( , use_this_text, attr1, attr2 # This is rarely needed. ) start_pos = LibUI.attributed_string_len() end_pos = start_pos + what.length LibUI.attributed_string_append_unattributed(, use_this_text) LibUI.attributed_string_set_attribute(, attr1, start_pos, end_pos) LibUI.attributed_string_set_attribute(, attr2, start_pos, end_pos) if attr2 end |
#callback_for_the_slider ⇒ Object
#
callback_for_the_slider
#
16 17 18 19 20 |
# File 'lib/libui_paradise/examples/complex/007_slider_example.rb', line 16 def proc { |pointer| puts "New Slider value: #{UI.(pointer)}" } end |
#construct_graph(datapoints, width, height, should_extend) ⇒ Object
construct_graph
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/libui_paradise/examples/simple/002_histogram_example.rb', line 63 def construct_graph(datapoints, width, height, should_extend) locations = point_locations(datapoints, width, height) path = LibUI.draw_new_path(0) # winding first_location = locations[0] # x and y UI.draw_path_new_figure(path, first_location[0], first_location[1]) locations.each { |loc| UI.draw_path_line_to(path, loc[0], loc[1]) } if should_extend LibUI.draw_path_line_to(path, width, height) LibUI.draw_path_line_to(path, 0, height) LibUI.draw_path_close_figure(path) end LibUI.draw_path_end(path) return path end |
#do_call_this_method ⇒ Object
7 8 9 |
# File 'lib/libui_paradise/experimental/dsl.rb', line 7 def do_call_this_method e 'Hello World!' end |
#draw_event(adp, attr_str, font_button, alignment) ⇒ Object
#
draw_event
#
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/libui_paradise/examples/simple/003_fancy_text_example.rb', line 157 def draw_event(adp, attr_str, , alignment) area_draw_params = UI::FFI::AreaDrawParams.new(adp) default_font = UI::FFI::FontDescriptor.malloc default_font.to_ptr.free = Fiddle::RUBY_FREE params = UI::FFI::DrawTextLayoutParams.malloc params.to_ptr.free = Fiddle::RUBY_FREE params.String = attr_str UI.(, default_font) params.DefaultFont = default_font params.Width = area_draw_params.AreaWidth params.Align = UI.combobox_selected(alignment) text_layout = UI.draw_new_text_layout(params) LibUI.draw_text(area_draw_params.Context, text_layout, 0, 0) LibUI.draw_free_text_layout(text_layout) LibUI.(default_font) end |
#graph_size(area_width, area_height) ⇒ Object
#
graph_size
#
39 40 41 42 43 |
# File 'lib/libui_paradise/examples/simple/002_histogram_example.rb', line 39 def graph_size(area_width, area_height) graph_width = area_width - X_OFF_LEFT - X_OFF_RIGHT graph_height = area_height - Y_OFF_TOP - Y_OFF_BOTTOM [graph_width, graph_height] end |
#make_attribute_string ⇒ Object
#
make_attribute_string
#
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/libui_paradise/examples/simple/003_fancy_text_example.rb', line 56 def make_attribute_string attr_str = LibUI.new_attributed_string( "Drawing strings with libui is done with the "\ "uiAttributedString and uiDrawTextLayout objects.\n" \ 'uiAttributedString lets you have a variety of attributes: ' ) attr1 = LibUI.new_family_attribute(USE_THIS_FONT) append_with_attribute(attr_str, 'font family', attr1, nil) LibUI.attributed_string_append_unattributed(attr_str, ', ') # ========================================================================= # # === Use a bigger font next # # The bigger font will be use for the String "font size". # ========================================================================= # bigger_font = UI.new_size_attribute(62) append_with_attribute(attr_str, 'font size', bigger_font, nil) LibUI.attributed_string_append_unattributed(attr_str, ', ') # Then append ','. # ========================================================================= # # === Make bold text next (bold tag) # ========================================================================= # attr1 = LibUI.new_weight_attribute(LibUI::TextWeightBold) append_with_attribute(attr_str, 'font weight', attr1, nil) LibUI.attributed_string_append_unattributed(attr_str, ', ') attr1 = LibUI.new_italic_attribute(LibUI::TextItalicItalic) append_with_attribute(attr_str, 'font italicness', attr1, nil) UI.attributed_string_append_unattributed(attr_str, ', ') attr1 = LibUI.new_stretch_attribute(LibUI::TextStretchCondensed) append_with_attribute(attr_str, 'font stretch', attr1, nil) UI.attributed_string_append_unattributed(attr_str, ', ') # ========================================================================= # # Influence the text-colour via RGB values. # ========================================================================= # attr1 = LibUI.new_color_attribute(0.75, 0.25, 0.5, 0.75) append_with_attribute(attr_str, 'text color', attr1, nil) UI.attributed_string_append_unattributed(attr_str, ', ') attr1 = LibUI.new_background_attribute(0.5, 0.5, 0.25, 0.5) append_with_attribute(attr_str, 'text background color', attr1, nil) UI.attributed_string_append_unattributed(attr_str, ', ') attr1 = UI.new_underline_attribute(LibUI::UnderlineSingle) append_with_attribute(attr_str, 'underline style', attr1, nil) UI.attributed_string_append_unattributed(attr_str, ', ') UI.attributed_string_append_unattributed(attr_str, 'and ') attr1 = LibUI.new_underline_attribute(LibUI::UnderlineDouble) attr2 = LibUI.new_underline_color_attribute(LibUI::UnderlineColorCustom, 1.0, 0.0, 0.5, 1.0) append_with_attribute(attr_str, 'underline color', attr1, attr2) UI.attributed_string_append_unattributed(attr_str, '. ') UI.attributed_string_append_unattributed(attr_str, 'Furthermore, there are attributes allowing for ') attr1 = LibUI.new_underline_attribute(LibUI::UnderlineSuggestion) attr2 = LibUI.new_underline_color_attribute(LibUI::UnderlineColorSpelling, 0, 0, 0, 0) append_with_attribute(attr_str, 'special underlines for indicating spelling errors', attr1, attr2) LibUI.attributed_string_append_unattributed(attr_str, ' (and other types of errors) ') LibUI.attributed_string_append_unattributed(attr_str, 'and control over OpenType features such as ligatures (for instance, ') otf = LibUI.new_open_type_features UI.open_type_features_add(otf, 'l', 'i', 'g', 'a', 0) attr1 = LibUI.new_features_attribute(otf) append_with_attribute(attr_str, 'afford', attr1, nil) UI.attributed_string_append_unattributed(attr_str, ' vs. ') UI.open_type_features_add(otf, 'l', 'i', 'g', 'a', 1) attr1 = LibUI.new_features_attribute(otf) append_with_attribute(attr_str, 'afford', attr1, nil) UI.free_open_type_features(otf) UI.attributed_string_append_unattributed(attr_str, ").\n") UI.attributed_string_append_unattributed(attr_str, 'Use the controls '\ 'opposite to the text '\ 'to control properties of the text.') attr_str # And return the String here. end |
#on_combobox_selected(area) ⇒ Object
#
on_combobox_selected
#
150 151 152 |
# File 'lib/libui_paradise/examples/simple/003_fancy_text_example.rb', line 150 def on_combobox_selected(i) UI.area_queue_redraw_all(i) end |
#on_font_changed(area) ⇒ Object
#
on_font_changed
#
143 144 145 |
# File 'lib/libui_paradise/examples/simple/003_fancy_text_example.rb', line 143 def on_font_changed(i) UI.area_queue_redraw_all(i) end |
#point_locations(datapoints, width, height) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/libui_paradise/examples/simple/002_histogram_example.rb', line 48 def point_locations(datapoints, width, height) xincr = width / 9.0 # 10 - 1 to make the last point be at the end = height / 100.0 data = [] datapoints.each_with_index do |dp, i| val = 100 - UI.spinbox_value(dp) data << [xincr * i, * val] i += 1 end data end |
#rbcallback(*args, &block) ⇒ Object
#
57 58 59 60 61 62 |
# File 'lib/libui_paradise/examples/complex/026_basic_table_image.rb', line 57 def rbcallback(*args, &block) args << [0] if args.size == 1 # Argument types are omitted block_caller = Fiddle::Closure::BlockCaller.new(*args, &block) @block_callers << block_caller block_caller end |
#set_solid_brush(brush, color, alpha) ⇒ Object
set_solid_brush
180 181 182 183 184 185 186 187 |
# File 'lib/libui_paradise/examples/simple/002_histogram_example.rb', line 180 def set_solid_brush(brush, color, alpha) brush.Type = 0 # solid brush.R = ((color >> 16) & 0xFF) / 255.0 brush.G = ((color >> 8) & 0xFF) / 255.0 brush.B = (color & 0xFF) / 255.0 brush.A = alpha brush end |
#the_button_was_clicked ⇒ Object
#
the_button_was_clicked
#
41 42 43 |
# File 'lib/libui_paradise/examples/complex/028_try_for_automatic_button_press_event_after_a_delay.rb', line 41 def LibUI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button!') end |