Skip to content

Commit

Permalink
feat: Adjust drawing top value
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Aug 15, 2024
1 parent ca41a79 commit 8297062
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.obd.graphs.bl.datalogger.dataLoggerPreferences
import org.obd.graphs.bl.query.Query
import kotlin.math.min

const val MARGIN_TOP = 20f
const val MARGIN_TOP = 8

@Suppress("NOTHING_TO_INLINE")
internal abstract class AbstractSurfaceRenderer(
Expand All @@ -35,9 +35,9 @@ internal abstract class AbstractSurfaceRenderer(
protected val fps: Fps,
protected val metricsCollector: MetricsCollector,
protected val viewSettings: ViewSettings
) :
SurfaceRenderer {
open fun getDrawTop(area: Rect): Float = area.top + MARGIN_TOP + viewSettings.marginTop
) : SurfaceRenderer {
open fun getTop(area: Rect): Float = area.top + getDefaultTopMargin() + viewSettings.marginTop
fun getDefaultTopMargin(): Float = 20f

override fun applyMetricsFilter(query: Query) {
if (dataLoggerPreferences.instance.individualQueryStrategyEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal class DragRacingSurfaceRenderer(
val dragRacingSettings = settings.getDragRacingScreenSettings()
val margin = if (dragRacingSettings.shiftLightsEnabled || dragRaceResults.readyToRace) SHIFT_LIGHTS_WIDTH else 0
val area = getArea(it, canvas, margin)
var top = getDrawTop(area)
var top = getTop(area)
var left = dragRacingDrawer.getMarginLeft(area.left.toFloat())

if (dragRacingSettings.shiftLightsEnabled) {
Expand All @@ -80,11 +80,11 @@ internal class DragRacingSurfaceRenderer(

if (settings.isStatusPanelEnabled()) {
dragRacingDrawer.drawStatusPanel(canvas, top, left, fps, metricsCollector, drawContextInfo = settings.getDragRacingScreenSettings().contextInfoEnabled)
top += 4
top += MARGIN_TOP
dragRacingDrawer.drawDivider(canvas, left, area.width().toFloat(), top, Color.DKGRAY)
top += 40
} else {
top += 8
top += MARGIN_TOP
}

if (isGMEExtensionsEnabled()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ internal class GaugeSurfaceRenderer(
drawerSettings = DrawerSettings(gaugeProgressBarType = settings.getGaugeRendererSetting().gaugeProgressBarType)
)

override fun getDrawTop(area: Rect): Float = if (settings.isStatusPanelEnabled()) {
area.top + viewSettings.marginTop.toFloat() + MARGIN_TOP
} else {
area.top + viewSettings.marginTop.toFloat()
}
override fun getTop(area: Rect): Float = if (settings.isStatusPanelEnabled()) {
area.top + viewSettings.marginTop.toFloat() + getDefaultTopMargin()
} else {
area.top + viewSettings.marginTop.toFloat()
}

override fun onDraw(canvas: Canvas, drawArea: Rect?) {

Expand All @@ -61,22 +61,23 @@ internal class GaugeSurfaceRenderer(

gaugeDrawer.drawBackground(canvas, area)

var top = getDrawTop(area)
var top = getTop(area)

if (settings.isStatusPanelEnabled()) {
val left = gaugeDrawer.getMarginLeft(area.left.toFloat())
gaugeDrawer.drawStatusPanel(canvas,top, left, fps)
top += 4
top += MARGIN_TOP
gaugeDrawer.drawDivider(canvas, left, area.width().toFloat(), top, Color.DKGRAY)
top += 10
}

when (metrics.size) {
0 -> {}
1 -> {
gaugeDrawer.drawGauge(
canvas = canvas,
left = area.left + area.width() / 6f,
top = top,
top = top + 6f,
width = area.width() * widthScaleRatio(metrics),
metric = metrics[0],
labelCenterYPadding = 22f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private const val CURRENT_MAX = 72f
private const val NEW_MAX = 1.6f
private const val NEW_MIN = 0.6f
private const val AREA_MAX_WIDTH = 500
private const val MARGIN_TOP = 4


@Suppress("NOTHING_TO_INLINE")
internal class GiuliaSurfaceRenderer(
Expand Down Expand Up @@ -65,7 +65,7 @@ internal class GiuliaSurfaceRenderer(

giuliaDrawer.drawBackground(canvas, area)

var top = getDrawTop(area)
var top = getTop(area)
var left = giuliaDrawer.getMarginLeft(area.left.toFloat())

if (settings.isStatusPanelEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.obd.graphs.bl.collector.MetricsCollector
import org.obd.graphs.bl.query.*
import org.obd.graphs.renderer.*


@Suppress("NOTHING_TO_INLINE")
internal class TripInfoSurfaceRenderer(
context: Context,
Expand All @@ -51,16 +50,16 @@ internal class TripInfoSurfaceRenderer(

val margin = 0
val area = getArea(it, canvas, margin)
var top = getDrawTop(area)
var top = getTop(area)
val left = tripInfoDrawer.getMarginLeft(area.left.toFloat())

if (settings.isStatusPanelEnabled()) {
tripInfoDrawer.drawStatusPanel(canvas, top, left, fps, metricsCollector, drawContextInfo = true)
top += 4
top += MARGIN_TOP
tripInfoDrawer.drawDivider(canvas, left, area.width().toFloat(), top, Color.DKGRAY)
top += 40
} else {
top += 8
top += MARGIN_TOP
}

tripInfoDrawer.drawScreen(
Expand Down

0 comments on commit 8297062

Please sign in to comment.