[vlc-commits] [Git][videolan/vlc][3.0.x] 5 commits: macosx: Set correct font for NSButton in extensions

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Apr 9 08:42:38 UTC 2022



Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC


Commits:
3d7ae99e by Marvin Scholz at 2022-04-09T06:59:59+00:00
macosx: Set correct font for NSButton in extensions

(cherry picked from commit f7c023b5cdb795f858428951ea686b748e516dfc)
Signed-off-by: Marvin Scholz <epirat07 at gmail.com>

- - - - -
c95425f1 by Marvin Scholz at 2022-04-09T06:59:59+00:00
macosx: Fix default font in extensions UI

Default to the system font for extension textfields, labels and
webviews.

(cherry picked from commit 222bc139ad6c92dda41aee35a5aa0a53b3d1d200)
Signed-off-by: Marvin Scholz <epirat07 at gmail.com>

- - - - -
5060fbf8 by Marvin Scholz at 2022-04-09T06:59:59+00:00
macosx: Make links in extension UI labels clickable

(cherry picked from commit e18cdcddbfd59ad49f5df3505af669f31e524101)
Signed-off-by: Marvin Scholz <epirat07 at gmail.com>

- - - - -
fa4cb723 by Marvin Scholz at 2022-04-09T06:59:59+00:00
macosx: Force arrow cursor for extension UI labels

Now that labels have to be selectable, force the cursor to the arrow
cursor instead of the text selection cursor.

(cherry picked from commit 4980447fd4e52291b6c8e5a5754ee8492f81ea2a)
Signed-off-by: Marvin Scholz <epirat07 at gmail.com>

- - - - -
4e17d578 by Marvin Scholz at 2022-04-09T06:59:59+00:00
macosx: Add missing EXTENSION_WIDGET_PASSWORD handling

(cherry picked from commit 2c0fa9d11015301b0fbb79ba2d831e86135382e5)
Signed-off-by: Marvin Scholz <epirat07 at gmail.com>

- - - - -


3 changed files:

- modules/gui/macosx/VLCExtensionsDialogProvider.m
- modules/gui/macosx/VLCUIWidgets.h
- modules/gui/macosx/VLCUIWidgets.m


Changes:

=====================================
modules/gui/macosx/VLCExtensionsDialogProvider.m
=====================================
@@ -55,10 +55,12 @@ static NSView *createControlFromWidget(extension_widget_t *widget, id self)
             }
             case EXTENSION_WIDGET_LABEL:
             {
-                NSTextField *field = [[NSTextField alloc] init];
+                VLCDialogLabel *field = [[VLCDialogLabel alloc] init];
                 [field setEditable:NO];
                 [field setBordered:NO];
                 [field setDrawsBackground:NO];
+                [field setAllowsEditingTextAttributes:YES];
+                [field setSelectable:YES];
                 [field setFont:[NSFont systemFontOfSize:0]];
                 [[field cell] setControlSize:NSRegularControlSize];
                 [field setAutoresizingMask:NSViewNotSizable];
@@ -74,6 +76,17 @@ static NSView *createControlFromWidget(extension_widget_t *widget, id self)
                 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(syncTextField:)  name:NSControlTextDidChangeNotification object:field];
                 return field;
             }
