Skip to content

Commit 9cb67ef

Browse files
committed
Convert the circular widget to another form that is less obvious
1 parent 5b6ecc9 commit 9cb67ef

File tree

8 files changed

+166
-113
lines changed

8 files changed

+166
-113
lines changed

Core/Sources/HostApp/FeatureSettings/Suggestion/SuggestionFeatureDisabledLanguageListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct SuggestionFeatureDisabledLanguageListView: View {
7474
if settings.suggestionFeatureDisabledLanguageList.isEmpty {
7575
Text("""
7676
Empty
77-
Disable the language of a file by right clicking the circular widget.
77+
Disable the language of a file by right clicking the indicator widget.
7878
""")
7979
.multilineTextAlignment(.center)
8080
.padding()

Core/Sources/HostApp/FeatureSettings/Suggestion/SuggestionFeatureEnabledProjectListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct SuggestionFeatureEnabledProjectListView: View {
8282
Text("""
8383
Empty
8484
Add project with "+" button
85-
Or right clicking the circular widget
85+
Or right clicking the indicator widget
8686
""")
8787
.multilineTextAlignment(.center)
8888
}

Core/Sources/HostApp/GeneralView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ struct GeneralSettingsView: View {
280280
}
281281

282282
Toggle(isOn: $settings.hideCircularWidget) {
283-
Text("Hide circular widget")
283+
Text("Hide indicator widget")
284284
}
285285
}.padding()
286286
}

Core/Sources/SuggestionWidget/Styles.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ enum Style {
88
static let panelWidth: Double = 454
99
static let inlineSuggestionMinWidth: Double = 540
1010
static let inlineSuggestionMaxHeight: Double = 400
11-
static let widgetHeight: Double = 20
12-
static var widgetWidth: Double { widgetHeight }
11+
static let widgetHeight: Double = 30
12+
static var widgetWidth: Double = 8
1313
static let widgetPadding: Double = 4
14+
static let indicatorBottomPadding: Double = 40
1415
static let chatWindowTitleBarHeight: Double = 24
1516
static let trafficLightButtonSize: Double = 12
1617
}

Core/Sources/SuggestionWidget/WidgetPositionStrategy.swift

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public struct WidgetLocation: Equatable {
1717
enum UpdateLocationStrategy {
1818
struct AlignToTextCursor {
1919
func framesForWindows(
20+
windowFrame: CGRect,
2021
editorFrame: CGRect,
2122
mainScreen: NSScreen,
2223
activeScreen: NSScreen,
@@ -33,6 +34,7 @@ enum UpdateLocationStrategy {
3334
)
3435
else {
3536
return FixedToBottom().framesForWindows(
37+
windowFrame: windowFrame,
3638
editorFrame: editorFrame,
3739
mainScreen: mainScreen,
3840
activeScreen: activeScreen,
@@ -43,6 +45,7 @@ enum UpdateLocationStrategy {
4345
let found = AXValueGetValue(rect, .cgRect, &frame)
4446
guard found else {
4547
return FixedToBottom().framesForWindows(
48+
windowFrame: windowFrame,
4649
editorFrame: editorFrame,
4750
mainScreen: mainScreen,
4851
activeScreen: activeScreen,
@@ -51,6 +54,7 @@ enum UpdateLocationStrategy {
5154
}
5255
return HorizontalMovable().framesForWindows(
5356
y: mainScreen.frame.height - frame.maxY,
57+
windowFrame: windowFrame,
5458
alignPanelTopToAnchor: nil,
5559
editorFrame: editorFrame,
5660
mainScreen: mainScreen,
@@ -63,6 +67,7 @@ enum UpdateLocationStrategy {
6367

6468
struct FixedToBottom {
6569
func framesForWindows(
70+
windowFrame: CGRect,
6671
editorFrame: CGRect,
6772
mainScreen: NSScreen,
6873
activeScreen: NSScreen,
@@ -73,6 +78,7 @@ enum UpdateLocationStrategy {
7378
) -> WidgetLocation {
7479
var frames = HorizontalMovable().framesForWindows(
7580
y: mainScreen.frame.height - editorFrame.maxY + Style.widgetPadding,
81+
windowFrame: windowFrame,
7682
alignPanelTopToAnchor: false,
7783
editorFrame: editorFrame,
7884
mainScreen: mainScreen,
@@ -97,6 +103,7 @@ enum UpdateLocationStrategy {
97103
struct HorizontalMovable {
98104
func framesForWindows(
99105
y: CGFloat,
106+
windowFrame: CGRect,
100107
alignPanelTopToAnchor fixedAlignment: Bool?,
101108
editorFrame: CGRect,
102109
mainScreen: NSScreen,
@@ -130,6 +137,13 @@ enum UpdateLocationStrategy {
130137
width: Style.widgetWidth,
131138
height: Style.widgetHeight
132139
)
140+
141+
let widgetFrame = CGRect(
142+
x: windowFrame.minX,
143+
y: mainScreen.frame.height - windowFrame.maxY + Style.indicatorBottomPadding,
144+
width: Style.widgetWidth,
145+
height: Style.widgetHeight
146+
)
133147

134148
if !hideCircularWidget {
135149
proposedAnchorFrameOnTheRightSide = widgetFrameOnTheRightSide
@@ -150,7 +164,7 @@ enum UpdateLocationStrategy {
150164
x: proposedPanelX,
151165
y: alignPanelTopToAnchor
152166
? anchorFrame.maxY - Style.panelHeight
153-
: anchorFrame.minY - editorFrameExpendedSize.height,
167+
: anchorFrame.minY,
154168
width: Style.panelWidth,
155169
height: Style.panelHeight
156170
)
@@ -164,7 +178,7 @@ enum UpdateLocationStrategy {
164178
)
165179

166180
return .init(
167-
widgetFrame: widgetFrameOnTheRightSide,
181+
widgetFrame: widgetFrame,
168182
tabFrame: tabFrame,
169183
sharedPanelLocation: .init(
170184
frame: panelFrame,
@@ -227,7 +241,7 @@ enum UpdateLocationStrategy {
227241
height: Style.widgetHeight
228242
)
229243
return .init(
230-
widgetFrame: widgetFrameOnTheLeftSide,
244+
widgetFrame: widgetFrame,
231245
tabFrame: tabFrame,
232246
sharedPanelLocation: .init(
233247
frame: panelFrame,
@@ -244,10 +258,8 @@ enum UpdateLocationStrategy {
244258
let panelFrame = CGRect(
245259
x: anchorFrame.maxX - Style.panelWidth,
246260
y: alignPanelTopToAnchor
247-
? anchorFrame.maxY - Style.panelHeight - Style.widgetHeight
248-
- Style.widgetPadding
249-
: anchorFrame.maxY + Style.widgetPadding
250-
- editorFrameExpendedSize.height,
261+
? anchorFrame.maxY - Style.panelHeight
262+
: anchorFrame.maxY - editorFrameExpendedSize.height,
251263
width: Style.panelWidth,
252264
height: Style.panelHeight
253265
)
@@ -258,7 +270,7 @@ enum UpdateLocationStrategy {
258270
height: Style.widgetHeight
259271
)
260272
return .init(
261-
widgetFrame: widgetFrameOnTheRightSide,
273+
widgetFrame: widgetFrame,
262274
tabFrame: tabFrame,
263275
sharedPanelLocation: .init(
264276
frame: panelFrame,
@@ -426,10 +438,6 @@ enum UpdateLocationStrategy {
426438
let foundFirstLine = AXValueGetValue(selectedRange, .cfRange, &firstLineRange)
427439
firstLineRange.length = 0
428440

429-
#warning(
430-
"FIXME: When selection is too low and out of the screen, the selection range becomes something else."
431-
)
432-
433441
if foundFirstLine,
434442
let firstLineSelectionRange = AXValueCreate(.cfRange, &firstLineRange),
435443
let firstLineRect: AXValue = try? editor.copyParameterizedValue(

0 commit comments

Comments
 (0)