This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Row { | |
if (startFromF) { | |
AccidentalPianoKey(10.dp) | |
AccidentalPianoKey(5.dp) | |
AccidentalPianoKey(4.dp) | |
AccidentalPianoKey(21.dp) | |
AccidentalPianoKey(4.dp) | |
} else { | |
AccidentalPianoKey(10.dp) | |
AccidentalPianoKey(5.dp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun AccidentalPianoKey(leftSpacing: Dp) { | |
Spacer(modifier = LayoutWidth(leftSpacing)) | |
ColoredRect( | |
color = Color.Black, | |
height = 40.dp, | |
width = 13.dp | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (showNoteNames) { | |
Row { | |
repeat(7) { noteIndex -> | |
Container( | |
LayoutPadding(right = 1.dp) + LayoutSize(16.dp, 62.dp), | |
alignment = Alignment.BottomCenter | |
) { | |
val noteName = formatNoteName(startFromF, noteIndex, octave) | |
Text(text = noteName, style = TextStyle(fontSize = 8.sp)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun PianoChord(chord: List<PianoKey>) { | |
val lower = chord.lowerKey() | |
val upper = chord.upperKey() | |
PianoRoll(lower, upper, true, chord) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun PianoRollOctave( | |
startFromF: Boolean = false, | |
showNoteNames: Boolean = false, | |
octave: Int? = 0, | |
highlightedKeys: List<PianoKey>? = null | |
) { | |
Stack { | |
WhiteNotes(startFromF, octave, highlightedKeys) | |
BlackNotes(startFromF, octave, highlightedKeys) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Fretboard() { | |
Column { | |
Container { | |
Stack { | |
Row(modifier = LayoutWidth.Fill) { | |
// Fretwire + Nut layer | |
} | |
Column(modifier = LayoutWidth.Fill) { | |
// String layer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun FretMarkerLayer( | |
fromFret: Int, | |
toFret: Int, | |
markers: List<Marker>, | |
scale: Float = 1.5f | |
) { | |
val fretRange = toFret - fromFret | |
Table(columns = fretRange) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun Fretwire(modifier: Modifier, scale: Float = 1.5f) { | |
Container(modifier = modifier, alignment = Alignment.CenterRight) { | |
ColoredRect( | |
modifier = Border( | |
RoundedCornerShape(1.dp), | |
1.dp, | |
Color.Black | |
) + LayoutSize(width = (BASE_FRETWIRE_WIDTH * scale).dp, height = (BASE_FRETBOARD_HEIGHT * scale).dp), | |
brush = SolidColor(Color.Gray) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun GuitarString(modifier: Modifier, thickness: Dp = 3.dp) { | |
Container(modifier = modifier, alignment = Alignment.CenterRight) { | |
ColoredRect( | |
modifier = modifier + Border( | |
RoundedCornerShape(1.dp), | |
1.dp, | |
Color.Black | |
) + LayoutHeight(thickness), brush = SolidColor(Color.LightGray) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyViewModel : BaseViewModel() { | |
val data: LiveData<String> = MutableLiveData() | |
fun load() { | |
data.value = "Hello, World" | |
} | |
} | |
class MyActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { |