]> git.sesse.net Git - vlc/commitdiff
*: fix alignment of widgets.
authorJérome Decoodt <djc@videolan.org>
Sat, 7 May 2005 01:12:16 +0000 (01:12 +0000)
committerJérome Decoodt <djc@videolan.org>
Sat, 7 May 2005 01:12:16 +0000 (01:12 +0000)
- What shall we do for files and module list ?
- Why is there a space after "Audio viualization" in src/libvlc.h ?

modules/gui/macosx/prefs.m
modules/gui/macosx/prefs_widgets.h
modules/gui/macosx/prefs_widgets.m

index 875d1766b12e2668b8342dbd48f6e8c88019881b..e5d64dec2943808d4e87ec2f19aae940670d8f93 100644 (file)
@@ -97,7 +97,6 @@ static VLCPrefs *_o_sharedMainInstance = nil;
     [o_prefs_view setBorderType: NSGrooveBorder];
     [o_prefs_view setHasVerticalScroller: YES];
     [o_prefs_view setDrawsBackground: NO];
-    [o_prefs_view setRulersVisible: NO];
     [o_prefs_view setDocumentView: o_empty_view];
     [o_tree selectRow:0 byExtendingSelection:NO];
 }
@@ -469,9 +468,11 @@ fprintf( stderr, "[%s] showView\n", [o_name UTF8String] );
 
     s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
     o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
-    [o_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+    [o_view setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin |
+                                    NSViewMaxYMargin];
 
-/* Create all subviews if it isn't already done because we cannot use setHiden for MacOS < 10.3*/
+/* Create all subviews if it isn't already done because we cannot use */
+/* setHiden for MacOS < 10.3*/
     if( o_subviews == nil )
     {
         intf_thread_t   *p_intf = VLCIntf;
@@ -618,11 +619,21 @@ fprintf( stderr, "%s (%d)", p_item->psz_name, p_item->i_type );
     {
         int i_lastItem = 0;
         int i_yPos = -2;
-        unsigned int i;
-        for( i = 0 ; i < [o_subviews count] ; i++ )
+        int i_max_label = 0;
+        NSEnumerator *enumerator = [o_subviews objectEnumerator];
+        VLCConfigControl *o_widget;
+        NSRect o_frame;
+        
+        while( ( o_widget = [enumerator nextObject] ) )
+            if( ( [o_widget isAdvanced] ) && (! b_advanced) )
+                continue;
+            else if( i_max_label < [o_widget getLabelSize] )
+                i_max_label = [o_widget getLabelSize];
+
+        enumerator = [o_subviews objectEnumerator];
+        while( ( o_widget = [enumerator nextObject] ) )
         {
             int i_widget;
-            VLCConfigControl *o_widget = [o_subviews objectAtIndex:i];
             if( ( [o_widget isAdvanced] ) && (! b_advanced) )
                 continue;
 
@@ -630,12 +641,20 @@ fprintf( stderr, "%s (%d)", p_item->psz_name, p_item->i_type );
             i_yPos += [VLCConfigControl calcVerticalMargin:i_widget
                 lastItem:i_lastItem];
             [o_widget setYPos:i_yPos];
+            o_frame = [o_widget frame];
+            o_frame.size.width = [o_view frame].size.width -
+                                    LEFTMARGIN - RIGHTMARGIN;
+            [o_widget setFrame:o_frame];
+            [o_widget alignWithXPosition: i_max_label];
             i_yPos += [o_widget frame].size.height;
             i_lastItem = i_widget;
             [o_view addSubview:o_widget];
          }
-
+        o_frame = [o_view frame];
+        o_frame.size.height = i_yPos;
+        [o_view setFrame:o_frame];
         [o_prefs_view setDocumentView:o_view];
+
     }
     return o_view;
 }
index f1c1ef0005c54eb34852fc00591955e7d4928fb9..f533cb9ddc8bbc769fb84a75ed13f8a9a0fbb787 100644 (file)
@@ -25,9 +25,8 @@
 #define CONFIG_ITEM_RANGED_INTEGER (CONFIG_ITEM_INTEGER + 1)
 #define CONFIG_ITEM_KEY_BEFORE_10_3 (CONFIG_ITEM_KEY + 1)
 #define CONFIG_ITEM_KEY_AFTER_10_3 (CONFIG_ITEM_KEY + 2)
-#define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
-            @"/System/Library/CoreServices/SystemVersion.plist"] \
-            objectForKey: @"ProductVersion"] floatValue]
+#define LEFTMARGIN  18
+#define RIGHTMARGIN 18
 
 @interface VLCConfigControl : NSView
 {
@@ -51,6 +50,8 @@
 - (float)floatValue;
 - (char *)stringValue;
 - (void)applyChanges;
+- (int)getLabelSize;
+- (void) alignWithXPosition:(int)i_xPos;
 static NSMenu   *o_keys_menu = nil;
 
 + (int)calcVerticalMargin: (int)i_curItem lastItem:(int)i_lastItem;
index 4096111797ccd8b923d590ae00ffd7f2d00c3297..18c98fb5de9e53765ea4e9e60423c5406fe23fc7 100644 (file)
@@ -38,8 +38,9 @@
 #define OFFSET_RIGHT 20
 #define OFFSET_BETWEEN 2
 
-#define LEFTMARGIN  18
-#define RIGHTMARGIN 18
+#define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
+            @"/System/Library/CoreServices/SystemVersion.plist"] \
+            objectForKey: @"ProductVersion"] floatValue]
 
 #define UPWARDS_WHITE_ARROW                 "\xE2\x87\xA7" 
 #define OPTION_KEY                          "\xE2\x8C\xA5"
@@ -383,23 +384,6 @@ if( MACOS_VERSION >= 10.3 )                                                 \
     [o_checkbox sizeToFit];                                                 \
 }
 
-#define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
-    tooltip, init_value, position )                                         \
-{                                                                           \
-    NSRect s_rc = superFrame;                                               \
-    s_rc.size.height = 18;                                                  \
-    s_rc.origin.x = x_offset - 2;                                           \
-    s_rc.origin.y = superFrame.size.height - 18 + my_y_offset;              \
-    o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain];           \
-    [o_checkbox setFont:[NSFont systemFontOfSize:0]];                       \
-    [o_checkbox setButtonType: NSSwitchButton];                             \
-    [o_checkbox setImagePosition: position];                                \
-    [o_checkbox setIntValue: init_value];                                   \
-    [o_checkbox setTitle: label];                                           \
-    [o_checkbox setToolTip: tooltip];                                       \
-    [o_checkbox sizeToFit];                                                 \
-}
-
 @implementation VLCConfigControl
 - (id)initWithFrame: (NSRect)frame
 {
@@ -676,37 +660,37 @@ if( MACOS_VERSION >= 10.3 )                                                 \
         switch( i_lastItem )
         {
         case CONFIG_ITEM_STRING:
-            i_margin = 6;
+            i_margin = 10;
             break;
         case CONFIG_ITEM_STRING_LIST:
-            i_margin = 5;
+            i_margin = 9;
             break;
         case CONFIG_ITEM_FILE:
-            i_margin = 4;
+            i_margin = 8;
             break;
         case CONFIG_ITEM_MODULE:
-            i_margin = 2;
+            i_margin = 6;
             break;
         case CONFIG_ITEM_INTEGER:
-            i_margin = 5;
+            i_margin = 9;
             break;
         case CONFIG_ITEM_RANGED_INTEGER:
-            i_margin = 3;
+            i_margin = 7;
             break;
         case CONFIG_ITEM_BOOL:
-            i_margin = 3;
+            i_margin = 7;
             break;
         case CONFIG_ITEM_KEY_BEFORE_10_3:
-            i_margin = 3;
+            i_margin = 7;
             break;
         case CONFIG_ITEM_KEY_AFTER_10_3:
-            i_margin = 2;
+            i_margin = 5;
             break;
         case CONFIG_ITEM_MODULE_LIST:
-            i_margin = 6;
+            i_margin = 10;
             break;
         default:
-            i_margin = 18;
+            i_margin = 20;
             break;
         }
         break;
@@ -993,6 +977,11 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
         break;
     }
 }
