Module: CryptopunksGui::View::PreferencesDialog

Defined in:
app/view/preferences_dialog.rb

Instance Method Summary collapse

Instance Method Details

#preferences_dialog(root:, image:) ⇒ Object



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
# File 'app/view/preferences_dialog.rb', line 4

def preferences_dialog(root: , image: )
  toplevel(root) {
    title 'Preferences'
    width 1280
    height 700
    escapable true
    
    scrollbar_frame {
      label {
        grid row: 0, column: 0
        text ''
      }
      
      label {
        grid row: 0, column: 1
        text 'Collection Name'
      }
      
      label {
        grid row: 0, column: 2
        text 'URL'
        width 82
      }
      
      label {
        grid row: 0, column: 3
        text 'Width'
        width 3
      }
      
      label {
        grid row: 0, column: 4
        text 'Height'
        width 3
      }
      
      label {
        grid row: 0, column: 5
        text "Default\nZoom"
        width 3
      }
      
      label {
        grid row: 0, column: 6, column_span: 3
        text 'Actions'
      }
      
      image.collections_map.each_with_index do |pair, index|
        collection_name, collection_options = pair
        row = index + 1
        
        checkbutton { |cb|
          grid row: row, column: 0
          # TODO consider using hash_proxy object to bind more effectively
          variable <= [image.collections_map[collection_name], :enabled]
          
          on('command') do
            collection_options[:enabled] = cb.variable
          end
        }
        
        entry {
          grid row: row, column: 1
          text collection_name
        }
        
        entry {
          grid row: row, column: 2
          text collection_options[:url]
          width 82
        }
        
        spinbox {
          grid row: row, column: 3
          from 1
          to 512
          text collection_options[:width]
          width 3
        }
        
        spinbox {
          grid row: row, column: 4
          from 1
          to 512
          text collection_options[:height]
          width 3
        }
        
        spinbox {
          grid row: row, column: 5
          from 1
          to 72
          text collection_options[:default_zoom]
          width 3
        }
        
        button {
          grid row: row, column: 6
          text 'X'
          width 1
        }
        button {
          grid row: row, column: 7
          text '^'
          width 1
        }
        button {
          grid row: row, column: 8
          text 'v'
          width 1
        }
      end
    
      row = image.collections_map.keys.size + 1
      
      checkbutton {
        grid row: row, column: 0
        
      }
      
      entry {
        grid row: row, column: 1
        text ''
      }
      
      entry {
        grid row: row, column: 2
        text ''
        width 82
      }
      
      spinbox {
        grid row: row, column: 3
        from 1
        to 512
        text '24'
        width 3
      }
      
      spinbox {
        grid row: row, column: 4
        from 1
        to 512
        text '24'
        width 3
      }
      
      spinbox {
        grid row: row, column: 5
        from 1
        to 72
        text '12'
        width 3
      }
    }
    
    frame {
      button {
        text 'Reset'
        
        on('command') do
          image.initialize_collections_map(reset: true)
          # TODO cause an update to all collections
        end
      }
    }
  }
end