treeform / fidget

Figma based UI library for nim, with HTML and OpenGL backends.
MIT License
768 stars 33 forks source link

How to run? #3

Closed andreaferretti closed 4 years ago

andreaferretti commented 4 years ago

Hi, are there any instructions on how to run at least the fidget examples? I tried to compile at least fidgetgen (not sure what that is), but it complains about a missing dependency (chroma) which is not in the nimble file, so thought I should ask for instructions first.

treeform commented 4 years ago

Sorry this project is not ready yet. I am still working on it.

I need to update nimble.

You just run the projects directly nim c -r ...yourfile...

fidgetgen was for some thing else..

andreaferretti commented 4 years ago

I understand that the project is not in shape right now. If you ever have the time, I think it would be worthwhile to actually include the dependencies (with working versions) in the nimble file. Right now, it is a hit and miss guessing which dependencies are needed, and I have not been able to compile any example

treeform commented 4 years ago

I have added the .nimble dependancies. I have tested it working on mac and windows.

There is still a ton of work todo.

andreaferretti commented 4 years ago

Thank you! Now I understand the problem I had with the dependencies. Your nimble file declares

requires "glfw >= 3.2.1"

but the latest version published on https://github.com/ephja/nim-glfw is 0.3.1

Do you have access to a more up to date version of glfw?

SolitudeSF commented 4 years ago

@andreaferretti thats probably it https://github.com/nimgl/glfw nimble file should point to git repo instead of just glfw

andreaferretti commented 4 years ago

Then maybe this should be published on nimble. On https://github.com/nim-lang/packages/blob/master/packages.json, glfw points to https://github.com/ephja/nim-glfw

SolitudeSF commented 4 years ago

it is published on nimble in form of https://github.com/nimgl/nimgl subpackage

andreaferretti commented 4 years ago

That is good to know, but what does it mean? On the README of Nimble, subpackages are not even mentioned

SolitudeSF commented 4 years ago

it means you import it with nimgl/glfw instead of just glfw. i mean a logical subpackage.

andreaferretti commented 4 years ago

Then... I guess it should not be mentioned at all in the nimble file and the import should become import nimgl/glfw?

Anyway, I tried changing the nimble file by removing

requires "glfw >= 3.2.1"

and adding

requires "nimgl >= 1.0.1"

and changing src/fidget/openglbackend/base.nim like this

import nimgl/glfw
# import glfw3

and it still does not compile (Error: undeclared identifier: 'GetWindowSize').

Now, I understand that this is a project in development, so it's ok.

I am a little worried about the dependencies though. I guess Nimble should just forbid global installs (no more nimble install somelibrary) in favour of requires somelibrary, otherwise the Nim ecosystem is going to become quite brittle.

treeform commented 4 years ago

I am using https://github.com/rafaelvasco/nimrod-glfw/blob/master/glfw.nimble

packageName   = "glfw"
version       = "3.2.1"

I don't use https://github.com/nimgl/nimgl so that will not work.

treeform commented 4 years ago

I think the https://github.com/rafaelvasco/nimrod-glfw/blob/master/glfw.nimble is broken. It installs as requires "nimrod-glfw >= 3.2.1" but internally calls itself glfw and goes into a folder called glfw-3.2.1 but you import it as glfw3 ... its a mess?

andreaferretti commented 4 years ago

Well, a little mess, but less than I had feared! :-) Nimble suggests to use a module name equal to the package name, but this is not enforced (yet?).

So, it is just a matter of changing

requires "glfw >= 3.2.1"

to

requires "nimrod-glfw >= 3.2.1"

At least now I am able to compile! :-) Not that I see much, the text and inputs are still missing, but I guess that's just the status of the native backend

treeform commented 4 years ago

Sorry the text missing was caused by recent "Mac fix". I have fixed it again. Some of the examples should be showing up now. Added a section to the readme about which examples to run:

Now to run the examples:

Native examples for Windows, macOS, and Linux:

cd examples
nim c -r bars/bars.nim
nim c -r fonts/fonts.nim
nim c -r hovers/hovers.nim
nim c -r inputs/inputs.nim
nim c -r padoftext/padoftext.nim
nim c -r padofcode/padofcode.nim
nim c -r basic/basic.nim

Runs the same examples as HTML:

