ft: minor fixes

pull/1506/head
Alexander Medvednikov 2019-08-07 13:00:19 +02:00
parent ff6e0df0a5
commit cebb6cd537
2 changed files with 13 additions and 18 deletions

View File

@ -1191,9 +1191,10 @@ fn (p mut Parser) statement(add_semi bool) string {
// this can be `user = ...` or `user.field = ...`, in both cases `v` is `user`
fn (p mut Parser) assign_statement(v Var, ph int, is_map bool) {
p.log('assign_statement() name=$v.name tok=')
is_vid := p.fileis('vid') // TODO remove
tok := p.tok
//if !v.is_mut && !v.is_arg && !p.pref.translated && !v.is_global{
if !v.is_mut && !p.pref.translated && !v.is_global{
if !v.is_mut && !p.pref.translated && !v.is_global && !is_vid {
p.error('`$v.name` is immutable')
}
if !v.is_changed {
@ -1758,7 +1759,7 @@ fn (p mut Parser) dot(str_typ string, method_ph int) string {
// Is the next token `=`, `+=` etc? (Are we modifying the field?)
next := p.peek()
modifying := next.is_assign() || next == .inc || next == .dec
is_vi := p.fileis('vi')
is_vi := p.fileis('vid')
if !p.builtin_mod && !p.pref.translated && modifying && !field.is_mut && !is_vi {
p.error('cannot modify immutable field `$field_name` (type `$typ.name`)')
}

View File

@ -248,20 +248,11 @@ fn (ctx mut GG) init_utf8_runes() {
// fn (ctx &GG) render_text(text string, x, y, scale f32, color gx.Color) {
pub fn (ctx &GG) draw_text(_x, _y int, text string, cfg gx.TextCfg) {
// dont draw non ascii for now
/*
for i := 0; i < text.len; i++ {
c := text[i]
if int(c) > 128 {
// ctx.text_ctx._draw_text(_x, _y, '[NON ASCII]', cfg)
// return
}
}
*/
// # glScissor(0,0,300,300);
println('draw text start')
utext := text.ustring_tmp()
// utext := text.ustring()
ctx.text_ctx._draw_text(_x, _y, utext, cfg)
ctx._draw_text(_x, _y, utext, cfg)
println('draw text end')
// utext.free()
// # glScissor(0,0,ctx->width*2,ctx->height*2);
// gl.disable(GL_SCISSOR_TEST)// TODO
@ -286,16 +277,19 @@ fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) {
}
}
*/
mut x := f32(_x)
mut y := f32(_y)
// println('scale=$ctx.scale size=$cfg.size')
if cfg.align == gx.ALIGN_RIGHT {
width := utext.len * 7
_x -= width + 10
x -= width + 10
}
x := f32(_x) * ctx.scale// f32(2)
x *= ctx.scale// f32(2)
// println('y=$_y height=$ctx.height')
// _y = _y * int(ctx.scale) //+ 26
_y = _y * int(ctx.scale) + ((cfg.size * ctx.scale) / 2) + 5 * ctx.scale
y := f32(ctx.height - _y)
y = y * int(ctx.scale) + ((cfg.size * ctx.scale) / 2) + 5 * ctx.scale
y = f32(ctx.height) - y
println('($x, $y)' )
color := cfg.color
// Activate corresponding render state
ctx.shader.use()