cocoawebview 0.5.0 → 0.7.0

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: b4a5dc8becbe3e08126dfc0c5920a10f73c7dc83c6dbd0498a61df08e716b198
4
- data.tar.gz: df179bc016e9c58461733d6b9aa1028f636dd95234781612406d0358731669e2
3
+ metadata.gz: 1eaad92103199618abce2cb57159fe668e574ec4027c6f3b5f5a1d509630bc42
4
+ data.tar.gz: 95871ddbcef856aae806203c7b30eb42b23a7ff7769e88e0e1a297bda6df3a17
5
5
  SHA512:
6
- metadata.gz: 2545e3fc29b1e863015317a9e8375534bfb98050475cac4ed52ccad54a0c9ee9604b6f1b36bc43510ec5b2428681228ae417788a006f4af3020b7d22253d2ed3
7
- data.tar.gz: 9173d6c094e3a87dfd6945b3c8f145f8f702d0264ff874d9279bd336d2ebdc76288a65ffb0259b2fdd61f8a5825f3cdadc852bf287d82a69f27795baeda3a670
6
+ metadata.gz: efc2abd762985a17d26b50021e98cd4ee78d5db1d2080794376f09331643e0119cb901f7937bd581a9eae586428b77c70b23b3f61a018ec199c6cd8d56114c48
7
+ data.tar.gz: a77f8969e8b8f647487485cdf3b2098fff4e5f0cfe26b6f16da03776b5d5576990ee3b3b2755bd3f2db5ddc838d66b2ce89076151a0fd66f992db4863e4b042f
@@ -11,7 +11,7 @@ VALUE nsapp_initialize(VALUE self);
11
11
  VALUE nsapp_run(VALUE self);
12
12
  VALUE nsapp_exit(VALUE self);
13
13
 
14
- VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons, VALUE delta_y);
14
+ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons, VALUE delta_y, VALUE hide_title_bar);
15
15
  VALUE webview_navigate(VALUE self, VALUE url);
16
16
  VALUE webview_show(VALUE self);
17
17
  VALUE webview_hide(VALUE self);
@@ -26,6 +26,7 @@ VALUE webview_center(VALUE self);
26
26
  VALUE webview_is_visible(VALUE self);
27
27
  VALUE webview_set_topmost(VALUE self, VALUE topmost);
28
28
  VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
29
+ VALUE webview_increase_normal_level(VALUE self, VALUE delta);
29
30
 
30
31
  @interface FileDropContainerView : NSView {
31
32
  VALUE rb_cocoawebview;
@@ -127,10 +128,11 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
127
128
  FileDropContainerView *fileDropView;
128
129
  int deltaY;
129
130
  }
131
+ - (void)increaseNormalLevel:(int)delta;
130
132
  - (void)setShouldMoveTitleButtons:(BOOL)flag;
131
133
  - (void)setDevTool:(BOOL)flag;
132
134
  - (void)setDeltaY:(int)dy;
133
- - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons deltaY:(int)dy;
135
+ - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons deltaY:(int)dy hideTitleBar:(BOOL)hideTitleBar;
134
136
  - (void)eval:(NSString*)code;
135
137
  - (void)navigate:(NSString*)url;
136
138
  - (void)setCocoaWebview:(VALUE)view;
@@ -138,7 +140,7 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
138
140
  @end
139
141
 
140
142
  @implementation CocoaWebview
141
- - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons deltaY:(int)dy {
143
+ - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons deltaY:(int)dy hideTitleBar:(BOOL)hideTitleBar{
142
144
  self = [super initWithContentRect:frame
143
145
  styleMask:style
144
146
  backing:NSBackingStoreBuffered
@@ -148,8 +150,12 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
148
150
  [self setTitle:@"My Custom Window"];
149
151
  [self setDevTool:flag];
150
152
  [self setDeltaY:dy];
151
- [self setTitlebarAppearsTransparent: YES];
152
- [self setTitleVisibility:NSWindowTitleHidden];
153
+ if (hideTitleBar) {
154
+ [self setTitlebarAppearsTransparent: YES];
155
+ [self setTitleVisibility:NSWindowTitleHidden];
156
+ } else {
157
+ [self setTitlebarAppearsTransparent: NO];
158
+ }
153
159
  [self addWebViewToWindow:self];
154
160
  [self setShouldMoveTitleButtons:moveTitleButtons];
155
161
  if (moveTitleButtons) {
@@ -163,6 +169,10 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
163
169
  return self;
164
170
  }
165
171
 
172
+ - (void)increaseNormalLevel:(int)delta {
173
+ [self setLevel:NSNormalWindowLevel + delta];
174
+ }
175
+
166
176
  - (void)setDeltaY:(int)dy {
167
177
  deltaY = dy;
168
178
  }
@@ -310,7 +320,7 @@ Init_cocoawebview(void)
310
320
 
311
321
  /* CocoaWebview */
312
322
  rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
313
- rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 4);
323
+ rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 5);
314
324
  rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
315
325
  rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
316
326
  rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
@@ -325,7 +335,7 @@ Init_cocoawebview(void)
325
335
  rb_define_method(rb_mCocoaWebviewClass, "visible?", webview_is_visible, 0);
326
336
  rb_define_method(rb_mCocoaWebviewClass, "set_topmost", webview_set_topmost, 1);
327
337
  rb_define_method(rb_mCocoaWebviewClass, "set_bg", webview_set_bg, 4);
328
-
338
+ rb_define_method(rb_mCocoaWebviewClass, "increase_normal_level", webview_increase_normal_level, 1);
329
339
  }
330
340
 
331
341
  VALUE nsapp_initialize(VALUE self) {
@@ -345,7 +355,7 @@ VALUE nsapp_exit(VALUE self) {
345
355
  [[NSApplication sharedApplication] terminate:nil];
346
356
  }
347
357
 
348
- VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons, VALUE delta_y) {
358
+ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons, VALUE delta_y, VALUE hide_title_bar) {
349
359
  rb_iv_set(self, "@var", rb_hash_new());
350
360
  rb_iv_set(self, "@bindings", rb_hash_new());
351
361
  BOOL flag = NO;
@@ -361,9 +371,15 @@ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_
361
371
  } else {
362
372
  c_move_title_buttons = NO;
363
373
  }
374
+ BOOL c_hide_title_bar = NO;
375
+ if (hide_title_bar == Qtrue) {
376
+ c_hide_title_bar = YES;
377
+ } else {
378
+ c_hide_title_bar = NO;
379
+ }
364
380
  int c_style = NUM2INT(style);
365
381
  int c_delta_y = NUM2INT(delta_y);
366
- CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style moveTitleButtons:c_move_title_buttons deltaY:c_delta_y];
382
+ CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style moveTitleButtons:c_move_title_buttons deltaY:c_delta_y hideTitleBar:c_hide_title_bar];
367
383
 
368
384
  [webview setReleasedWhenClosed:NO];
369
385
  [webview setCocoaWebview:self];
@@ -542,3 +558,12 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a) {
542
558
  alpha:c_a];
543
559
  [webview setBackgroundColor:rgbColor];
544
560
  }
561
+
562
+ VALUE webview_increase_normal_level(VALUE self, VALUE delta) {
563
+ VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
564
+ CocoaWebview *webview;
565
+ TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
566
+
567
+ int c_delta = NUM2INT(delta);
568
+ [webview increaseNormalLevel:c_delta];
569
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "0.5.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/cocoawebview.rb CHANGED
@@ -32,16 +32,18 @@ module CocoaWebview
32
32
  class CocoaWebview
33
33
  attr_accessor :callback
34
34
 
35
- def self.create(debug: false, min: true, resize: true, close: true, move_title_buttons: false, delta_y: 10, &block)
35
+ def self.create(debug: false, min: true, resize: true, close: true, move_title_buttons: false, delta_y: 10, hide_title_bar: true, &block)
36
36
  style = NSWindowStyleMaskTitled | NSWindowStyleMaskFullSizeContentView
37
37
 
38
38
  style = style | NSWindowStyleMaskMiniaturizable if min
39
39
  style = style | NSWindowStyleMaskResizable if resize
40
40
  style = style | NSWindowStyleMaskClosable if close
41
41
 
42
- style &= ~NSWindowStyleMaskFullScreen
42
+ if hide_title_bar
43
+ style &= ~NSWindowStyleMaskFullScreen
44
+ end
43
45
 
44
- webview = new(debug, style, move_title_buttons, delta_y)
46
+ webview = new(debug, style, move_title_buttons, delta_y, hide_title_bar)
45
47
  webview.callback = block
46
48
  webview
47
49
  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.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-10-16 00:00:00.000000000 Z
10
+ date: 2025-10-17 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Webview ruby binding for macOS
13
13
  email: