Closed ghost closed 2 years ago
I do not understand the problem that this solves. Can you add an example that does not compile at master, but does with your PR?
This compiles on both master, and in your PR, so it is not a good example imho:
import ui
fn main() {
lbl := ui.label(text: 'Label')
window := ui.window(
width: 300
height: 200
children: [ui.row(children: [lbl])]
)
ui.run(window)
}
In conclusion, this is the kind of error I get.
/home/tsukasa/.vmodules/ui/debug/ui_extra_debug.v:7:7: error: cannot define new methods on non-local type ui.Stack
5 |
6 | // Draw bounding box for Stack
7 | fn (s &ui.Stack) draw_bb() {
| ~~~~~~~~~
8 | mut col := gx.red
9 | if s.direction == .row {
> v -d bb run simple.v
Then you listen to the compiler and adjust it, and finally you get that error.
I don't know non-local type
exactly.
In any case, having fn (mut s Stack)
in ui_extra_debug.v
is not a good prospect, so the choice is whether to bring this method to stack.v
or make it an argument in this file. In this case, I decided that the latter would be better.
This compiles on both master, and in your PR, so it is not a good example imho:
import ui fn main() { lbl := ui.label(text: 'Label') window := ui.window( width: 300 height: 200 children: [ui.row(children: [lbl])] ) ui.run(window) }
The build_examples.vsh
is too heavy for my computer, so this sample was more desirable to inspect several times during development.
That sample is not absolutely necessary for this PR.
I thought about deleting it before I did the PR, but I thought it would be a good sample of how ui
works even if it is minimal and doesn't use Layout, so I didn't delete it. And I can use it next time too.
It's not absolutely necessary, so should I delete it?
For some reason, this could not be merged through the web UI. I merged it through following the instructions from here:
This is the second time, that it happens with one of your PRs @kahsa, can you please check the settings of your github repository, and/or delete it, then fork https://github.com/vlang/ui again?
In
ui_extra_debug.v
, there are methods forStack
andWidget
, but if you use these structs as receivers in this file, you will get a compilation error if the Stack file and this file are not in the same module. On the other hand, if you move the receiver as an argument, you can just import the Stack. In this way, it is loosely coupled and allows for more flexibility in module differentiation.Consequently, the function names have also been adjusted.
Added
examples/simple.v
for temporal quick check.