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
library: Add Toggle Button Entry #219
Conversation
Kept This Entry minimalistic for a clean design, Implemented icons instead of labels for a nicer feel and look. |
The wide "home" button is a bit weird, what exactly are you trying to demo there? Width-request? Sensitive? My feeling is that button could be dropped, or if you want to make it more unique it could be a button with icon+label. Not sure that belongs in this demo vs. the button one though... Also, I'd not use the two volume icons next to each other, that implies some kind of audio functionality at first glance. I'd use some other icon as the second one, e.g. list-compact or some other generic symbol. |
Maybe replace the home button with a text toggle button (not disabled). Or as Tobias said a button + icon 👍 https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.ButtonContent.html |
I tried implementing some sort of logic as we may get in discord ,i.e, deafen and undeafen audio so i thought it was a good example for the grouped toggle buttons where one is active the other automatically gets untoggled. But as you said I'll implement the changes for the last toggle button and the second toggle button as well |
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 make this look a bit better
ToggleButton button_first { | ||
active: true; | ||
icon-name: "audio-volume-muted-symbolic"; | ||
halign: center; | ||
margin-end: 12; | ||
margin-bottom: 18; | ||
} | ||
|
||
ToggleButton button_second { | ||
active: false; | ||
icon-name: "list-compact"; | ||
halign: center; | ||
group: button_first; | ||
margin-bottom: 18; | ||
} |
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.
ha it's a group then you should use "linked" on the parent box and no space between
please also add a label to explain what each example is about, here "Group"
For the icons - maybe best to use something with a clear on/off state like "eye-not-looking-symbolic" and "eye-open-negative-filled-symbolic"
If you move margin-bottom: 18;
to the parent - it doesn't need to be repeated
label: "Console"; | ||
icon-name: "code-symbolic"; |
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.
label: "Console"; | |
icon-name: "code-symbolic"; | |
label: "Console"; | |
icon-name: "terminal-symbolic"; |
ToggleButton disabled { | ||
halign: center; | ||
margin-bottom: 18; | ||
sensitive: 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.
ToggleButton disabled { | |
halign: center; | |
margin-bottom: 18; | |
sensitive: false; | |
ToggleButton { | |
halign: center; | |
margin-bottom: 18; |
a disabled example isn't helpful here because it's the same as a regular disabled button
third.connect("toggled", () => { | ||
toggle_count_camera++; | ||
console.log( | ||
toggle_count_camera % 2 !== 0 ? "Camera Toggled On" : "Camera Toggled Off", |
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.
use the active
property instead
also, for the text, "Camera on" and "Camera off"
toggle_count_flashlight++; | ||
console.log( | ||
toggle_count_flashlight % 2 !== 0 | ||
? "Flashlight Toggled On" | ||
: "Flashlight Toggled Off", |
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.
same here
Sure, I'll make the changes. |
Box { | ||
orientation: vertical; | ||
|
||
Box Grouped_Toggle_Buttons { |
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.
this id is not used
also - lower case only for ids
} | ||
|
||
Label { | ||
label: "Grouped Toggle Buttons"; |
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.
label: "Grouped Toggle Buttons"; | |
label: "Grouped"; |
|
||
Label { | ||
label: "Grouped Toggle Buttons"; | ||
justify: center; |
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.
this does nothing
in general - remove properties which don't do anything (unless we need them for examples)
Box Grouped_Toggle_Buttons { | ||
orientation: horizontal; | ||
halign: center; | ||
margin-bottom: 12; |
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 use 6px spacing for things that are relevant to each others like the label and its content
active: false; | ||
icon-name: "photo-camera-symbolic"; | ||
halign: center; | ||
margin-end: 6; |
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.
use spacing
on the parent indead
label: "Console"; | ||
icon-name: "terminal-symbolic"; | ||
} | ||
} |
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 add a label to this one as well - "With label"
const terminal = workbench.builder.get_object("console"); | ||
|
||
camera.connect("toggled", () => { | ||
console.log(camera.get_active() ? "Camera On" : "Camera Off"); |
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.
as I said before - use properties when possible - not methods
console.log(flashlight.get_active() ? "Flashlight On" : "Flashlight Off"); | ||
}); | ||
terminal.connect("toggled", () => { | ||
console.log(terminal.get_active() ? "Entered Console" : "Exited Console"); |
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'd use On / Off here too
@@ -0,0 +1,13 @@ | |||
const camera = workbench.builder.get_object("button_third"); | |||
const flashlight = workbench.builder.get_object("button_fourth"); | |||
const terminal = workbench.builder.get_object("console"); |
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.
there should be a Code demo to get the current selected button from the group
ToggleButton button_second { | ||
active: false; | ||
icon-name: "eye-open-negative-filled-symbolic"; | ||
group: button_first; |
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.
there should be a Code demo to get the current selected button from the group
I'll make the required changes |
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 made a small improvemets 44d9ec8
Mostly increase spacing between the various "modes" so everything doesn't look pack and to clarify what the label describes.
Simplified the JS a bit and used notify::active
which is the right way to listen for change son the active
property.
Added Toggle Button Entry/Demo under User Interface section in Library.
Issue workbenchdev/demos#3