├── .gitignore ├── Example ├── VMMultiHandleSlider.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── VMMultiHandleSlider │ ├── Base.lproj │ │ └── MainMenu.xib │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── VMAppDelegate.h │ ├── VMAppDelegate.m │ ├── VMMultiHandleSlider-Info.plist │ ├── VMMultiHandleSlider-Prefix.pch │ ├── en.lproj │ │ ├── Credits.rtf │ │ └── InfoPlist.strings │ ├── hud_slider-knobBlack-N.tiff │ ├── hud_slider-knobBlack-N@2x.tiff │ ├── hud_slider-knobGray-N.tiff │ ├── hud_slider-knobGray-N@2x.tiff │ ├── hud_slider-knobWhite-N.tiff │ ├── hud_slider-knobWhite-N@2x.tiff │ └── main.m └── VMMultiHandleSliderTests │ ├── VMMultiHandleSliderTests-Info.plist │ ├── VMMultiHandleSliderTests.m │ └── en.lproj │ └── InfoPlist.strings ├── LICENSE ├── README.md ├── Screenshot.png ├── VMMultiHandleSlider ├── VMMultiHandleSlider.h └── VMMultiHandleSlider.m └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DFF0A855196BF7AA007C4C97 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFF0A854196BF7AA007C4C97 /* Cocoa.framework */; }; 11 | DFF0A85F196BF7AA007C4C97 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A85D196BF7AA007C4C97 /* InfoPlist.strings */; }; 12 | DFF0A861196BF7AA007C4C97 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF0A860196BF7AA007C4C97 /* main.m */; }; 13 | DFF0A865196BF7AA007C4C97 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A863196BF7AA007C4C97 /* Credits.rtf */; }; 14 | DFF0A868196BF7AA007C4C97 /* VMAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF0A867196BF7AA007C4C97 /* VMAppDelegate.m */; }; 15 | DFF0A86B196BF7AA007C4C97 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A869196BF7AA007C4C97 /* MainMenu.xib */; }; 16 | DFF0A86D196BF7AA007C4C97 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A86C196BF7AA007C4C97 /* Images.xcassets */; }; 17 | DFF0A874196BF7AA007C4C97 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFF0A873196BF7AA007C4C97 /* XCTest.framework */; }; 18 | DFF0A875196BF7AA007C4C97 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFF0A854196BF7AA007C4C97 /* Cocoa.framework */; }; 19 | DFF0A87D196BF7AA007C4C97 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A87B196BF7AA007C4C97 /* InfoPlist.strings */; }; 20 | DFF0A87F196BF7AA007C4C97 /* VMMultiHandleSliderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF0A87E196BF7AA007C4C97 /* VMMultiHandleSliderTests.m */; }; 21 | DFF0A88B196BF7C5007C4C97 /* VMMultiHandleSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF0A88A196BF7C5007C4C97 /* VMMultiHandleSlider.m */; }; 22 | DFF0A89E196C1627007C4C97 /* hud_slider-knobBlack-N.tiff in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A898196C1627007C4C97 /* hud_slider-knobBlack-N.tiff */; }; 23 | DFF0A89F196C1627007C4C97 /* hud_slider-knobBlack-N@2x.tiff in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A899196C1627007C4C97 /* hud_slider-knobBlack-N@2x.tiff */; }; 24 | DFF0A8A0196C1627007C4C97 /* hud_slider-knobGray-N.tiff in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A89A196C1627007C4C97 /* hud_slider-knobGray-N.tiff */; }; 25 | DFF0A8A1196C1627007C4C97 /* hud_slider-knobGray-N@2x.tiff in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A89B196C1627007C4C97 /* hud_slider-knobGray-N@2x.tiff */; }; 26 | DFF0A8A2196C1627007C4C97 /* hud_slider-knobWhite-N.tiff in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A89C196C1627007C4C97 /* hud_slider-knobWhite-N.tiff */; }; 27 | DFF0A8A3196C1627007C4C97 /* hud_slider-knobWhite-N@2x.tiff in Resources */ = {isa = PBXBuildFile; fileRef = DFF0A89D196C1627007C4C97 /* hud_slider-knobWhite-N@2x.tiff */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXContainerItemProxy section */ 31 | DFF0A876196BF7AA007C4C97 /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = DFF0A849196BF7AA007C4C97 /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = DFF0A850196BF7AA007C4C97; 36 | remoteInfo = VMMultiHandleSlider; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | DFF0A851196BF7AA007C4C97 /* VMMultiHandleSlider.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VMMultiHandleSlider.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | DFF0A854196BF7AA007C4C97 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 43 | DFF0A857196BF7AA007C4C97 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 44 | DFF0A858196BF7AA007C4C97 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 45 | DFF0A859196BF7AA007C4C97 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 46 | DFF0A85C196BF7AA007C4C97 /* VMMultiHandleSlider-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "VMMultiHandleSlider-Info.plist"; sourceTree = ""; }; 47 | DFF0A85E196BF7AA007C4C97 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 48 | DFF0A860196BF7AA007C4C97 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 49 | DFF0A862196BF7AA007C4C97 /* VMMultiHandleSlider-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "VMMultiHandleSlider-Prefix.pch"; sourceTree = ""; }; 50 | DFF0A864196BF7AA007C4C97 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; 51 | DFF0A866196BF7AA007C4C97 /* VMAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VMAppDelegate.h; sourceTree = ""; }; 52 | DFF0A867196BF7AA007C4C97 /* VMAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VMAppDelegate.m; sourceTree = ""; }; 53 | DFF0A86A196BF7AA007C4C97 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 54 | DFF0A86C196BF7AA007C4C97 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 55 | DFF0A872196BF7AA007C4C97 /* VMMultiHandleSliderTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VMMultiHandleSliderTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | DFF0A873196BF7AA007C4C97 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 57 | DFF0A87A196BF7AA007C4C97 /* VMMultiHandleSliderTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "VMMultiHandleSliderTests-Info.plist"; sourceTree = ""; }; 58 | DFF0A87C196BF7AA007C4C97 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 59 | DFF0A87E196BF7AA007C4C97 /* VMMultiHandleSliderTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VMMultiHandleSliderTests.m; sourceTree = ""; }; 60 | DFF0A889196BF7C5007C4C97 /* VMMultiHandleSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMMultiHandleSlider.h; sourceTree = ""; }; 61 | DFF0A88A196BF7C5007C4C97 /* VMMultiHandleSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VMMultiHandleSlider.m; sourceTree = ""; }; 62 | DFF0A898196C1627007C4C97 /* hud_slider-knobBlack-N.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "hud_slider-knobBlack-N.tiff"; sourceTree = ""; }; 63 | DFF0A899196C1627007C4C97 /* hud_slider-knobBlack-N@2x.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "hud_slider-knobBlack-N@2x.tiff"; sourceTree = ""; }; 64 | DFF0A89A196C1627007C4C97 /* hud_slider-knobGray-N.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "hud_slider-knobGray-N.tiff"; sourceTree = ""; }; 65 | DFF0A89B196C1627007C4C97 /* hud_slider-knobGray-N@2x.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "hud_slider-knobGray-N@2x.tiff"; sourceTree = ""; }; 66 | DFF0A89C196C1627007C4C97 /* hud_slider-knobWhite-N.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "hud_slider-knobWhite-N.tiff"; sourceTree = ""; }; 67 | DFF0A89D196C1627007C4C97 /* hud_slider-knobWhite-N@2x.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "hud_slider-knobWhite-N@2x.tiff"; sourceTree = ""; }; 68 | /* End PBXFileReference section */ 69 | 70 | /* Begin PBXFrameworksBuildPhase section */ 71 | DFF0A84E196BF7AA007C4C97 /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | DFF0A855196BF7AA007C4C97 /* Cocoa.framework in Frameworks */, 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | DFF0A86F196BF7AA007C4C97 /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | DFF0A875196BF7AA007C4C97 /* Cocoa.framework in Frameworks */, 84 | DFF0A874196BF7AA007C4C97 /* XCTest.framework in Frameworks */, 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | /* End PBXFrameworksBuildPhase section */ 89 | 90 | /* Begin PBXGroup section */ 91 | DFF0A848196BF7AA007C4C97 = { 92 | isa = PBXGroup; 93 | children = ( 94 | DFF0A85A196BF7AA007C4C97 /* VMMultiHandleSlider */, 95 | DFF0A878196BF7AA007C4C97 /* VMMultiHandleSliderTests */, 96 | DFF0A853196BF7AA007C4C97 /* Frameworks */, 97 | DFF0A852196BF7AA007C4C97 /* Products */, 98 | ); 99 | sourceTree = ""; 100 | }; 101 | DFF0A852196BF7AA007C4C97 /* Products */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | DFF0A851196BF7AA007C4C97 /* VMMultiHandleSlider.app */, 105 | DFF0A872196BF7AA007C4C97 /* VMMultiHandleSliderTests.xctest */, 106 | ); 107 | name = Products; 108 | sourceTree = ""; 109 | }; 110 | DFF0A853196BF7AA007C4C97 /* Frameworks */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | DFF0A854196BF7AA007C4C97 /* Cocoa.framework */, 114 | DFF0A873196BF7AA007C4C97 /* XCTest.framework */, 115 | DFF0A856196BF7AA007C4C97 /* Other Frameworks */, 116 | ); 117 | name = Frameworks; 118 | sourceTree = ""; 119 | }; 120 | DFF0A856196BF7AA007C4C97 /* Other Frameworks */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | DFF0A857196BF7AA007C4C97 /* AppKit.framework */, 124 | DFF0A858196BF7AA007C4C97 /* CoreData.framework */, 125 | DFF0A859196BF7AA007C4C97 /* Foundation.framework */, 126 | ); 127 | name = "Other Frameworks"; 128 | sourceTree = ""; 129 | }; 130 | DFF0A85A196BF7AA007C4C97 /* VMMultiHandleSlider */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | DFF0A888196BF7AE007C4C97 /* View */, 134 | DFF0A866196BF7AA007C4C97 /* VMAppDelegate.h */, 135 | DFF0A867196BF7AA007C4C97 /* VMAppDelegate.m */, 136 | DFF0A869196BF7AA007C4C97 /* MainMenu.xib */, 137 | DFF0A86C196BF7AA007C4C97 /* Images.xcassets */, 138 | DFF0A898196C1627007C4C97 /* hud_slider-knobBlack-N.tiff */, 139 | DFF0A899196C1627007C4C97 /* hud_slider-knobBlack-N@2x.tiff */, 140 | DFF0A89A196C1627007C4C97 /* hud_slider-knobGray-N.tiff */, 141 | DFF0A89B196C1627007C4C97 /* hud_slider-knobGray-N@2x.tiff */, 142 | DFF0A89C196C1627007C4C97 /* hud_slider-knobWhite-N.tiff */, 143 | DFF0A89D196C1627007C4C97 /* hud_slider-knobWhite-N@2x.tiff */, 144 | DFF0A85B196BF7AA007C4C97 /* Supporting Files */, 145 | ); 146 | path = VMMultiHandleSlider; 147 | sourceTree = ""; 148 | }; 149 | DFF0A85B196BF7AA007C4C97 /* Supporting Files */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | DFF0A85C196BF7AA007C4C97 /* VMMultiHandleSlider-Info.plist */, 153 | DFF0A85D196BF7AA007C4C97 /* InfoPlist.strings */, 154 | DFF0A860196BF7AA007C4C97 /* main.m */, 155 | DFF0A862196BF7AA007C4C97 /* VMMultiHandleSlider-Prefix.pch */, 156 | DFF0A863196BF7AA007C4C97 /* Credits.rtf */, 157 | ); 158 | name = "Supporting Files"; 159 | sourceTree = ""; 160 | }; 161 | DFF0A878196BF7AA007C4C97 /* VMMultiHandleSliderTests */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | DFF0A87E196BF7AA007C4C97 /* VMMultiHandleSliderTests.m */, 165 | DFF0A879196BF7AA007C4C97 /* Supporting Files */, 166 | ); 167 | path = VMMultiHandleSliderTests; 168 | sourceTree = ""; 169 | }; 170 | DFF0A879196BF7AA007C4C97 /* Supporting Files */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | DFF0A87A196BF7AA007C4C97 /* VMMultiHandleSliderTests-Info.plist */, 174 | DFF0A87B196BF7AA007C4C97 /* InfoPlist.strings */, 175 | ); 176 | name = "Supporting Files"; 177 | sourceTree = ""; 178 | }; 179 | DFF0A888196BF7AE007C4C97 /* View */ = { 180 | isa = PBXGroup; 181 | children = ( 182 | DFF0A889196BF7C5007C4C97 /* VMMultiHandleSlider.h */, 183 | DFF0A88A196BF7C5007C4C97 /* VMMultiHandleSlider.m */, 184 | ); 185 | name = View; 186 | path = ../../VMMultiHandleSlider; 187 | sourceTree = ""; 188 | }; 189 | /* End PBXGroup section */ 190 | 191 | /* Begin PBXNativeTarget section */ 192 | DFF0A850196BF7AA007C4C97 /* VMMultiHandleSlider */ = { 193 | isa = PBXNativeTarget; 194 | buildConfigurationList = DFF0A882196BF7AA007C4C97 /* Build configuration list for PBXNativeTarget "VMMultiHandleSlider" */; 195 | buildPhases = ( 196 | DFF0A84D196BF7AA007C4C97 /* Sources */, 197 | DFF0A84E196BF7AA007C4C97 /* Frameworks */, 198 | DFF0A84F196BF7AA007C4C97 /* Resources */, 199 | ); 200 | buildRules = ( 201 | ); 202 | dependencies = ( 203 | ); 204 | name = VMMultiHandleSlider; 205 | productName = VMMultiHandleSlider; 206 | productReference = DFF0A851196BF7AA007C4C97 /* VMMultiHandleSlider.app */; 207 | productType = "com.apple.product-type.application"; 208 | }; 209 | DFF0A871196BF7AA007C4C97 /* VMMultiHandleSliderTests */ = { 210 | isa = PBXNativeTarget; 211 | buildConfigurationList = DFF0A885196BF7AA007C4C97 /* Build configuration list for PBXNativeTarget "VMMultiHandleSliderTests" */; 212 | buildPhases = ( 213 | DFF0A86E196BF7AA007C4C97 /* Sources */, 214 | DFF0A86F196BF7AA007C4C97 /* Frameworks */, 215 | DFF0A870196BF7AA007C4C97 /* Resources */, 216 | ); 217 | buildRules = ( 218 | ); 219 | dependencies = ( 220 | DFF0A877196BF7AA007C4C97 /* PBXTargetDependency */, 221 | ); 222 | name = VMMultiHandleSliderTests; 223 | productName = VMMultiHandleSliderTests; 224 | productReference = DFF0A872196BF7AA007C4C97 /* VMMultiHandleSliderTests.xctest */; 225 | productType = "com.apple.product-type.bundle.unit-test"; 226 | }; 227 | /* End PBXNativeTarget section */ 228 | 229 | /* Begin PBXProject section */ 230 | DFF0A849196BF7AA007C4C97 /* Project object */ = { 231 | isa = PBXProject; 232 | attributes = { 233 | CLASSPREFIX = VM; 234 | LastUpgradeCheck = 0510; 235 | ORGANIZATIONNAME = "Void Main"; 236 | TargetAttributes = { 237 | DFF0A871196BF7AA007C4C97 = { 238 | TestTargetID = DFF0A850196BF7AA007C4C97; 239 | }; 240 | }; 241 | }; 242 | buildConfigurationList = DFF0A84C196BF7AA007C4C97 /* Build configuration list for PBXProject "VMMultiHandleSlider" */; 243 | compatibilityVersion = "Xcode 3.2"; 244 | developmentRegion = English; 245 | hasScannedForEncodings = 0; 246 | knownRegions = ( 247 | en, 248 | Base, 249 | ); 250 | mainGroup = DFF0A848196BF7AA007C4C97; 251 | productRefGroup = DFF0A852196BF7AA007C4C97 /* Products */; 252 | projectDirPath = ""; 253 | projectRoot = ""; 254 | targets = ( 255 | DFF0A850196BF7AA007C4C97 /* VMMultiHandleSlider */, 256 | DFF0A871196BF7AA007C4C97 /* VMMultiHandleSliderTests */, 257 | ); 258 | }; 259 | /* End PBXProject section */ 260 | 261 | /* Begin PBXResourcesBuildPhase section */ 262 | DFF0A84F196BF7AA007C4C97 /* Resources */ = { 263 | isa = PBXResourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | DFF0A89E196C1627007C4C97 /* hud_slider-knobBlack-N.tiff in Resources */, 267 | DFF0A8A0196C1627007C4C97 /* hud_slider-knobGray-N.tiff in Resources */, 268 | DFF0A85F196BF7AA007C4C97 /* InfoPlist.strings in Resources */, 269 | DFF0A8A2196C1627007C4C97 /* hud_slider-knobWhite-N.tiff in Resources */, 270 | DFF0A86D196BF7AA007C4C97 /* Images.xcassets in Resources */, 271 | DFF0A865196BF7AA007C4C97 /* Credits.rtf in Resources */, 272 | DFF0A86B196BF7AA007C4C97 /* MainMenu.xib in Resources */, 273 | DFF0A8A3196C1627007C4C97 /* hud_slider-knobWhite-N@2x.tiff in Resources */, 274 | DFF0A8A1196C1627007C4C97 /* hud_slider-knobGray-N@2x.tiff in Resources */, 275 | DFF0A89F196C1627007C4C97 /* hud_slider-knobBlack-N@2x.tiff in Resources */, 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | DFF0A870196BF7AA007C4C97 /* Resources */ = { 280 | isa = PBXResourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | DFF0A87D196BF7AA007C4C97 /* InfoPlist.strings in Resources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | /* End PBXResourcesBuildPhase section */ 288 | 289 | /* Begin PBXSourcesBuildPhase section */ 290 | DFF0A84D196BF7AA007C4C97 /* Sources */ = { 291 | isa = PBXSourcesBuildPhase; 292 | buildActionMask = 2147483647; 293 | files = ( 294 | DFF0A861196BF7AA007C4C97 /* main.m in Sources */, 295 | DFF0A868196BF7AA007C4C97 /* VMAppDelegate.m in Sources */, 296 | DFF0A88B196BF7C5007C4C97 /* VMMultiHandleSlider.m in Sources */, 297 | ); 298 | runOnlyForDeploymentPostprocessing = 0; 299 | }; 300 | DFF0A86E196BF7AA007C4C97 /* Sources */ = { 301 | isa = PBXSourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | DFF0A87F196BF7AA007C4C97 /* VMMultiHandleSliderTests.m in Sources */, 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | }; 308 | /* End PBXSourcesBuildPhase section */ 309 | 310 | /* Begin PBXTargetDependency section */ 311 | DFF0A877196BF7AA007C4C97 /* PBXTargetDependency */ = { 312 | isa = PBXTargetDependency; 313 | target = DFF0A850196BF7AA007C4C97 /* VMMultiHandleSlider */; 314 | targetProxy = DFF0A876196BF7AA007C4C97 /* PBXContainerItemProxy */; 315 | }; 316 | /* End PBXTargetDependency section */ 317 | 318 | /* Begin PBXVariantGroup section */ 319 | DFF0A85D196BF7AA007C4C97 /* InfoPlist.strings */ = { 320 | isa = PBXVariantGroup; 321 | children = ( 322 | DFF0A85E196BF7AA007C4C97 /* en */, 323 | ); 324 | name = InfoPlist.strings; 325 | sourceTree = ""; 326 | }; 327 | DFF0A863196BF7AA007C4C97 /* Credits.rtf */ = { 328 | isa = PBXVariantGroup; 329 | children = ( 330 | DFF0A864196BF7AA007C4C97 /* en */, 331 | ); 332 | name = Credits.rtf; 333 | sourceTree = ""; 334 | }; 335 | DFF0A869196BF7AA007C4C97 /* MainMenu.xib */ = { 336 | isa = PBXVariantGroup; 337 | children = ( 338 | DFF0A86A196BF7AA007C4C97 /* Base */, 339 | ); 340 | name = MainMenu.xib; 341 | sourceTree = ""; 342 | }; 343 | DFF0A87B196BF7AA007C4C97 /* InfoPlist.strings */ = { 344 | isa = PBXVariantGroup; 345 | children = ( 346 | DFF0A87C196BF7AA007C4C97 /* en */, 347 | ); 348 | name = InfoPlist.strings; 349 | sourceTree = ""; 350 | }; 351 | /* End PBXVariantGroup section */ 352 | 353 | /* Begin XCBuildConfiguration section */ 354 | DFF0A880196BF7AA007C4C97 /* Debug */ = { 355 | isa = XCBuildConfiguration; 356 | buildSettings = { 357 | ALWAYS_SEARCH_USER_PATHS = NO; 358 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 359 | CLANG_CXX_LIBRARY = "libc++"; 360 | CLANG_ENABLE_MODULES = YES; 361 | CLANG_ENABLE_OBJC_ARC = YES; 362 | CLANG_WARN_BOOL_CONVERSION = YES; 363 | CLANG_WARN_CONSTANT_CONVERSION = YES; 364 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 365 | CLANG_WARN_EMPTY_BODY = YES; 366 | CLANG_WARN_ENUM_CONVERSION = YES; 367 | CLANG_WARN_INT_CONVERSION = YES; 368 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 369 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 370 | COPY_PHASE_STRIP = NO; 371 | GCC_C_LANGUAGE_STANDARD = gnu99; 372 | GCC_DYNAMIC_NO_PIC = NO; 373 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 374 | GCC_OPTIMIZATION_LEVEL = 0; 375 | GCC_PREPROCESSOR_DEFINITIONS = ( 376 | "DEBUG=1", 377 | "$(inherited)", 378 | ); 379 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 380 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 381 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 382 | GCC_WARN_UNDECLARED_SELECTOR = YES; 383 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 384 | GCC_WARN_UNUSED_FUNCTION = YES; 385 | GCC_WARN_UNUSED_VARIABLE = YES; 386 | MACOSX_DEPLOYMENT_TARGET = 10.9; 387 | ONLY_ACTIVE_ARCH = YES; 388 | SDKROOT = macosx; 389 | }; 390 | name = Debug; 391 | }; 392 | DFF0A881196BF7AA007C4C97 /* Release */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | ALWAYS_SEARCH_USER_PATHS = NO; 396 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 397 | CLANG_CXX_LIBRARY = "libc++"; 398 | CLANG_ENABLE_MODULES = YES; 399 | CLANG_ENABLE_OBJC_ARC = YES; 400 | CLANG_WARN_BOOL_CONVERSION = YES; 401 | CLANG_WARN_CONSTANT_CONVERSION = YES; 402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 407 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 408 | COPY_PHASE_STRIP = YES; 409 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 410 | ENABLE_NS_ASSERTIONS = NO; 411 | GCC_C_LANGUAGE_STANDARD = gnu99; 412 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 413 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 414 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 415 | GCC_WARN_UNDECLARED_SELECTOR = YES; 416 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 417 | GCC_WARN_UNUSED_FUNCTION = YES; 418 | GCC_WARN_UNUSED_VARIABLE = YES; 419 | MACOSX_DEPLOYMENT_TARGET = 10.9; 420 | SDKROOT = macosx; 421 | }; 422 | name = Release; 423 | }; 424 | DFF0A883196BF7AA007C4C97 /* Debug */ = { 425 | isa = XCBuildConfiguration; 426 | buildSettings = { 427 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 428 | COMBINE_HIDPI_IMAGES = YES; 429 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 430 | GCC_PREFIX_HEADER = "VMMultiHandleSlider/VMMultiHandleSlider-Prefix.pch"; 431 | INFOPLIST_FILE = "VMMultiHandleSlider/VMMultiHandleSlider-Info.plist"; 432 | PRODUCT_NAME = "$(TARGET_NAME)"; 433 | WRAPPER_EXTENSION = app; 434 | }; 435 | name = Debug; 436 | }; 437 | DFF0A884196BF7AA007C4C97 /* Release */ = { 438 | isa = XCBuildConfiguration; 439 | buildSettings = { 440 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 441 | COMBINE_HIDPI_IMAGES = YES; 442 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 443 | GCC_PREFIX_HEADER = "VMMultiHandleSlider/VMMultiHandleSlider-Prefix.pch"; 444 | INFOPLIST_FILE = "VMMultiHandleSlider/VMMultiHandleSlider-Info.plist"; 445 | PRODUCT_NAME = "$(TARGET_NAME)"; 446 | WRAPPER_EXTENSION = app; 447 | }; 448 | name = Release; 449 | }; 450 | DFF0A886196BF7AA007C4C97 /* Debug */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/VMMultiHandleSlider.app/Contents/MacOS/VMMultiHandleSlider"; 454 | COMBINE_HIDPI_IMAGES = YES; 455 | FRAMEWORK_SEARCH_PATHS = ( 456 | "$(DEVELOPER_FRAMEWORKS_DIR)", 457 | "$(inherited)", 458 | ); 459 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 460 | GCC_PREFIX_HEADER = "VMMultiHandleSlider/VMMultiHandleSlider-Prefix.pch"; 461 | GCC_PREPROCESSOR_DEFINITIONS = ( 462 | "DEBUG=1", 463 | "$(inherited)", 464 | ); 465 | INFOPLIST_FILE = "VMMultiHandleSliderTests/VMMultiHandleSliderTests-Info.plist"; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | TEST_HOST = "$(BUNDLE_LOADER)"; 468 | WRAPPER_EXTENSION = xctest; 469 | }; 470 | name = Debug; 471 | }; 472 | DFF0A887196BF7AA007C4C97 /* Release */ = { 473 | isa = XCBuildConfiguration; 474 | buildSettings = { 475 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/VMMultiHandleSlider.app/Contents/MacOS/VMMultiHandleSlider"; 476 | COMBINE_HIDPI_IMAGES = YES; 477 | FRAMEWORK_SEARCH_PATHS = ( 478 | "$(DEVELOPER_FRAMEWORKS_DIR)", 479 | "$(inherited)", 480 | ); 481 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 482 | GCC_PREFIX_HEADER = "VMMultiHandleSlider/VMMultiHandleSlider-Prefix.pch"; 483 | INFOPLIST_FILE = "VMMultiHandleSliderTests/VMMultiHandleSliderTests-Info.plist"; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | TEST_HOST = "$(BUNDLE_LOADER)"; 486 | WRAPPER_EXTENSION = xctest; 487 | }; 488 | name = Release; 489 | }; 490 | /* End XCBuildConfiguration section */ 491 | 492 | /* Begin XCConfigurationList section */ 493 | DFF0A84C196BF7AA007C4C97 /* Build configuration list for PBXProject "VMMultiHandleSlider" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | DFF0A880196BF7AA007C4C97 /* Debug */, 497 | DFF0A881196BF7AA007C4C97 /* Release */, 498 | ); 499 | defaultConfigurationIsVisible = 0; 500 | defaultConfigurationName = Release; 501 | }; 502 | DFF0A882196BF7AA007C4C97 /* Build configuration list for PBXNativeTarget "VMMultiHandleSlider" */ = { 503 | isa = XCConfigurationList; 504 | buildConfigurations = ( 505 | DFF0A883196BF7AA007C4C97 /* Debug */, 506 | DFF0A884196BF7AA007C4C97 /* Release */, 507 | ); 508 | defaultConfigurationIsVisible = 0; 509 | defaultConfigurationName = Release; 510 | }; 511 | DFF0A885196BF7AA007C4C97 /* Build configuration list for PBXNativeTarget "VMMultiHandleSliderTests" */ = { 512 | isa = XCConfigurationList; 513 | buildConfigurations = ( 514 | DFF0A886196BF7AA007C4C97 /* Debug */, 515 | DFF0A887196BF7AA007C4C97 /* Release */, 516 | ); 517 | defaultConfigurationIsVisible = 0; 518 | defaultConfigurationName = Release; 519 | }; 520 | /* End XCConfigurationList section */ 521 | }; 522 | rootObject = DFF0A849196BF7AA007C4C97 /* Project object */; 523 | } 524 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | Default 540 | 541 | 542 | 543 | 544 | 545 | 546 | Left to Right 547 | 548 | 549 | 550 | 551 | 552 | 553 | Right to Left 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | Default 565 | 566 | 567 | 568 | 569 | 570 | 571 | Left to Right 572 | 573 | 574 | 575 | 576 | 577 | 578 | Right to Left 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/VMAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // VMAppDelegate.h 3 | // VMMultiHandleSlider 4 | // 5 | // Created by Sun Peng on 7/8/14. 6 | // Copyright (c) 2014 Void Main. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class VMMultiHandleSlider; 12 | @interface VMAppDelegate : NSObject 13 | 14 | @property (assign) IBOutlet NSWindow *window; 15 | @property (weak) IBOutlet VMMultiHandleSlider *multiHandleSlider; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/VMAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // VMAppDelegate.m 3 | // VMMultiHandleSlider 4 | // 5 | // Created by Sun Peng on 7/8/14. 6 | // Copyright (c) 2014 Void Main. All rights reserved. 7 | // 8 | 9 | #import "VMAppDelegate.h" 10 | #import "VMMultiHandleSlider.h" 11 | 12 | @implementation VMAppDelegate 13 | 14 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 15 | { 16 | [self.multiHandleSlider addHandle:@"High" 17 | image:[NSImage imageNamed:@"hud_slider-knobWhite-N"] 18 | initRatio:1.0 19 | valueBlock:^float(float inVal) { 20 | return inVal; 21 | } 22 | invValueBlock:^float(float inVal) { 23 | return inVal; 24 | } 25 | ]; 26 | 27 | [self.multiHandleSlider addHandle:@"Low" 28 | image:[NSImage imageNamed:@"hud_slider-knobBlack-N"] 29 | initRatio:0.0 30 | valueBlock:^float(float inVal) { 31 | return inVal; 32 | } 33 | invValueBlock:^float(float inVal) { 34 | return inVal; 35 | } 36 | ]; 37 | 38 | [self.multiHandleSlider addHandle:@"Gamma" 39 | image:[NSImage imageNamed:@"hud_slider-knobGray-N"] 40 | initRatio:0.5 41 | valueBlock:^float(float inVal) { 42 | return inVal * 2; 43 | } 44 | invValueBlock:^float(float inVal) { 45 | return inVal / 2; 46 | } 47 | ]; 48 | 49 | [self.multiHandleSlider setValueChangedBlock:^(NSDictionary *handles) { 50 | NSLog(@"Low: %f | High: %f | Gamma: %f", [[handles objectForKey:@"Low"] floatValue], [[handles objectForKey:@"High"] floatValue], [[handles objectForKey:@"Gamma"] floatValue]); 51 | }]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/VMMultiHandleSlider-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | me.voidmain.app.mac.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2014 Void Main. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/VMMultiHandleSlider-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #endif 10 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/hud_slider-knobBlack-N.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-main/VMMultiHandleSlider/96d7466b170e9a405d96fa1257160c352e168771/Example/VMMultiHandleSlider/hud_slider-knobBlack-N.tiff -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/hud_slider-knobBlack-N@2x.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-main/VMMultiHandleSlider/96d7466b170e9a405d96fa1257160c352e168771/Example/VMMultiHandleSlider/hud_slider-knobBlack-N@2x.tiff -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/hud_slider-knobGray-N.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-main/VMMultiHandleSlider/96d7466b170e9a405d96fa1257160c352e168771/Example/VMMultiHandleSlider/hud_slider-knobGray-N.tiff -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/hud_slider-knobGray-N@2x.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-main/VMMultiHandleSlider/96d7466b170e9a405d96fa1257160c352e168771/Example/VMMultiHandleSlider/hud_slider-knobGray-N@2x.tiff -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/hud_slider-knobWhite-N.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-main/VMMultiHandleSlider/96d7466b170e9a405d96fa1257160c352e168771/Example/VMMultiHandleSlider/hud_slider-knobWhite-N.tiff -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/hud_slider-knobWhite-N@2x.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-main/VMMultiHandleSlider/96d7466b170e9a405d96fa1257160c352e168771/Example/VMMultiHandleSlider/hud_slider-knobWhite-N@2x.tiff -------------------------------------------------------------------------------- /Example/VMMultiHandleSlider/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // VMMultiHandleSlider 4 | // 5 | // Created by Sun Peng on 7/8/14. 6 | // Copyright (c) 2014 Void Main. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) 12 | { 13 | return NSApplicationMain(argc, argv); 14 | } 15 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSliderTests/VMMultiHandleSliderTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | me.voidmain.app.mac.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSliderTests/VMMultiHandleSliderTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // VMMultiHandleSliderTests.m 3 | // VMMultiHandleSliderTests 4 | // 5 | // Created by Sun Peng on 7/8/14. 6 | // Copyright (c) 2014 Void Main. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface VMMultiHandleSliderTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation VMMultiHandleSliderTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Example/VMMultiHandleSliderTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014 Peng Sun 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | VMMultiHandleSlider 2 | ============= 3 | 4 | A mimic of iPhoto's multi-handle slider. 5 | 6 | Demo: 7 | 8 | ![Demo](demo.gif) 9 | 10 | ## Usage 11 | The setup is quite easy. 12 | 13 | ### Copy Files 14 | First of all, copy `VMMultiHandleSlider.h` and `VMMultiHandleSlider.m` from `VMMultiHandleSlider` folder in your project. 15 | 16 | ### Create Custom View 17 | After that, you can choose to add a `Custom View` from IB and set its class to `VMMultiHandleSlider` or you can use `initWithFrame:` initializer in your code. 18 | 19 | ### Add Handles 20 | To add handle to the slider, use `- (void)addHandle:(NSString *)name image:(NSImage *)image initRatio:(float)initRatio valueBlock:(ValueBlock)valueBlock invValueBlock:(ValueBlock)invValueBlock`. 21 | 22 | - `name` field is key of that slider, it is used for not only updating value but also KVO bindings. So please make sure it is unique. 23 | - `image` is the handle image, this will be extended to a set of images representing different control states. 24 | - `initRatio` is the initial value of this slider. Should be a normalized value between 0 to 1. 25 | - `valueBlock` and `invValueBlock` as their name indicates, the blocks are used to convert value from normalized ratio to real value. 26 | 27 | ### Value Change Notification 28 | To get notification if the value of the handles get changed, call `- (void)setValueChangedBlock:(ValueChangedBlock)valueChangedBlock` and pass in a block which takes a `NSDictionary` as argument and returns nothing. 29 | 30 | The keys in that dictionary are, as you can predict, the names you set while adding handles. And the values are float-point values represented with `NSNumber` objects that is computed with `valueBlock` you've set when creating the handle. 31 | 32 | ### KVO 33 | `VMMultiHandleSlider` also supports KVO. To bind the value of a slider to cocoa controls, simply use `values.HANDLE_NAME` as `keyPath`, where `HANDLE_NAME` is the name you've set when you create the object. 34 | 35 | For a more detailed example, please refer to the example project I've created in `Example` folder. 36 | 37 | ## Known Issues (TODO) 38 | - The handle size is a constant (13x17 points) 39 | - Input validation 40 | - No control state for handles (disable, dragged, etc) 41 | 42 | ## Credits 43 | The handle image I've used in the sample project is copied from `iPhoto` app. :) -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-main/VMMultiHandleSlider/96d7466b170e9a405d96fa1257160c352e168771/Screenshot.png -------------------------------------------------------------------------------- /VMMultiHandleSlider/VMMultiHandleSlider.h: -------------------------------------------------------------------------------- 1 | // 2 | // VMMultiHandleSlider.h 3 | // VMMultiHandleSlider 4 | // 5 | // Created by Sun Peng on 7/8/14. 6 | // Copyright (c) 2014 Void Main. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef float(^ValueBlock)(float); 12 | typedef void(^ValueChangedBlock)(NSDictionary *handles); 13 | 14 | @class VMSliderHandle; 15 | @interface VMMultiHandleSlider : NSView { 16 | ValueChangedBlock _valueChangedBlock; 17 | } 18 | 19 | @property (nonatomic, weak) VMSliderHandle *activeHandle; 20 | @property (nonatomic, weak) NSView *activeHandleView; 21 | @property (nonatomic) NSArray *activeBoundary; 22 | @property (nonatomic, retain) NSMutableDictionary *handles; 23 | @property (nonatomic, strong) NSMutableDictionary *values; 24 | @property (nonatomic) float lastValue; 25 | 26 | - (void)setValueChangedBlock:(ValueChangedBlock)valueChangedBlock; 27 | 28 | - (void)addHandle:(NSString *)name image:(NSImage *)image initRatio:(float)initRatio valueBlock:(ValueBlock)valueBlock invValueBlock:(ValueBlock)invValueBlock; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /VMMultiHandleSlider/VMMultiHandleSlider.m: -------------------------------------------------------------------------------- 1 | // 2 | // VMMultiHandleSlider.m 3 | // VMMultiHandleSlider 4 | // 5 | // Created by Sun Peng on 7/8/14. 6 | // Copyright (c) 2014 Void Main. All rights reserved. 7 | // 8 | 9 | #import "VMMultiHandleSlider.h" 10 | 11 | #define kSliderHandleWidth 13 12 | #define kSliderHandleHeight 17 13 | #define kSliderBarHeight 4 14 | #define kSliderBarColor [NSColor blackColor] 15 | 16 | #define kStaticViewTag 1001 17 | #define kDynamicViewTag 1002 18 | 19 | static void *VMMultiHandleSliderContext = nil; 20 | 21 | @interface VMSliderHandle : NSObject { 22 | ValueBlock _valueBlock; 23 | ValueBlock _invValueBlock; 24 | } 25 | 26 | @property (nonatomic, strong) NSString *name; 27 | @property (nonatomic, strong) NSImage *handleImage; 28 | @property (nonatomic) float curRatio; 29 | @property (nonatomic, weak) NSView *handleView; 30 | 31 | - (void)setValueBlock:(ValueBlock)valueBlock; 32 | - (void)setInvValueBlock:(ValueBlock)valueBlock; 33 | - (float)curValue; 34 | - (float)ratioForValue:(float)value; 35 | 36 | @end 37 | 38 | @implementation VMSliderHandle 39 | 40 | - (void)setValueBlock:(ValueBlock)valueBlock { 41 | _valueBlock = valueBlock; 42 | } 43 | 44 | - (void)setInvValueBlock:(ValueBlock)valueBlock { 45 | _invValueBlock = valueBlock; 46 | } 47 | 48 | - (float)curValue 49 | { 50 | float value = self.curRatio; 51 | if (_valueBlock) { 52 | value = _valueBlock(value); 53 | } 54 | 55 | return value; 56 | } 57 | 58 | - (float)ratioForValue:(float)value 59 | { 60 | float ratio = value; 61 | if (_invValueBlock) { 62 | ratio = _invValueBlock(value); 63 | } 64 | 65 | return ratio; 66 | } 67 | 68 | @end 69 | 70 | @implementation VMMultiHandleSlider 71 | 72 | - (id)initWithFrame:(NSRect)frame 73 | { 74 | self = [super initWithFrame:frame]; 75 | if (self) { 76 | NSImage *sliderBarImage = [self sliderBarImage]; 77 | float startX = (frame.size.width - sliderBarImage.size.width) * 0.5; 78 | float startY = (frame.size.height - sliderBarImage.size.height) * 0.5; 79 | NSImageView *imageView = [[NSImageView alloc] initWithFrame:NSMakeRect(startX, startY, sliderBarImage.size.width, sliderBarImage.size.height)]; 80 | imageView.image = sliderBarImage; 81 | imageView.tag = 0; 82 | [self addSubview:imageView]; 83 | } 84 | return self; 85 | } 86 | 87 | - (NSImage *)sliderBarImage 88 | { 89 | float slidableWidth = self.bounds.size.width - kSliderHandleWidth; 90 | NSImage *barImage = [[NSImage alloc] initWithSize:NSMakeSize(slidableWidth, kSliderBarHeight)]; 91 | [barImage lockFocus]; 92 | [kSliderBarColor set]; 93 | NSRectFill(NSMakeRect(0, 0, barImage.size.width, barImage.size.height)); 94 | [barImage unlockFocus]; 95 | return barImage; 96 | } 97 | 98 | - (void)setValueChangedBlock:(ValueChangedBlock)valueChangedBlock 99 | { 100 | _valueChangedBlock = valueChangedBlock; 101 | } 102 | 103 | - (void)addHandle:(NSString *)name image:(NSImage *)image initRatio:(float)initRatio valueBlock:(ValueBlock)valueBlock invValueBlock:(ValueBlock)invValueBlock 104 | { 105 | if (self.handles == nil) { 106 | self.handles = [[NSMutableDictionary alloc] init]; 107 | self.values = [[NSMutableDictionary alloc] init]; 108 | } 109 | 110 | VMSliderHandle *handle = [[VMSliderHandle alloc] init]; 111 | handle.name = name; 112 | handle.handleImage = image; 113 | handle.curRatio = initRatio; 114 | [handle setValueBlock:valueBlock]; 115 | [handle setInvValueBlock:invValueBlock]; 116 | [self.handles setObject:handle forKey:name]; 117 | [self.values setObject:[NSNumber numberWithFloat:[handle curValue]] forKey:name]; 118 | 119 | [self addObserver:self forKeyPath:[NSString stringWithFormat:@"values.%@", name] options:NSKeyValueObservingOptionNew context:&VMMultiHandleSliderContext]; 120 | 121 | float slidableWidth = self.bounds.size.width - kSliderHandleWidth; 122 | float midY = NSMidY(self.bounds); 123 | NSRect handleRect = NSMakeRect(slidableWidth * handle.curRatio, midY - kSliderHandleHeight * 0.5, kSliderHandleWidth, kSliderHandleHeight); 124 | NSImageView *imageView = [[NSImageView alloc] initWithFrame:NSMakeRect(0, 0, kSliderHandleWidth, kSliderHandleHeight)]; 125 | imageView.image = handle.handleImage; 126 | imageView.tag = kDynamicViewTag; 127 | [self addSubview:imageView]; 128 | imageView.frame = handleRect; 129 | 130 | handle.handleView = imageView; 131 | 132 | [self setNeedsDisplay:YES]; 133 | } 134 | 135 | #pragma mrak - 136 | #pragma mark Mouse Events 137 | - (void)mouseDown:(NSEvent *)theEvent 138 | { 139 | NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil]; 140 | 141 | for (NSView *view in self.subviews) { 142 | if (view.tag == kDynamicViewTag) { 143 | if (NSPointInRect(clickPoint, view.frame)) { 144 | self.activeHandleView = view; 145 | for (NSString *key in self.handles) { 146 | VMSliderHandle *handle = [self.handles objectForKey:key]; 147 | if (handle.handleView == view) { 148 | self.activeHandle = handle; 149 | break; 150 | } 151 | } 152 | self.activeBoundary = [self boundaryForView:self.activeHandleView]; 153 | self.lastValue = self.activeHandle.curRatio; 154 | break; 155 | } 156 | } 157 | } 158 | } 159 | 160 | - (void)mouseDragged:(NSEvent *)theEvent 161 | { 162 | if (self.activeHandleView == nil) { 163 | return [super mouseDragged:theEvent]; 164 | } 165 | 166 | NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil]; 167 | float left = [[self.activeBoundary objectAtIndex:0] floatValue]; 168 | float right = [[self.activeBoundary objectAtIndex:1] floatValue]; 169 | float newX = clickPoint.x; 170 | float halfWidth = self.activeHandleView.frame.size.width * 0.5; 171 | if (newX - halfWidth < left) newX = left + halfWidth; 172 | if (newX + halfWidth > right) newX = right - halfWidth; 173 | 174 | self.activeHandleView.frame = NSMakeRect(newX - self.activeHandleView.frame.size.width * 0.5, self.activeHandleView.frame.origin.y, self.activeHandleView.frame.size.width, self.activeHandleView.frame.size.height); 175 | float slidableWidth = self.bounds.size.width - kSliderHandleWidth; 176 | float ratio = (newX - halfWidth) / slidableWidth; 177 | self.activeHandle.curRatio = ratio; 178 | 179 | float changeDiff = ABS(self.activeHandle.curRatio - self.lastValue); 180 | if (changeDiff > FLT_EPSILON && _valueChangedBlock) { 181 | self.lastValue = self.activeHandle.curRatio; 182 | 183 | for (NSString *key in self.handles) { 184 | VMSliderHandle *handle = [self.handles objectForKey:key]; 185 | float oldValue = [[self.values objectForKey:key] floatValue]; 186 | float curValue = [handle curValue]; 187 | 188 | if (ABS(curValue - oldValue) > FLT_EPSILON) { 189 | [self.values setObject:[NSNumber numberWithFloat:[handle curValue]] forKey:key]; 190 | } 191 | } 192 | _valueChangedBlock([self.values copy]); 193 | } 194 | } 195 | 196 | - (void)mouseUp:(NSEvent *)theEvent 197 | { 198 | self.activeHandle = nil; 199 | self.activeHandleView = nil; 200 | self.activeBoundary = nil; 201 | } 202 | 203 | #pragma mark - 204 | #pragma mark Help methods 205 | - (NSArray *)boundaryForView:(NSView *)view 206 | { 207 | NSMutableArray *boundary = [[NSMutableArray alloc] initWithCapacity:2]; 208 | float min = 0; 209 | float max = self.frame.size.width; 210 | float viewLeftBounday = view.frame.origin.x; 211 | float viewRightBounday = view.frame.origin.x + view.frame.size.width; 212 | for (NSView *subview in view.superview.subviews) { 213 | if (subview != view && subview.tag == kDynamicViewTag) { 214 | float leftBoundary = subview.frame.origin.x; 215 | float rightBoundary = subview.frame.origin.x + subview.frame.size.width; 216 | if (rightBoundary <= viewLeftBounday && rightBoundary > min) { 217 | min = rightBoundary; 218 | } 219 | 220 | if (leftBoundary >= viewRightBounday && leftBoundary < max) { 221 | max = leftBoundary; 222 | } 223 | } 224 | } 225 | 226 | [boundary setObject:[NSNumber numberWithFloat:min] atIndexedSubscript:0]; 227 | [boundary setObject:[NSNumber numberWithFloat:max] atIndexedSubscript:1]; 228 | return [boundary copy]; 229 | } 230 | 231 | #pragma mark - 232 | #pragma mark KVO 233 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 234 | { 235 | if (context != &VMMultiHandleSliderContext) { 236 | return [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; 237 | } 238 | 239 | if ([keyPath hasPrefix:@"values."]) { 240 | NSString *key = [[keyPath componentsSeparatedByString:@"."] objectAtIndex:1]; 241 | VMSliderHandle *handle = [self.handles objectForKey:key]; 242 | id obj = [change objectForKey:NSKeyValueChangeNewKey]; 243 | 244 | if ([obj class] == [NSNull class]) { 245 | return; 246 | } 247 | 248 | float newValue = [[change objectForKey:NSKeyValueChangeNewKey] floatValue]; 249 | float ratio = [handle ratioForValue:newValue]; 250 | float slidableWidth = self.bounds.size.width - kSliderHandleWidth; 251 | NSArray *boundary = [self boundaryForView:handle.handleView]; 252 | float halfWidth = kSliderHandleWidth * 0.5; 253 | float left = [[boundary objectAtIndex:0] floatValue]; 254 | float right = [[boundary objectAtIndex:1] floatValue]; 255 | float minRatio = (left + halfWidth) / slidableWidth; 256 | float maxRatio = (right - halfWidth) / slidableWidth; 257 | 258 | ratio = MAX(ratio, minRatio); 259 | ratio = MIN(ratio, maxRatio); 260 | 261 | if (ABS(ratio - handle.curRatio) > FLT_EPSILON) { 262 | handle.curRatio = ratio; 263 | float newX = slidableWidth * ratio; 264 | handle.handleView.frame = NSMakeRect(newX - handle.handleView.frame.size.width * 0.5, handle.handleView.frame.origin.y, handle.handleView.frame.size.width, handle.handleView.frame.size.height); 265 | 266 | [self willChangeValueForKey:keyPath]; 267 | [self.values setObject:[NSNumber numberWithFloat:[handle curValue]] forKey:key]; 268 | [self didChangeValueForKey:keyPath]; 269 | 270 | if (_valueChangedBlock) { 271 | _valueChangedBlock([self.values copy]); 272 | } 273 | } 274 | } 275 | } 276 | 277 | @end 278 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-main/VMMultiHandleSlider/96d7466b170e9a405d96fa1257160c352e168771/demo.gif --------------------------------------------------------------------------------