Skip to content

Commit

Permalink
#194 removed button.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich2 committed Dec 14, 2022
1 parent 53ad6ad commit dac4c77
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Dev/src/pCiv/CivGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ case class CivGui(canv: CanvasPlatform, scen: CivScen) extends HGridSysGui("Civ
Rectangle.curvedCornersCentred(1.2, 0.8, 0.3, hc.toPt2Reg).parentAll(lu, lu.colour, 2, lu.colour.contrast, 16, 4.toString)
}

def thisTop(): Unit = reTop(navButtons)
def thisTop(): Unit = reTop(proj.buttons)
thisTop()
def frame: GraphicElems = (tiles ++ lunits).slate(-focus).scale(cPScale) +% sls
repaint()
Expand Down
2 changes: 1 addition & 1 deletion Dev/src/pzug/ZugGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ case class ZugGui(canv: CanvasPlatform, scenIn: ZugScen) extends HGridSysGui("Zu
}

statusText = "Welcome to ZugFuher"
def thisTop(): Unit = reTop(RArr(bTurn) ++ proj.buttons.appends(zoomIn, zoomOut))
def thisTop(): Unit = reTop(bTurn %: proj.buttons)
thisTop()
def frame: GraphicElems = polyFills ++ sides1 ++ (lines ++ lunits).slate(-focus).scale(cPScale) ++ active ++ text
proj.getFrame = () => frame
Expand Down
43 changes: 0 additions & 43 deletions Tiling/src/prid/TGridSysGui.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,4 @@ abstract class TGridSysGui(title: String) extends CmdBarGui(title)
var focus: Vec2 = Vec2(0, 0)

def tilePScaleStr = s"scale = ${ptScale.str2} pixels per tile"


def zoomIn: PolygonCompound = clickButton("+"){_ =>
cPScale *= 1.1
repaint()
statusText = tilePScaleStr
thisTop()
}

def zoomOut: PolygonCompound = clickButton("-"){_ =>
cPScale /= 1.1
repaint()
statusText = tilePScaleStr
thisTop()
}

def focusAdj(uniStr: String)(f: (Vec2, Double) => Vec2): PolygonCompound = clickButton(uniStr){butt =>
val delta = butt(1, 10, 100, 0)
focus = f(focus, cPScale * delta / 40)
repaint()
statusText = focus.strSemi(2, 2)
thisTop()
}

def focusLeft: PolygonCompound = focusAdj("\u2190"){ (v, d) =>
val newX: Double = (v.x - d).max(gridSys.left)
Vec2(newX, v.y)
}
def focusRight: PolygonCompound = focusAdj("\u2192"){ (v, d) =>
val newX: Double = (v.x + d).min(gridSys.right)
Vec2(newX, v.y)
}
def focusUp: PolygonCompound = focusAdj("\u2191"){ (v, d) =>
val newY: Double = (v.y + d).min(gridSys.top)
Vec2(v.x, newY)
}

def focusDown: PolygonCompound = focusAdj("\u2193"){ (v, d) =>
val newY: Double = (v.y - d).max(gridSys.bottom)
Vec2(v.x, newY)
}

def navButtons: RArr[PolygonCompound] = RArr(zoomIn, zoomOut, focusLeft, focusRight, focusUp, focusDown)
}
45 changes: 45 additions & 0 deletions Tiling/src/prid/psq/SqGridScen.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,53 @@
/* Copyright 2018-22 Richard Oliver. Licensed under Apache Licence version 2.0. */
package ostrat; package prid; package psq
import geom._, pgui._

abstract class SqSysGui(title: String) extends TGridSysGui(title)
{ override def ptScale: Double = cPScale * 2

def zoomIn: PolygonCompound = clickButton("+") { _ =>
cPScale *= 1.1
repaint()
statusText = tilePScaleStr
thisTop()
}

def zoomOut: PolygonCompound = clickButton("-") { _ =>
cPScale /= 1.1
repaint()
statusText = tilePScaleStr
thisTop()
}

def focusAdj(uniStr: String)(f: (Vec2, Double) => Vec2): PolygonCompound = clickButton(uniStr) { butt =>
val delta = butt(1, 10, 100, 0)
focus = f(focus, cPScale * delta / 40)
repaint()
statusText = focus.strSemi(2, 2)
thisTop()
}

def focusLeft: PolygonCompound = focusAdj("\u2190") { (v, d) =>
val newX: Double = (v.x - d).max(gridSys.left)
Vec2(newX, v.y)
}

def focusRight: PolygonCompound = focusAdj("\u2192") { (v, d) =>
val newX: Double = (v.x + d).min(gridSys.right)
Vec2(newX, v.y)
}

def focusUp: PolygonCompound = focusAdj("\u2191") { (v, d) =>
val newY: Double = (v.y + d).min(gridSys.top)
Vec2(v.x, newY)
}

def focusDown: PolygonCompound = focusAdj("\u2193") { (v, d) =>
val newY: Double = (v.y - d).max(gridSys.bottom)
Vec2(v.x, newY)
}

def navButtons: RArr[PolygonCompound] = RArr(zoomIn, zoomOut, focusLeft, focusRight, focusUp, focusDown)
}

trait SqGridScen extends GridTurnScen
Expand Down

0 comments on commit dac4c77

Please sign in to comment.