cocoawebview 0.2.10 → 0.3.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: bf110ec9ea94b5606dbaa5636e433a90d270658858a8aaa0cd9d119b2d214712
4
- data.tar.gz: f44dcefabcf6dcc713cec9be86fd79888eedca31a9d921de046518707d18687b
3
+ metadata.gz: a6429fedf1d1f28dd4375f23a4874920db7df15a3ad1b8385ae97332315f9031
4
+ data.tar.gz: 2697a99cd838afd93bf2af09c9a5d32e94ca596685149d53cab3735249b4d8f4
5
5
  SHA512:
6
- metadata.gz: 7397d6370ce8eac4393adb458f2a83d51fe98730b4836a2497843b4df2c33d900695471f3735236b14db7539c789b6d7fe547705833eae613d275cdb06558ee7
7
- data.tar.gz: fa1400d3b9337b9263fbbab762d887882b21fe3c8498a9c673a485ff0bd1640703df5b1006f565fb93c5f2904d8fee5a532ca4b59cd2ce09ed923fd3f4bdf6e3
6
+ metadata.gz: 4cdd3cd1510626f4ae76f0ed65005e3d934d6ce6dfb35a490ec3e2293be6fe2b740427f7add14642c6566769d8d688e6f64f866ca1dbdb7442d6e025739e1bd2
7
+ data.tar.gz: 7ca9097dbfecace2f6bdbfb42674d2d8ec8ae52751dc2a1e4b79ec04415ffc7d1deb71c3e0e220c22399751c241789a8c063a428a34f3299460540be716707b4
@@ -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);
14
+ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons);
15
15
  VALUE webview_show(VALUE self);
16
16
  VALUE webview_hide(VALUE self);
17
17
  VALUE webview_eval(VALUE self, VALUE code);
@@ -45,16 +45,18 @@ VALUE webview_set_topmost(VALUE self, VALUE topmost);
45
45
  WKWebView *webView;
46
46
  VALUE rb_cocoawebview;
47
47
  BOOL showDevTool;
48
+ BOOL shouldMoveTitleButtons;
48
49
  }
50
+ - (void)setShouldMoveTitleButtons:(BOOL)flag;
49
51
  - (void)setDevTool:(BOOL)flag;
50
- - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style;
52
+ - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons;
51
53
  - (void)eval:(NSString*)code;
52
54
  - (void)setCocoaWebview:(VALUE)view;
53
55
  - (void)dragging;
54
56
  @end
55
57
 
56
58
  @implementation CocoaWebview
57
- - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style{
59
+ - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons{
58
60
  self = [super initWithContentRect:frame
59
61
  styleMask:style
60
62
  backing:NSBackingStoreBuffered
@@ -66,10 +68,42 @@ VALUE webview_set_topmost(VALUE self, VALUE topmost);
66
68
  [self setTitlebarAppearsTransparent: YES];
67
69
  [self setTitleVisibility:NSWindowTitleHidden];
68
70
  [self addWebViewToWindow:self];
71
+ [self setShouldMoveTitleButtons:moveTitleButtons];
72
+ if (moveTitleButtons) {
73
+ [self moveWindowButtonsForWindow:self];
74
+ }
75
+ [[NSNotificationCenter defaultCenter] addObserver:self
76
+ selector:@selector(windowDidResize:)
77
+ name:NSWindowDidResizeNotification
78
+ object:self];
69
79
  }
70
80
  return self;
71
81
  }
72
82
 
83
+ - (void)setShouldMoveTitleButtons:(BOOL)flag {
84
+ shouldMoveTitleButtons = flag;
85
+ }
86
+
87
+ - (void)windowDidResize:(NSNotification *)notification {
88
+ if (shouldMoveTitleButtons) {
89
+ [self moveWindowButtonsForWindow:self];
90
+ }
91
+ }
92
+
93
+ - (void)moveWindowButtonsForWindow:(NSWindow *)window {
94
+ //Close Button
95
+ NSButton *closeButton = [window standardWindowButton:NSWindowCloseButton];
96
+ [closeButton setFrameOrigin:NSMakePoint(closeButton.frame.origin.x + 10, closeButton.frame.origin.y - 10)];
97
+
98
+ //Minimize Button
99
+ NSButton *minimizeButton = [window standardWindowButton:NSWindowMiniaturizeButton];
100
+ [minimizeButton setFrameOrigin:NSMakePoint(minimizeButton.frame.origin.x + 10, minimizeButton.frame.origin.y - 10)];
101
+
102
+ //Zoom Button
103
+ NSButton *zoomButton = [window standardWindowButton:NSWindowZoomButton];
104
+ [zoomButton setFrameOrigin:NSMakePoint(zoomButton.frame.origin.x + 10, zoomButton.frame.origin.y - 10)];
105
+ }
106
+
73
107
  - (void)close {
74
108
  [self orderOut:nil]; // Hide instead of destroy
75
109
  }
@@ -177,7 +211,7 @@ Init_cocoawebview(void)
177
211
 
178
212
  /* CocoaWebview */
179
213
  rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
180
- rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 2);
214
+ rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 3);
181
215
  rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
182
216
  rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
183
217
  rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
@@ -210,7 +244,7 @@ VALUE nsapp_exit(VALUE self) {
210
244
  [[NSApplication sharedApplication] terminate:nil];
211
245
  }
212
246
 
213
- VALUE webview_initialize(VALUE self, VALUE debug, VALUE style) {
247
+ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons) {
214
248
  rb_iv_set(self, "@var", rb_hash_new());
215
249
  rb_iv_set(self, "@bindings", rb_hash_new());
216
250
  BOOL flag = NO;
@@ -220,8 +254,14 @@ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style) {
220
254
  flag = NO;
221
255
  }
222
256
 
257
+ BOOL c_move_title_buttons = NO;
258
+ if (move_title_buttons == Qtrue) {
259
+ c_move_title_buttons = YES;
260
+ } else {
261
+ c_move_title_buttons = NO;
262
+ }
223
263
  int c_style = NUM2INT(style);
224
- CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style];
264
+ CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style moveTitleButtons:c_move_title_buttons];
225
265
 
226
266
  [webview setReleasedWhenClosed:NO];
227
267
  [webview setCocoaWebview:self];
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "0.2.10"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/cocoawebview.rb CHANGED
@@ -24,7 +24,7 @@ module CocoaWebview
24
24
  class CocoaWebview
25
25
  attr_accessor :callback
26
26
 
27
- def self.create(debug: false, min: true, resize: true, close: true, &block)
27
+ def self.create(debug: false, min: true, resize: true, close: true, move_title_buttons: false, &block)
28
28
  style = NSWindowStyleMaskTitled | NSWindowStyleMaskFullSizeContentView
29
29
 
30
30
  style = style | NSWindowStyleMaskMiniaturizable if min
@@ -33,7 +33,7 @@ module CocoaWebview
33
33
 
34
34
  style &= ~NSWindowStyleMaskFullScreen
35
35
 
36
- webview = new(debug, style)
36
+ webview = new(debug, style, move_title_buttons)
37
37
  webview.callback = block
38
38
  webview
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoawebview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff