-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
led and ledbar widget to visualize binary data #88
base: master
Are you sure you want to change the base?
Conversation
Thanks this is very cool. |
Pull Request Test Coverage Report for Build 8478408157Details
💛 - Coveralls |
Hi @andydotxyz I made some tests with widget.Label but this widget inherits a lot of settings from theme (like padding for example). That make the text very hard to place under the led icon. (In alternative I would have to make a very bigger led). This object i more like a gauge so I think the text under it can be considered more like any other graphical item and in this way the coanvas.text give us more freedom to handle it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use the canvas.Text in this way it will need to respect the theme for at least the colour, if not the size information as well.
And you should test that it updates when the theme changes too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I agree with Andrew about using label instead. I also added a few suggestions inline.
var ( | ||
counter1 int | ||
ledbar1 *xwidget.LedBar | ||
ledbar2 *xwidget.LedBar | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use global variables please. Use an anonymous function in the main function instead or update the run function to take in pointer parameters for the things you have to modify.
if (state & b) == b { | ||
w.leds[l-i].(*Led).Set(true) | ||
} else { | ||
w.leds[l-i].(*Led).Set(false) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass in the boolean directly instead of branching.
if (state & b) == b { | |
w.leds[l-i].(*Led).Set(true) | |
} else { | |
w.leds[l-i].(*Led).Set(false) | |
} | |
w.leds[l-i].(*Led).Set(state & b == b) |
|
||
var l int = len(w.texts) - 1 | ||
var b int = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var l int = len(w.texts) - 1 | |
var b int = 1 | |
l := len(w.texts) - 1 | |
b := 1 |
if w.state { | ||
return w.OnColor | ||
} else { | ||
return w.offColor | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if w.state { | |
return w.OnColor | |
} else { | |
return w.offColor | |
} | |
if w.state { | |
return w.OnColor | |
} | |
return w.offColor |
} | ||
|
||
func (h *ledRenderer) MinSize() fyne.Size { | ||
log.Println(h.led.Size()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the debug print.
|
||
func (h *ledRenderer) MinSize() fyne.Size { | ||
log.Println(h.led.Size()) | ||
return fyne.NewSize(h.led.Size().Width, h.led.Size().Height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the current size should be the minimum but this is at least simpler than what is there currently:
return fyne.NewSize(h.led.Size().Width, h.led.Size().Height) | |
return h.led.Size() |
Small widget that show a led representation of a binary number.