cocoawebview 0.1.7 → 0.1.9
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 +84 -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: 67dea26836b578972cb64aa402855e157adc34db292a5efa20492a3d30a9a758
|
4
|
+
data.tar.gz: 983bd44da2e1a7dcd3f18b3792677c613cfe710ef95331d2efbfc05df73a2aca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab51c9514cdf7186675f94bc7e152e58d149033f1bf1243eb82bea31ad88afa84058d66788ae72b761987b338c442f2fad953c999dc501069875bb4afd0f98fb
|
7
|
+
data.tar.gz: 7b0f01438d1d13487a5e23a0356c699d7f32d0e315aaa76232cd6b843ea12d9e550316044018eec9f69e2af2114292f34cb63c71e3c0fdf2e99b5c1bc9cc4d4e
|
@@ -14,7 +14,11 @@ 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);
|
21
|
+
VALUE webview_dragging(VALUE self);
|
18
22
|
|
19
23
|
@interface AppDelegate : NSObject <NSApplicationDelegate> {
|
20
24
|
VALUE app;
|
@@ -41,6 +45,7 @@ VALUE webview_eval(VALUE self, VALUE code);
|
|
41
45
|
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag;
|
42
46
|
- (void)eval:(NSString*)code;
|
43
47
|
- (void)setCocoaWebview:(VALUE)view;
|
48
|
+
- (void)dragging;
|
44
49
|
@end
|
45
50
|
|
46
51
|
@implementation CocoaWebview
|
@@ -71,6 +76,11 @@ VALUE webview_eval(VALUE self, VALUE code);
|
|
71
76
|
[notification.object orderOut:nil];
|
72
77
|
}
|
73
78
|
|
79
|
+
- (void)dragging {
|
80
|
+
NSEvent *event = [NSApp currentEvent];
|
81
|
+
[self performWindowDragWithEvent:event];
|
82
|
+
}
|
83
|
+
|
74
84
|
- (void)userContentController:(WKUserContentController *)userContentController
|
75
85
|
didReceiveScriptMessage:(WKScriptMessage *)message {
|
76
86
|
if ([message.name isEqualToString:@"native"]) {
|
@@ -167,6 +177,11 @@ Init_cocoawebview(void)
|
|
167
177
|
rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
|
168
178
|
rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
|
169
179
|
rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
|
180
|
+
rb_define_method(rb_mCocoaWebviewClass, "set_size", webview_set_size, 2);
|
181
|
+
rb_define_method(rb_mCocoaWebviewClass, "get_size", webview_get_size, 0);
|
182
|
+
rb_define_method(rb_mCocoaWebviewClass, "set_pos", webview_set_pos, 2);
|
183
|
+
rb_define_method(rb_mCocoaWebviewClass, "get_pos", webview_get_pos, 0);
|
184
|
+
rb_define_method(rb_mCocoaWebviewClass, "dragging", webview_dragging, 0);
|
170
185
|
}
|
171
186
|
|
172
187
|
VALUE nsapp_initialize(VALUE self) {
|
@@ -228,3 +243,71 @@ VALUE webview_eval(VALUE self, VALUE code) {
|
|
228
243
|
|
229
244
|
[webview eval:js_code];
|
230
245
|
}
|
246
|
+
|
247
|
+
VALUE webview_set_size(VALUE self, VALUE width, VALUE height) {
|
248
|
+
int c_width = NUM2INT(width);
|
249
|
+
int c_height = NUM2INT(height);
|
250
|
+
|
251
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
252
|
+
CocoaWebview *webview;
|
253
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
254
|
+
|
255
|
+
NSRect frame = [webview frame];
|
256
|
+
frame.size = NSMakeSize(c_width, c_height);
|
257
|
+
[webview setFrame:frame display:YES];
|
258
|
+
}
|
259
|
+
|
260
|
+
VALUE webview_get_size(VALUE self) {
|
261
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
262
|
+
CocoaWebview *webview;
|
263
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
264
|
+
|
265
|
+
NSRect frame = [webview frame];
|
266
|
+
int width = (int)frame.size.width;
|
267
|
+
int height = (int)frame.size.height;
|
268
|
+
|
269
|
+
VALUE rb_width = INT2NUM(width);
|
270
|
+
VALUE rb_height = INT2NUM(height);
|
271
|
+
|
272
|
+
VALUE ary = rb_ary_new();
|
273
|
+
rb_ary_push(ary, rb_width);
|
274
|
+
rb_ary_push(ary, rb_height);
|
275
|
+
return ary;
|
276
|
+
}
|
277
|
+
|
278
|
+
VALUE webview_set_pos(VALUE self, VALUE x, VALUE y) {
|
279
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
280
|
+
CocoaWebview *webview;
|
281
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
282
|
+
|
283
|
+
int c_x = NUM2INT(x);
|
284
|
+
int c_y = NUM2INT(y);
|
285
|
+
|
286
|
+
NSPoint newOrigin = NSMakePoint(c_x, c_y);
|
287
|
+
[webview setFrameOrigin:newOrigin];
|
288
|
+
}
|
289
|
+
|
290
|
+
VALUE webview_get_pos(VALUE self) {
|
291
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
292
|
+
CocoaWebview *webview;
|
293
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
294
|
+
|
295
|
+
NSRect frame = [webview frame];
|
296
|
+
int x = frame.origin.x;
|
297
|
+
int y = frame.origin.y;
|
298
|
+
VALUE rb_x = INT2NUM(x);
|
299
|
+
VALUE rb_y = INT2NUM(y);
|
300
|
+
|
301
|
+
VALUE ary = rb_ary_new();
|
302
|
+
rb_ary_push(ary, rb_x);
|
303
|
+
rb_ary_push(ary, rb_y);
|
304
|
+
return ary;
|
305
|
+
}
|
306
|
+
|
307
|
+
VALUE webview_dragging(VALUE self) {
|
308
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
309
|
+
CocoaWebview *webview;
|
310
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
311
|
+
|
312
|
+
[webview dragging];
|
313
|
+
}
|
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.9
|
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:
|