feat: finish general image button

This commit is contained in:
allsochen committed 2024-07-08 15:28:02 +08:00
1 parent 577dfccdf4
commit dfa6b5a68e
10 files changed
+21 -23

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 KiB

After

Width:  |  Height:  |  Size: 771 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

+19 -21
View File
@@ -540,6 +540,12 @@ struct WidthHeightImage {
var width: CGFloat
var height: CGFloat
var name: String
init(width: CGFloat = 75, height: CGFloat = 50, name: String) {
self.width = width
self.height = height
self.name = name
}
}
protocol ImageMacroPreference: MacroPreference {
@@ -725,11 +731,9 @@ enum AlignThumbnailsPreference: String, CaseIterable, ImageMacroPreference {
}
var image: WidthHeightImage {
let width: CGFloat = 75
let height: CGFloat = 50
switch self {
case .left: return WidthHeightImage(width: width, height: height, name: "thumbnails")
case .center: return WidthHeightImage(width: width, height: height, name: "app_icons")
case .left: return WidthHeightImage(name: "align_left")
case .center: return WidthHeightImage(name: "align_center")
}
}
}
@@ -741,19 +745,17 @@ enum AppearanceModelPreference: String, CaseIterable, ImageMacroPreference {
var localizedString: LocalizedString {
switch self {
case .thumbnails: return NSLocalizedString("Thumbnails", comment: "")
case .appIcons: return NSLocalizedString("App Icons", comment: "")
case .titles: return NSLocalizedString("Titles", comment: "")
case .thumbnails: return NSLocalizedString("Thumbnails", comment: "")
case .appIcons: return NSLocalizedString("App Icons", comment: "")
case .titles: return NSLocalizedString("Titles", comment: "")
}
}
var image: WidthHeightImage {
let width: CGFloat = 75
let height: CGFloat = 50
switch self {
case .thumbnails: return WidthHeightImage(width: width, height: height, name: "thumbnails")
case .appIcons: return WidthHeightImage(width: width, height: height, name: "app_icons")
case .titles: return WidthHeightImage(width: width, height: height, name: "titles")
case .thumbnails: return WidthHeightImage(name: "thumbnails")
case .appIcons: return WidthHeightImage(name: "app_icons")
case .titles: return WidthHeightImage(name: "titles")
}
}
}
@@ -772,12 +774,10 @@ enum AppearanceSizePreference: String, CaseIterable, ImageMacroPreference {
}
var image: WidthHeightImage {
let width: CGFloat = 75
let height: CGFloat = 50
switch self {
case .small: return WidthHeightImage(width: width, height: height, name: "thumbnails")
case .middle: return WidthHeightImage(width: width, height: height, name: "app_icons")
case .large: return WidthHeightImage(width: width, height: height, name: "titles")
case .small: return WidthHeightImage(name: "small")
case .middle: return WidthHeightImage(name: "middle")
case .large: return WidthHeightImage(name: "large")
}
}
}
@@ -794,11 +794,9 @@ enum ThemePreference: String, CaseIterable, ImageMacroPreference {
}
var image: WidthHeightImage {
let width: CGFloat = 75
let height: CGFloat = 50
switch self {
case .macOs: return WidthHeightImage(width: width, height: height, name: "thumbnails")
case .windows10: return WidthHeightImage(width: width, height: height, name: "app_icons")
case .macOs: return WidthHeightImage(name: "macos")
case .windows10: return WidthHeightImage(name: "windows10")
}
}
@@ -57,7 +57,7 @@ class LabelAndControl: NSObject {
imageContainer.centerXAnchor.constraint(equalTo: button.centerXAnchor),
imageContainer.centerYAnchor.constraint(equalTo: button.centerYAnchor),
// Adjust width for border and padding
imageContainer.widthAnchor.constraint(equalTo: button.widthAnchor, constant: -5),
imageContainer.widthAnchor.constraint(equalTo: button.widthAnchor, constant: -4),
// Adjust height for border and padding
imageContainer.heightAnchor.constraint(equalTo: button.heightAnchor, constant: -4)
])
@@ -12,7 +12,7 @@ class AppearanceTab {
[makeSeparator(), makeSeparator(), makeSeparator()],
LabelAndControl.makeLabelWithImageRadioButtons(NSLocalizedString("Theme:", comment: ""), "theme", ThemePreference.allCases, buttonSpacing: 50),
[makeSeparator(), makeSeparator(), makeSeparator()],
LabelAndControl.makeLabelWithImageRadioButtons(NSLocalizedString("Align windows:", comment: ""), "alignThumbnails", AlignThumbnailsPreference.allCases),
LabelAndControl.makeLabelWithImageRadioButtons(NSLocalizedString("Align windows:", comment: ""), "alignThumbnails", AlignThumbnailsPreference.allCases, buttonSpacing: 60),
[makeSeparator(), makeSeparator(), makeSeparator()],
LabelAndControl.makeLabelWithDropdown(NSLocalizedString("Window title truncation:", comment: ""), "titleTruncation", TitleTruncationPreference.allCases),
LabelAndControl.makeLabelWithDropdown(NSLocalizedString("Show on:", comment: ""), "showOnScreen", ShowOnScreenPreference.allCases),