All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.peanuuutz.fork.ui.preset.theme.VanillaTheme.kt Maven / Gradle / Ivy

package net.peanuuutz.fork.ui.preset.theme

import net.peanuuutz.fork.ui.foundation.draw.BorderStroke
import net.peanuuutz.fork.ui.foundation.draw.painter.BrushPainter
import net.peanuuutz.fork.ui.foundation.draw.painter.ColorPainter
import net.peanuuutz.fork.ui.foundation.draw.painter.EmptyPainter
import net.peanuuutz.fork.ui.foundation.draw.painter.ImmutableLayeredPainter
import net.peanuuutz.fork.ui.foundation.draw.painter.PatchSide
import net.peanuuutz.fork.ui.foundation.draw.painter.PatchTexturePainter
import net.peanuuutz.fork.ui.foundation.draw.painter.TextureImagePainter
import net.peanuuutz.fork.ui.foundation.draw.painter.TexturePainter
import net.peanuuutz.fork.ui.foundation.text.TextSelectionStyle
import net.peanuuutz.fork.ui.foundation.text.field.CursorStyle
import net.peanuuutz.fork.ui.internal.util.createGuiTextureSpec
import net.peanuuutz.fork.ui.preset.BackgroundStyle
import net.peanuuutz.fork.ui.preset.ButtonStyle
import net.peanuuutz.fork.ui.preset.CheckboxStyle
import net.peanuuutz.fork.ui.preset.Colors
import net.peanuuutz.fork.ui.preset.DefaultBackgroundStyle
import net.peanuuutz.fork.ui.preset.DefaultButtonStyle
import net.peanuuutz.fork.ui.preset.DefaultCheckboxStyle
import net.peanuuutz.fork.ui.preset.DefaultPanelStyle
import net.peanuuutz.fork.ui.preset.DefaultScrollbarStyle
import net.peanuuutz.fork.ui.preset.DefaultSliderThumbStyle
import net.peanuuutz.fork.ui.preset.DefaultSliderTrackStyle
import net.peanuuutz.fork.ui.preset.DefaultSwitchThumbStyle
import net.peanuuutz.fork.ui.preset.DefaultSwitchTrackStyle
import net.peanuuutz.fork.ui.preset.DefaultTextFieldStyle
import net.peanuuutz.fork.ui.preset.DefaultTooltipAreaStyle
import net.peanuuutz.fork.ui.preset.PanelStyle
import net.peanuuutz.fork.ui.preset.ScrollbarStyle
import net.peanuuutz.fork.ui.preset.SliderThumbStyle
import net.peanuuutz.fork.ui.preset.SliderTrackStyle
import net.peanuuutz.fork.ui.preset.TextFieldStyle
import net.peanuuutz.fork.ui.preset.TooltipAreaStyle
import net.peanuuutz.fork.ui.ui.draw.Painter
import net.peanuuutz.fork.ui.ui.draw.ScaleFactor
import net.peanuuutz.fork.ui.ui.draw.shading.Brush
import net.peanuuutz.fork.ui.ui.draw.shading.TextureRegion
import net.peanuuutz.fork.ui.ui.draw.shading.TextureSpec
import net.peanuuutz.fork.ui.ui.unit.IntSize
import net.peanuuutz.fork.util.common.Color

object VanillaTheme {
    // -------- Common --------

    val SuccessColor: Color = Color(0xFF50D050)

    val ErrorColor: Color = Color(0xFFF05050)

    val DisabledColor: Color = Color(0xFFA0A0A0)

    val BackgroundTextureSpec: TextureSpec = createGuiTextureSpec(
        fileName = "options_background",
        size = IntSize(16, 16),
        namespace = "minecraft"
    )

    val WidgetTextureSpec: TextureSpec = createGuiTextureSpec(
        fileName = "widget",
        size = IntSize(64, 64)
    )

    val PanelTextureSpec: TextureSpec = createGuiTextureSpec(
        fileName = "panel",
        size = IntSize(32, 32)
    )

    val PanelInset: Painter = PatchTexturePainter(
        spec = PanelTextureSpec,
        topLeft = TextureRegion(0, 16, 6, 6),
        left = TextureRegion(0, 22, 6, 4),
        bottomLeft = TextureRegion(0, 26, 6, 6),
        bottom = TextureRegion(6, 26, 4, 6),
        bottomRight = TextureRegion(10, 26, 6, 6),
        right = TextureRegion(10, 22, 6, 4),
        topRight = TextureRegion(10, 16, 6, 6),
        top = TextureRegion(6, 16, 4, 6),
        center = TextureRegion.Placeholder,
        side = PatchSide.Hollow
    )

    val InactiveBorder: BorderStroke = BorderStroke(1.0f, Color.Black)

