Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize icons and padding capability added #101

Merged
merged 3 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Setting to adjust padding of Dozer icons
  • Loading branch information
blakedgordon committed Mar 25, 2020
commit 8fa283c62da0e9ba7d57995fe7ff18bac85b23b7
1 change: 1 addition & 0 deletions Dozer/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extension Defaults.Keys {
static let noIconMode: Defaults.Key<Bool> = Key<Bool>("noIconMode", default: false)
static let removeDozerIconEnabled: Defaults.Key<Bool> = Key<Bool>("removeStatusIconEnabled", default: false)
static let iconSize: Defaults.Key<Int> = Key<Int>("fontSize", default: 10)
static let buttonPadding: Defaults.Key<CGFloat> = Key<CGFloat>("buttonPadding", default: 25)
static let animationEnabled: Defaults.Key<Bool> = Key<Bool>("animationEnabeld", default: false)
}

Expand Down
9 changes: 9 additions & 0 deletions Dozer/DozerIcons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ public final class DozerIcons {
}
}
}

public var buttonPadding: CGFloat = defaults[.buttonPadding] {
didSet {
defaults[.buttonPadding] = self.buttonPadding
for icon in dozerIcons {
icon.setSize()
}
}
}

// MARK: Public methods
public func hide() {
Expand Down
2 changes: 1 addition & 1 deletion Dozer/Other/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>4.1.0</string>
<key>CFBundleVersion</key>
<string>10</string>
<string>12</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
11 changes: 9 additions & 2 deletions Dozer/StatusIconClasses/HelperStatusIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import Cocoa
import Defaults

private struct StatusIconLength {
static let show: CGFloat = 25
static var show: CGFloat {
get {
return defaults[.buttonPadding]
}
}
static let hide: CGFloat = 10_000
}

class HelperstatusIcon {
var type: StatusIconType

let statusIcon: NSStatusItem = NSStatusBar.system.statusItem(withLength: 25)
let statusIcon: NSStatusItem = NSStatusBar.system.statusItem(withLength: StatusIconLength.show)

init() {
type = .normal
Expand Down Expand Up @@ -59,6 +63,9 @@ class HelperstatusIcon {
}

func setSize() {
if statusIcon.length != StatusIconLength.hide {
statusIcon.length = StatusIconLength.show
}
guard let statusIconButton = statusIcon.button else {
fatalError("helper status item button failed")
}
Expand Down
6 changes: 6 additions & 0 deletions Dozer/ViewControllers/GeneralVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ final class General: NSViewController, PreferencePane {
@IBOutlet private var HideBothDozerIconsCheckbox: NSButton!
@IBOutlet private var EnableRemoveDozerIconCheckbox: NSButton!
@IBOutlet private var FontSizePopUpButton: NSPopUpButton!
@IBOutlet private var ButtonPaddingPopUpButton: NSPopUpButton!
@IBOutlet private var ToggleMenuItemsView: MASShortcutView!

override func viewDidLoad() {
Expand All @@ -46,6 +47,7 @@ final class General: NSViewController, PreferencePane {
HideBothDozerIconsCheckbox.isChecked = defaults[.noIconMode]
EnableRemoveDozerIconCheckbox.isChecked = defaults[.removeDozerIconEnabled]
FontSizePopUpButton.selectItem(withTag: defaults[.iconSize])
ButtonPaddingPopUpButton.selectItem(withTag: Int(defaults[.buttonPadding]))

ToggleMenuItemsView.associatedUserDefaultsKey = UserDefaultKeys.Shortcuts.ToggleMenuItems
view.addSubview(ToggleMenuItemsView)
Expand Down Expand Up @@ -83,6 +85,10 @@ final class General: NSViewController, PreferencePane {
DozerIcons.shared.iconFontSize = FontSizePopUpButton.selectedTag()
}

@IBAction func buttonPaddingChanged(_ sender: NSPopUpButton) {
DozerIcons.shared.buttonPadding = CGFloat(ButtonPaddingPopUpButton.selectedTag())
}

@IBAction private func enableRemoveDozerIconClicked(_ sender: NSButton) {
DozerIcons.shared.enableRemoveDozerIcon = EnableRemoveDozerIconCheckbox.isChecked
}
Expand Down
Loading