diff foosdk/sdk/foobar2000/helpers-mac/NSComboBox+fb2k.mm @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/foosdk/sdk/foobar2000/helpers-mac/NSComboBox+fb2k.mm	Mon Jan 05 02:15:46 2026 -0500
@@ -0,0 +1,23 @@
+#import "NSComboBox+fb2k.h"
+
+namespace fb2k {
+    void comboSetupHistory(NSComboBox * box, cfg_dropdown_history & var) {
+        [box removeAllItems];
+        pfc::string8 temp; var.get_state( temp );
+        NSString * str = [NSString stringWithUTF8String: temp.c_str()];
+        if ( str.length == 0 ) return;
+        NSArray * arr = [str componentsSeparatedByCharactersInSet: NSCharacterSet.newlineCharacterSet];
+        if ( arr.count == 0 ) return;
+        for( NSString * str in arr ) {
+            if ( str.length > 0 ) [box addItemWithObjectValue: str];
+        }
+        box.stringValue = arr.firstObject;
+        
+        [box.menu addItem: NSMenuItem.separatorItem];
+    }
+
+    void comboAddToHistory(NSComboBox * box, cfg_dropdown_history & var) {
+        NSString * str = box.stringValue;
+        if ( str.length > 0 ) var.add_item( str.UTF8String );
+    }
+} // namespace fb2k