<commit_before>//
//  CheckmarkSegmentedControl.swift
//  CheckmarkSegmentedControl
//
//  Created by <NAME> on 27/04/2015.
//  Copyright (c) 2015 gregttn. All rights reserved.
//

import UIKit

class CheckmarkSegmentedControl: UIControl {
    static let minCheckmarkHeight: CGFloat = 20.0
    
    var options: [CheckmarkOption] = []
    var titleFont: UIFont = UIFont.systemFontOfSize(12.0)
    var titleColor: UIColor = UIColor.blackColor()
    var titleLabelTopMargin: CGFloat = 6.0
    var strokeColor: UIColor = UIColor.blackColor() {
        didSet {
            options = options.map({CheckmarkOption(title: $0.title, borderColor: self.strokeColor, fillColor: $0.fillColor)})
        }
    }
    
    var lineWidth: CGFloat = 3.0 {
        didSet {
            self.tickLineWidth = lineWidth
            self.circleBorderLineWidth = lineWidth * 2
            
            setNeedsDisplay()
        }
    }
    
    var animationLength: CFTimeInterval = 0.4
    
    var selectedIndex: Int {
        get {
            return _selectedIndex
        }
        
        set {
            switch newValue{
                case 0..<options.count:
                    _selectedIndex = newValue
                case let v where v >= options.count:
                    _selectedIndex = options.count - 1
                default:<commit_msg>setting new options forces redraw<commit_after>//
//  CheckmarkSegmentedControl.swift
//  CheckmarkSegmentedControl
//
//  Created by <NAME> on 27/04/2015.
//  Copyright (c) 2015 gregttn. All rights reserved.
//

import UIKit

class CheckmarkSegmentedControl: UIControl {
    static let minCheckmarkHeight: CGFloat = 20.0
    
    var options: [CheckmarkOption] = [] {
        didSet {
            setNeedsDisplay()
        }
    }
    
    var animationLength: CFTimeInterval = 0.4
    var titleFont: UIFont = UIFont.systemFontOfSize(12.0)
    var titleColor: UIColor = UIColor.blackColor()
    var titleLabelTopMargin: CGFloat = 6.0
    var strokeColor: UIColor = UIColor.blackColor() {
        didSet {
            options = options.map({CheckmarkOption(title: $0.title, borderColor: self.strokeColor, fillColor: $0.fillColor)})
        }
    }
    
    var lineWidth: CGFloat = 3.0 {
        didSet {
            self.tickLineWidth = lineWidth
            self.circleBorderLineWidth = lineWidth * 2
            
            setNeedsDisplay()
        }
    }
    
    var selectedIndex: Int {
        get {
            return _selectedIndex
        }
        
        set {
            switch newValue{
                case 0..<options.count:
                    _selectedIndex = newValue
                case let v where v >= options.count:
                    _selectedIndex = options.count - 1
                default:
{'fraction_non_alphanumeric': 0.08613825551936301, 'fraction_numerical': 0.02099167571480275, 'mean_word_length': 1.79474216380182, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3746942', 'n_tokens_mistral': 837, 'n_tokens_neox': 796, 'n_words': 185}