-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add border highlight in multi-edit mode #50
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -313,12 +313,40 @@ private fun FieldBorderCanvas( | |||||||||
state.getEntryIndexesByBorderIndex(pointIndex).second == entryIndex | ||||||||||
) 1f else IDLE_LINE_ALPHA | ||||||||||
if (border in screenRange) { | ||||||||||
var strokeWidth: Float = STROKE_WIDTH | ||||||||||
var color = borderColor.copy(alpha = borderLineAlpha) | ||||||||||
if (editorConf.highlightCurrentEntryBorder) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add some checks about multiple edit mode here. |
||||||||||
val currentIndex = editorState.project.currentModule.currentIndex | ||||||||||
if (currentIndex == entryIndex || currentIndex == entryIndex - 1) { | ||||||||||
strokeWidth = editorConf.currentEntryBorderHighlightWidth | ||||||||||
color = editorConf.currentEntryBorderHighlightColor.toColor() | ||||||||||
} | ||||||||||
} | ||||||||||
// when dragging, the highlight border would glitch, but I have no idea how to fix that | ||||||||||
if (editorConf.highlightCursorPositionEntryBorder) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The most simple fix:
Suggested change
But this will cause the highlight to disappear when dragging. So if we want it perfectly, we need to add a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Um, I think I was wrong. So we probably should instead remember a relative offset of the clicked position and the parameter line being dragged, so when rendering the lines, we can get a stable cursor position. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got it working. Please have a look! (It's a git patch, if you don't now how to apply it please Google or GPT) |
||||||||||
cursorState.value.position?.let { position -> | ||||||||||
if (entryInPixel.getActualStart(labelerConf) <= position && | ||||||||||
position <= entryInPixel.getActualEnd(labelerConf) | ||||||||||
) { | ||||||||||
strokeWidth = editorConf.cursorPositionEntryBorderHighlightWidth | ||||||||||
color = editorConf.cursorPositionEntryBorderHighlightColor.toColor() | ||||||||||
} | ||||||||||
state.entriesInPixel.getOrNull(entryIndex - 1)?.let { entryInPixel -> | ||||||||||
if (entryInPixel.getActualStart(labelerConf) < position && | ||||||||||
position <= entryInPixel.getActualEnd(labelerConf) | ||||||||||
) { | ||||||||||
strokeWidth = editorConf.cursorPositionEntryBorderHighlightWidth | ||||||||||
color = editorConf.cursorPositionEntryBorderHighlightColor.toColor() | ||||||||||
} | ||||||||||
} | ||||||||||
} | ||||||||||
} | ||||||||||
val relativeBorder = border - screenRange.start | ||||||||||
drawLine( | ||||||||||
color = borderColor.copy(alpha = borderLineAlpha), | ||||||||||
color = color, | ||||||||||
start = Offset(relativeBorder, 0f), | ||||||||||
end = Offset(relativeBorder, canvasHeight), | ||||||||||
strokeWidth = STROKE_WIDTH, | ||||||||||
strokeWidth = strokeWidth, | ||||||||||
) | ||||||||||
} | ||||||||||
} | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -488,6 +488,16 @@ fun Strings.zhHans(): String? = when (this) { | |
PreferencesEditorContinuousLabelNamesEditableBackgroundColor -> "背景色(编辑中)" | ||
PreferencesEditorContinuousLabelNamesSize -> "大小" | ||
PreferencesEditorContinuousLabelNamesPosition -> "位置" | ||
PreferencesEditorBorderHighlight -> "边界高亮" | ||
PreferencesEditorBorderHighlightDescription -> "编辑在多条目编辑模式中边界高亮等的设置" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a period. |
||
PreferencesEditorHighlightCurrentEntryBorder -> "高亮当前条目的边界" | ||
PreferencesEditorHighlightCurrentEntryBorderDescription -> "在多条目编辑模式下高亮当前条目的边界" | ||
PreferencesEditorCurrentEntryBorderHighlightColor -> "当前条目边界的高亮颜色" | ||
PreferencesEditorCurrentEntryBorderHighlightWidth -> "当前条目边界的高亮宽度" | ||
PreferencesEditorHighlightCursorPositionEntryBorder -> "高亮光标位置条目的边界" | ||
PreferencesEditorHighlightCursorPositionEntryBorderDescription -> "在多条目编辑模式下高亮光标位置的条目边界" | ||
PreferencesEditorCursorPositionEntryBorderHighlightColor -> "光标位置条目边界的高亮颜色" | ||
PreferencesEditorCursorPositionEntryBorderHighlightWidth -> "光标位置条目边界的高亮宽度" | ||
PreferencesPlayback -> "播放" | ||
PreferencesPlaybackDescription -> "编辑音频播放的行为。" | ||
PreferencesPlaybackPlayOnDragging -> "预览播放" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,6 +547,18 @@ fun Strings.en(): String = when (this) { | |
PreferencesEditorContinuousLabelNamesEditableBackgroundColor -> "Background color (editing)" | ||
PreferencesEditorContinuousLabelNamesSize -> "Size" | ||
PreferencesEditorContinuousLabelNamesPosition -> "Position" | ||
PreferencesEditorBorderHighlight -> "Border Highlight" | ||
PreferencesEditorBorderHighlightDescription -> "Customize border highlighting in multiple entry edit mode" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a period. |
||
PreferencesEditorHighlightCurrentEntryBorder -> "Highlight current entry border" | ||
PreferencesEditorHighlightCurrentEntryBorderDescription, | ||
-> "Highlight current entry border in multiple entry edit mode." | ||
PreferencesEditorCurrentEntryBorderHighlightColor -> "Highlight color of current entry border" | ||
PreferencesEditorCurrentEntryBorderHighlightWidth -> "Highlight width of current entry border" | ||
PreferencesEditorHighlightCursorPositionEntryBorder -> "Highlight cursor position entry border" | ||
PreferencesEditorHighlightCursorPositionEntryBorderDescription, | ||
-> "Highlight cursor position entry border in multiple entry edit mode." | ||
PreferencesEditorCursorPositionEntryBorderHighlightColor -> "Highlight color of the cursor position entry border" | ||
PreferencesEditorCursorPositionEntryBorderHighlightWidth -> "Highlight width of the cursor position entry border" | ||
PreferencesPlayback -> "Playback" | ||
PreferencesPlaybackDescription -> "Customize the behavior about audio playback." | ||
PreferencesPlaybackPlayOnDragging -> "Preview playback" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use grouping (you can find examples in this file) to make it more clear, and some repeated texts can be simplified.
For example, these can be simply
Color
andWidth
under a group.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I feel like the default color/width settings should be inverted.
The cursor should have the highest visual priority.