summaryrefslogtreecommitdiffstats
path: root/lib/efl/elementary.rb
blob: aa90eafb6061a02fa94cda9fc90c80d633a02053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
require 'efl/evas'
require 'efl/native/elementary'
#
module Efl
    #
    module Native
        #
        class ElmGenlistItemClassStruct < FFI::Struct
            layout  :item_style,        :pointer,
                    :label_get,         :pointer,
                    :icon_get,          :pointer,
                    :state_get,         :pointer,
                    :del,               :pointer,
                    :moved,             :pointer,
                    :mode_item_style,   :pointer
        end
        #
    end
    #
    module Elm
        #
        def self.version
            Native::VersionStruct.new(Native.elm_version)
        end
        #
        module Helper
            def self.included kls
                def kls.constructor meth
                    self.class_eval <<-EOF
                    def initialize ptr, &block
                        if ptr.is_a? FFI::Pointer
                            super ptr, &block
                        else
                            super Native.method(:#{meth}), ptr, &block
                        end
                    end
                    EOF
                end
            end
        end
        #
        class << self
            def init *args
                a = args.select { |e| e.is_a? String }
                return Native.elm_init 0, FFI::MemoryPointer::NULL if a.length==0
                ptr = FFI::MemoryPointer.new :pointer, a.length
                a.each_with_index do |s,i|
                    ptr[i].write_pointer FFI::MemoryPointer.from_string(s)
                end
                Native.elm_init a.length, ptr
            end
        end
        #
        class ElmObject < Efl::Evas::REvasObject
            #
            search_prefixes 'elm_object_'
            #
            def smart_callback_add event_str, cb, data=FFI::MemoryPointer::NULL
                Native.evas_object_smart_callback_add @ptr, event_str, cb, data
            end
            #
            def text_set label
                Native.elm_object_text_part_set @ptr, nil, label
            end
            alias :text= :text_set
            #
            def text_get
                Native.elm_object_text_part_get @ptr, nil
            end
            alias :text :text_get
            #
            def obj_content_set content
                Native.elm_object_content_part_set @ptr, nil, content
            end
            alias :obj_content= :obj_content_set
            #
            def obj_content_get
                Native.elm_object_content_part_get @ptr, nil
            end
            alias :obj_content :obj_content_get
            #
            def obj_content_unset
                Native.elm_object_content_part_unset @ptr, nil
            end
            #
            def parent_widget_get
                ElmObject.new Native.elm_object_parent_widget_get @ptr
            end
            alias :parent_widget :parent_widget_get
        end
        #
        ####################################################################################
        #
        class ElmActionSlider < ElmObject
            #
            @as_pos = Native.enum_type :elm_actionslider_pos
            class << self
                attr_reader :as_pos
            end
            #
            include Helper
            constructor :elm_actionslider_add
            search_prefixes 'elm_actionslider_'
            #
            def texts_set l=nil, c=nil, r=nil
                l,c,r = *l if l.is_a? Array
                Native.elm_object_text_part_set @ptr, "left", l
                Native.elm_object_text_part_set @ptr, "center", c
                Native.elm_object_text_part_set @ptr, "right", r
            end
            alias :texts= :texts_set
            def indicator_set str
                p = self.class.as_pos
                v = (
                     case str
                     when 'l'
                         p[:elm_actionslider_left]
                     when 'c'
                         p[:elm_actionslider_center]
                     when 'r'
                         p[:elm_actionslider_right]
                     else
                         p[:elm_actionslider_none]
                     end
                    )
                Native.elm_actionslider_indicator_pos_set @ptr, v
            end
            alias :indicator= :indicator_set
            def enabled_set str
                p = self.class.as_pos
                v = p[:elm_actionslider_none]
                v |= p[:elm_actionslider_left] if str=~/l/
                v |= p[:elm_actionslider_center] if str=~/c/
                v |= p[:elm_actionslider_right] if str=~/r/
                v |= p[:elm_actionslider_all] if str=~/a/
                Native.elm_actionslider_enabled_pos_set @ptr, v
            end
            alias :enabled= :enabled_set
            def magnet_set str
                p = self.class.as_pos
                v = p[:elm_actionslider_none]
                v |= p[:elm_actionslider_left] if str=~/l/
                v |= p[:elm_actionslider_center] if str=~/c/
                v |= p[:elm_actionslider_right] if str=~/r/
                v |= p[:elm_actionslider_all] if str=~/a/
                Native.elm_actionslider_magnet_pos_set @ptr, v
            end
            alias :magnet= :magnet_set
            #
            def setup t=[], i='l', m='a', e='a'
                texts_set *t
                indicator_set i
                magnet_set m
                enabled_set e
            end
        end
        #
        class ElmAnchorBlock < ElmObject
            #
            include Helper
            constructor :elm_anchorblock_add
            search_prefixes 'elm_anchorblock_'
        end
        #
        class ElmAnchorView < ElmObject
            #
            include Helper
            constructor :elm_anchorview_add
            search_prefixes 'elm_anchorview_'
        end
        #
        class ElmBg < ElmObject
            #
            include Helper
            constructor :elm_bg_add
            search_prefixes 'elm_bg_'
            #
            def file_get
                f = FFI::MemoryPointer.new :pointer
                g = FFI::MemoryPointer.new :pointer
                Native.elm_bg_file_get @ptr, f, g
                [ f.read_pointer.read_string, g.read_pointer.read_string ]
            end
            alias :file :file_get
            def color_get
                r = FFI::MemoryPointer.new :int
                g = FFI::MemoryPointer.new :int
                b = FFI::MemoryPointer.new :int
                Native.elm_bg_color_get @ptr, r, g, b
                [ r.read_int, g.read_int, b.read_int ]
            end
            alias :color :color_get
        end
        #
        class ElmBox < ElmObject
            #
            include Helper
            constructor :elm_box_add
            search_prefixes 'elm_box_'
            #
            def padding_get
                x = FFI::MemoryPointer.new :int
                y = FFI::MemoryPointer.new :int
                Native::elm_box_padding_get @ptr, x, y
                [ x.read_int, y.read_int ]
            end
            alias :padding :padding_get
            #
            def align_get
                x = FFI::MemoryPointer.new :float
                y = FFI::MemoryPointer.new :float
                Native::elm_box_align_get @ptr, x, y
                [ x.read_float, y.read_float ]
            end
            alias :align :padding_get
            #
            def children_get
                Efl::EinaList::REinaList.new Native.elm_box_children_get @ptr
            end
            alias :children :children_get
        end
        #
        class ElmBubble < ElmObject
            #
            include Helper
            constructor :elm_bubble_add
            search_prefixes 'elm_bubble_'
        end
        #
        class ElmButton < ElmObject
            #
            include Helper
            constructor :elm_button_add
            search_prefixes 'elm_button_'
            #
        end
        #
        class ElmCalendar < ElmObject
            #
            include Helper
            constructor :elm_calendar_add
            search_prefixes 'elm_calendar_'
            #
        end
        #
        class ElmCheck < ElmObject
            #
            include Helper
            constructor :elm_check_add
            search_prefixes 'elm_check_'
            #
        end
        #
        class ElmClock < ElmObject
            #
            include Helper
            constructor :elm_clock_add
            search_prefixes 'elm_clock_'
        end
        #
        class ElmColorSelector < ElmObject
            #
            include Helper
            constructor :elm_colorselector_add
            search_prefixes 'elm_colorselector_'
            #
        end
        #
        class ElmDiskSelector < ElmObject
            #
            include Helper
            constructor :elm_diskselector_add
            search_prefixes 'elm_diskselector_'
            #
            def item_selected_set it, b
                Native::elm_diskselector_item_selected_set it, b
            end
            alias :item_selected= :item_selected_set
        end
        #
        class ElmDiskSelectorItem < ElmObject
            #
            search_prefixes 'elm_diskselector_item_'
            #
            def data_get
                Native::elm_diskselector_item_data_get @ptr
            end
            alias :data :data_get
        end
        #
        class ElmEntry < ElmObject
            #
            include Helper
            constructor :elm_entry_add
            search_prefixes 'elm_entry_'
            #
        end
        #
        class ElmFileSelector < ElmObject
            #
            include Helper
            constructor :elm_fileselector_add
            search_prefixes 'elm_fileselector_'
        end
        #
        class ElmFileSelectorButton < ElmObject
            #
            include Helper
            constructor :elm_fileselector_button_add
            search_prefixes 'elm_fileselector_button_'
        end
        #
        class ElmFileSelectorENtry < ElmObject
            #
            include Helper
            constructor :elm_fileselector_entry_add
            search_prefixes 'elm_fileselector_entry_'
        end
        #
        class ElmFlip < ElmObject
            #
            include Helper
            constructor :elm_flip_add
            search_prefixes 'elm_flip_'
        end
        #
        class ElmFlipSelector < ElmObject
            #
            include Helper
            constructor :elm_flipselector_add
            search_prefixes 'elm_flipselector_'
            #
            def item_append label, cb, data
                ElmFlipSelectorItem.new Native::elm_flipselector_item_append @ptr, label, cb, data
            end
            #
            def selected_item_get
                ElmFlipSelectorItem.new Native::elm_flipselector_selected_item_get @ptr
            end
            alias :selected_item :selected_item_get
        end
        #
        class ElmFlipSelectorItem < ElmObject
            #
            search_prefixes 'elm_flipselector_item_'
            #
        end
        #
        class ElmFrame < ElmObject
            #
            include Helper
            constructor :elm_frame_add
            search_prefixes 'elm_frame_'
        end
        #
        class ElmGenGrid < ElmObject
            #
            include Helper
            constructor :elm_gengrid_add
            search_prefixes 'elm_gengrid_'
        end
        #
        class ElmGenList < ElmObject
            #
            include Helper
            constructor :elm_genlist_add
            search_prefixes 'elm_genlist_'
            #
        end
        #
        class ElmGestureLayer < ElmObject
            #
            include Helper
            constructor :elm_gesture_layer_add
            search_prefixes 'elm_gesture_layer_'
        end
        #
        class ElmGlView < ElmObject
            #
            include Helper
            constructor :elm_glview_add
            search_prefixes 'elm_glview_'
            #
        end
        #
        class ElmGrid < ElmObject
            #
            include Helper
            constructor :elm_grid_add
            search_prefixes 'elm_grid_'
            #
        end
        #
        class ElmHover < ElmObject
            #
            include Helper
            constructor :elm_hover_add
            search_prefixes 'elm_hover_'
            #
        end
        #
        class ElmHoverSel < ElmObject
            #
            include Helper
            constructor :elm_hoversel_add
            search_prefixes 'elm_hoversel_'
            #
            def item_add label, icon_file=nil, icon_type=:elm_icon_none, cb=nil, data=nil
                ElmHoverselItem.new Native::elm_hoversel_item_add @ptr, label, icon_file, icon_type, cb, data
            end
        end
        #
        class ElmHoverSelItem < ElmObject
            #
            search_prefixes 'elm_hoversel_item_'
            #
        end
        #
        class ElmIcon < ElmObject
            #
            include Helper
            constructor :elm_icon_add
            search_prefixes 'elm_icon_'
            #
            def scale_set args
                Native.elm_icon_scale_set @ptr, *args
            end
            alias :scale= :scale_set
        end
        #
        class ElmImage < ElmObject
            #
            include Helper
            constructor :elm_image_add
            search_prefixes 'elm_image_'
            #
        end
        #
        class ElmIndex < ElmObject
            #
            include Helper
            constructor :elm_index_add
            search_prefixes 'elm_index_'
            #
        end
        #
        class ElmInWin < ElmObject
            #
            search_prefixes 'elm_win_inwin_', 'elm_win_'
            #
            def initialize parent, &block
                super Native.method(:elm_win_inwin_add), parent, &block
            end
            #
        end
        #
        class ElmLabel < ElmObject
            #
            include Helper
            constructor :elm_label_add
            search_prefixes 'elm_label_'
            #
        end
        #
        class ElmLayout < ElmObject
            #
            include Helper
            constructor :elm_layout_add
            search_prefixes 'elm_layout_'
            #
            def edje_get &block
                Efl::Edje::REdje.new Native.method(:elm_layout_edje_get), @ptr, &block
            end
            alias :edje :edje_get
        end
        #
        class ElmList < ElmObject
            #
            include Helper
            constructor :elm_list_add
            search_prefixes 'elm_list_'
            #
            def item_append label, left_icon=nil, right_icon=nil, cb=nil, data=nil
                ElmListItem.new Native::elm_list_item_append @ptr, label, left_icon, right_icon, cb, data
            end
        end
        #
        class ElmListItem < ElmObject
            #
            search_prefixes 'elm_list_item_'
            #
            def data_get
                Native::elm_list_item_data_get @ptr
            end
            alias :data :data_get
        end
        #
        class ElmMenu < ElmObject
            #
            include Helper
            constructor :elm_menu_add
            search_prefixes 'elm_menu_'
            #
        end
        #
        class ElmMenuItem < ElmObject
            #
            include Helper
            constructor :elm_menu_item_add
            search_prefixes 'elm_menu_item_'
            #
        end
        #
        class ElmMenuItemSeparator < ElmObject
            #
            include Helper
            constructor :elm_menu_item_separator_add
            search_prefixes 'elm_menu_item_separator_'
            #
        end
        #
        class ElmNaviFrame < ElmObject
            #
            include Helper
            constructor :elm_naviframe_add
            search_prefixes 'elm_naviframe_'
            #
        end
        #
        class ElmNotify < ElmObject
            #
            include Helper
            constructor :elm_notify_add
            search_prefixes 'elm_notify_'
            #
        end
        #
        class ElmPager < ElmObject
            #
            include Helper
            constructor :elm_pager_add
            search_prefixes 'elm_pager_'
            #
        end
        #
        class ElmPanel < ElmObject
            #
            include Helper
            constructor :elm_panel_add
            search_prefixes 'elm_panel_'
            #
        end
        #
        class ElmPanes < ElmObject
            #
            include Helper
            constructor :elm_panes_add
            search_prefixes 'elm_panes_'
            #
        end
        #
        class ElmPlayer < ElmObject
            #
            include Helper
            constructor :elm_player_add
            search_prefixes 'elm_player_'
            #
        end
        #
        class ElmPhoto < ElmObject
            #
            include Helper
            constructor :elm_photo_add
            search_prefixes 'elm_photo_'
        end
        #
        class ElmPhotoCam < ElmObject
            #
            include Helper
            constructor :elm_photocam_add
            search_prefixes 'elm_photocam_'
        end
        #
        class ElmProgressBar < ElmObject
            #
            include Helper
            constructor :elm_progressbar_add
            search_prefixes 'elm_progressbar_'
        end
        #
        class ElmRadio < ElmObject
            #
            include Helper
            constructor :elm_radio_add
            search_prefixes 'elm_radio_'
            #
        end
        #
        class ElmScroller < ElmObject
            #
            include Helper
            constructor :elm_scroller_add
            search_prefixes 'elm_scroller_'
            #
        end
        #
        class ElmSeparator < ElmObject
            #
            include Helper
            constructor :elm_separator_add
            search_prefixes 'elm_separator_'
            #
        end
        #
        class ElmSlider < ElmObject
            #
            include Helper
            constructor :elm_slider_add
            search_prefixes 'elm_slider_'
            #
        end
        #
        class ElmSlideshow < ElmObject
            #
            include Helper
            constructor :elm_slideshow_add
            search_prefixes 'elm_slideshow_'
            #
        end
        #
        class ElmSpinner < ElmObject
            #
            include Helper
            constructor :elm_spinner_add
            search_prefixes 'elm_spinner_'
            #
        end
        #
        class ElmTable < ElmObject
            #
            include Helper
            constructor :elm_table_add
            search_prefixes 'elm_table_'
        end
        #
        class ElmThumb < ElmObject
            #
            include Helper
            constructor :elm_thumb_add
            search_prefixes 'elm_thumb_'
        end
        #
        class ElmToolbar < ElmObject
            #
            include Helper
            constructor :elm_toolbar_add
            search_prefixes 'elm_toolbar_'
        end
        #
        class ElmVideo < ElmObject
            #
            include Helper
            constructor :elm_video_add
            search_prefixes 'elm_video_'
        end
        #
        class ElmWin < ElmObject
            #
            search_prefixes 'elm_win_'
            #
            def initialize parent, title, type=:elm_win_basic, &block
                super Native.method(:elm_win_add), parent, title, type, &block
            end
            def inwin_add
                ElmInWin.new @ptr
            end
            def screen_position_get
                x = FFI::MemoryPointer.new :int
                y = FFI::MemoryPointer.new :int
                Native.elm_win_screen_position_get @ptr, x, y
                [ x.read_int, y.read_int ]
            end
            alias :screen_position :screen_position_get
        end
        #
    end
end
#
# EOF