Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Scala, Scala Native etc. #7

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.3
0.11.8
11 changes: 6 additions & 5 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import mill._
import mill.scalalib._
import mill.scalanativelib._
import mill.scalalib.publish._
import $ivy.`com.goyeau::mill-scalafix::0.2.8`
import $ivy.`com.goyeau::mill-scalafix::0.4.0`
import com.goyeau.mill.scalafix.ScalafixModule
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.1.4`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import de.tobiasroeser.mill.vcs.version.VcsVersion

trait Common extends ScalaNativeModule {
def scalaVersion = "2.13.8"
def scalaNativeVersion = "0.4.4"
def scalaVersion = "3.3.3"
def scalaNativeVersion = "0.5.4"
}

trait Publish extends PublishModule {
Expand All @@ -19,7 +19,8 @@ trait Publish extends PublishModule {
organization = "com.github.lolgab",
url = "https://github.com/lolgab/scalaui",
licenses = Seq(License.MIT),
versionControl = VersionControl.github(owner = "lolgab", repo = "scalaui"),
versionControl =
VersionControl.github(owner = "lolgab", repo = "scalaui"),
developers = Seq(
Developer("lolgab", "Lorenzo Gabriele", "https://github.com/lolgab")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ object WriteOnScreenExample {
val s = texts.head._1
if (s != "") texts = texts.head.copy(_1 = s.init) :: texts.tail
case Key.Down(Key.Coded(key)) =>
val k = if (key >= 'a' && key <= 'z' && e.shiftDown) key - 32 else key
texts = texts.head.copy(_1 = texts.head._1 + k.toChar) :: texts.tail
val k: Char =
if (key >= 'a' && key <= 'z' && e.shiftDown) (key - 32).toChar
else key
texts = texts.head.copy(_1 = texts.head._1 + k) :: texts.tail
case _ =>
}
a.queueRedraw()
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/AbstractTextArea.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait AbstractTextArea extends Component {
fromCString(uiMultilineEntryText(control))
}

def text_=(s: String): Unit = Zone { implicit z =>
def text_=(s: String): Unit = Zone {
require(initialized)
uiMultilineEntrySetText(control, toCString(s))
}
Expand Down
16 changes: 8 additions & 8 deletions scalaui/src/scalaui/AttributedString.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AttributedString private () extends Freeable {

def this(s: String) = {
this()
Zone { implicit z => control = uiNewAttributedString(toCString(s)) }
Zone { control = uiNewAttributedString(toCString(s)) }
}

def text: String = fromCString(uiAttributedStringString(control))
Expand All @@ -21,9 +21,9 @@ class AttributedString private () extends Freeable {
family: String,
start: Int = 0,
end: Int = length
): AttributedString = Zone { implicit z =>
): AttributedString = Zone {
val attr = uiNewFamilyAttribute(toCString(family))
uiAttributedStringSetAttribute(control, attr, start.toULong, end.toULong)
uiAttributedStringSetAttribute(control, attr, start.toCSize, `end`.toCSize)
this
}
def withSize(
Expand All @@ -32,7 +32,7 @@ class AttributedString private () extends Freeable {
end: Int = length
): AttributedString = {
val attr = uiNewSizeAttribute(size)
uiAttributedStringSetAttribute(control, attr, start.toULong, end.toULong)
uiAttributedStringSetAttribute(control, attr, start.toCSize, end.toCSize)
this
}
def withBackground(
Expand All @@ -42,7 +42,7 @@ class AttributedString private () extends Freeable {
): AttributedString = {
val attr =
uiNewBackgroundAttribute(color.red, color.green, color.blue, color.alpha)
uiAttributedStringSetAttribute(control, attr, start.toULong, end.toULong)
uiAttributedStringSetAttribute(control, attr, start.toCSize, end.toCSize)
this
}
def withColor(
Expand All @@ -52,7 +52,7 @@ class AttributedString private () extends Freeable {
): AttributedString = {
val attr =
uiNewColorAttribute(color.red, color.green, color.blue, color.alpha)
uiAttributedStringSetAttribute(control, attr, start.toULong, end.toULong)
uiAttributedStringSetAttribute(control, attr, start.toCSize, end.toCSize)
this
}
def withWeight(
Expand All @@ -61,7 +61,7 @@ class AttributedString private () extends Freeable {
end: Int = length
): AttributedString = {
val attr = uiNewWeightAttribute(weight.toUInt)
uiAttributedStringSetAttribute(control, attr, start.toULong, end.toULong)
uiAttributedStringSetAttribute(control, attr, start.toCSize, end.toCSize)
this
}
def withItalic(
Expand All @@ -70,7 +70,7 @@ class AttributedString private () extends Freeable {
end: Int = length
): AttributedString = {
val attr = uiNewItalicAttribute(italic.id.toUInt)
uiAttributedStringSetAttribute(control, attr, start.toULong, end.toULong)
uiAttributedStringSetAttribute(control, attr, start.toCSize, end.toCSize)
this
}

Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/Brush.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GradientBrush(
control.Y1 = end.y

private val stopsArrayArray = ByteArray.alloc(
(colors.length.toULong * sizeof[uiDrawBrushGradientStop]).toInt
(colors.length.toCSize * sizeof[uiDrawBrushGradientStop]).toInt
)
private[scalaui] val stopsArray: Ptr[uiDrawBrushGradientStop] =
stopsArrayArray.at(0).asInstanceOf[Ptr[uiDrawBrushGradientStop]]
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/Button.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ui._
class Button(text: String, onClick: CFuncPtr0[Unit]) extends Component {
//private val cCallback = CFuncPtr.fromFunction0(onClick)

private[scalaui] def build(): Unit = Zone { implicit z =>
private[scalaui] def build(): Unit = Zone {
control = uiNewButton(toCString(text))
uiButtonOnClicked(control, onClick, null)
}
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/Checkbox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class Checkbox(text: String, onToggled: CFuncPtr0[Unit] = doNothing _)
}

private[scalaui] override def build(): Unit = {
Zone { implicit z => control = uiNewCheckbox(toCString(text)) }
Zone { control = uiNewCheckbox(toCString(text)) }
}
}
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/ComboBox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ComboBox(
}
def selectedName: String = names(selected)

private[scalaui] override def build(): Unit = Zone { implicit z =>
private[scalaui] override def build(): Unit = Zone {
control = uiNewCombobox()
for (name <- names) {
uiComboboxAppend(control, toCString(name))
Expand Down
4 changes: 2 additions & 2 deletions scalaui/src/scalaui/EditableComboBox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class EditableComboBox(
require(initialized)
fromCString(uiEditableComboboxText(control))
}
def currentText_=(v: String): Unit = Zone { implicit z =>
def currentText_=(v: String): Unit = Zone {
require(initialized)
uiEditableComboboxSetText(control, toCString(v))
}

private[scalaui] override def build(): Unit = Zone { implicit z =>
private[scalaui] override def build(): Unit = Zone {
control = uiNewEditableCombobox()
for (name <- names) {
uiEditableComboboxAppend(control, toCString(name))
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/FontButton.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FontButton private (
}

object FontButton {
private def changeFont(b: Ptr[uiFontButton], data: Ptr[Byte]): Unit = {
private def changeFont(b: Ptr[uiFontButton], data: CVoidPtr): Unit = {
val onChange = CFuncPtr.fromPtr[CFuncPtr0[Unit]](data)
onChange()
}
Expand Down
4 changes: 2 additions & 2 deletions scalaui/src/scalaui/Group.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.scalanative.unsafe._
import ui._

class Group(t: String, content: Component, margin: Int = 0) extends Component {
private[scalaui] override def build(): Unit = Zone { implicit z =>
private[scalaui] override def build(): Unit = Zone {
control = uiNewGroup(toCString(t))
content.build()
uiGroupSetChild(control, content.control)
Expand All @@ -16,7 +16,7 @@ class Group(t: String, content: Component, margin: Int = 0) extends Component {
fromCString(uiGroupTitle(control))
}

def title_=(title: String): Unit = Zone { implicit z =>
def title_=(title: String): Unit = Zone {
require(initialized)
uiGroupSetTitle(control, toCString(title))
}
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/Label.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.scalanative.unsafe._
import ui._

class Label(text: String) extends Component {
private[scalaui] def build(): Unit = Zone { implicit z =>
private[scalaui] def build(): Unit = Zone {
control = uiNewLabel(toCString(text))
}
}
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/Menu.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.scalanative.unsafe._
import ui._

class Menu(name: String, items: AppendableToMenu*) extends GraphicObject {
private[scalaui] def build(): Unit = Zone { implicit z =>
private[scalaui] def build(): Unit = Zone {
control = uiNewMenu(toCString(name))
for (item <- items) {
item match {
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/RadioButtons.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RadioButtons(
names(selected)
}

private[scalaui] override def build(): Unit = Zone { implicit z =>
private[scalaui] override def build(): Unit = Zone {
control = uiNewRadioButtons()
for (name <- names) {
uiRadioButtonsAppend(control, toCString(name))
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/Tabs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.scalanative.unsafe._
import ui._

class Tabs(tabs: Seq[(String, Component)]) extends Component {
private[scalaui] override def build(): Unit = Zone { implicit z =>
private[scalaui] override def build(): Unit = Zone {
control = uiNewTab()
for ((name, component) <- tabs) {
component.build()
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/TextField.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.scalanative.unsafe._
import ui._

class TextField(initialText: String) extends Field {
private[scalaui] override def build(): Unit = Zone { implicit z =>
private[scalaui] override def build(): Unit = Zone {
control = uiNewEntry()
uiEntrySetText(control, toCString(initialText))
}
Expand Down
2 changes: 1 addition & 1 deletion scalaui/src/scalaui/TextLayout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private[scalaui] class TextLayout(
) {
//TODO waiting for issue (returning Ptr from Zone) being solved
private[scalaui] var control: Ptr[uiDrawTextLayout] = null
def build(): Unit = Zone { implicit z =>
def build(): Unit = Zone {
val params = alloc[uiDrawTextLayoutParams]()
params.String = text.control
params.DefaultFont = defaultFont.control
Expand Down
8 changes: 4 additions & 4 deletions scalaui/src/scalaui/Window.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Window(
) extends GraphicObject
with Freeable {

private[scalaui] def build(): Unit = Zone { implicit z =>
private[scalaui] def build(): Unit = Zone {
for (menu <- menus) menu.build()
control = uiNewWindow(toCString(_title), width, height, menus.nonEmpty)
content.build()
Expand All @@ -39,12 +39,12 @@ class Window(
}

def messageBox(title: String, description: String): Unit = Zone {
implicit z =>
implicit z: Zone =>
require(initialized)
uiMsgBox(control, toCString(title), toCString(description))
}

def errorBox(title: String, description: String): Unit = Zone { implicit z =>
def errorBox(title: String, description: String): Unit = Zone {
require(initialized)
uiMsgBoxError(control, toCString(title), toCString(description))
}
Expand All @@ -55,7 +55,7 @@ class Window(
else _title
}

def title_=(v: String): Unit = Zone { implicit z =>
def title_=(v: String): Unit = Zone {
require(initialized)
uiWindowSetTitle(control, toCString(v))
}
Expand Down
8 changes: 4 additions & 4 deletions scalaui/src/scalaui/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ package object scalaui {
private var _initialized = false
private[scalaui] def initialized: Boolean = _initialized

private def onShouldQuit(data: Ptr[Byte]): CInt = {
private def onShouldQuit(data: CVoidPtr): CInt = {
uiControlDestroy(data.asInstanceOf[Ptr[uiWindow]])
1
}

private def onClosing(w: Ptr[uiWindow], data: Ptr[Byte]): CInt = {
private def onClosing(w: Ptr[uiWindow], data: CVoidPtr): CInt = {
if (CFuncPtr.fromPtr[CFuncPtr0[Boolean]](data).apply()) {
for (window <- windows; if window.control == w) {
windows = windows.filter(_ != window)
Expand Down Expand Up @@ -186,8 +186,8 @@ package object scalaui {
}

def held(b: MouseButton.Value): Boolean = {
if (b == MouseButton.NoButton) e.Held1To64 == 0.toULong
else (e.Held1To64 & (1.toULong << b.id - 1)) == 1.toULong
if (b == MouseButton.NoButton) e.Held1To64 == 0.toCSize
else (e.Held1To64 & (1.toCSize << b.id - 1)) == 1.toCSize
}
}

Expand Down
Loading
Loading