cocoawebview 0.1.7 → 0.1.8
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 +4 -4
- data/ext/cocoawebview/cocoawebview.m +68 -1
- data/lib/cocoawebview/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af5d4d2a057730847e5354f0edb5532d493d1a2e62ee9f0fe89b53bb9661169a
|
4
|
+
data.tar.gz: 31d27c9b34f8c51ea6221e64bf86e09ed316ad2c363ce33aafc2bab7ed975da5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3e35eff72df95170073b749d45f1a0b2cfa38a9ad672b866ca3e79443e1198fbb875abaf8dd38ea6c97c20fe525457ef4302c4d0be1ef54ca8cd8dfa60891f3
|
7
|
+
data.tar.gz: e1114c1d94e0c602e4fa4535b1fef57d51ec6ec9eed367bdec666080ee297e4d4aba3196ceec3af421de42e6ac9b0effcfe4ca91254aff17a30adfb1f227c544
|
@@ -14,7 +14,10 @@ VALUE webview_initialize(VALUE self, VALUE debug);
|
|
14
14
|
VALUE webview_show(VALUE self);
|
15
15
|
VALUE webview_hide(VALUE self);
|
16
16
|
VALUE webview_eval(VALUE self, VALUE code);
|
17
|
-
|
17
|
+
VALUE webview_set_size(VALUE self, VALUE width, VALUE height);
|
18
|
+
VALUE webview_get_size(VALUE self);
|
19
|
+
VALUE webview_set_pos(VALUE self, VALUE x, VALUE y);
|
20
|
+
VALUE webview_get_pos(VALUE self);
|
18
21
|
|
19
22
|
@interface AppDelegate : NSObject <NSApplicationDelegate> {
|
20
23
|
VALUE app;
|
@@ -167,6 +170,10 @@ Init_cocoawebview(void)
|
|
167
170
|
rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
|
168
171
|
rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
|
169
172
|
rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
|
173
|
+
rb_define_method(rb_mCocoaWebviewClass, "set_size", webview_set_size, 2);
|
174
|
+
rb_define_method(rb_mCocoaWebviewClass, "get_size", webview_get_size, 0);
|
175
|
+
rb_define_method(rb_mCocoaWebviewClass, "set_pos", webview_set_pos, 2);
|
176
|
+
rb_define_method(rb_mCocoaWebviewClass, "get_pos", webview_get_pos, 0);
|
170
177
|
}
|
171
178
|
|
172
179
|
VALUE nsapp_initialize(VALUE self) {
|
@@ -228,3 +235,63 @@ VALUE webview_eval(VALUE self, VALUE code) {
|
|
228
235
|
|
229
236
|
[webview eval:js_code];
|
230
237
|
}
|
238
|
+
|
239
|
+
VALUE webview_set_size(VALUE self, VALUE width, VALUE height) {
|
240
|
+
int c_width = NUM2INT(width);
|
241
|
+
int c_height = NUM2INT(height);
|
242
|
+
|
243
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
244
|
+
CocoaWebview *webview;
|
245
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
246
|
+
|
247
|
+
NSRect frame = [webview frame];
|
248
|
+
frame.size = NSMakeSize(c_width, c_height);
|
249
|
+
[webview setFrame:frame display:YES];
|
250
|
+
}
|
251
|
+
|
252
|
+
VALUE webview_get_size(VALUE self) {
|
253
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
254
|
+
CocoaWebview *webview;
|
255
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
256
|
+
|
257
|
+
NSRect frame = [webview frame];
|
258
|
+
int width = (int)frame.size.width;
|
259
|
+
int height = (int)frame.size.height;
|
260
|
+
|
261
|
+
VALUE rb_width = INT2NUM(width);
|
262
|
+
VALUE rb_height = INT2NUM(height);
|
263
|
+
|
264
|
+
VALUE ary = rb_ary_new();
|
265
|
+
rb_ary_push(ary, rb_width);
|
266
|
+
rb_ary_push(ary, rb_height);
|
267
|
+
return ary;
|
268
|
+
}
|
269
|
+
|
270
|
+
VALUE webview_set_pos(VALUE self, VALUE x, VALUE y) {
|
271
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
272
|
+
CocoaWebview *webview;
|
273
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
274
|
+
|
275
|
+
int c_x = NUM2INT(x);
|
276
|
+
int c_y = NUM2INT(y);
|
277
|
+
|
278
|
+
NSPoint newOrigin = NSMakePoint(c_x, c_y);
|
279
|
+
[webview setFrameOrigin:newOrigin];
|
280
|
+
}
|
281
|
+
|
282
|
+
VALUE webview_get_pos(VALUE self) {
|
283
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
284
|
+
CocoaWebview *webview;
|
285
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
286
|
+
|
287
|
+
NSRect frame = [webview frame];
|
288
|
+
int x = frame.origin.x;
|
289
|
+
int y = frame.origin.y;
|
290
|
+
VALUE rb_x = INT2NUM(x);
|
291
|
+
VALUE rb_y = INT2NUM(y);
|
292
|
+
|
293
|
+
VALUE ary = rb_ary_new();
|
294
|
+
rb_ary_push(ary, rb_x);
|
295
|
+
rb_ary_push(ary, rb_y);
|
296
|
+
return ary;
|
297
|
+
}
|
data/lib/cocoawebview/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoawebview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy Jeff
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-06-
|
10
|
+
date: 2025-06-30 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: Webview ruby binding for macOS
|
13
13
|
email:
|