    val InactiveBorderVariant: BorderStroke = BorderStroke(1.0f, DisabledColor)

    val ActiveBorder: BorderStroke = BorderStroke(1.0f, Color.White)

    val InactiveBackground: Painter = TexturePainter(
        spec = WidgetTextureSpec,
        region = TextureRegion(32, 0, 32, 32)
    )

    val InactiveBackgroundVariant: Painter = ColorPainter(Color.Black)

    val ActiveBackground: Painter = PatchTexturePainter(
        spec = WidgetTextureSpec,
        topLeft = TextureRegion(0, 0, 1, 1),
        left = TextureRegion(0, 1, 1, 30),
        bottomLeft = TextureRegion(0, 31, 1, 1),
        bottom = TextureRegion(1, 31, 30, 1),
        bottomRight = TextureRegion(31, 31, 1, 1),
        right = TextureRegion(31, 1, 1, 30),
        topRight = TextureRegion(31, 0, 1, 1),
        top = TextureRegion(1, 0, 30, 1),
        center = TextureRegion(1, 1, 30, 30)
    )

    // -------- Background --------

    val CommonBackground: BackgroundStyle = DefaultBackgroundStyle(
        background = TexturePainter(
            spec = BackgroundTextureSpec,
            scaleFactor = ScaleFactor(2),
            tintColor = Color(0xFF404040)
        ),
        content = Color.White
    )

    val ContainerBackground: BackgroundStyle = DefaultBackgroundStyle(
        background = BrushPainter(
            brush = Brush.verticalGradient(
                0.0f to Color(0xC0101010),
                1.0f to Color(0xD0101010)
            )
        ),
        content = Color.White
    )

    // -------- Button --------

    val Button: ButtonStyle = DefaultButtonStyle(
        border = InactiveBorder,
        background = ActiveBackground,
        contentColor = Color.White,
        selectedBorder = ActiveBorder,
        selectedBackground = ActiveBackground,
        disabledBorder = InactiveBorder,
        disabledBackground = InactiveBackground,
        disabledContentColor = DisabledColor
    )

    // -------- Text Field --------

    val TextField: TextFieldStyle = DefaultTextFieldStyle(
        border = InactiveBorderVariant,
        background = InactiveBackgroundVariant,
        textColor = Color.White,
        cursorStyle = CursorStyle(Color.White),
        leadingIconColor = Color.White,
        trailingIconColor = Color.White,
        placeholderColor = DisabledColor,
        selectedBorder = ActiveBorder,
        selectedBackground = InactiveBackgroundVariant,
        errorBorder = BorderStroke(
            width = 1.0f,
            color = ErrorColor
        ),
        errorBackground = InactiveBackgroundVariant,
        errorTextColor = ErrorColor,
        errorCursorStyle = CursorStyle(ErrorColor),
        errorLeadingIconColor = ErrorColor,
        errorTrailingIconColor = ErrorColor,
        disabledBorder = InactiveBorderVariant,
        disabledBackground = InactiveBackgroundVariant,
        disabledTextColor = DisabledColor,
        disabledLeadingIconColor = DisabledColor,
        disabledTrailingIconColor = DisabledColor,
        disabledPlaceholderColor = DisabledColor,
        selectionStyle = TextSelectionStyle.Default
    )

    // -------- Checkbox --------

    val Checkbox: CheckboxStyle = DefaultCheckboxStyle(
        border = InactiveBorder,
        background = InactiveBackground,
        checkedBorder = InactiveBorder,
        checkedBackground = InactiveBackground,
        selectedBorder = ActiveBorder,
        selectedBackground = InactiveBackground,
        selectedCheckedBorder = ActiveBorder,
        selectedCheckedBackground = InactiveBackground,
        checkmark = TextureImagePainter(
            spec = createGuiTextureSpec(
                fileName = "checkmark",
                size = IntSize(16, 16)
            ),
            region = TextureRegion(0, 0, 12, 9)
        ),
        disabledBorder = InactiveBorder,
        disabledBackground = InactiveBackground
    )

    // -------- Switch --------

    val SwitchTrack: SliderTrackStyle = kotlin.run {
        val checkedBackground = ImmutableLayeredPainter(
            InactiveBackground to 1.0f,
            ColorPainter(SuccessColor) to 0.5f
        )
        DefaultSwitchTrackStyle(
            border = InactiveBorder,
            background = InactiveBackground,
            checkedBorder = InactiveBorder,
            checkedBackground = checkedBackground,
            selectedBorder = ActiveBorder,
            selectedBackground = InactiveBackground,
            selectedCheckedBorder = ActiveBorder,
            selectedCheckedBackground = checkedBackground,
            disabledBorder = InactiveBorder,
            disabledBackground = InactiveBackground,
            disabledCheckedBorder = InactiveBorder,
            disabledCheckedBackground = checkedBackground
        )
    }

