figuro icon indicating copy to clipboard operation
figuro copied to clipboard

dancer text

Open Martinix75 opened this issue 5 months ago • 5 comments

Hi these days I finally have some time and I am learning to "play" with a figguro. To start I wrote this, (very simple to understand the mechanisms), but my problem is the centering the text in the green button. Because so I wrote it with the window just created it is in a position, but if the explanation moves where he wants, while I would always like it to the center (with every size) where is I wrong? Is there one way to make it fixed in the center in every situation?

import figuro
import figuro/widgets/button

let typeface = defaultTypeface()
let font = Uifont(typefaceId: typeface, size:18)
type
  Main* = ref object of Figuro
proc initialize*(self: Main) {.slot.} =
  self.setTitle("Test 123 init ")
  
proc draw*(self: Main) {.slot.} =
  #self.setTitle("Test 123 draw")
  withWidget(self):
    this.setName "pippo"
    Rectangle.new "sfondo":
      with this:
        box 0'ux, 0'ux, 100'pp, 100'pp
        fill css"#FF00F0"
      Text.new "scritta":
        with this:
          #box 50'ux, 20'ux, 200'ux, 250'ux
          offset 10'pp, 10'pp
          #justify Center
          text({font: "Ciao"})
      Button.new "b1":
        with this:
          #box 50'ux, 60'ux, 200'ux, 30'ux
          offset 10'pp, 25'pp
          size 10'pp, 15'pp
          fill css "#4caf50"
          cornerRadius 5.0'ux
        Text.new "testob1":
          with this:
            offset 50'pp, 50'pp
            #size 100'pp, 100'pp
            justify Center
            #align Middle
            text({font: "Pippo"})

var main = Main.new()
var frame = newAppFrame(main, size=(700'ui, 240'ui))
startFiguro(frame)

bye by Martin A.

Martinix75 avatar Jul 10 '25 09:07 Martinix75

Thanks for trying Figuro out and reporting an issue!

I’ll try and take a look this weekend to see what’s happening.

elcritch avatar Jul 10 '25 10:07 elcritch

+++ I rewritten the code like this, and it happens un very strange thing ... Upon start, the "Pippo" text is at the perfect center of the button, once I maximize the window, the "Pippo" text moves up, but if I click the button back to the center. Strange behavior, but try (I hope it's not a problem on my PC).

import figuro
import figuro/widgets/button

let typeface = defaultTypeface()
let font = Uifont(typefaceId: typeface, size:18)
type
  Main* = ref object of Figuro
proc initialize*(self: Main) {.slot.} =
  self.setTitle("Test 123 init ")
  
proc draw*(self: Main) {.slot.} =
  #self.setTitle("Test 123 draw")
  withWidget(self):
    this.setName "pippo"
    Rectangle.new "sfondo":
      with this:
        box 0'ux, 0'ux, 100'pp, 100'pp
        fill css"#FF00F0"
      Text.new "scritta":
        with this:
          #box 50'ux, 20'ux, 200'ux, 250'ux
          offset 10'pp, 10'pp
          #justify Center
          text({font: "Ciao"})
      Button.new "b1":
        with this:
          #box 50'ux, 60'ux, 200'ux, 30'ux
          offset 10'pp, 25'pp
          size 10'pp, 15'pp
          fill css "#4caf50"
          cornerRadius 5.0'ux
        Text.new "testob1":
          with this:
            #offset 50'pp, 50'pp
            size 100'pp, 100'pp
            justify Center
            align Middle
            text({font: "Pippo"})
        #[Text.new "btnText":
            size 100'pp, 100'pp
            foreground blackColor
            justify Center
            align Middle
            text({font: "testing"}) ]#

var main = Main.new()
var frame = newAppFrame(main, size=(700'ui, 240'ui))
startFiguro(frame)

auto_awesome Visualizzazione delle traduzioni per spero possa essere utile. ciao da Traduci invece spero possa essrre utile. ciao da 34 / 5.000 I hope it can be useful. Hello from Martin A.

it seems a problem of re-draw!!

Martinix75 avatar Jul 10 '25 12:07 Martinix75

Keep in mind that much of what I say, they can be my mistakes! But I noticed that for example:

ext.new "tx1":
          size 100'pp, 100'pp #--> size or  position??
          justify Center
          align Middle
          foreground css"#11BB99" #blackColor
          text({font: "Test"})

size 100'pp, 100'pp --> The size of the character does not vary as one might think, But it varies its position inside the widget (in my case of the button). Maybe I don't understand the idea well.

For today you don't disturb you anymore. Good evening!

Martinix75 avatar Jul 10 '25 14:07 Martinix75

Keep in mind that much of what I say, they can be my mistakes!

No worries! The feedback is appreciated.

size 100'pp, 100'pp --> The size of the character does not vary as one might think

Ah yes, that only sets the size of the text box, not the font size itself. One difference from HTML currently is that text widgets have their own box size.

You need to modify the font to change the size. You can have multiple different spans of text which have different font sizes in the same text box.

elcritch avatar Jul 10 '25 14:07 elcritch

it seems a problem of re-draw!!

Oh yeah there’s a known problem with re-draw on text sizing. For some reason the font layouts only get partially updated. On the next frame they get fully updated. Once it’s updated they should be stable though.

I’ll file an issue for it. It’s annoying as the text widget does a refresh() call. It’s an annoying glitch.

elcritch avatar Jul 10 '25 14:07 elcritch