+
+- (int)getLabelSize
+{
+    return [o_label frame].size.width;
+}
 @end
 
 @implementation StringConfigControl
@@ -1037,9 +1026,22 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    NSRect superFrame = [self frame];
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_textfield frame];
+    frame.origin.x = i_xPos + 2;
+    frame.size.width = superFrame.size.width - frame.origin.x - 1;
+    [o_textfield setFrame:frame];
+}
+
 - (void)dealloc
 {
-    [o_label release];
     [o_textfield release];
     [super dealloc];
 }
@@ -1092,6 +1094,20 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    NSRect superFrame = [self frame];
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_combo frame];
+    frame.origin.x = i_xPos + 2;
+    frame.size.width = superFrame.size.width - frame.origin.x + 2;
+    [o_combo setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_combo release];
@@ -1181,6 +1197,11 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    ;
+}
+
 - (void)dealloc
 {
     [o_textfield release];
@@ -1316,6 +1337,20 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    NSRect superFrame = [self frame];
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_popup frame];
+    frame.origin.x = i_xPos - 1;
+    frame.size.width = superFrame.size.width - frame.origin.x + 2;
+    [o_popup setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_popup release];
@@ -1402,7 +1437,7 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
                                 localizedString: p_item->psz_text];
         else
             o_labelString = [NSString stringWithString:@""];
-        ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
+        ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
         [o_label setAutoresizingMask:NSViewNotSizable ];
         [self addSubview: o_label];
 
@@ -1410,7 +1445,7 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
         ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
             0, o_tooltip, -1600, 1600)
         [o_stepper setIntValue: p_item->i_value];
-        [o_stepper setAutoresizingMask:NSViewMinXMargin ];
+        [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
         [self addSubview: o_stepper];
 
         /* build the textfield */
@@ -1427,12 +1462,28 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
             selector: @selector(textfieldChanged:)
             name: NSControlTextDidChangeNotification
             object: o_textfield];
-        [o_textfield setAutoresizingMask:NSViewMinXMargin ];
+        [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
         [self addSubview: o_textfield];
     }
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_textfield frame];
+    frame.origin.x = i_xPos + 2;
+    [o_textfield setFrame:frame];
+
+    frame = [o_stepper frame];
+    frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
+    [o_stepper setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_stepper release];
@@ -1503,6 +1554,20 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    NSRect superFrame = [self frame];
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_combo frame];
+    frame.origin.x = i_xPos + 2;
+    frame.size.width = superFrame.size.width - frame.origin.x + 2;
+    [o_combo setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_combo release];
@@ -1578,6 +1643,7 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
         ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
         [o_textfield_min setIntValue: p_item->i_min];
         [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
+        [o_textfield_min setAlignment:NSRightTextAlignment];
         [self addSubview: o_textfield_min];
 
         /* build the maxtextfield */
@@ -1606,6 +1672,18 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_textfield frame];
+    frame.origin.x = i_xPos + 2;
+    [o_textfield setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_textfield release];
@@ -1664,7 +1742,7 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
         ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
             0, o_tooltip, -1600, 1600)
         [o_stepper setFloatValue: p_item->f_value];
-        [o_stepper setAutoresizingMask:NSViewMinXMargin ];
+        [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
         [self addSubview: o_stepper];
 
         /* build the textfield */
@@ -1681,12 +1759,28 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
             selector: @selector(textfieldChanged:)
             name: NSControlTextDidChangeNotification
             object: o_textfield];
