Class: AsciiParadise::GUI::UniversalWidgets::AnimatedFrame

Inherits:
Base
  • Object
show all
Includes:
UniversalWidgets::BaseModule
Defined in:
lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb

Overview

AsciiParadise::GUI::UniversalWidgets::AnimatedFrame

Constant Summary collapse

TITLE =
#

TITLE

#
'Animated ASCII components'
DEFAULT_TITLE_FOR_THE_START_BUTTON =
#

DEFAULT_TITLE_FOR_THE_START_BUTTON

#
'⬅️ Run this ascii component'
WIDTH =
#

WIDTH

#
'60% or minimum 1280px'
HEIGHT =
#

HEIGHT

#
'30% or minimum 880px'
USE_THIS_FONT =
#

USE_THIS_FONT

#
'Mono 20'
LARGER_FONT =
#

LARGER_FONT

#
:hack_25
SMALLER_FONT =
#

SMALLER_FONT

#
:hack_20
DEFAULT_RUN_N_TIMES =
#

DEFAULT_RUN_N_TIMES

How many times to run the animation fully. I keep this set to 1 so that the default state means to iterate over the dataset only once, and then stop. The user can change this via a gtk-entry setpoint.

#
5
FONT_SIZE =
#

FONT_SIZE

#
'19'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

animation_dir?, #animation_directory?, #clear_screen, #colour_parse_this_string, #debug?, #do_not_run_already, #do_not_use_clear, #do_use_random_colour, #do_wait_for_keypress_event, e, #e, #enable_debug, #is_animated?, #menu, #project_base_dir?, #register_sigint, #remove_trailing_ansci_escape_code, #report_how_many_animated_components_exist, #return_basename_of_this_file_without_the_extension, #return_random_colour, #rev, #royalblue, #set_use_this_colour, #sfancy, #sfile, #show_available_components, #show_help, #simp, #slategrey, #sort_files, #static_dir?, #steelblue, #swarn, #use_colours?

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ AnimatedFrame

#

initialize

#


83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 83

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  super(:vertical) if use_gtk3?
  determine_the_GUI_to_be_used(commandline_arguments) # This must come first, even before reset().
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  on_delete_event_quit_the_application
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

AsciiParadise::GUI::UniversalWidgets::AnimatedFrame[]

#


322
323
324
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 322

def self.[](i = ARGV)
  new(i)
end

.run(i = ARGV) ⇒ Object

#

AsciiParadise::GUI::Gtk::AnimatedFrame.run

#


305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 305

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::AsciiParadise::GUI::Gtk::AnimatedFrame.new(i)
  r = ::Gtk.run
  _.set_parent_widget(r) # Must come before we enable the key-combinations.
  r << _
  r.automatic_size_then_automatic_title
  r.enable_quick_exit
  r.set_background :white
  r.top_left_then_run
end

Instance Method Details

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


197
198
199
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 197

def border_size?
  10
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag)

#


231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 231

def connect_the_skeleton
  abort_on_exception

  outer_vbox = create_vbox

  label_on_top = bold_label('Showing the individual frames')
  outer_vbox.minimal(label_on_top, 0)
  @text_buffer = create_text_buffer
  @text_view = create_text_view(@text_buffer)
  @text_view.set_editable(true)
  @text_view.cursor_visible = false

  @scrolled_window = create_scrolled_window(@text_view)
  if @scrolled_window.respond_to? :min_content_height
    @scrolled_window.min_content_height = 500
  end
  @scrolled_window.show_scrollbars

  outer_vbox.maximal(@scrolled_window, 2)
  create_the_combo_box_entry
  populate_the_combo_box
  @combo_box_entry.active = 0
  @combo_box_entry.on_changed {
    if @combo_box_entry.active_iter
      active_text = @combo_box_entry.active_text
      @array_dataset = AsciiParadise.dataset_for(
        active_text,
        :do_not_uppercase
      )
      # =================================================================== #
      # We will display the first element of the Array.
      # =================================================================== #
      if @array_dataset.respond_to? :first
        set_text(@array_dataset.first)
      end
    end
  }
  outer_vbox.maximal(@combo_box_entry, 0)

  window = create_window_or_runner
  window << outer_vbox

  properly_prepare_this_window(window,
    {
      title:       title?,
      font:        font?,
      width:       width?,
      height:      height?,
      padding:     padding?,
      border_size: border_size?
    }
  )
  window.show_all
  window.top_left
  do_all_startup_related_actions
  run_main
end

#create_the_combo_box_entryObject

#

create_the_combo_box_entry

#


214
215
216
217
218
219
220
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 214

def create_the_combo_box_entry
  # ======================================================================= #
  # Add the combobox next.
  # ======================================================================= #
  @combo_box_entry = create_combo_box_text
  @combo_box_entry.css_class('combo_box1')
end

#create_the_skeletonObject

#

create_the_skeleton (create tag, skeleton tag)

#


292
293
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 292

def create_the_skeleton
end
#
#


225
226
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 225

def do_all_startup_related_actions
end

#favicon?Boolean

#

favicon?

#

Returns:

  • (Boolean)


131
132
133
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 131

def favicon?
  :tabble
end

#handle_CSS_rulesObject

#

handle_CSS_rules (CSS tag)

#


145
146
147
148
149
150
151
152
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 145

def handle_CSS_rules
  use_gtk_paradise_project_css_file
  append_project_css_file
  more_CSS_then_apply_it '


'
end

#minimum_height?Boolean

#

minimum_height?

#

Returns:

  • (Boolean)


183
184
185
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 183

def minimum_height?
  200
end

#minimum_width?Boolean

#

minimum_width?

#

Returns:

  • (Boolean)


190
191
192
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 190

def minimum_width?
  120
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


166
167
168
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 166

def padding?
  0
end

#populate_the_combo_boxObject

#

populate_the_combo_box

#


204
205
206
207
208
209
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 204

def populate_the_combo_box
  # Populate the combo-box.
  @available_components.each {|entry|
    @combo_box_entry.append_text(entry)
  }
end

#resetObject

#

reset (reset tag)

#


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
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 100

def reset
  super() if respond_to?(:super)
  reset_the_shared_module # This can come early.
  reset_the_base_module
  reset_the_internal_variables
  infer_the_namespace
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, namespace?]
  # ======================================================================= #
  # === Set the title, width, height and the font in use.
  # ======================================================================= #
  title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
  if use_gtk3?
    handle_CSS_rules
  end
  infer_the_size_automatically
  # ======================================================================= #
  # === @array_dataset
  # ======================================================================= #
  @array_dataset = [] # This variable will contain the whole Array.
  # ======================================================================= #
  # === @available_components
  # ======================================================================= #
  @available_components = ::AsciiParadise.available_components? - [:AnimatedProgressBar]
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.

#


160
161
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 160

def reset_the_shared_module
end

#runObject

#

run (run tag)

#


298
299
300
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 298

def run
  run_super
end

#set_text(i) ⇒ Object

#

set_text

This method can be used to set a new text for the main buffer.

#


176
177
178
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 176

def set_text(i)
  @text_view.buffer.set_text(i)
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


138
139
140
# File 'lib/ascii_paradise/gui/universal_widgets/animated_frame/animated_frame.rb', line 138

def smaller_font?
  SMALLER_FONT
end