From e6f11cccb8db2f22111186b841932b70507c008b Mon Sep 17 00:00:00 2001 From: AkshayWarrier Date: Sun, 4 Jun 2023 01:04:44 +0530 Subject: [PATCH 1/7] library: Add Advanced Buttons entry --- src/Library/demos/Advanced Buttons/main.blp | 210 +++++++++++++++++++ src/Library/demos/Advanced Buttons/main.json | 7 + 2 files changed, 217 insertions(+) create mode 100644 src/Library/demos/Advanced Buttons/main.blp create mode 100644 src/Library/demos/Advanced Buttons/main.json diff --git a/src/Library/demos/Advanced Buttons/main.blp b/src/Library/demos/Advanced Buttons/main.blp new file mode 100644 index 000000000..050c93d61 --- /dev/null +++ b/src/Library/demos/Advanced Buttons/main.blp @@ -0,0 +1,210 @@ +using Gtk 4.0; +using Adw 1; + +Adw.StatusPage { + title: "Advanced Buttons"; + description: _("Complex buttons with menus and icons"); + + Box { + orientation: vertical; + halign: center; + spacing: 6; + + Box { + spacing: 6; + halign: center; + orientation: vertical; + + Label { + label: _("Split Button"); + + styles ["title-4"] + } + + Label { + label: _("A combined button and dropdown widget"); + } + + Box { + halign: center; + margin-top: 12; + homogeneous: true; + spacing: 18; + + Box { + margin-top: 6; + margin-bottom: 6; + orientation: vertical; + spacing: 6; + + Adw.SplitButton { + icon-name: "execute-from-symbolic"; + menu-model: button_run_menu; + } + + Label { + label: _("Menu Model"); + } + } + + Box { + margin-top: 6; + margin-bottom: 6; + orientation: vertical; + spacing: 6; + + Adw.SplitButton { + label: _("Open"); + popover: button_popover; + } + + Label { + label: _("Popover"); + } + } + } + } + + LinkButton { + margin-bottom: 18; + label: "API Reference"; + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/class.SplitButton.html"; + } + + Box { + spacing: 6; + halign: center; + orientation: vertical; + + Label { + label: _("Button Content"); + + styles ["title-4"] + } + + Label { + label: _("A helper widget to create buttons with icons and labels"); + } + + Box { + halign: center; + margin-top: 12; + homogeneous: true; + spacing: 18; + + Box { + margin-top: 6; + margin-bottom: 6; + orientation: vertical; + spacing: 6; + + Button { + Adw.ButtonContent { + label: _("Edit"); + icon-name: "edit-symbolic"; + } + } + + Label { + label: _("Button"); + } + } + + Box { + margin-top: 6; + margin-bottom: 6; + orientation: vertical; + spacing: 6; + + MenuButton { + menu-model: button_new_menu; + + Adw.ButtonContent { + label: _("New"); + icon-name: "plus-symbolic"; + } + } + + Label { + label: _("Menu Button"); + } + } + + Box { + margin-top: 6; + margin-bottom: 6; + orientation: vertical; + spacing: 6; + + ToggleButton { + Adw.ButtonContent { + label: _("Alerts"); + icon-name: "bell-large-symbolic"; + } + } + + Label { + label: _("Toggle Button"); + } + } + } + } + + LinkButton { + label: "API Reference"; + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/class.ButtonContent.html"; + } + } +} + +Popover button_popover { + Box { + orientation: vertical; + + SearchEntry { + placeholder-text: _("Search documents"); + } + + Adw.StatusPage { + margin-start: 12; + margin-end: 12; + margin-top: 12; + margin-bottom: 12; + title: _("No Recent Documents"); + icon-name: "clock-symbolic"; + + styles [ + "compact", + "dim-label", + ] + } + } +} + +menu button_new_menu { + item ("New File") + item ("New Folder") + item ("New Window") +} + +menu button_run_menu { + section { + item ("Run") + item ("Run with Leak Detector") + item ("Run with Debugger") + } + + section { + label: _("Settings"); + submenu { + label: _("Accessibility"); + item ("High Contrast") + + section { + label: _("Text Direction"); + item ("Left-to-Right") + item ("Right-to-Left") + } + } + } +} diff --git a/src/Library/demos/Advanced Buttons/main.json b/src/Library/demos/Advanced Buttons/main.json new file mode 100644 index 000000000..0ee106c2e --- /dev/null +++ b/src/Library/demos/Advanced Buttons/main.json @@ -0,0 +1,7 @@ +{ + "name": "Advanced Buttons", + "category": "controls", + "description": "Complex buttons with menus and icons", + "panels": ["ui", "preview"], + "autorun": true +} From 78779b3901311d2d667a84b2078b2e14bbdb57ad Mon Sep 17 00:00:00 2001 From: AkshayWarrier Date: Mon, 5 Jun 2023 18:18:15 +0530 Subject: [PATCH 2/7] Advanced Buttons: Changes from review --- src/Library/demos/Advanced Buttons/main.blp | 14 ++++++-------- src/Library/demos/Advanced Buttons/main.css | 3 +++ 2 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 src/Library/demos/Advanced Buttons/main.css diff --git a/src/Library/demos/Advanced Buttons/main.blp b/src/Library/demos/Advanced Buttons/main.blp index 050c93d61..12811283d 100644 --- a/src/Library/demos/Advanced Buttons/main.blp +++ b/src/Library/demos/Advanced Buttons/main.blp @@ -2,7 +2,7 @@ using Gtk 4.0; using Adw 1; Adw.StatusPage { - title: "Advanced Buttons"; + title: _("Advanced Buttons"); description: _("Complex buttons with menus and icons"); Box { @@ -38,6 +38,7 @@ Adw.StatusPage { spacing: 6; Adw.SplitButton { + halign: center; icon-name: "execute-from-symbolic"; menu-model: button_run_menu; } @@ -66,7 +67,7 @@ Adw.StatusPage { } LinkButton { - margin-bottom: 18; + margin-bottom: 36; label: "API Reference"; uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/class.SplitButton.html"; } @@ -160,16 +161,13 @@ Adw.StatusPage { Popover button_popover { Box { orientation: vertical; - SearchEntry { + margin-bottom: 6; placeholder-text: _("Search documents"); } - + Separator {} Adw.StatusPage { - margin-start: 12; - margin-end: 12; - margin-top: 12; - margin-bottom: 12; + name: "popover_page"; title: _("No Recent Documents"); icon-name: "clock-symbolic"; diff --git a/src/Library/demos/Advanced Buttons/main.css b/src/Library/demos/Advanced Buttons/main.css new file mode 100644 index 000000000..78b163ecc --- /dev/null +++ b/src/Library/demos/Advanced Buttons/main.css @@ -0,0 +1,3 @@ + #popover_page { + min-width: 300px; + } From c5041e51253eb78a7cf8f4dde38d7b60b97712ce Mon Sep 17 00:00:00 2001 From: Karol Lademan Date: Sat, 3 Jun 2023 22:10:44 +0200 Subject: [PATCH 3/7] library: Add Boxed lists entry (#210) --- src/Library/demos/Boxed Lists/main.blp | 74 +++++++++++++++++++++++++ src/Library/demos/Boxed Lists/main.json | 10 ++++ src/about.js | 1 + 3 files changed, 85 insertions(+) create mode 100644 src/Library/demos/Boxed Lists/main.blp create mode 100644 src/Library/demos/Boxed Lists/main.json diff --git a/src/Library/demos/Boxed Lists/main.blp b/src/Library/demos/Boxed Lists/main.blp new file mode 100644 index 000000000..474bb44e7 --- /dev/null +++ b/src/Library/demos/Boxed Lists/main.blp @@ -0,0 +1,74 @@ +using Gtk 4.0; +using Adw 1; + +Adw.StatusPage { + title: _("Boxed Lists"); + description: _("List to present both controls and information"); + + Adw.Clamp { + maximum-size: 500; + + Box { + orientation: vertical; + + ListBox { + selection-mode: none; + styles ["boxed-list"] + + Adw.ActionRow { + title: _("ActionRow can have a prefix child"); + + [prefix] + CheckButton checkbox { + active: true; + } + } + + Adw.ActionRow { + title: _("ActionRow can have a suffix child"); + subtitle: _("The checkbox above controls the spinner"); + + [suffix] + Spinner { + spinning: bind checkbox.active; + } + } + + Adw.EntryRow { + title: _("A row can be an entry"); + } + + Adw.ComboRow { + title: _("Choose an item"); + subtitle: _("ComboRow can have a drop down list"); + model: StringList list { + strings ["this", "is", "a", "string", "list"] + }; + } + + Adw.ExpanderRow { + title: _("Rows can be expandable"); + show-enable-switch: true; + + Adw.ActionRow { + title: _("First row"); + } + Adw.ActionRow { + title: _("Second row"); + } + } + } + + LinkButton { + margin-top: 24; + label: "API Reference"; + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/boxed-lists.html"; + } + + LinkButton { + label: "Human Interface Guidelines"; + uri: "https://developer.gnome.org/hig/patterns/containers/boxed-lists.html"; + } + } + } +} diff --git a/src/Library/demos/Boxed Lists/main.json b/src/Library/demos/Boxed Lists/main.json new file mode 100644 index 000000000..cd9a19b2a --- /dev/null +++ b/src/Library/demos/Boxed Lists/main.json @@ -0,0 +1,10 @@ +{ + "name": "Boxed Lists", + "category": "user_interface", + "description": "List to present both controls and information", + "panels": [ + "preview", + "ui" + ], + "autorun": true +} diff --git a/src/about.js b/src/about.js index ddcbfd5ae..ce8ed3d88 100644 --- a/src/about.js +++ b/src/about.js @@ -59,6 +59,7 @@ ${getBlueprintVersion()} "Angelo Verlain https://www.vixalien.com", "bazylevnik0 https://github.com/bazylevnik0", "Felipe Kinoshita https://mastodon.social/@fkinoshita", + "Karol Lademan https://github.com/karl0d", "Nasah Kuma https://www.mantohnasah.com/", // Add yourself as // "John Doe", From c191b4d4ca78d7fb6f3757638f6e68d69409a90b Mon Sep 17 00:00:00 2001 From: halfmexican <103920890+halfmexican@users.noreply.github.com> Date: Tue, 6 Jun 2023 22:09:03 -0500 Subject: [PATCH 4/7] Library: add Drag-and-Drop entry (#253) Add a basic example of Drag-and-Drop, with re-orderable list box rows. --- src/Library/demos/Drag and Drop/main.blp | 78 ++++++++++++++++++++ src/Library/demos/Drag and Drop/main.js | 87 +++++++++++++++++++++++ src/Library/demos/Drag and Drop/main.json | 7 ++ 3 files changed, 172 insertions(+) create mode 100644 src/Library/demos/Drag and Drop/main.blp create mode 100644 src/Library/demos/Drag and Drop/main.js create mode 100644 src/Library/demos/Drag and Drop/main.json diff --git a/src/Library/demos/Drag and Drop/main.blp b/src/Library/demos/Drag and Drop/main.blp new file mode 100644 index 000000000..2f2a1dba4 --- /dev/null +++ b/src/Library/demos/Drag and Drop/main.blp @@ -0,0 +1,78 @@ +using Gtk 4.0; +using Adw 1; + +Adw.StatusPage { + title: _("Drag and Drop"); + description: _("A User interaction pattern where users drag a UI element from one place to another"); + + Box { + orientation: vertical; + + Adw.Clamp { + maximum-size: 400; + + ListBox list { + styles ["boxed-list"] + + Adw.ActionRow { + title: _("Row 1"); + + [prefix] + Image { + styles ["dim-label"] + icon-name: "list-drag-handle-symbolic"; + } + } + + Adw.ActionRow { + title: _("Row 2"); + + [prefix] + Image { + styles ["dim-label"] + icon-name: "list-drag-handle-symbolic"; + } + } + + Adw.ActionRow { + title: _("Row 3"); + + [prefix] + Image { + styles ["dim-label"] + icon-name: "list-drag-handle-symbolic"; + } + } + + Adw.ActionRow { + title: _("Row 4"); + + [prefix] + Image { + styles ["dim-label"] + icon-name: "list-drag-handle-symbolic"; + } + } + + Adw.ActionRow { + title: _("Row 5"); + + [prefix] + Image { + styles ["dim-label"] + icon-name: "list-drag-handle-symbolic"; + } + } + } + } + + LinkButton { + label: "API Reference"; + uri: "https://docs.gtk.org/gtk4/drag-and-drop.html"; + margin-top: 24; + } + } +} + + + diff --git a/src/Library/demos/Drag and Drop/main.js b/src/Library/demos/Drag and Drop/main.js new file mode 100644 index 000000000..ce96fe0a6 --- /dev/null +++ b/src/Library/demos/Drag and Drop/main.js @@ -0,0 +1,87 @@ +import Gtk from "gi://Gtk"; +import Adw from "gi://Adw"; +import Gdk from "gi://Gdk"; +import GObject from "gi://GObject"; + +const list = workbench.builder.get_object("list"); +const drop_target = Gtk.DropTarget.new(Gtk.ListBoxRow, Gdk.DragAction.MOVE); + +list.add_controller(drop_target); + +// Iterate over ListBox children +for (const row of list) { + let drag_x; + let drag_y; + + const drop_controller = new Gtk.DropControllerMotion(); + + const drag_source = new Gtk.DragSource({ + actions: Gdk.DragAction.MOVE, + }); + + row.add_controller(drag_source); + row.add_controller(drop_controller); + + // Drag handling + drag_source.connect("prepare", (_source, x, y) => { + drag_x = x; + drag_y = y; + + const value = new GObject.Value(); + value.init(Gtk.ListBoxRow); + value.set_object(row); + + return Gdk.ContentProvider.new_for_value(value); + }); + + drag_source.connect("drag-begin", (_source, drag) => { + const allocation = row.get_allocation(); + const drag_widget = new Gtk.ListBox(); + + drag_widget.set_size_request(allocation.width, allocation.height); + drag_widget.add_css_class("boxed-list"); + + const drag_row = new Adw.ActionRow({ title: row.title }); + drag_row.add_prefix( + new Gtk.Image({ + icon_name: "list-drag-handle-symbolic", + css_classes: ["dim-label"], + }), + ); + + drag_widget.append(drag_row); + drag_widget.drag_highlight_row(drag_row); + + const icon = Gtk.DragIcon.get_for_drag(drag); + icon.child = drag_widget; + + drag.set_hotspot(drag_x, drag_y); + }); + + // Update row visuals during DnD operation + drop_controller.connect("enter", () => { + list.drag_highlight_row(row); + }); + + drop_controller.connect("leave", () => { + list.drag_unhighlight_row(); + }); +} + +// Drop Handling +drop_target.connect("drop", (_drop, value, _x, y) => { + const target_row = list.get_row_at_y(y); + const target_index = target_row.get_index(); + + // If value or the target row is null, do not accept the drop + if (!value || !target_row) { + return false; + } + + list.remove(value); + list.insert(value, target_index); + target_row.set_state_flags(Gtk.StateFlags.NORMAL, true); + + // If everything is successful, return true to accept the drop + return true; +}); diff --git a/src/Library/demos/Drag and Drop/main.json b/src/Library/demos/Drag and Drop/main.json new file mode 100644 index 000000000..3f1e880c3 --- /dev/null +++ b/src/Library/demos/Drag and Drop/main.json @@ -0,0 +1,7 @@ +{ + "name": "Drag and Drop", + "category": "user_interface", + "description": "A User interaction pattern where users drag a UI element from one place to another", + "panels": ["code", "ui", "preview"], + "autorun": false +} From 59a8e96ef9369af62ca6c8881e9b7d7ad4d37d02 Mon Sep 17 00:00:00 2001 From: AkshayWarrier <58233418+AkshayWarrier@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:50:38 +0530 Subject: [PATCH 5/7] library: Add TabView entry (#304) --- src/Library/Library.blp | 4 ++ src/Library/demos/Tab View/main.blp | 66 +++++++++++++++++++++++ src/Library/demos/Tab View/main.js | 39 ++++++++++++++ src/Library/demos/Tab View/main.json | 7 +++ src/Library/demos/View Switcher/main.json | 2 +- 5 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 src/Library/demos/Tab View/main.blp create mode 100644 src/Library/demos/Tab View/main.js create mode 100644 src/Library/demos/Tab View/main.json diff --git a/src/Library/Library.blp b/src/Library/Library.blp index 625288e93..901a982e9 100644 --- a/src/Library/Library.blp +++ b/src/Library/Library.blp @@ -39,6 +39,10 @@ Adw.PreferencesWindow library { title: _("Feedback"); } + Adw.PreferencesGroup library_navigation { + title: _("Navigation"); + } + Adw.PreferencesGroup library_user_interface { title: "User Interface"; } diff --git a/src/Library/demos/Tab View/main.blp b/src/Library/demos/Tab View/main.blp new file mode 100644 index 000000000..9a55fde0f --- /dev/null +++ b/src/Library/demos/Tab View/main.blp @@ -0,0 +1,66 @@ +using Gtk 4.0; +using Adw 1; + +Adw.Window { + default-height: 600; + default-width: 800; + title: _("Tab View Demo"); + Adw.TabOverview overview{ + enable-new-tab: true; + view: tab_view; + Box { + orientation: vertical; + Adw.HeaderBar { + Button button_new_tab{ + icon-name: "tab-new-filled-symbolic"; + } + Button button_overview { + icon-name: "grid-filled-symbolic"; + } + } + Adw.TabBar { + view: tab_view; + } + Adw.TabView tab_view{ + Adw.TabPage main_tab_page{ + title: _("Main Page"); + child: + Adw.StatusPage { + hexpand: true; + vexpand: true; + title: _("Tab View"); + description: _("A dynamic tabbed container"); + + Box { + spacing: 6; + orientation: vertical; + Label { + label: _("API References"); + } + Box{ + halign: center; + LinkButton { + label: "Tab View"; + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/class.TabView.html"; + } + LinkButton { + label: "Tab Bar"; + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/class.TabBar.html"; + } + LinkButton { + label: "Tab Overview"; + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/class.TabOverview.html"; + } + } + LinkButton { + label: "Human Interface Guidelines"; + uri: "https://developer.gnome.org/hig/patterns/nav/tabs.html"; + } + } + }; + } + } + } + } +} + diff --git a/src/Library/demos/Tab View/main.js b/src/Library/demos/Tab View/main.js new file mode 100644 index 000000000..8dde8a91d --- /dev/null +++ b/src/Library/demos/Tab View/main.js @@ -0,0 +1,39 @@ +import Gtk from "gi://Gtk"; +import Adw from "gi://Adw"; + +const tab_view = workbench.builder.get_object("tab_view"); +const button_new_tab = workbench.builder.get_object("button_new_tab"); +const overview = workbench.builder.get_object("overview"); +const button_overview = workbench.builder.get_object("button_overview"); +let tab_count = 1; + +overview.connect("create-tab", () => { + return add_page(); +}); + +button_overview.connect("clicked", () => { + overview.open = true; +}); + +button_new_tab.connect("clicked", () => { + add_page(); +}); + +function add_page() { + const title = `Tab ${tab_count}`; + const page = create_page(title); + const tab_page = tab_view.append(page); + tab_page.title = title; + tab_page.live_thumbnail = true; + + tab_count += 1; + return tab_page; +} + +function create_page(title) { + const page = new Adw.StatusPage({ + title: title, + vexpand: true, + }); + return page; +} diff --git a/src/Library/demos/Tab View/main.json b/src/Library/demos/Tab View/main.json new file mode 100644 index 000000000..94ea9806c --- /dev/null +++ b/src/Library/demos/Tab View/main.json @@ -0,0 +1,7 @@ +{ + "name": "Tab View", + "category": "navigation", + "description": "A dynamic tabbed container", + "panels": ["ui", "preview"], + "autorun": true +} diff --git a/src/Library/demos/View Switcher/main.json b/src/Library/demos/View Switcher/main.json index 6ec6243ee..d3c4aa112 100644 --- a/src/Library/demos/View Switcher/main.json +++ b/src/Library/demos/View Switcher/main.json @@ -1,6 +1,6 @@ { "name": "View Switcher", - "category": "user_interface", + "category": "navigation", "description": "View Switchers allow users to switch between different predefined pages", "panels": ["code", "ui", "preview"], "autorun": true From c8dd6035a2242feca957d5873d5fc35ee83cb418 Mon Sep 17 00:00:00 2001 From: niko bazylev <42851684+bazylevnik0@users.noreply.github.com> Date: Wed, 7 Jun 2023 13:38:46 +0300 Subject: [PATCH 6/7] Library: Add Drawing area (#261) --- src/Library/demos/Drawing Area/main.blp | 29 ++++++++ src/Library/demos/Drawing Area/main.js | 85 ++++++++++++++++++++++++ src/Library/demos/Drawing Area/main.json | 10 +++ 3 files changed, 124 insertions(+) create mode 100644 src/Library/demos/Drawing Area/main.blp create mode 100644 src/Library/demos/Drawing Area/main.js create mode 100644 src/Library/demos/Drawing Area/main.json diff --git a/src/Library/demos/Drawing Area/main.blp b/src/Library/demos/Drawing Area/main.blp new file mode 100644 index 000000000..4d6fb361a --- /dev/null +++ b/src/Library/demos/Drawing Area/main.blp @@ -0,0 +1,29 @@ +using Gtk 4.0; +using Adw 1; + +Adw.StatusPage { + title: "Drawing Area"; + description: _("Programmatically draw onto a surface."); + + Box { + halign: center; + orientation: vertical; + + DrawingArea drawing_area { + content-width: 300; + content-height: 300; + } + + Scale scale { + orientation: horizontal; + width-request: 300; + draw-value: true; + adjustment: Gtk.Adjustment { + lower: -25; + upper: 25; + value: 0; + }; + } + } +} +//https://docs.gtk.org/gtk4/class.DrawingArea.html diff --git a/src/Library/demos/Drawing Area/main.js b/src/Library/demos/Drawing Area/main.js new file mode 100644 index 000000000..ecbf1ece4 --- /dev/null +++ b/src/Library/demos/Drawing Area/main.js @@ -0,0 +1,85 @@ +import Cairo from "cairo"; +import Gtk from "gi://Gtk?version=4.0"; +Gtk.init(); + +const drawingArea = workbench.builder.get_object("drawing_area"); +const scaleRotate = workbench.builder.get_object("scale"); + +let triangle = [3]; +triangle[0] = [2]; +triangle[0][0] = 100; +triangle[0][1] = 100; +triangle[1] = [2]; +triangle[1][0] = 0; +triangle[1][1] = -100; +triangle[2] = [2]; +triangle[2][0] = -100; +triangle[2][1] = 100; +let triangle_original = [3]; +for (let i = 0; i < 3; i++) { + let temp = [2]; + temp[0] = triangle[i][0]; + temp[1] = triangle[i][1]; + triangle_original[i] = temp; +} + +drawingArea.set_draw_func((area, cr, width, height) => { + // Draw triangle in context + cr.moveTo(150 + triangle[0][0], 150 + triangle[0][1]); + cr.lineTo(150 + triangle[1][0], 150 + triangle[1][1]); + cr.lineTo(150 + triangle[2][0], 150 + triangle[2][1]); + cr.lineTo(150 + triangle[0][0], 150 + triangle[0][1]); + + cr.setSourceRGBA(1, 0, 1, 1); + cr.stroke(); + // Freeing the context before returning from the callback + cr.$dispose(); +}); + +scaleRotate.connect("value-changed", () => { + // Recalculate value of points of triangle + for (let i = 0; i < 3; i++) { + // Calculate original angle + let x = triangle_original[i][0]; + let y = triangle_original[i][1]; + let angle = Math.atan(Math.abs(y) / Math.abs(x)); + if (x > 0 && y > 0) { + angle = angle; + } + if (x < 0 && y > 0) { + angle = Math.PI - angle; + } + if (x < 0 && y < 0) { + angle = Math.PI + angle; + } + if (x > 0 && y < 0) { + angle = Math.PI * 2 - angle; + } + if (x === 0) { + if (y > 0) { + angle = angle; + } + if (y < 0) { + angle = -1 * angle; + } + } + if (y === 0) { + if (x > 0) { + angle = angle; + } + if (x < 0) { + angle = M_PI; + } + } + // Add to original angle scale value + angle += (scaleRotate.get_value() * Math.PI) / 180; + // Set new value to triangle + let radius = Math.sqrt(x * x + y * y); + + triangle[i][0] = radius * Math.cos(angle); + triangle[i][1] = radius * Math.sin(angle); + } + // Redraw drawing_area + drawingArea.queue_draw(); +}); +//https://www.cairographics.org/tutorial/ diff --git a/src/Library/demos/Drawing Area/main.json b/src/Library/demos/Drawing Area/main.json new file mode 100644 index 000000000..fda5be0e1 --- /dev/null +++ b/src/Library/demos/Drawing Area/main.json @@ -0,0 +1,10 @@ +{ + "name": "Drawing Area", + "category": "user_interface", + "description": "Programmatically draw onto a surface.", + "panels": [ + "ui", + "code" + ], + "autorun": true +} From a7b579bfbe2ec86a3edef414d73e92f4ec91e2c3 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 10 Jun 2023 14:56:15 +0200 Subject: [PATCH 7/7] minor changes --- src/Library/demos/Advanced Buttons/main.blp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Library/demos/Advanced Buttons/main.blp b/src/Library/demos/Advanced Buttons/main.blp index 12811283d..3ed0feb82 100644 --- a/src/Library/demos/Advanced Buttons/main.blp +++ b/src/Library/demos/Advanced Buttons/main.blp @@ -102,7 +102,7 @@ Adw.StatusPage { Button { Adw.ButtonContent { label: _("Edit"); - icon-name: "edit-symbolic"; + icon-name: "document-edit-symbolic"; } } @@ -140,7 +140,7 @@ Adw.StatusPage { ToggleButton { Adw.ButtonContent { label: _("Alerts"); - icon-name: "bell-large-symbolic"; + icon-name: "bell-symbolic"; } } @@ -162,15 +162,15 @@ Popover button_popover { Box { orientation: vertical; SearchEntry { - margin-bottom: 6; placeholder-text: _("Search documents"); } - Separator {} + Adw.StatusPage { name: "popover_page"; title: _("No Recent Documents"); icon-name: "clock-symbolic"; - + width-request: 300; + height-request: 300; styles [ "compact", "dim-label",