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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9f4a168ace8cc683153ac2792ec3f453ea966771f15d14f7087ed6e5b2ca9fa
4
- data.tar.gz: e2c86bb86c0fca2c9f2d915041e0bd7b5f81bb6412ef54ee8a60ce0a3db9b31e
3
+ metadata.gz: af5d4d2a057730847e5354f0edb5532d493d1a2e62ee9f0fe89b53bb9661169a
4
+ data.tar.gz: 31d27c9b34f8c51ea6221e64bf86e09ed316ad2c363ce33aafc2bab7ed975da5
5
5
  SHA512:
6
- metadata.gz: 2f811c8dafea57c643bc2dfcf65b9f60460ca9d2635c6e7840266a14d1cfe8a9553f7e606e0832f93f6923ae7787a9e6f81ad22b389e62e249151f4af5257953
7
- data.tar.gz: e8c9ce7a9edc78a19eb25a24d47cb465ae8624c59674121c8c65ba069e11bf927f9d9ddf1d3156d582ead94b6dee6d9682943179f61938b1c5ba7a1b88fcc63e
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
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
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.7
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-29 00:00:00.000000000 Z
10
+ date: 2025-06-30 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Webview ruby binding for macOS
13
13
  email: