kredki 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/kredki/core/application.rb +314 -0
- data/lib/kredki/core/color.rb +100 -0
- data/lib/kredki/core/event/block_event_reaction.rb +44 -0
- data/lib/kredki/core/event/composite_event_manager.rb +37 -0
- data/lib/kredki/core/event/event.rb +91 -0
- data/lib/kredki/core/event/event_manager.rb +60 -0
- data/lib/kredki/core/event/event_manager_jobs.rb +53 -0
- data/lib/kredki/core/event/event_reaction.rb +36 -0
- data/lib/kredki/core/event/family/drop_event.rb +40 -0
- data/lib/kredki/core/event/family/exit_event.rb +5 -0
- data/lib/kredki/core/event/family/focus_enter_event.rb +5 -0
- data/lib/kredki/core/event/family/focus_leave_event.rb +5 -0
- data/lib/kredki/core/event/family/hide_event.rb +5 -0
- data/lib/kredki/core/event/family/joystick_event.rb +102 -0
- data/lib/kredki/core/event/family/key_event.rb +40 -0
- data/lib/kredki/core/event/family/mouse_event.rb +190 -0
- data/lib/kredki/core/event/family/pastele_event.rb +11 -0
- data/lib/kredki/core/event/family/show_event.rb +5 -0
- data/lib/kredki/core/event/family/text_event.rb +23 -0
- data/lib/kredki/core/event/family/tick_event.rb +5 -0
- data/lib/kredki/core/event/family/update_complete_event.rb +5 -0
- data/lib/kredki/core/event/family/window_event.rb +108 -0
- data/lib/kredki/core/event/job_event_reaction.rb +44 -0
- data/lib/kredki/core/event/joystick_event_manager.rb +30 -0
- data/lib/kredki/core/event/keyboard_event_manager.rb +29 -0
- data/lib/kredki/core/event/method_event_reaction.rb +46 -0
- data/lib/kredki/core/event/mouse_event_manager.rb +27 -0
- data/lib/kredki/core/font.rb +53 -0
- data/lib/kredki/core/job/after_job.rb +59 -0
- data/lib/kredki/core/job/job.rb +108 -0
- data/lib/kredki/core/job/loop_job.rb +87 -0
- data/lib/kredki/core/job/play_animation_job.rb +44 -0
- data/lib/kredki/core/job/play_job.rb +41 -0
- data/lib/kredki/core/job/play_loop_animation_job.rb +98 -0
- data/lib/kredki/core/job/play_loop_job.rb +104 -0
- data/lib/kredki/core/job/side_job.rb +62 -0
- data/lib/kredki/core/kernel-path.rb +71 -0
- data/lib/kredki/core/kredki.rb +89 -0
- data/lib/kredki/core/linear_gradient.rb +43 -0
- data/lib/kredki/core/media/clipboard.rb +35 -0
- data/lib/kredki/core/media/joystick.rb +199 -0
- data/lib/kredki/core/media/keyboard.rb +84 -0
- data/lib/kredki/core/media/keyboard_modifiers_decoder.rb +154 -0
- data/lib/kredki/core/media/mouse.rb +197 -0
- data/lib/kredki/core/paint/animation.rb +247 -0
- data/lib/kredki/core/paint/area.rb +67 -0
- data/lib/kredki/core/paint/block_shape_area.rb +102 -0
- data/lib/kredki/core/paint/ellipse.rb +22 -0
- data/lib/kredki/core/paint/paint.rb +392 -0
- data/lib/kredki/core/paint/picture.rb +126 -0
- data/lib/kredki/core/paint/rectangle.rb +202 -0
- data/lib/kredki/core/paint/scene.rb +277 -0
- data/lib/kredki/core/paint/shape.rb +394 -0
- data/lib/kredki/core/paint/shape_area.rb +57 -0
- data/lib/kredki/core/paint/text.rb +222 -0
- data/lib/kredki/core/pastele/pastele-extern.rb +139 -0
- data/lib/kredki/core/pastele/pastele.rb +205 -0
- data/lib/kredki/core/radial_gradient.rb +45 -0
- data/lib/kredki/core/setup.rb +214 -0
- data/lib/kredki/core/window/pane.rb +178 -0
- data/lib/kredki/core/window/pane_event_manager.rb +44 -0
- data/lib/kredki/core/window/pane_events.rb +366 -0
- data/lib/kredki/core/window/window.rb +584 -0
- data/lib/kredki/core.rb +2 -0
- data/lib/kredki/hide.rb +9 -0
- data/lib/kredki/irb.rb +90 -0
- data/lib/kredki/module.rb +3 -0
- data/lib/kredki/pads/application.rb +13 -0
- data/lib/kredki/pads/button.rb +151 -0
- data/lib/kredki/pads/checkbox/checkbox.rb +68 -0
- data/lib/kredki/pads/checkbox/checkbox_button.rb +65 -0
- data/lib/kredki/pads/context/item.rb +65 -0
- data/lib/kredki/pads/context/item_group.rb +10 -0
- data/lib/kredki/pads/context/layer.rb +59 -0
- data/lib/kredki/pads/context/menu.rb +77 -0
- data/lib/kredki/pads/context/pad.rb +26 -0
- data/lib/kredki/pads/context/primary_layer.rb +51 -0
- data/lib/kredki/pads/context/secondary_layer.rb +60 -0
- data/lib/kredki/pads/item/item.rb +140 -0
- data/lib/kredki/pads/item/item_group.rb +44 -0
- data/lib/kredki/pads/item/item_x.rb +22 -0
- data/lib/kredki/pads/item/item_y.rb +31 -0
- data/lib/kredki/pads/label.rb +71 -0
- data/lib/kredki/pads/layer.rb +326 -0
- data/lib/kredki/pads/layout/align.rb +10 -0
- data/lib/kredki/pads/layout/layout.rb +88 -0
- data/lib/kredki/pads/layout/way.rb +99 -0
- data/lib/kredki/pads/layout/x_way.rb +119 -0
- data/lib/kredki/pads/layout/y_way.rb +120 -0
- data/lib/kredki/pads/list/item.rb +117 -0
- data/lib/kredki/pads/list/item_group.rb +36 -0
- data/lib/kredki/pads/list/pad.rb +74 -0
- data/lib/kredki/pads/list/tree/item.rb +138 -0
- data/lib/kredki/pads/list/tree/item_group.rb +86 -0
- data/lib/kredki/pads/list/tree/pad.rb +94 -0
- data/lib/kredki/pads/module.rb +11 -0
- data/lib/kredki/pads/note.rb +212 -0
- data/lib/kredki/pads/notes.rb +32 -0
- data/lib/kredki/pads/option/option.rb +121 -0
- data/lib/kredki/pads/option/option_item.rb +15 -0
- data/lib/kredki/pads/option/option_item_group.rb +16 -0
- data/lib/kredki/pads/option/option_layer.rb +81 -0
- data/lib/kredki/pads/pad/animation_pad.rb +106 -0
- data/lib/kredki/pads/pad/glyph_pad.rb +71 -0
- data/lib/kredki/pads/pad/pad.rb +1290 -0
- data/lib/kredki/pads/pad/pad_events.rb +358 -0
- data/lib/kredki/pads/pad/picture_pad.rb +89 -0
- data/lib/kredki/pads/pad/rectangle_pad.rb +181 -0
- data/lib/kredki/pads/pad/scroll_pad.rb +176 -0
- data/lib/kredki/pads/pad/shape_pad.rb +148 -0
- data/lib/kredki/pads/pad/space_pad.rb +33 -0
- data/lib/kredki/pads/pad/text_pad.rb +310 -0
- data/lib/kredki/pads/pane.rb +267 -0
- data/lib/kredki/pads/portal_layer.rb +94 -0
- data/lib/kredki/pads/radio/group.rb +45 -0
- data/lib/kredki/pads/radio/item.rb +69 -0
- data/lib/kredki/pads/radio/item_button.rb +143 -0
- data/lib/kredki/pads/service/event_queue.rb +79 -0
- data/lib/kredki/pads/service/service.rb +248 -0
- data/lib/kredki/pads/service/service_event_manager.rb +43 -0
- data/lib/kredki/pads/service/service_filter.rb +98 -0
- data/lib/kredki/pads/service/service_inherited.rb +48 -0
- data/lib/kredki/pads/setup.rb +36 -0
- data/lib/kredki/pads/slider/slider.rb +145 -0
- data/lib/kredki/pads/slider/slider_x.rb +41 -0
- data/lib/kredki/pads/slider/slider_y.rb +41 -0
- data/lib/kredki/pads/table/cell.rb +22 -0
- data/lib/kredki/pads/table/column.rb +63 -0
- data/lib/kredki/pads/table/column_layout.rb +88 -0
- data/lib/kredki/pads/table/pad.rb +116 -0
- data/lib/kredki/pads/table/row.rb +24 -0
- data/lib/kredki/pads/table/scroll_rows.rb +50 -0
- data/lib/kredki/pads/text/editable_text_verse.rb +77 -0
- data/lib/kredki/pads/text/editable_text_verses.rb +59 -0
- data/lib/kredki/pads/text/navigable_text_pad.rb +413 -0
- data/lib/kredki/pads/text/text_edition.rb +97 -0
- data/lib/kredki/pads/text/text_navigation.rb +109 -0
- data/lib/kredki/pads/toolbar/item.rb +62 -0
- data/lib/kredki/pads/toolbar/item_group.rb +22 -0
- data/lib/kredki/pads/toolbar/layer.rb +41 -0
- data/lib/kredki/pads/toolbar/pad.rb +51 -0
- data/lib/kredki/pads/toolbar/primary_layer.rb +64 -0
- data/lib/kredki/pads/window.rb +11 -0
- data/lib/kredki/script.rb +29 -0
- data/lib/kredki/setup.rb +2 -0
- data/lib/kredki/test.rb +35 -0
- data/lib/kredki.rb +10 -0
- data/lib/readme.md +31 -0
- data/stuff/config/config.rb +431 -0
- data/stuff/config/pads_config.rb +111 -0
- data/stuff/dll/SDL3.dll +0 -0
- data/stuff/dll/pastele.dll +0 -0
- data/stuff/dll/thorvg-1.dll +0 -0
- data/stuff/font/MartianMono-StdRg.ttf +0 -0
- data/stuff/font/MavenPro-Medium.ttf +0 -0
- data/stuff/font/MavenPro-Regular.ttf +0 -0
- data/stuff/glyph/alert-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/alert-triangle-svgrepo-com.svg +12 -0
- data/stuff/glyph/archivebox-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-2-ccw-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-2-cw-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-2-rectangle-path-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-4-way-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-ccw-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-circle-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-circle-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-circle-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-circle-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-cw-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-from-line-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-line-left-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-line-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-line-up-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-shape-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-shape-up-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-right-arrow-left-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-shape-turn-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-shape-turn-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-small-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-small-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-small-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-small-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-thin-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-thin-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-thin-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-thin-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-to-line-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-line-left-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-line-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-line-up-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-shape-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-shape-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-trend-down-svgrepo-com.svg +12 -0
- data/stuff/glyph/arrow-trend-up-svgrepo-com.svg +12 -0
- data/stuff/glyph/arrow-turn-down-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-down-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-left-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-left-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-right-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-right-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-up-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-up-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-up-arrow-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/at-sign-svgrepo-com.svg +4 -0
- data/stuff/glyph/bag-svgrepo-com.svg +4 -0
- data/stuff/glyph/bell-slash-svgrepo-com.svg +6 -0
- data/stuff/glyph/bell-svgrepo-com.svg +5 -0
- data/stuff/glyph/book-open-svgrepo-com.svg +5 -0
- data/stuff/glyph/bookmark-svgrepo-com.svg +4 -0
- data/stuff/glyph/box-svgrepo-com.svg +6 -0
- data/stuff/glyph/calendar-svgrepo-com.svg +5 -0
- data/stuff/glyph/camera-svgrepo-com.svg +4 -0
- data/stuff/glyph/caret-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/caret-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/caret-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/caret-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/cart-svgrepo-com.svg +6 -0
- data/stuff/glyph/chart-pie-svgrepo-com.svg +5 -0
- data/stuff/glyph/chartbar-2-svgrepo-com.svg +7 -0
- data/stuff/glyph/chartbar-svgrepo-com.svg +7 -0
- data/stuff/glyph/checkmark-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/checkmark-double-svgrepo-com.svg +5 -0
- data/stuff/glyph/checkmark-square-svgrepo-com.svg +4 -0
- data/stuff/glyph/checkmark-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-left-chevron-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/chevron-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-small-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-small-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-small-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-small-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-up-chevron-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/chevron-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/clock-svgrepo-com.svg +4 -0
- data/stuff/glyph/cloud-arrow-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/cloud-download-svgrepo-com.svg +4 -0
- data/stuff/glyph/cloud-slash-svgrepo-com.svg +5 -0
- data/stuff/glyph/cloud-svgrepo-com.svg +4 -0
- data/stuff/glyph/columns-svgrepo-com.svg +5 -0
- data/stuff/glyph/command-svgrepo-com.svg +4 -0
- data/stuff/glyph/compass-svgrepo-com.svg +5 -0
- data/stuff/glyph/credit-card-svgrepo-com.svg +5 -0
- data/stuff/glyph/crop-svgrepo-com.svg +5 -0
- data/stuff/glyph/crown-svgrepo-com.svg +4 -0
- data/stuff/glyph/delete-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/device-desktop-svgrepo-com.svg +4 -0
- data/stuff/glyph/device-mobile-svgrepo-com.svg +4 -0
- data/stuff/glyph/device-tablet-svgrepo-com.svg +4 -0
- data/stuff/glyph/doc-svgrepo-com.svg +5 -0
- data/stuff/glyph/dot-small-svgrepo-com.svg +4 -0
- data/stuff/glyph/dots-3-horizontal-svgrepo-com.svg +6 -0
- data/stuff/glyph/dots-3-vertical-svgrepo-com.svg +6 -0
- data/stuff/glyph/dots-6-horizontal-svgrepo-com.svg +9 -0
- data/stuff/glyph/dots-6-vertical-svgrepo-com.svg +9 -0
- data/stuff/glyph/dots-9-svgrepo-com.svg +12 -0
- data/stuff/glyph/emoji-frown-svgrepo-com.svg +4 -0
- data/stuff/glyph/emoji-meh-svgrepo-com.svg +4 -0
- data/stuff/glyph/emoji-smile-svgrepo-com.svg +4 -0
- data/stuff/glyph/envelope-svgrepo-com.svg +5 -0
- data/stuff/glyph/external-link-svgrepo-com.svg +5 -0
- data/stuff/glyph/eye-slash-svgrepo-com.svg +15 -0
- data/stuff/glyph/eye-svgrepo-com.svg +4 -0
- data/stuff/glyph/filter-svgrepo-com.svg +4 -0
- data/stuff/glyph/flame-svgrepo-com.svg +4 -0
- data/stuff/glyph/floppy-disk-svgrepo-com.svg +4 -0
- data/stuff/glyph/folder-svgrepo-com.svg +4 -0
- data/stuff/glyph/fullscreen-alt-svgrepo-com.svg +7 -0
- data/stuff/glyph/fullscreen-exit-alt-svgrepo-com.svg +7 -0
- data/stuff/glyph/fullscreen-exit-svgrepo-com.svg +5 -0
- data/stuff/glyph/fullscreen-svgrepo-com.svg +5 -0
- data/stuff/glyph/gear-svgrepo-com.svg +4 -0
- data/stuff/glyph/giftbox-svgrepo-com.svg +6 -0
- data/stuff/glyph/half-star-svgrepo-com.svg +4 -0
- data/stuff/glyph/hashtag-svgrepo-com.svg +4 -0
- data/stuff/glyph/headphones-svgrepo-com.svg +4 -0
- data/stuff/glyph/heart-half-svgrepo-com.svg +4 -0
- data/stuff/glyph/heart-svgrepo-com.svg +4 -0
- data/stuff/glyph/house-svgrepo-com.svg +4 -0
- data/stuff/glyph/image-svgrepo-com.svg +4 -0
- data/stuff/glyph/info-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/key-svgrepo-com.svg +4 -0
- data/stuff/glyph/layers-3-svgrepo-com.svg +6 -0
- data/stuff/glyph/layout-svgrepo-com.svg +6 -0
- data/stuff/glyph/line-3-svgrepo-com.svg +6 -0
- data/stuff/glyph/link-alt-svgrepo-com.svg +5 -0
- data/stuff/glyph/link-svgrepo-com.svg +6 -0
- data/stuff/glyph/list-bullet-svgrepo-com.svg +9 -0
- data/stuff/glyph/location-svgrepo-com.svg +4 -0
- data/stuff/glyph/lock-open-svgrepo-com.svg +4 -0
- data/stuff/glyph/lock-svgrepo-com.svg +4 -0
- data/stuff/glyph/map-pin-svgrepo-com.svg +4 -0
- data/stuff/glyph/medal-svgrepo-com.svg +13 -0
- data/stuff/glyph/media-backward-end-svgrepo-com.svg +5 -0
- data/stuff/glyph/media-backward-svgrepo-com.svg +5 -0
- data/stuff/glyph/media-forward-end-svgrepo-com.svg +5 -0
- data/stuff/glyph/media-forward-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-pause-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-pause-svgrepo-com.svg +5 -0
- data/stuff/glyph/media-play-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-play-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-stop-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-stop-svgrepo-com.svg +4 -0
- data/stuff/glyph/message-bubble-2-svgrepo-com.svg +4 -0
- data/stuff/glyph/message-bubble-svgrepo-com.svg +4 -0
- data/stuff/glyph/mic-slash-svgrepo-com.svg +6 -0
- data/stuff/glyph/mic-svgrepo-com.svg +5 -0
- data/stuff/glyph/minus-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/minus-square-svgrepo-com.svg +4 -0
- data/stuff/glyph/minus-svgrepo-com.svg +4 -0
- data/stuff/glyph/moon-svgrepo-com.svg +4 -0
- data/stuff/glyph/music-note-svgrepo-com.svg +4 -0
- data/stuff/glyph/nosign-svgrepo-com.svg +4 -0
- data/stuff/glyph/paper-clip-svgrepo-com.svg +4 -0
- data/stuff/glyph/paper-plane-svgrepo-com.svg +4 -0
- data/stuff/glyph/pen-tool-svgrepo-com.svg +4 -0
- data/stuff/glyph/pencil-svgrepo-com.svg +5 -0
- data/stuff/glyph/percent-svgrepo-com.svg +6 -0
- data/stuff/glyph/phone-incoming-svgrepo-com.svg +5 -0
- data/stuff/glyph/phone-missed-svgrepo-com.svg +4 -0
- data/stuff/glyph/phone-outgoing-svgrepo-com.svg +5 -0
- data/stuff/glyph/phone-slash-svgrepo-com.svg +4 -0
- data/stuff/glyph/phone-svgrepo-com.svg +4 -0
- data/stuff/glyph/plus-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/plus-square-svgrepo-com.svg +4 -0
- data/stuff/glyph/plus-svgrepo-com.svg +4 -0
- data/stuff/glyph/power-svgrepo-com.svg +5 -0
- data/stuff/glyph/printer-svgrepo-com.svg +5 -0
- data/stuff/glyph/question-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/scissors-svgrepo-com.svg +5 -0
- data/stuff/glyph/search-svgrepo-com.svg +4 -0
- data/stuff/glyph/server-svgrepo-com.svg +5 -0
- data/stuff/glyph/shape-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/shape-rhombus-svgrepo-com.svg +4 -0
- data/stuff/glyph/shape-square-svgrepo-com.svg +4 -0
- data/stuff/glyph/shape-triangle-svgrepo-com.svg +12 -0
- data/stuff/glyph/share-svgrepo-com.svg +4 -0
- data/stuff/glyph/shield-slash-svgrepo-com.svg +13 -0
- data/stuff/glyph/shield-svgrepo-com.svg +4 -0
- data/stuff/glyph/shippingbox-svgrepo-com.svg +7 -0
- data/stuff/glyph/slider-3-horizontal-svgrepo-com.svg +9 -0
- data/stuff/glyph/slider-3-vertical-svgrepo-com.svg +9 -0
- data/stuff/glyph/speaker-svgrepo-com.svg +4 -0
- data/stuff/glyph/speaker-wave-1-svgrepo-com.svg +5 -0
- data/stuff/glyph/speaker-wave-2-svgrepo-com.svg +6 -0
- data/stuff/glyph/speaker-xmark-svgrepo-com.svg +5 -0
- data/stuff/glyph/square-4-grid-svgrepo-com.svg +7 -0
- data/stuff/glyph/square-on-square-svgrepo-com.svg +5 -0
- data/stuff/glyph/star-svgrepo-com.svg +4 -0
- data/stuff/glyph/sun-svgrepo-com.svg +12 -0
- data/stuff/glyph/tag-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-align-center-svgrepo-com.svg +7 -0
- data/stuff/glyph/text-align-justify-svgrepo-com.svg +7 -0
- data/stuff/glyph/text-align-left-svgrepo-com.svg +7 -0
- data/stuff/glyph/text-align-right-svgrepo-com.svg +7 -0
- data/stuff/glyph/text-bold-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-heading-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-italic-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-underline-svgrepo-com.svg +5 -0
- data/stuff/glyph/thumbs-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/thumbs-up-svgrepo-com.svg +5 -0
- data/stuff/glyph/trash-svgrepo-com.svg +5 -0
- data/stuff/glyph/tray-svgrepo-com.svg +4 -0
- data/stuff/glyph/umbrela-svgrepo-com.svg +4 -0
- data/stuff/glyph/user-svgrepo-com.svg +5 -0
- data/stuff/glyph/users-svgrepo-com.svg +7 -0
- data/stuff/glyph/video-svgrepo-com.svg +12 -0
- data/stuff/glyph/waveform-ecg-svgrepo-com.svg +4 -0
- data/stuff/glyph/wi-fi-svgrepo-com.svg +7 -0
- data/stuff/glyph/xmark-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/xmark-small-svgrepo-com.svg +4 -0
- data/stuff/glyph/xmark-svgrepo-com.svg +4 -0
- data/stuff/glyph/zap-svgrepo-com.svg +4 -0
- data/stuff/glyph/zoom-in-svgrepo-com.svg +5 -0
- data/stuff/glyph/zoom-out-svgrepo-com.svg +5 -0
- data/stuff/readme.md +266 -0
- data/stuff/so/libSDL3.so +0 -0
- data/stuff/so/libpastele.so +0 -0
- data/stuff/so/libthorvg-1.so +0 -0
- metadata +427 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9af44856eae558d033e3b429e6e767ef560c0b828b9d55286ad19e374ee8d6d4
|
|
4
|
+
data.tar.gz: ea9590394ddc1d90e13fb15e803435844a688df926dec21f21c0a271a8c8e737
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5861f30176a2fff56ad78f3db95ec785920c1cdc3aac28d5b2fd9424087b5904e6004131846c047f8047bf73332c8277f636517df076d7191e52a72da0a5f62d
|
|
7
|
+
data.tar.gz: 60cb7728819220bd7dccc22a0a20cbd5bb217c4927add4f3682fe7082d37fbe5685b435030b661a0fdd9d7e93cfe25f437def526e299e3e2af1ecc115a56642d
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
module Kredki
|
|
2
|
+
class Application
|
|
3
|
+
|
|
4
|
+
# Run application event loop.
|
|
5
|
+
def run
|
|
6
|
+
@run_ms = Kredki.ms
|
|
7
|
+
Pastele.application_run @pointer
|
|
8
|
+
Kredki.clear_app
|
|
9
|
+
@result
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Open window in application.
|
|
13
|
+
def open opened = nil, *a, hidden: false, **ka, &b
|
|
14
|
+
case opened
|
|
15
|
+
when Window
|
|
16
|
+
window = opened
|
|
17
|
+
result = put_window(window).pane!.set(*a, **ka, &b)
|
|
18
|
+
window.show unless hidden
|
|
19
|
+
else
|
|
20
|
+
window = default_window
|
|
21
|
+
pane = opened || window.default_pane
|
|
22
|
+
result = put_window(window).set_pane(pane).set(*a, **ka, &b)
|
|
23
|
+
window.show unless hidden
|
|
24
|
+
end
|
|
25
|
+
result
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Get window.
|
|
29
|
+
def window key = nil
|
|
30
|
+
(key ? @windows[key] : @main_window)&.then{|it| it.scene }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Get milliseconds since run.
|
|
34
|
+
def ms
|
|
35
|
+
Kredki.ms - (@run_ms || 0)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Break event loop.
|
|
39
|
+
def return result = nil
|
|
40
|
+
@result = result
|
|
41
|
+
@windows.each_value{|it| delete_window it, false }
|
|
42
|
+
Pastele.application_exit @pointer
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# General event exception handler.
|
|
46
|
+
def rescue &block
|
|
47
|
+
@rescue = block if block
|
|
48
|
+
@rescue
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# :section: LEVEL 2
|
|
52
|
+
|
|
53
|
+
class DropData
|
|
54
|
+
def initialize source, text, type
|
|
55
|
+
@source = source
|
|
56
|
+
@text = text
|
|
57
|
+
@type = type
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
attr_accessor :source
|
|
61
|
+
attr_accessor :text
|
|
62
|
+
attr_accessor :type
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def initialize
|
|
66
|
+
@pointer = Pastele.application_new
|
|
67
|
+
ObjectSpace.define_finalizer(self, Application.finalizer(@pointer))
|
|
68
|
+
|
|
69
|
+
@event_callback = Fiddle::Closure::BlockCaller.new(Fiddle::TYPE_INT, [Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP], &method(:event))
|
|
70
|
+
Pastele.application_set_event_handler @pointer, @event_callback
|
|
71
|
+
@rescue = nil
|
|
72
|
+
@windows = {}
|
|
73
|
+
@early_close_next_text_event = false
|
|
74
|
+
@drop_data = nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.finalizer pointer
|
|
78
|
+
proc{ Pastele.application_delete pointer }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def run_ms
|
|
82
|
+
@run_ms
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def event event_type, event_ptr
|
|
86
|
+
event = case event_type
|
|
87
|
+
when 0x202
|
|
88
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
89
|
+
window_event abi.window_id, ShowEvent.new(abi)
|
|
90
|
+
when 0x203
|
|
91
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
92
|
+
window_event abi.window_id, HideEvent.new(abi)
|
|
93
|
+
when 0x204
|
|
94
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
95
|
+
application_event WindowExposeEvent.new(abi)
|
|
96
|
+
when 0x205
|
|
97
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
98
|
+
window_event abi.window_id, MoveEvent.new(abi.data1, abi.data2, abi)
|
|
99
|
+
when 0x206
|
|
100
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
101
|
+
window_event abi.window_id, ResizeEvent.new(abi.data1, abi.data2, abi)
|
|
102
|
+
when 0x209
|
|
103
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
104
|
+
window_event abi.window_id, WindowMinimizeEvent.new(abi)
|
|
105
|
+
when 0x20A
|
|
106
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
107
|
+
window_event abi.window_id, WindowMaximizeEvent.new(abi)
|
|
108
|
+
when 0x20B
|
|
109
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
110
|
+
window_event abi.window_id, WindowRestoreEvent.new(abi)
|
|
111
|
+
when 0x20C
|
|
112
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
113
|
+
event = MousePointerEnterEvent.new abi
|
|
114
|
+
if window = @windows[abi.window_id]
|
|
115
|
+
window.update_mouse_in true
|
|
116
|
+
window.report event
|
|
117
|
+
end
|
|
118
|
+
event
|
|
119
|
+
when 0x20D
|
|
120
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
121
|
+
event = MousePointerLeaveEvent.new abi
|
|
122
|
+
if window = @windows[abi.window_id]
|
|
123
|
+
window.update_mouse_in false
|
|
124
|
+
window.report event
|
|
125
|
+
end
|
|
126
|
+
event
|
|
127
|
+
when 0x20E
|
|
128
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
129
|
+
window_event abi.window_id, FocusEnterEvent.new(abi)
|
|
130
|
+
when 0x20F
|
|
131
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
132
|
+
window_event abi.window_id, FocusLeaveEvent.new(abi)
|
|
133
|
+
when 0x210
|
|
134
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
135
|
+
window_event abi.window_id, WindowCloseEvent.new(abi) do |event|
|
|
136
|
+
unless event.closed?
|
|
137
|
+
window = @windows[abi.window_id]
|
|
138
|
+
delete_window window if window
|
|
139
|
+
event.close
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
when 0x211
|
|
143
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
144
|
+
window_event abi.window_id, WindowHitTestEvent.new(abi)
|
|
145
|
+
when 0x212
|
|
146
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
147
|
+
window_event abi.window_id, WindowIccprofChangeEvent.new(abi)
|
|
148
|
+
when 0x213
|
|
149
|
+
abi = Pastele::WindowEvent.new event_ptr
|
|
150
|
+
window_event abi.window_id, WindowDisplayChangeEvent.new(abi)
|
|
151
|
+
when 0x300 # SDL_EVENT_KEY_DOWN
|
|
152
|
+
abi = Pastele::KeyboardEvent.new event_ptr
|
|
153
|
+
if keyboard = Kredki.keyboard
|
|
154
|
+
event = keyboard.key_press_event abi
|
|
155
|
+
window_event abi.window_id, event do |event|
|
|
156
|
+
@early_close_next_text_event = event.closed? && (32..122).include?(event.code)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
when 0x301 # SDL_EVENT_KEY_UP
|
|
160
|
+
abi = Pastele::KeyboardEvent.new event_ptr
|
|
161
|
+
if keyboard = Kredki.keyboard
|
|
162
|
+
event = keyboard.key_release_event abi
|
|
163
|
+
window_event abi.window_id, event
|
|
164
|
+
end
|
|
165
|
+
when 0x400 # SDL_EVENT_MOUSE_MOTION
|
|
166
|
+
abi = Pastele::MouseMotionEvent.new event_ptr
|
|
167
|
+
if mouse = Kredki.mouse
|
|
168
|
+
event = mouse.pointer_move_event abi
|
|
169
|
+
window_event abi.window_id, event
|
|
170
|
+
end
|
|
171
|
+
when 0x401 # SDL_EVENT_MOUSE_BUTTON_DOWN
|
|
172
|
+
abi = Pastele::MouseButtonEvent.new event_ptr
|
|
173
|
+
if mouse = Kredki.mouse
|
|
174
|
+
event = mouse.button_press_event abi
|
|
175
|
+
window_event abi.window_id, event
|
|
176
|
+
end
|
|
177
|
+
when 0x402 # SDL_EVENT_MOUSE_BUTTON_UP
|
|
178
|
+
abi = Pastele::MouseButtonEvent.new event_ptr
|
|
179
|
+
if mouse = Kredki.mouse
|
|
180
|
+
event = mouse.button_release_event abi
|
|
181
|
+
window_event abi.window_id, event
|
|
182
|
+
event
|
|
183
|
+
end
|
|
184
|
+
when 0x403 # SDL_EVENT_MOUSE_WHEEL
|
|
185
|
+
abi = Pastele::MouseWheelEvent.new event_ptr
|
|
186
|
+
if mouse = Kredki.mouse
|
|
187
|
+
event = Kredki.mouse.wheel_scroll_event abi
|
|
188
|
+
window_event abi.window_id, event
|
|
189
|
+
end
|
|
190
|
+
when 0x303 # SDL_EVENT_TEXT_EDITING
|
|
191
|
+
abi = Pastele::TextInputEvent.new event_ptr
|
|
192
|
+
event = TextInputEvent.new event_ptr, abi
|
|
193
|
+
@early_close_next_text_event &&= event.close && false
|
|
194
|
+
window_event abi.window_id, event
|
|
195
|
+
when 0x600 # SDL_EVENT_JOYSTICK_AXIS_MOTION
|
|
196
|
+
abi_event = Pastele::JoyAxisEvent.new event_ptr
|
|
197
|
+
application_event JoystickAxisMoveEvent.new(Kredki.opened_joysticks[abi_event.which], abi_event)
|
|
198
|
+
when 0x602 # SDL_EVENT_JOYSTICK_HAT_MOTION
|
|
199
|
+
abi_event = Pastele::JoyHatEvent.new event_ptr
|
|
200
|
+
application_event JoystickHatSwitchEvent.new(Kredki.opened_joysticks[abi_event.which], abi_event)
|
|
201
|
+
when 0x603 # SDL_EVENT_JOYSTICK_BUTTON_DOWN
|
|
202
|
+
abi_event = Pastele::JoyButtonEvent.new event_ptr
|
|
203
|
+
application_event JoystickButtonPressEvent.new(Kredki.opened_joysticks[abi_event.which], abi_event)
|
|
204
|
+
when 0x604 # SDL_EVENT_JOYSTICK_BUTTON_UP
|
|
205
|
+
abi_event = Pastele::JoyButtonEvent.new event_ptr
|
|
206
|
+
application_event JoystickButtonReleaseEvent.new(Kredki.opened_joysticks[abi_event.which], abi_event)
|
|
207
|
+
when 0x605 # SDL_EVENT_JOYSTICK_ADDED
|
|
208
|
+
abi_event = Pastele::JoyDeviceEvent.new event_ptr
|
|
209
|
+
joystick = (Kredki.joysticks.values - Kredki.opened_joysticks.values).max{ _1.match abi_event.which } || Joystick.new
|
|
210
|
+
application_event JoystickConnectEvent.new(joystick, abi_event) do |event|
|
|
211
|
+
unless event.closed?
|
|
212
|
+
device_id = Pastele.joystick_open abi_event.which
|
|
213
|
+
Kredki.opened_joysticks[device_id] = joystick
|
|
214
|
+
joystick.device_id = device_id
|
|
215
|
+
event.close
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
when 0x606 # SDL_EVENT_JOYSTICK_REMOVED
|
|
219
|
+
abi_event = Pastele::JoyDeviceEvent.new event_ptr
|
|
220
|
+
device_id = abi_event.which
|
|
221
|
+
joystick = Kredki.opened_joysticks[device_id]
|
|
222
|
+
application_event JoystickDisconnectEvent.new(joystick, abi_event) do |event|
|
|
223
|
+
unless event.closed?
|
|
224
|
+
joystick = Kredki.opened_joysticks.delete device_id
|
|
225
|
+
joystick&.device_id = nil
|
|
226
|
+
event.close
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
when 0x1000 # SDL_EVENT_DROP_FILE
|
|
230
|
+
abi = Pastele::DropEvent.new event_ptr
|
|
231
|
+
@drop_data << DropData.new(
|
|
232
|
+
abi.source.then{|it| it.null? ? nil : it.to_s.force_encoding("utf-8") },
|
|
233
|
+
abi.data.to_s.force_encoding("utf-8"),
|
|
234
|
+
:file,
|
|
235
|
+
)
|
|
236
|
+
nil
|
|
237
|
+
when 0x1001 # SDL_EVENT_DROP_TEXT
|
|
238
|
+
abi = Pastele::DropEvent.new event_ptr
|
|
239
|
+
@drop_data << DropData.new(
|
|
240
|
+
abi.source.then{|it| it.null? ? nil : it.to_s.force_encoding("utf-8") },
|
|
241
|
+
abi.data.to_s.force_encoding("utf-8"),
|
|
242
|
+
:text,
|
|
243
|
+
)
|
|
244
|
+
nil
|
|
245
|
+
when 0x1002 # SDL_EVENT_DROP_BEGIN
|
|
246
|
+
@drop_data = []
|
|
247
|
+
abi = Pastele::DropEvent.new event_ptr
|
|
248
|
+
window_event abi.window_id, DropBeginEvent.new(abi)
|
|
249
|
+
when 0x1003 # SDL_EVENT_DROP_COMPLETE
|
|
250
|
+
abi = Pastele::DropEvent.new event_ptr
|
|
251
|
+
if @drop_data.empty?
|
|
252
|
+
window_event abi.window_id, DropCancelEvent.new(abi)
|
|
253
|
+
else
|
|
254
|
+
window_event abi.window_id, DropEvent.new(@drop_data, abi)
|
|
255
|
+
end
|
|
256
|
+
when 0x1004 # SDL_EVENT_DROP_POSITION
|
|
257
|
+
abi = Pastele::DropEvent.new event_ptr
|
|
258
|
+
event = MousePointerDropEvent.new Kredki.mouse, abi
|
|
259
|
+
window_event abi.window_id, event
|
|
260
|
+
when 256
|
|
261
|
+
application_event ExitEvent.new(Pastele::QuitEvent.new event_ptr)
|
|
262
|
+
when 0x8001 # USEREVENT_UPDATEWINDOW
|
|
263
|
+
abi = Pastele::UserEvent.new event_ptr
|
|
264
|
+
window_event abi.window_id, TickEvent.new(abi)
|
|
265
|
+
when 0x8007 # Close window Event
|
|
266
|
+
abi = Pastele::UserEvent.new event_ptr
|
|
267
|
+
window_event abi.window_id, TickEvent.new(abi)
|
|
268
|
+
when 0x8008 # USEREVENT_UPDATECOMPLETEWINDOW
|
|
269
|
+
abi = Pastele::UserEvent.new event_ptr
|
|
270
|
+
window_event abi.window_id, UpdateCompleteEvent.new(abi)
|
|
271
|
+
else # unsupported event
|
|
272
|
+
# puts event_type.to_s 16
|
|
273
|
+
nil
|
|
274
|
+
end
|
|
275
|
+
event&.closed? ? 1 : 0
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def put_window window
|
|
279
|
+
window_id = Pastele.application_insert_window @pointer, window.pointer
|
|
280
|
+
@windows[window_id] = window
|
|
281
|
+
@main_window ||= window
|
|
282
|
+
window.attach self
|
|
283
|
+
window
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def delete_window window, last_exit = true
|
|
287
|
+
window.hide
|
|
288
|
+
window_id = Pastele.application_erase_window(@pointer, window.pointer)
|
|
289
|
+
@windows.delete window_id
|
|
290
|
+
window.detach
|
|
291
|
+
if last_exit && @windows.empty?
|
|
292
|
+
self.return
|
|
293
|
+
else
|
|
294
|
+
@main_window = @windows.values.first if @main_window == window
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def window_event window_id, event, &post_process
|
|
299
|
+
@windows[window_id]&.report event
|
|
300
|
+
post_process&.call event
|
|
301
|
+
event
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def application_event event, &post_process
|
|
305
|
+
@windows.values.each{|it| it.report event }
|
|
306
|
+
post_process&.call event
|
|
307
|
+
event
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def default_window
|
|
311
|
+
Window.new
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
module Kredki
|
|
2
|
+
# Immutable color model
|
|
3
|
+
class Color
|
|
4
|
+
|
|
5
|
+
# Get red channel value.
|
|
6
|
+
def r
|
|
7
|
+
@r
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Get green channel value.
|
|
11
|
+
def g
|
|
12
|
+
@g
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Get blue channel value.
|
|
16
|
+
def b
|
|
17
|
+
@b
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Get alpha channel value.
|
|
21
|
+
def a
|
|
22
|
+
@a
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Get color copy with RGB channels saturation increased by a +level+.
|
|
26
|
+
def lighten level = 10
|
|
27
|
+
Color.new *to_a(:rgb).map{ (_1 + level).clamp(0, 255) }, @a
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Get color copy with RGB channels saturation decreased by a +level+.
|
|
31
|
+
def darken level = 10
|
|
32
|
+
Color.new *to_a(:rgb).map{ (_1 - level).clamp(0, 255) }, @a
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Get color copy with changed Alpha channel saturation.
|
|
36
|
+
def clarify a = 255
|
|
37
|
+
a = (255 * a).to_i if a.is_a? Rational
|
|
38
|
+
Color.new *to_a(:rgb), a
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Get color copy with tuned RGB channels saturation.
|
|
42
|
+
def tune r = 0, g = 0, b = 0
|
|
43
|
+
Color.new (@r + r).clamp(0, 255), (@g + g).clamp(0, 255), (@b + b).clamp(0, 255), @a
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Get textual representation.
|
|
47
|
+
def to_s
|
|
48
|
+
"##{ to_a.map{|it| it.to_s(16).rjust(2, "0") }.join }"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# :section: LEVEL 2
|
|
52
|
+
|
|
53
|
+
def initialize r, g, b, a = 255
|
|
54
|
+
@r = r
|
|
55
|
+
@g = g
|
|
56
|
+
@b = b
|
|
57
|
+
@a = a
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.parse *a
|
|
61
|
+
case a = Util.uncover(a)
|
|
62
|
+
when String
|
|
63
|
+
a = a[1..] if a.start_with? "#"
|
|
64
|
+
alpha = a.length > 6 ? a[6...8].to_i(16) : 255
|
|
65
|
+
Color.new a[0...2].to_i(16), a[2...4].to_i(16), a[4...6].to_i(16), alpha
|
|
66
|
+
when Array
|
|
67
|
+
Color.new *a
|
|
68
|
+
else raise_ia a
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def to_rgb
|
|
73
|
+
[@r, @g, @b]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def to_rgba
|
|
77
|
+
[@r, @g, @b, @a]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def to_a mode = :rgba
|
|
81
|
+
case mode
|
|
82
|
+
when :rgb
|
|
83
|
+
to_rgb
|
|
84
|
+
else
|
|
85
|
+
to_rgba
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
alias_method :to_ary, :to_a
|
|
90
|
+
|
|
91
|
+
def ==(other)
|
|
92
|
+
Color === other &&
|
|
93
|
+
r == other.r &&
|
|
94
|
+
g == other.g &&
|
|
95
|
+
b == other.b &&
|
|
96
|
+
a == other.a
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Kredki
|
|
2
|
+
# Block based event reaction.
|
|
3
|
+
class BlockEventReaction < EventReaction
|
|
4
|
+
|
|
5
|
+
# Attach copy of reaction to another manager.
|
|
6
|
+
def attach manager, always = false
|
|
7
|
+
self.class.new @block, manager, always
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Cancel reaction.
|
|
11
|
+
def cancel
|
|
12
|
+
super
|
|
13
|
+
@block = nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# :section: LEVEL 2
|
|
17
|
+
|
|
18
|
+
def initialize block, ...
|
|
19
|
+
super(...)
|
|
20
|
+
@block = block
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
attr_accessor :block
|
|
24
|
+
|
|
25
|
+
def call event = nil
|
|
26
|
+
return if !@always && event&.closed?
|
|
27
|
+
event&.reaction = self
|
|
28
|
+
begin
|
|
29
|
+
@block.call event
|
|
30
|
+
rescue => e
|
|
31
|
+
res = Kredki.app.rescue
|
|
32
|
+
if res
|
|
33
|
+
res.call e, event
|
|
34
|
+
else
|
|
35
|
+
raise inspect
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def inspect
|
|
41
|
+
"#{self.class}:#{object_id} #{[@block.binding.receiver, @block]}"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Kredki
|
|
2
|
+
# Collection of event managers used as a single entity.
|
|
3
|
+
class CompositeEventManager
|
|
4
|
+
include EventManagerJobs
|
|
5
|
+
|
|
6
|
+
# :section: LEVEL 2
|
|
7
|
+
|
|
8
|
+
def initialize managers
|
|
9
|
+
@managers = managers
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def attach attached, always: false
|
|
13
|
+
reaction = case attached
|
|
14
|
+
when BlockEventReaction
|
|
15
|
+
BlockEventReaction.new attached.block, self, always
|
|
16
|
+
when MethodEventReaction
|
|
17
|
+
MethodEventReaction.new attached.method, self, always
|
|
18
|
+
when JobEventReaction
|
|
19
|
+
JobEventReaction.new attached.job, self, always
|
|
20
|
+
when Proc
|
|
21
|
+
BlockEventReaction.new attached, self, always
|
|
22
|
+
else raise_ia attached
|
|
23
|
+
end
|
|
24
|
+
@managers.each{|it| it.reactions << reaction }
|
|
25
|
+
reaction
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def <<(attached)
|
|
29
|
+
attach attached
|
|
30
|
+
self
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def detach reaction
|
|
34
|
+
@managers.each{|it| it.detach reaction }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
module Kredki
|
|
2
|
+
# General event.
|
|
3
|
+
class Event
|
|
4
|
+
|
|
5
|
+
# Attach few events to identical reaction.
|
|
6
|
+
def self.each *event_managers, do: nil, &block
|
|
7
|
+
attached = block || binding.local_variable_get(:do)
|
|
8
|
+
event_managers.map{|it| it.attach attached }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Make new event.
|
|
12
|
+
def initialize source = nil, target = nil
|
|
13
|
+
@source = source
|
|
14
|
+
@target = target
|
|
15
|
+
@closed = false
|
|
16
|
+
@reaction = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Set target.
|
|
20
|
+
def target= target
|
|
21
|
+
@target = target
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Get target.
|
|
25
|
+
def target
|
|
26
|
+
@target
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Set source.
|
|
30
|
+
def source= source
|
|
31
|
+
@source = source
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Get source.
|
|
35
|
+
def source
|
|
36
|
+
@source
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# See #param.
|
|
40
|
+
def ~
|
|
41
|
+
param
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Get event main parameter. Method overrided in inheriting classes.
|
|
45
|
+
def param
|
|
46
|
+
nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Get whether event is closed. Closed events are processed only by reactions with always = +true+.
|
|
50
|
+
def closed?
|
|
51
|
+
@closed
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Close event. Closed events are processed only by reactions with always = +true+.
|
|
55
|
+
def close
|
|
56
|
+
@closed = true
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Get current event reaction.
|
|
60
|
+
def reaction
|
|
61
|
+
Array === @reaction ? @reaction.last : @reaction
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Set whether all visited reactions are collected.
|
|
65
|
+
def trace= trace
|
|
66
|
+
if trace
|
|
67
|
+
@reaction = Util.cover @reaction
|
|
68
|
+
else
|
|
69
|
+
@reaction = reaction
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# :section: LEVEL 2
|
|
74
|
+
|
|
75
|
+
def inspect
|
|
76
|
+
"#{self.class}:#{object_id}"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def reaction= reaction
|
|
80
|
+
if Array === @reaction
|
|
81
|
+
@reaction << reaction
|
|
82
|
+
else
|
|
83
|
+
@reaction = reaction
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def reactions
|
|
88
|
+
@reaction
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require_relative 'event_reaction'
|
|
2
|
+
require_relative 'block_event_reaction'
|
|
3
|
+
require_relative 'method_event_reaction'
|
|
4
|
+
require_relative 'job_event_reaction'
|
|
5
|
+
require_relative 'event_manager_jobs'
|
|
6
|
+
|
|
7
|
+
module Kredki
|
|
8
|
+
# Manage event reactions.
|
|
9
|
+
class EventManager
|
|
10
|
+
include EventManagerJobs
|
|
11
|
+
|
|
12
|
+
# :section: LEVEL 2
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@reactions = []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
attr :reactions
|
|
19
|
+
|
|
20
|
+
def report event
|
|
21
|
+
@reactions.each{|it| it.call event }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def attach attached = nil, always: false, at: true, &block
|
|
25
|
+
attached ||= block
|
|
26
|
+
reaction = case attached
|
|
27
|
+
when Proc
|
|
28
|
+
BlockEventReaction.new attached, self, always
|
|
29
|
+
when Method
|
|
30
|
+
MethodEventReaction.new attached, self, always
|
|
31
|
+
when Job
|
|
32
|
+
JobEventReaction.new attached, self, always
|
|
33
|
+
when EventReaction
|
|
34
|
+
attached.attach self, always
|
|
35
|
+
else raise_is attached
|
|
36
|
+
end
|
|
37
|
+
case at
|
|
38
|
+
when true
|
|
39
|
+
@reactions.prepend reaction
|
|
40
|
+
when Integer
|
|
41
|
+
@reactions.insert at, service
|
|
42
|
+
when EventReaction
|
|
43
|
+
@reactions.insert @reactions.index(at), service
|
|
44
|
+
when :last
|
|
45
|
+
@reactions.append reaction
|
|
46
|
+
else raise_ia at
|
|
47
|
+
end
|
|
48
|
+
reaction
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def <<(attached)
|
|
52
|
+
attach attached
|
|
53
|
+
self
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def detach reaction
|
|
57
|
+
@reactions.delete reaction
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Kredki
|
|
2
|
+
# Job reaction methods.
|
|
3
|
+
module EventManagerJobs
|
|
4
|
+
|
|
5
|
+
# Create and attach job after.
|
|
6
|
+
def after delay = 0, &block
|
|
7
|
+
case delay
|
|
8
|
+
when Numeric
|
|
9
|
+
job = AfterJob.new block, delay
|
|
10
|
+
attach job
|
|
11
|
+
job
|
|
12
|
+
when Job
|
|
13
|
+
attach delay
|
|
14
|
+
delay
|
|
15
|
+
when Proc
|
|
16
|
+
job = AfterJob.new delay, 0
|
|
17
|
+
attach job
|
|
18
|
+
job
|
|
19
|
+
else raise_ia delay
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Create and attach Kredki::LoopJob.
|
|
24
|
+
def loop period = 0, &block
|
|
25
|
+
after LoopJob.new block, period
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Create and attach Kredki::SideJob.
|
|
29
|
+
def side &block
|
|
30
|
+
after SideJob.new block
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Create and attach play job.
|
|
34
|
+
def play subject, speed: 1, &block
|
|
35
|
+
case subject
|
|
36
|
+
when Numeric
|
|
37
|
+
after PlayJob.new block, subject, speed
|
|
38
|
+
else
|
|
39
|
+
after PlayAnimationJob.new block, subject, speed
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Create and attach play in loop job.
|
|
44
|
+
def play_loop subject, speed: 1, &block
|
|
45
|
+
case subject
|
|
46
|
+
when Numeric
|
|
47
|
+
after PlayLoopJob.new block, subject, speed
|
|
48
|
+
else
|
|
49
|
+
after PlayLoopAnimationJob.new block, subject, speed
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|