cd examples
nim js -o:bars/bars.js bars/bars.nim
nim js -o:fonts/fonts.js fonts/fonts.nim
nim js -o:hovers/hovers.js hovers/hovers.nim
nim js -o:inputs/inputs.js inputs/inputs.nim
nim js -o:padoftext/padoftext.js padoftext/padoftext.nim
nim js -o:padofcode/padofcode.js padofcode/padofcode.nim
nim js -o:basic/basic.js basic/basic.nim
andreaferretti commented 4 years ago

Great, thank you! Now all examples run for me as well! :-)

matkuki commented 4 years ago

Hi guys,

I have added the changes to nimrod-glfw as noted above but I still get this error during compilation:

...\.nimble\pkgs\fidget-0.2.1\fidget\openglbackend\slate.nim(27, 33) Error: type mismatch: got <seq[uint8]>
but expected one of:
proc compress(input: string): string
  first type mismatch at position: 1
  required type for input: string
  but expression 'mip.data' is of type: seq[uint8]

expression: snappy.compress(mip.data)

I'm on Windows 10 with Nim Compiler Version 1.1.1 [Windows: amd64].

treeform commented 4 years ago

@matkuki it looks like you have the wrong snappy version? Make sure you have this one: https://github.com/treeform/snappy

It looks like the nimble's snappy is not mine? https://nimble.directory/pkg/snappy

I'll fix my .nimble file.

treeform commented 4 years ago

I have updated the nimble file see if it works for you now.

Also latest version of nim is 1.0.2 not 1.1.1! https://nim-lang.org/blog.html

SolitudeSF commented 4 years ago

1.1.1 is devel

matkuki commented 4 years ago

Yes, I did a fresh install a couple of days ago.

@treeform I deleted my old snappy installation and tried your new nimble file, but I had to change the line: requires "https://github.com/treeform/snappy@4c900cb0d979a2b8fc07835925d268319a6b1129" to requires "https://github.com/treeform/snappy" otherwise I got an error when nimble wanted to download the repository. But I still get the same error.

andreaferretti commented 4 years ago

The right incantation is requires "https://github.com/treeform/snappy#4c900cb0d979a2b8fc07835925d268319a6b1129"

matkuki commented 4 years ago

@andreaferretti Thanks, yes that fixes the snappy installation. Just noticed that the nim js ... compilation works, but the nim c ... doesn't. I guess it's not ready yet?

treeform commented 4 years ago

What issue do you get? It supposed to all work.

matkuki commented 4 years ago

Hey @treeform As I showed above, it's the same error when compiling for example examples/basic/basic.nim with nim c basic.nim:

Hint: slate [Processing]
Hint: snappy [Processing]
...\.nimble\pkgs\fidget-0.2.1\fidget\openglbackend\slate.nim(27, 33) Error: type mismatch: got <seq[uint8]>
but expected one of:
proc compress(input: string): string
  first type mismatch at position: 1
  required type for input: string
  but expression 'mip.data' is of type: seq[uint8]

expression: snappy.compress(mip.data)

... but compiling with nim js basic.nim works.

treeform commented 4 years ago

I have fixed the nimble file can you try reinstalling this package (which should fix the dependencies) and see if it works for you?

matkuki commented 4 years ago

Hey @treeform I removed fidget and reinstalled it with nimble install https://github.com/treeform/fidget and compiled the basic.nim with ˙nim c basic.nim˙ again and got the same error I think:

$ nim c basic.nim
Hint: used config file 'C:\Nim\config\nim.cfg' [Conf]
Hint: used config file '...\nim.cfg' [Conf]
Hint: used config file 'C:\Nim\config\config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: basic [Processing]
Hint: fidget [Processing]
Hint: macros [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: algorithm [Processing]
Hint: json [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: unicode [Processing]
Hint: lexbase [Processing]
Hint: streams [Processing]
Hint: parsejson [Processing]
Hint: options [Processing]
Hint: typetraits [Processing]
Hint: chroma [Processing]
Hint: names [Processing]
Hint: colortypes [Processing]
Hint: transformations [Processing]
Hint: print [Processing]
Hint: vmath [Processing]
Hint: random [Processing]
Hint: times [Processing]
Hint: winlean [Processing]
Hint: dynlib [Processing]
Hint: time_t [Processing]
Hint: uibase [Processing]
Hint: sequtils [Processing]
Hint: textboxes [Processing]
Hint: typography [Processing]
Hint: flippy [Processing]
Hint: os [Processing]
Hint: pathnorm [Processing]
Hint: osseps [Processing]
Hint: read [Processing]
Hint: components [Processing]
Hint: write [Processing]
Hint: font [Processing]
Hint: svg [Processing]
Hint: xmlparser [Processing]
Hint: parsexml [Processing]
Hint: strtabs [Processing]
Hint: xmltree [Processing]
Hint: ttf [Processing]
Hint: endians [Processing]
Hint: opentype [Processing]
Hint: encodings [Processing]
Hint: opentypedata [Processing]
Hint: rasterizer [Processing]
Hint: layout [Processing]
...\fidget\src\fidget\uibase.nim(1, 23) Warning: imported and not used: 'sequtils' [UnusedImport]
Hint: backendopengl [Processing]
Hint: base [Processing]
Hint: opengl [Processing]
Hint: input [Processing]
...\fidget\src\fidget\openglbackend\input.nim(1, 8) Warning: imported and not used: 'unicode' [UnusedImport]
Hint: perf [Processing]
Hint: strformat [Processing]
Hint: staticglfw [Processing]
C:\Nim\lib\system\timers.nim(27, 8) Hint: '-' is declared but not used [XDeclaredButNotUsed]
C:\Nim\lib\system\timers.nim(24, 8) Hint: 'getTicks' is declared but not used [XDeclaredButNotUsed]
...\fidget\src\fidget\openglbackend\base.nim(3, 31) Warning: imported and not used: 'print' [UnusedImport]
...\fidget\src\fidget\openglbackend\base.nim(2, 17) Warning: imported and not used: 'sequtils' [UnusedImport]
Hint: context [Processing]
Hint: meshes [Processing]
Hint: shaders [Processing]
...\fidget\src\fidget\openglbackend\shaders.nim(3, 8) Warning: imported and not used: 'times' [UnusedImport]
Hint: textures [Processing]
...\fidget\src\fidget\openglbackend\textures.nim(90, 23) Hint: conversion from GLenum to itself is pointless [ConvFromXtoItselfNotNeeded]

...\fidget\src\fidget\openglbackend\textures.nim(91, 23) Hint: conversion from GLenum to itself is pointless [ConvFromXtoItselfNotNeeded]

...\fidget\src\fidget\openglbackend\textures.nim(1, 8) Warning: imported and not used: 'os' [UnusedImport]
...\fidget\src\fidget\openglbackend\textures.nim(1, 12) Warning: imported and not used: 'streams' [UnusedImport]
...\fidget\src\fidget\openglbackend\textures.nim(1, 21) Warning: imported and not used: 'tables' [UnusedImport]
...\fidget\src\fidget\openglbackend\textures.nim(1, 29) Warning: imported and not used: 'strutils' [UnusedImport]
...\fidget\src\fidget\openglbackend\textures.nim(1, 39) Warning: imported and not used: 'times' [UnusedImport]
...\fidget\src\fidget\openglbackend\textures.nim(2, 23) Warning: imported and not used: 'vmath' [UnusedImport]
...\fidget\src\fidget\openglbackend\textures.nim(2, 16) Warning: imported and not used: 'print' [UnusedImport]
Hint: slate [Processing]
Hint: snappy [Processing]
...\fidget\src\fidget\openglbackend\slate.nim(27, 33) Error: type mismatch: got <seq[uint8]>
but expected one of:
proc compress(input: string): string
  first type mismatch at position: 1
  required type for input: string
  but expression 'mip.data' is of type: seq[uint8]

expression: snappy.compress(mip.data)

I also tried removing snappy and fidget (as snappy seems to be causing the problem), then reinstalled fidget, but the error persists.

treeform commented 4 years ago

Could you remove snappy? And run my installer again? So that it installs the right one.

On Tue, Jan 14, 2020, 12:30 PM matkuki notifications@github.com wrote:

Hey @treeform https://github.com/treeform I removed fidget and reinstalled it with nimble install https://github.com/treeform/fidget and compiled the basic.nim with ˙nim c basic.nim˙ again and got the same error I think:

$ nim c basic.nim

Hint: used config file 'C:\Nim\config\nim.cfg' [Conf]

Hint: used config file '...\nim.cfg' [Conf]

Hint: used config file 'C:\Nim\config\config.nims' [Conf]

Hint: system [Processing]

Hint: widestrs [Processing]

Hint: io [Processing]

Hint: basic [Processing]

Hint: fidget [Processing]

Hint: macros [Processing]

Hint: tables [Processing]

Hint: hashes [Processing]

Hint: math [Processing]

Hint: bitops [Processing]

Hint: algorithm [Processing]

Hint: json [Processing]

Hint: strutils [Processing]

Hint: parseutils [Processing]

Hint: unicode [Processing]

Hint: lexbase [Processing]

Hint: streams [Processing]

Hint: parsejson [Processing]

Hint: options [Processing]

Hint: typetraits [Processing]

Hint: chroma [Processing]

Hint: names [Processing]

Hint: colortypes [Processing]

Hint: transformations [Processing]

Hint: print [Processing]

Hint: vmath [Processing]

Hint: random [Processing]

Hint: times [Processing]

Hint: winlean [Processing]

Hint: dynlib [Processing]

Hint: time_t [Processing]

Hint: uibase [Processing]

Hint: sequtils [Processing]

Hint: textboxes [Processing]

Hint: typography [Processing]

Hint: flippy [Processing]

Hint: os [Processing]

Hint: pathnorm [Processing]

Hint: osseps [Processing]

Hint: read [Processing]

Hint: components [Processing]

Hint: write [Processing]

Hint: font [Processing]

Hint: svg [Processing]

Hint: xmlparser [Processing]

Hint: parsexml [Processing]

Hint: strtabs [Processing]

Hint: xmltree [Processing]

Hint: ttf [Processing]

Hint: endians [Processing]

Hint: opentype [Processing]

Hint: encodings [Processing]

Hint: opentypedata [Processing]

Hint: rasterizer [Processing]

Hint: layout [Processing]

...\fidget\src\fidget\uibase.nim(1, 23) Warning: imported and not used: 'sequtils' [UnusedImport]

Hint: backendopengl [Processing]

Hint: base [Processing]

Hint: opengl [Processing]

Hint: input [Processing]

...\fidget\src\fidget\openglbackend\input.nim(1, 8) Warning: imported and not used: 'unicode' [UnusedImport]

Hint: perf [Processing]

Hint: strformat [Processing]

Hint: staticglfw [Processing]

C:\Nim\lib\system\timers.nim(27, 8) Hint: '-' is declared but not used [XDeclaredButNotUsed]

C:\Nim\lib\system\timers.nim(24, 8) Hint: 'getTicks' is declared but not used [XDeclaredButNotUsed]

...\fidget\src\fidget\openglbackend\base.nim(3, 31) Warning: imported and not used: 'print' [UnusedImport]

...\fidget\src\fidget\openglbackend\base.nim(2, 17) Warning: imported and not used: 'sequtils' [UnusedImport]

Hint: context [Processing]

Hint: meshes [Processing]

Hint: shaders [Processing]

...\fidget\src\fidget\openglbackend\shaders.nim(3, 8) Warning: imported and not used: 'times' [UnusedImport]

Hint: textures [Processing]

...\fidget\src\fidget\openglbackend\textures.nim(90, 23) Hint: conversion from GLenum to itself is pointless [ConvFromXtoItselfNotNeeded]

...\fidget\src\fidget\openglbackend\textures.nim(91, 23) Hint: conversion from GLenum to itself is pointless [ConvFromXtoItselfNotNeeded]

...\fidget\src\fidget\openglbackend\textures.nim(1, 8) Warning: imported and not used: 'os' [UnusedImport]

...\fidget\src\fidget\openglbackend\textures.nim(1, 12) Warning: imported and not used: 'streams' [UnusedImport]

...\fidget\src\fidget\openglbackend\textures.nim(1, 21) Warning: imported and not used: 'tables' [UnusedImport]

...\fidget\src\fidget\openglbackend\textures.nim(1, 29) Warning: imported and not used: 'strutils' [UnusedImport]

...\fidget\src\fidget\openglbackend\textures.nim(1, 39) Warning: imported and not used: 'times' [UnusedImport]

...\fidget\src\fidget\openglbackend\textures.nim(2, 23) Warning: imported and not used: 'vmath' [UnusedImport]

...\fidget\src\fidget\openglbackend\textures.nim(2, 16) Warning: imported and not used: 'print' [UnusedImport]

Hint: slate [Processing]

Hint: snappy [Processing]

...\fidget\src\fidget\openglbackend\slate.nim(27, 33) Error: type mismatch: got <seq[uint8]>

but expected one of:

proc compress(input: string): string

first type mismatch at position: 1

required type for input: string

but expression 'mip.data' is of type: seq[uint8]

expression: snappy.compress(mip.data)

I also tried removing the snappy and fidget (as snappy seems to be causing the problem), then reinstalled fidget, but the error persists.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/treeform/fidget/issues/3?email_source=notifications&email_token=AAA6X7FCGJS4DOQINDKK4CTQ5YOF7A5CNFSM4JKDJPL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI6ANFQ#issuecomment-574359190, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA6X7AJJYEVWUKF6FUJ3KDQ5YOF7ANCNFSM4JKDJPLQ .

matkuki commented 4 years ago

I tried removing snappy again and reinstalling fidget with:

git clone https://github.com/treeform/fidget
cd fidget 
nimble install
cd examples/minimal
nim c -r minimal

But the installation always installs the same version of snappy:

$ nimble install
  Verifying dependencies for fidget@0.2.1
      Info: Dependency on chroma@>= 0.0.1 already satisfied
  Verifying dependencies for chroma@0.1.0
      Info: Dependency on typography@>= 0.2.2 already satisfied
  Verifying dependencies for typography@0.2.2
      Info: Dependency on flippy@>= 0.2.0 already satisfied
  Verifying dependencies for flippy@0.4.0
      Info: Dependency on vmath@>= 0.1.0 already satisfied
  Verifying dependencies for vmath@0.2.2
      Info: Dependency on chroma@>= 0.0.1 already satisfied
  Verifying dependencies for chroma@0.1.0
      Info: Dependency on print@>= 0.1.0 already satisfied
  Verifying dependencies for print@0.1.0
      Info: Dependency on stb_image@>= 2.1 already satisfied
  Verifying dependencies for stb_image@2.4
      Info: Dependency on vmath@>= 0.2.0 already satisfied
  Verifying dependencies for vmath@0.2.2
      Info: Dependency on chroma@>= 0.0.1 already satisfied
  Verifying dependencies for chroma@0.1.0
      Info: Dependency on print@>= 0.1.0 already satisfied
  Verifying dependencies for print@0.1.0
      Info: Dependency on stb_image@>= 2. already satisfied
  Verifying dependencies for stb_image@2.4
      Info: Dependency on flippy@>= 0.2.0 already satisfied
  Verifying dependencies for flippy@0.4.0
      Info: Dependency on vmath@>= 0.1.0 already satisfied
  Verifying dependencies for vmath@0.2.2
      Info: Dependency on chroma@>= 0.0.1 already satisfied
  Verifying dependencies for chroma@0.1.0
      Info: Dependency on print@>= 0.1.0 already satisfied
  Verifying dependencies for print@0.1.0
      Info: Dependency on stb_image@>= 2.1 already satisfied
  Verifying dependencies for stb_image@2.4
      Info: Dependency on vmath@>= 0.2.0 already satisfied
  Verifying dependencies for vmath@0.2.2
      Info: Dependency on print@>= 0.1.0 already satisfied
  Verifying dependencies for print@0.1.0
      Info: Dependency on opengl@>= 1.2.3 already satisfied
  Verifying dependencies for opengl@#head
 Installing snappy@any version
Downloading https://github.com/jangko/snappy using git
  Verifying dependencies for snappy@0.1.0
 Installing snappy@0.1.0
   Success: snappy installed successfully.
      Info: Dependency on html5_canvas@any version already satisfied
  Verifying dependencies for html5_canvas@1.3
      Info: Dependency on https://github.com/treeform/staticglfw@#dfebb6dc9b7ecabfa87608cb9d645692545f7880 already satisfied
  Verifying dependencies for staticglfw@#dfebb6dc9b7ecabfa87608cb9d645692545f7880
 Installing fidget@0.2.1
   Success: fidget installed successfully.

The error is still there.

treeform commented 4 years ago

There is some thing strange going on with snappy. Its complaining about this signature:

proc compress(input: string): string

But its not part of https://github.com/jangko/snappy/blob/master/snappy.nim .

The signature there is:

template compress*(src: openArray[byte]): seq[byte] =

It looks like you are getting it from this snappy: https://github.com/dfdeshom/nimsnappy

It claims to be nimsnappy but the file it provides is snappy.nim so it clashes with the other import.

Please uninstall that nimsnappy so that proper snappy can be found. Which is https://github.com/jangko/snappy/blob/master/snappy.nim version.

So can go into your ~/.nimble/pkg folder and make sure all things that look like "snappy" are gone.

matkuki commented 4 years ago

Yes, that did it! nimsnappy was the culprit! Uninstalling snappy and nimsnappy and reinstalling fidget fixed the issue.

Thank you, @treeform !

I would close this issue, but I don't have the necessary rights.

treeform commented 4 years ago

Cool I am glad that worked!