+            case EXTENSION_WIDGET_PASSWORD:
+            {
+                VLCDialogSecureTextField *field = [[VLCDialogSecureTextField alloc] init];
+                [field setWidget:widget];
+                [field setAutoresizingMask:NSViewWidthSizable];
+                [field setFont:[NSFont systemFontOfSize:0]];
+                [[field cell] setControlSize:NSRegularControlSize];
+                [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(syncTextField:)  name:NSControlTextDidChangeNotification object:field];
+                return field;
+            }
+
             case EXTENSION_WIDGET_CHECK_BOX:
             {
                 VLCDialogButton *button = [[VLCDialogButton alloc] init];
@@ -81,6 +94,7 @@ static NSView *createControlFromWidget(extension_widget_t *widget, id self)
                 [button setWidget:widget];
                 [button setAction:@selector(triggerClick:)];
                 [button setTarget:self];
+                [button setFont:[NSFont systemFontOfSize:0.0]];
                 [[button cell] setControlSize:NSRegularControlSize];
                 [button setAutoresizingMask:NSViewWidthSizable];
                 return button;
@@ -92,6 +106,7 @@ static NSView *createControlFromWidget(extension_widget_t *widget, id self)
                 [button setWidget:widget];
                 [button setAction:@selector(triggerClick:)];
                 [button setTarget:self];
+                [button setFont:[NSFont systemFontOfSize:0.0]];
                 [[button cell] setControlSize:NSRegularControlSize];
                 [button setAutoresizingMask:NSViewNotSizable];
                 return button;
@@ -149,13 +164,16 @@ static NSView *createControlFromWidget(extension_widget_t *widget, id self)
 static void updateControlFromWidget(NSView *control, extension_widget_t *widget, id self)
 {
     @autoreleasepool {
+        NSString * const defaultStyleCSS = @"<style>*{ font-family: \
+            -apple-system-body, -apple-system, \
+            HelveticaNeue, Arial, sans-serif; }</style>";
         switch (widget->type) {
             case EXTENSION_WIDGET_HTML:
             {
                 // Get the web view
                 assert([control isKindOfClass:[WebView class]]);
                 WebView *webView = (WebView *)control;
-                NSString *string = toNSStr(widget->psz_text);
+                NSString *string = [defaultStyleCSS stringByAppendingString:toNSStr(widget->psz_text)];
                 [[webView mainFrame] loadHTMLString:string baseURL:[NSURL URLWithString:@""]];
                 [webView setNeedsDisplay:YES];
                 break;
@@ -168,7 +186,7 @@ static void updateControlFromWidget(NSView *control, extension_widget_t *widget,
                     break;
                 assert([control isKindOfClass:[NSControl class]]);
                 NSControl *field = (NSControl *)control;
-                NSString *string = toNSStr(widget->psz_text);
+                NSString *string = [defaultStyleCSS stringByAppendingString:toNSStr(widget->psz_text)];
                 NSAttributedString *attrString = [[NSAttributedString alloc] initWithHTML:[string dataUsingEncoding: NSISOLatin1StringEncoding] documentAttributes:NULL];
                 [field setAttributedStringValue:attrString];
                 break;
@@ -308,9 +326,17 @@ static void extensionDialogCallback(extension_dialog_t *p_ext_dialog,
 - (void)syncTextField:(NSNotification *)notifcation
 {
     id sender = [notifcation object];
-    assert([sender isKindOfClass:[VLCDialogTextField class]]);
-    VLCDialogTextField *field = sender;
-    extension_widget_t *widget = [field widget];
+    assert([sender isKindOfClass:[VLCDialogTextField class]] ||
+        [sender isKindOfClass:[VLCDialogSecureTextField class]]);
+    NSTextField *field = sender;
+    extension_widget_t *widget;
+
+    if ([sender isKindOfClass:[VLCDialogTextField class]])
+        widget = [(VLCDialogTextField*)field widget];
+    else if ([sender isKindOfClass:[VLCDialogSecureTextField class]])
+        widget = [(VLCDialogSecureTextField*)field widget];
+    else
+        return;
 
     vlc_mutex_lock(&widget->p_dialog->lock);
     free(widget->psz_text);


=====================================
modules/gui/macosx/VLCUIWidgets.h
=====================================
@@ -35,10 +35,17 @@
 @property (readwrite) extension_widget_t *widget;
 @end
 
+ at interface VLCDialogLabel : NSTextField
+ at end
+
 @interface VLCDialogTextField : NSTextField
 @property (readwrite) extension_widget_t *widget;
 @end
 
+ at interface VLCDialogSecureTextField : NSSecureTextField
+ at property (readwrite) extension_widget_t *widget;
+ at end
+
 @interface VLCDialogWindow : NSWindow
 @property (readwrite) extension_dialog_t *dialog;
 @property (readwrite) BOOL has_lock;


=====================================
modules/gui/macosx/VLCUIWidgets.m
=====================================
@@ -42,6 +42,17 @@
 @end
 
 
+ at implementation VLCDialogSecureTextField
+
+ at end
+
+
+ at implementation VLCDialogLabel
+- (void)resetCursorRects {
+    [self addCursorRect:[self bounds] cursor:[NSCursor arrowCursor]];
+}
+ at end
+
 @implementation VLCDialogWindow
 
 @end



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cb39c3b56d314120aa86a4402a1d013c432f487f...4e17d578b44d49350a172efcdb3161a12929c62f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cb39c3b56d314120aa86a4402a1d013c432f487f...4e17d578b44d49350a172efcdb3161a12929c62f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list