    val SwitchThumb: SliderThumbStyle = DefaultSwitchThumbStyle(
        border = InactiveBorder,
        background = ActiveBackground,
        checkedBorder = InactiveBorder,
        checkedBackground = ActiveBackground,
        selectedBorder = ActiveBorder,
        selectedBackground = ActiveBackground,
        selectedCheckedBorder = ActiveBorder,
        selectedCheckedBackground = ActiveBackground,
        disabledBorder = BorderStroke.Empty,
        disabledBackground = EmptyPainter.Placeholder,
        disabledCheckedBorder = BorderStroke.Empty,
        disabledCheckedBackground = EmptyPainter.Placeholder
    )

    // -------- Tooltip Area --------

    val TooltipArea: TooltipAreaStyle = DefaultTooltipAreaStyle(
        border = BorderStroke.Empty,
        background = VanillaTooltipBackground,
        content = Color.White
    )

    // -------- Slider --------

    val SliderTrack: SliderTrackStyle = DefaultSliderTrackStyle(
        border = InactiveBorder,
        background = InactiveBackground,
        contentColor = Color.White,
        selectedBorder = ActiveBorder,
        selectedBackground = InactiveBackground,
        disabledBorder = InactiveBorder,
        disabledBackground = InactiveBackground,
        disabledContentColor = DisabledColor
    )

    val SliderThumb: SliderThumbStyle = DefaultSliderThumbStyle(
        border = InactiveBorder,
        background = ActiveBackground,
        selectedBorder = ActiveBorder,
        selectedBackground = ActiveBackground,
        disabledBorder = BorderStroke.Empty,
        disabledBackground = EmptyPainter.Placeholder
    )

    // -------- Scrollbar --------

    val Scrollbar: ScrollbarStyle = DefaultScrollbarStyle(
        background = ActiveBackground
    )

    // -------- Light --------

    object Light {
        // -------- Colors --------

        val Colors: Colors = Colors(
            onBackground = Color.White,
            onBackgroundVariant = Color.White,
            onPanel = Color(0xFF404040),
            onPanelVariant = Color(0xFF8B8B8B),
            onWidget = Color.White,
            onWidgetVariant = Color.White,
            success = SuccessColor,
            error = ErrorColor,
            disabled = DisabledColor
        )

        // -------- Panel --------

        val PanelBackground: Painter = PatchTexturePainter(
            spec = PanelTextureSpec,
            topLeft = TextureRegion(0, 0, 4, 4),
            left = TextureRegion(0, 4, 4, 8),
            bottomLeft = TextureRegion(0, 12, 4, 4),
            bottom = TextureRegion(4, 12, 8, 4),
            bottomRight = TextureRegion(12, 12, 4, 4),
            right = TextureRegion(12, 4, 4, 8),
            topRight = TextureRegion(12, 0, 4, 4),
            top = TextureRegion(4, 0, 8, 4),
            center = TextureRegion(4, 4, 8, 8)
        )

        val Panel: PanelStyle = DefaultPanelStyle(
            border = BorderStroke.Empty,
            background = PanelBackground,
            content = Colors.onPanel,
            inset = PanelInset,
            insetContent = Colors.onBackground
        )
    }

    // -------- Dark --------

    object Dark {
        // -------- Colors --------

        val Colors: Colors = Colors(
            onBackground = Color.White,
            onBackgroundVariant = Color.White,
            onPanel = Color.White,
            onPanelVariant = Color(0xFF8B8B8B),
            onWidget = Color.White,
            onWidgetVariant = Color.White,
            success = SuccessColor,
            error = ErrorColor,
            disabled = DisabledColor
        )

        // -------- Panel --------

        val PanelBackground: Painter = PatchTexturePainter(
            spec = PanelTextureSpec,
            topLeft = TextureRegion(16, 0, 4, 4),
            left = TextureRegion(16, 4, 4, 8),
            bottomLeft = TextureRegion(16, 12, 4, 4),
            bottom = TextureRegion(20, 12, 8, 4),
            bottomRight = TextureRegion(28, 12, 4, 4),
            right = TextureRegion(28, 4, 4, 8),
            topRight = TextureRegion(28, 0, 4, 4),
            top = TextureRegion(20, 0, 8, 4),
            center = TextureRegion(20, 4, 8, 8)
        )

        val Panel: PanelStyle = DefaultPanelStyle(
            border = BorderStroke.Empty,
            background = PanelBackground,
            content = Colors.onPanel,
            inset = PanelInset,
            insetContent = Colors.onBackground
        )
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy