-
-
Notifications
You must be signed in to change notification settings - Fork 90
library: Add Box entry #216
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
84c4638
library: Add Box entry
AkshayWarrier d044502
Box: Remove unnecessary line
AkshayWarrier c273df4
Box: Add references
AkshayWarrier f8d2fcf
Box: Some changes from PR review
AkshayWarrier af2c16b
Box: Apply all changes from PR review
AkshayWarrier 226d5ab
Box: Changes from PR review
AkshayWarrier 1443808
Merge branch 'main' into add-box-entry
sonnyp 6c984a1
add tooltips
sonnyp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| using Gtk 4.0; | ||
| using Adw 1; | ||
|
|
||
| Adw.Clamp { | ||
| maximum-size: 1024; | ||
|
|
||
| Box { | ||
| orientation: vertical; | ||
|
|
||
| Label { | ||
| label: "Box"; | ||
| margin-top: 12; | ||
| margin-bottom: 12; | ||
| styles [ | ||
| "title-1", | ||
| ] | ||
| } | ||
|
|
||
| Label { | ||
| label: _("A widget that arranges its child widgets into a single row or column"); | ||
| } | ||
|
|
||
| Box{ | ||
| halign: center; | ||
| valign: end; | ||
| margin-bottom: 12; | ||
|
|
||
| LinkButton{ | ||
| label: "Tutorial"; | ||
| uri: "https://developer.gnome.org/documentation/tutorials/beginners/components/box.html"; | ||
| } | ||
|
|
||
| LinkButton{ | ||
| label: "API Reference"; | ||
| uri: "https://docs.gtk.org/gtk4/class.Box.html"; | ||
| } | ||
| } | ||
|
|
||
| Box { | ||
| orientation: vertical; | ||
|
|
||
| Box { | ||
| hexpand: true; | ||
| orientation: vertical; | ||
| spacing: 12; | ||
| margin-bottom:24; | ||
|
|
||
| Box { | ||
| halign: center; | ||
| spacing: 18; | ||
|
|
||
| Button button_append{ | ||
| label: _("Append Item"); | ||
| styles [ | ||
| "pill", | ||
| ] | ||
| } | ||
|
|
||
| Button button_prepend{ | ||
| label: _("Prepend Item"); | ||
| styles [ | ||
| "pill", | ||
| ] | ||
| } | ||
|
|
||
| Button button_remove{ | ||
| label: _("Remove Item"); | ||
| styles [ | ||
| "pill", | ||
| ] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Box { | ||
| halign:center; | ||
| spacing:18; | ||
|
|
||
| Box{ | ||
| spacing: 18; | ||
| Label { | ||
| label: _("orientation"); | ||
| } | ||
|
|
||
| Box { | ||
| margin-start: 6; | ||
| homogeneous: true; | ||
| halign: center; | ||
| styles ["linked"] | ||
|
|
||
| ToggleButton toggle_orientation_horizontal { | ||
| label: _("horizontal"); | ||
| active: true; | ||
| } | ||
| ToggleButton toggle_orientation_vertical { | ||
| label: _("vertical"); | ||
| group: toggle_orientation_horizontal; | ||
| } | ||
|
AkshayWarrier marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| CheckButton highlight{ | ||
| label: _("Highlight Box"); | ||
| } | ||
| } | ||
|
|
||
| Grid { | ||
|
AkshayWarrier marked this conversation as resolved.
|
||
| margin-top:12; | ||
| margin-bottom:12; | ||
| margin-start:12; | ||
| row-spacing:18; | ||
| margin-end: 114; | ||
|
|
||
| Box { | ||
| tooltip-text: _("Horizontal Alignment"); | ||
| orientation: vertical; | ||
| layout { | ||
| row:0; | ||
| column:1; | ||
| } | ||
| Label { | ||
| margin-top:12; | ||
| margin-bottom:12; | ||
| label: _("halign"); | ||
| } | ||
| Box { | ||
| homogeneous: true; | ||
| halign: center; | ||
| spacing: 36; | ||
| ToggleButton halign_toggle_fill{ | ||
| label: _("fill"); | ||
| active:true; | ||
| } | ||
| ToggleButton halign_toggle_start{ | ||
| label: _("start"); | ||
| group: halign_toggle_fill; | ||
| } | ||
| ToggleButton halign_toggle_center{ | ||
| label: _("center"); | ||
| group: halign_toggle_fill; | ||
| } | ||
| ToggleButton halign_toggle_end{ | ||
| label: _("end"); | ||
| group: halign_toggle_fill; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Box { | ||
| tooltip-text: _("Vertical Alignment"); | ||
| layout { | ||
| row:1; | ||
| column:0; | ||
| } | ||
| Label { | ||
| label: _("valign"); | ||
| styles ["rotate"] | ||
| } | ||
| Box { | ||
| valign:center; | ||
| orientation: vertical; | ||
| spacing: 60; | ||
|
|
||
| ToggleButton valign_toggle_fill{ | ||
| label: _("fill"); | ||
| active:true; | ||
| styles ["rotate"] | ||
| } | ||
| ToggleButton valign_toggle_start{ | ||
| label: _("start"); | ||
| group: valign_toggle_fill; | ||
| styles ["rotate"] | ||
| } | ||
| ToggleButton valign_toggle_center{ | ||
| label: _("center"); | ||
| group: valign_toggle_fill; | ||
| styles ["rotate"] | ||
| } | ||
| ToggleButton valign_toggle_end{ | ||
| label: _("end"); | ||
| group: valign_toggle_fill; | ||
| styles ["rotate"] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ScrolledWindow { | ||
| hexpand: true; | ||
| vexpand:true; | ||
| has-frame: true; | ||
|
|
||
| layout { | ||
| row:1; | ||
| column:1; | ||
| } | ||
| Box interactive_box{ | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| .card { | ||
| margin: 6px; | ||
| padding: 24px; | ||
|
AkshayWarrier marked this conversation as resolved.
|
||
| } | ||
|
|
||
| .border { | ||
| border: 3px solid @accent_color; | ||
| } | ||
|
|
||
| .rotate { | ||
| transform: rotate(-90deg); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import Gtk from "gi://Gtk"; | ||
|
|
||
| const interactive_box = workbench.builder.get_object("interactive_box"); | ||
| const button_append = workbench.builder.get_object("button_append"); | ||
| const button_prepend = workbench.builder.get_object("button_prepend"); | ||
| const button_remove = workbench.builder.get_object("button_remove"); | ||
| let count = 0; | ||
|
|
||
| button_append.connect("clicked", () => { | ||
| const label = new Gtk.Label({ | ||
| name: "card", | ||
| label: `Item ${count + 1}`, | ||
| css_classes: ["card"], | ||
| }); | ||
| interactive_box.append(label); | ||
| count++; | ||
| }); | ||
|
|
||
| button_prepend.connect("clicked", () => { | ||
| const label = new Gtk.Label({ | ||
| name: "card", | ||
| label: `Item ${count + 1}`, | ||
| css_classes: ["card"], | ||
| }); | ||
| interactive_box.prepend(label); | ||
| count++; | ||
| }); | ||
|
|
||
| button_remove.connect("clicked", () => { | ||
| if (count) { | ||
| interactive_box.remove(interactive_box.get_last_child()); | ||
| count--; | ||
| } else { | ||
| console.log("The box has no child widgets to remove"); | ||
| } | ||
| }); | ||
|
|
||
| const toggle_orientation_horizontal = workbench.builder.get_object( | ||
| "toggle_orientation_horizontal", | ||
| ); | ||
| const toggle_orientation_vertical = workbench.builder.get_object( | ||
| "toggle_orientation_vertical", | ||
| ); | ||
|
|
||
| toggle_orientation_horizontal.connect("toggled", () => { | ||
| if (toggle_orientation_horizontal.active) | ||
| interactive_box.orientation = Gtk.Orientation.HORIZONTAL; | ||
| }); | ||
|
|
||
| toggle_orientation_vertical.connect("toggled", () => { | ||
| if (toggle_orientation_vertical.active) | ||
| interactive_box.orientation = Gtk.Orientation.VERTICAL; | ||
| }); | ||
|
|
||
| const highlight = workbench.builder.get_object("highlight"); | ||
| highlight.connect("toggled", () => { | ||
| highlight.active | ||
| ? interactive_box.add_css_class("border") | ||
| : interactive_box.remove_css_class("border"); | ||
| }); | ||
|
|
||
| const halign_toggle_fill = workbench.builder.get_object("halign_toggle_fill"); | ||
| const halign_toggle_start = workbench.builder.get_object("halign_toggle_start"); | ||
| const halign_toggle_center = workbench.builder.get_object( | ||
| "halign_toggle_center", | ||
| ); | ||
| const halign_toggle_end = workbench.builder.get_object("halign_toggle_end"); | ||
|
|
||
| halign_toggle_fill.connect("toggled", () => { | ||
| if (halign_toggle_fill.active) interactive_box.halign = Gtk.Align.FILL; | ||
| }); | ||
|
|
||
| halign_toggle_start.connect("toggled", () => { | ||
| if (halign_toggle_start.active) interactive_box.halign = Gtk.Align.START; | ||
| }); | ||
|
|
||
| halign_toggle_center.connect("toggled", () => { | ||
| if (halign_toggle_center.active) interactive_box.halign = Gtk.Align.CENTER; | ||
| }); | ||
|
|
||
| halign_toggle_end.connect("toggled", () => { | ||
| if (halign_toggle_end.active) interactive_box.halign = Gtk.Align.END; | ||
| }); | ||
|
|
||
| const valign_toggle_fill = workbench.builder.get_object("valign_toggle_fill"); | ||
| const valign_toggle_start = workbench.builder.get_object("valign_toggle_start"); | ||
| const valign_toggle_center = workbench.builder.get_object( | ||
| "valign_toggle_center", | ||
| ); | ||
| const valign_toggle_end = workbench.builder.get_object("valign_toggle_end"); | ||
|
|
||
| valign_toggle_fill.connect("toggled", () => { | ||
| if (valign_toggle_fill.active) interactive_box.valign = Gtk.Align.FILL; | ||
| }); | ||
|
|
||
| valign_toggle_start.connect("toggled", () => { | ||
| if (valign_toggle_start.active) interactive_box.valign = Gtk.Align.START; | ||
| }); | ||
|
|
||
| valign_toggle_center.connect("toggled", () => { | ||
| if (valign_toggle_center.active) interactive_box.valign = Gtk.Align.CENTER; | ||
| }); | ||
| valign_toggle_end.connect("toggled", () => { | ||
| if (valign_toggle_end.active) interactive_box.valign = Gtk.Align.END; | ||
| }); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "Box", | ||
| "category": "user_interface", | ||
| "description": "A widget that arranges its child widgets into a single row or column", | ||
| "panels": [ | ||
| "preview" | ||
| ], | ||
| "autorun": true | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.