-        [o_textfield setAutoresizingMask:NSViewMinXMargin ];
+        [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
         [self addSubview: o_textfield];
     }
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_textfield frame];
+    frame.origin.x = i_xPos + 2;
+    [o_textfield setFrame:frame];
+
+    frame = [o_stepper frame];
+    frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
+    [o_stepper setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_stepper release];
@@ -1754,6 +1848,7 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
         ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
         [o_textfield_min setFloatValue: p_item->f_min];
         [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
+        [o_textfield_min setAlignment:NSRightTextAlignment];
         [self addSubview: o_textfield_min];
 
         /* build the maxtextfield */
@@ -1782,6 +1877,18 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_textfield frame];
+    frame.origin.x = i_xPos + 2;
+    [o_textfield setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_textfield release];
@@ -1824,23 +1931,39 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     {
         i_view_type = CONFIG_ITEM_BOOL;
 
-        /* add the checkbox */
+        /* add the label */
         if( p_item->psz_text )
             o_labelString = [[VLCMain sharedInstance]
                                 localizedString: p_item->psz_text];
         else
             o_labelString = [NSString stringWithString:@""];
+        ADD_LABEL( o_label, mainFrame, 0, 0, o_labelString )
+        [o_label setAutoresizingMask:NSViewNotSizable ];
+        [self addSubview: o_label];
+        /* add the checkbox */
         o_tooltip = [[VLCMain sharedInstance]
             wrapString: [[VLCMain sharedInstance]
             localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
-        ADD_CHECKBOX( o_checkbox, mainFrame, 0, 0, o_labelString,
-            o_tooltip, p_item->i_value, NSImageRight)
+        ADD_CHECKBOX( o_checkbox, mainFrame, [o_label frame].size.width,
+                        0, @"", o_tooltip, p_item->i_value, NSImageLeft)
         [o_checkbox setAutoresizingMask:NSViewNotSizable ];
         [self addSubview: o_checkbox];
     }
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_checkbox frame];
+    frame.origin.x = i_xPos;
+    [o_checkbox setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_checkbox release];
@@ -1941,6 +2064,39 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    NSRect superFrame = [self frame];
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_cmd_checkbox frame];
+    frame.origin.x = i_xPos;
+    [o_cmd_checkbox setFrame:frame];
+
+    frame = [o_ctrl_checkbox frame];
+    frame.origin.x = [o_cmd_checkbox frame].size.width +
+                        [o_cmd_checkbox frame].origin.x + 4;
+    [o_ctrl_checkbox setFrame:frame];
+
+    frame = [o_alt_checkbox frame];
+    frame.origin.x = i_xPos;
+    [o_alt_checkbox setFrame:frame];
+
+    frame = [o_shift_checkbox frame];
+    frame.origin.x = [o_cmd_checkbox frame].size.width +
+                        [o_cmd_checkbox frame].origin.x + 4;
+    [o_shift_checkbox setFrame:frame];
+
+    frame = [o_popup frame];
+    frame.origin.x = [o_shift_checkbox frame].origin.x +
+                        [o_shift_checkbox frame].size.width + 3;
+    frame.size.width = superFrame.size.width - frame.origin.x + 2;
+    [o_popup setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_cmd_checkbox release];
@@ -2021,6 +2177,20 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    NSRect frame;
+    NSRect superFrame = [self frame];
+    frame = [o_label frame];
+    frame.origin.x = i_xPos - frame.size.width - 3;
+    [o_label setFrame:frame];
+
+    frame = [o_popup frame];
+    frame.origin.x = i_xPos - 1;
+    frame.size.width = superFrame.size.width - frame.origin.x + 2;
+    [o_popup setFrame:frame];
+}
+
 - (void)dealloc
 {
     [o_popup release];
@@ -2178,6 +2348,11 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
     return self;
 }
 
+- (void) alignWithXPosition:(int)i_xPos
+{
+    ;
+}
+
 - (IBAction)tableChanged:(id)sender
 {
     NSString *o_newstring = @"";