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

commonMain.org.jetbrains.letsPlot.livemap.ui.UiEntitiesRenderingSystem.kt Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2019. JetBrains s.r.o.
 * Use of this source code is governed by the MIT license that can be found in the LICENSE file.
 */

package org.jetbrains.letsPlot.livemap.ui

import org.jetbrains.letsPlot.livemap.core.ecs.AbstractSystem
import org.jetbrains.letsPlot.livemap.core.ecs.EcsComponent
import org.jetbrains.letsPlot.livemap.core.ecs.EcsComponentManager
import org.jetbrains.letsPlot.livemap.core.layers.CanvasLayerComponent
import org.jetbrains.letsPlot.livemap.core.layers.DirtyCanvasLayerComponent
import org.jetbrains.letsPlot.livemap.mapengine.LiveMapContext

class UiEntitiesRenderingSystem(
    componentManager: EcsComponentManager
) : AbstractSystem(componentManager) {

    override fun updateImpl(context: LiveMapContext, dt: Double) {
        val uiLayer = getSingletonEntity(UiLayerComponent::class)

        if (uiLayer.contains()) {
            uiLayer
                .get()
                .canvasLayer
                .addRenderTask { context2d ->
                    getEntities(UiRenderComponent::class).toList().forEach {
                        val renderObject = it.get().renderBox
                        context.mapRenderContext.draw(context2d, renderObject.origin, renderObject)
                    }
                }
        }
    }

    class UiLayerComponent : EcsComponent
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy