~mrms/proped

bc5d8ec1c0716dfd2260fb9fd3c4dbc82f2f8b5a — Marek Maškarinec 2 months ago 3e64e17
port to tophat v0.10
3 files changed, 13 insertions(+), 18 deletions(-)

M gui.um
M main.um
M proped.um
M gui.um => gui.um +4 -4
@@ 66,7 66,7 @@ fn button*(r: rect.Rect, label: str, toggled: bool = false): bool {
	}
	r = drawRect(r, toggled)

	window.beginScissorRect(r)
	canvas.beginScissorRect(r)

	dm := ft.measure(label).mulf(uiscale)



@@ 76,7 76,7 @@ fn button*(r: rect.Rect, label: str, toggled: bool = false): bool {

	ft.draw(label, p, t.fg, uiscale)

	window.endScissor()
	canvas.endScissor()

	pressed := hover && input.isJustReleased(input.mouse1)



@@ 133,7 133,7 @@ fn textbox*(r: rect.Rect, tb: ^TextBox, number: bool = false): str {
	}

	r = drawRect(r, true)
	window.beginScissorRect(r)
	canvas.beginScissorRect(r)

	dm := ft.measure(tb.buffer).mulf(uiscale)



@@ 156,7 156,7 @@ fn textbox*(r: rect.Rect, tb: ^TextBox, number: bool = false): str {
		canvas.drawRect(t.fg, rect.mk(c.x, c.y, 1*uiscale, dm.y))
	}

	window.endScissor()
	canvas.endScissor()

	return tb.buffer
}

M main.um => main.um +4 -3
@@ 1,18 1,19 @@

import (
	"window.um"
	"signal.um"

	"proped.um"
	"thdefs/thdefs.um"
)

fn main() {
fn init*() {
	window.setup("proped", 640, 480)

	proped.setup()
	thdefs.setup()

	for window.cycle() {
	window.onFrame.register(signal.Callback{
		proped.draw()
	}
	}, null)
}

M proped.um => proped.um +5 -11
@@ 456,22 456,16 @@ fn handleKeys*() {
		shift.y -= 20
	}

	if input.isJustPressed('w') {
	if input.isJustPressedc('w') {
		gui.uiscale += 0.1
	}

	if input.isJustPressed('s') {
	if input.isJustPressedc('s') {
		gui.uiscale -= 0.1
	}

	if gui.selIdx == 0 {
		if input.isJustPressed(input.mouse_up) {
			zoom += 0.2
		}
		
		if input.isJustPressed(input.mouse_down) {
			zoom -= 0.2
		}
		zoom += input.getMouseScroll().y * 0.2
	}
}



@@ 486,13 480,13 @@ fn handleInput*() {
}

fn drawWorkspace*(r: rect.Rect) {
	window.beginScissorRect(r)
	canvas.beginScissorRect(r)
		if grid && snap > 0 { drawGrid(r) }
		drawAxis(r)
		r.x += shift.x
		r.y += shift.y
		types[value.typeName].drawFn(r, value)
	window.endScissor()
	canvas.endScissor()
}

fn draw*() {