Class: GamesAndRpgParadise::GUI::Gtk::ViewCard
- Inherits:
-
Gtk::Box
- Object
- Gtk::Box
- GamesAndRpgParadise::GUI::Gtk::ViewCard
show all
- Includes:
- Gtk::BaseModule
- Defined in:
- lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb
Overview
GamesAndRpgParadise::GUI::Gtk::ViewCard
Constant Summary
collapse
- NAMESPACE =
inspect
- TITLE =
'View card'
- WIDTH =
'35% or minimum 400px'
- HEIGHT =
'25% or minimum 300px'
- USE_THIS_FONT =
:dejavu_condensed_20
- USE_THIS_AS_BACKGROUND_COLOUR_FOR_THE_WIDGET =
:white
- DEFAULT_CARD =
::GamesAndRpgParadise::MagicTheGathering.log_directory?+
'aether_revolt/'\
'Aerial_Modification.png'
- HASH_DESIGNATED_KEY_COMBINATIONS =
#
HASH_DESIGNATED_KEY_COMBINATIONS
#
{
'alt+a': 'activate_about_menu',
'ctrl+a': 'activate_about_menu'
}
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(commandline_arguments = ARGV, run_already = true) ⇒ ViewCard
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 75
def initialize(
commandline_arguments = ARGV,
run_already = true
)
super(:vertical)
register_sigint
reset
set_commandline_arguments(
commandline_arguments
)
modify_background(
:normal,
USE_THIS_AS_BACKGROUND_COLOUR_FOR_THE_WIDGET
)
handle_events
run if run_already
end
|
Class Method Details
.run(i = ARGV, run_already = true) ⇒ Object
#
GamesAndRpgParadise::GUI::Gtk::ViewCard.run
This method can be used to instantiate a new ViewCard GUI widget. This widget will show a magic card (if available locally).
#
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 379
def self.run(
i = ARGV,
run_already = true
)
require 'gtk_paradise/run'
_ = ::GamesAndRpgParadise::GUI::Gtk::ViewCard.new(i, run_already)
r = ::Gtk.run { :add_a_new_accel_group }
r << _
_.enable_these_key_combinations(HASH_DESIGNATED_KEY_COMBINATIONS)
r.show_all
r.background_colour :white
r.automatic_size_then_automatic_title
r.add_shortcut(1, 'activate_about_menu', :strg)
r.top_left_then_run
end
|
Instance Method Details
369
370
371
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 369
def
e 'YO!'
end
|
#border_size? ⇒ Boolean
172
173
174
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 172
def border_size?
10
end
|
#connect_skeleton ⇒ Object
#
connect_skeleton (connect tag)
#
204
205
206
207
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 204
def connect_skeleton
abort_on_exception
add(@event_box) end
|
#create_skeleton ⇒ Object
#
create_skeleton (create tag)
#
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 186
def create_skeleton
try_to_create_the_pixbuf_image
@main_image = gtk_image(@pixbuf_image)
create_the_event_box
end
|
#create_the_event_box ⇒ Object
#
create_the_event_box
This method will handle the events.
#
278
279
280
281
282
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 278
def create_the_event_box
@event_box = gtk_event_box(@main_image)
@event_box.on_clicked { do_reveal_the_popover }
@event_box.show_all
end
|
#do_reveal_the_popover ⇒ Object
#
do_reveal_the_popover
This will currently only work on ruby-gtk3.
#
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 289
def do_reveal_the_popover
@popover = gtk_popover
vbox = gtk_vbox
= text("Path to the image file:\n")
.use_this_font = :dejavu_18
vbox.pack_start(
,
fill: false, expand: true, padding: 10
)
_ = text(path?, 5) _.use_this_font = :hack_14
_.make_selectable
_.deselect
vbox.minimal(_)
vbox.set_border_width(12)
@popover.add(vbox)
@popover.set_position(:bottom)
@popover.set_relative_to(@main_image)
@popover.show_all
@popover.
end
|
#handle_events ⇒ Object
267
268
269
270
271
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 267
def handle_events
on_button_press_event {
output_the_location_of_the_image
}
end
|
#location_to_the_image_file? ⇒ Boolean
Also known as:
path?
#
location_to_the_image_file?
#
212
213
214
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 212
def location_to_the_image_file?
@location_to_the_image_file
end
|
#main_image? ⇒ Boolean
260
261
262
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 260
def main_image?
@main_image
end
|
#output_the_location_of_the_image(i = @location_to_the_image_file) ⇒ Object
#
output_the_location_of_the_image
#
219
220
221
222
223
224
225
226
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 219
def output_the_location_of_the_image(
i = @location_to_the_image_file
)
e "#{Colours.rev}The path to the image is:"
e
e " #{Colours.sfile(i)}"
e
end
|
#padding? ⇒ Boolean
165
166
167
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 165
def padding?
12
end
|
#register_sigint ⇒ Object
179
180
181
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 179
def register_sigint
Signal.trap('SIGINT') { exit }
end
|
#reset ⇒ Object
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
139
140
141
142
143
144
145
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 96
def reset
reset_the_internal_variables
@configuration = [true, __dir__, NAMESPACE]
title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
use_gtk_paradise_project_css_file
infer_the_size_automatically
@location_to_the_image_file = DEFAULT_CARD
@pixbuf_image = nil
@width_of_a_regular_magic_card = 365
@height_of_a_regular_magic_card = 509
@scale_up_by_n_percent = 12
@scaling_mode_to_use = :bilinear add_more_CSS_rules_then_apply_them '
tooltip {
border: 3px solid darkblue;
padding: 12px;
}
'
end
|
#run ⇒ Object
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 317
def run
create_skeleton_then_connect_skeleton
@event_box.signal_connect(:event) {|widget, event|
original_pixbuf = main_image?.pixbuf
case name_of_this_event?(event)
when 'GDK_LEAVE_NOTIFY'
upscaled_image = original_pixbuf.scale(
@width_of_a_regular_magic_card,
@height_of_a_regular_magic_card,
@scaling_mode_to_use
)
@main_image.pixbuf = upscaled_image
when 'GDK_ENTER_NOTIFY'
new_width = (@width_of_a_regular_magic_card * (100 + percentage_upscaling?.to_f)) / 100.0
new_height = (@height_of_a_regular_magic_card * (100 + percentage_upscaling?.to_f)) / 100.0
new_width = 1400 if new_width > 2000
new_height = 1000 if new_height > 2000
upscaled_image = original_pixbuf.scale(
new_width,
new_height,
@scaling_mode_to_use
)
@main_image.pixbuf = upscaled_image
end
}
end
|
#scale_up_by_n_percent? ⇒ Boolean
Also known as:
percentage_upscaling?
#
scale_up_by_n_percent?
#
150
151
152
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 150
def scale_up_by_n_percent?
@scale_up_by_n_percent
end
|
#set_path(i = DEFAULT_CARD) ⇒ Object
#
set_path
This method can be used to assign to a new image for the widget that displays the card at hand.
#
250
251
252
253
254
255
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 250
def set_path(
i = DEFAULT_CARD
)
@location_to_the_image_file = i
@main_image.set_path(@location_to_the_image_file)
end
|
#set_scale_up_by_n_percent(i) ⇒ Object
#
set_scale_up_by_n_percent
#
157
158
159
160
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 157
def set_scale_up_by_n_percent(i)
i = i.to_i
@scale_up_by_n_percent = i
end
|
#try_to_create_the_pixbuf_image(i = @location_to_the_image_file) ⇒ Object
#
try_to_create_the_pixbuf_image
This method will create the pixbuf image.
#
233
234
235
236
237
238
239
240
241
242
|
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/view_card/view_card.rb', line 233
def try_to_create_the_pixbuf_image(
i = @location_to_the_image_file
)
if File.exist? i
@pixbuf_image = GdkPixbuf::Pixbuf.new(file: @location_to_the_image_file) end
end
|