Skip to content
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

Merged
merged 7 commits into from Mar 21, 2023
Merged

Conversation

SoNiC-HeRE
Copy link
Contributor

Added Toggle Button Entry/Demo under User Interface section in Library.
Issue workbenchdev/demos#3

@SoNiC-HeRE SoNiC-HeRE changed the title library:Add Toggle Button Entry library: Add Toggle Button Entry Mar 11, 2023
@SoNiC-HeRE
Copy link
Contributor Author

Kept This Entry minimalistic for a clean design, Implemented icons instead of labels for a nicer feel and look.
Divided into 3 sections : 1) Grouped Toggle Buttons 2) Ungrouped Toggle Buttons 3) Disabled Toggle Button.
Could've implemented icon-change design (when a button is toggled) for a better look but probably wont help with grouped Toggle Buttons. Used Icons with more day to day use so that user can relate.

@bertob
Copy link

bertob commented Mar 13, 2023

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.

image

@sonnyp
Copy link
Contributor

sonnyp commented Mar 13, 2023

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

@SoNiC-HeRE
Copy link
Contributor Author

SoNiC-HeRE commented Mar 13, 2023

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

Copy link
Contributor

@sonnyp sonnyp left a 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

Comment on lines 15 to 29
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;
}
Copy link
Contributor

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

Comment on lines 60 to 61
label: "Console";
icon-name: "code-symbolic";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label: "Console";
icon-name: "code-symbolic";
label: "Console";
icon-name: "terminal-symbolic";

Comment on lines 52 to 55
ToggleButton disabled {
halign: center;
margin-bottom: 18;
sensitive: false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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",
Copy link
Contributor

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"

Comment on lines 13 to 17
toggle_count_flashlight++;
console.log(
toggle_count_flashlight % 2 !== 0
? "Flashlight Toggled On"
: "Flashlight Toggled Off",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@SoNiC-HeRE
Copy link
Contributor Author

Sure, I'll make the changes.

@sonnyp sonnyp assigned sonnyp and unassigned bertob Mar 16, 2023
Box {
orientation: vertical;

Box Grouped_Toggle_Buttons {
Copy link
Contributor

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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label: "Grouped Toggle Buttons";
label: "Grouped";


Label {
label: "Grouped Toggle Buttons";
justify: center;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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";
}
}
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

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;
Copy link
Contributor

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

@SoNiC-HeRE
Copy link
Contributor Author

I'll make the required changes

@SoNiC-HeRE SoNiC-HeRE requested review from sonnyp and removed request for bertob March 21, 2023 12:07
Copy link
Contributor

@sonnyp sonnyp left a 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.

@sonnyp sonnyp merged commit 8e2c8df into workbenchdev:main Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants