Skip to content

Commit

Permalink
Added Scale Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
SoNiC-HeRE committed Mar 3, 2023
1 parent 230b011 commit b53212e
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Library/demos/Scale/main.blp
@@ -0,0 +1,44 @@
using Gtk 4.0;
using Adw 1;

Adw.StatusPage {
title: "Scale";
description: _("A simple sliding control");

Box {
orientation: vertical;
halign: center;

Scale one {
orientation: horizontal;
margin-bottom: 20;
}

Scale two {
orientation: horizontal;
margin-bottom: 20;
}

Scale disabled {
orientation: horizontal;
sensitive: false;
margin-bottom: 20;
}

LinkButton {
label: "Tutoral";
uri: "https://developer-old.gnome.org/gtkmm-tutorial/stable/sec-scale-widgets.html.en";
}

LinkButton {
label: "API Reference";
uri: "https://docs.gtk.org/gtk4/class.Scale.html";
}

LinkButton {
label: "Human Interface Guidelines";
uri: "https://developer.gnome.org/hig/patterns/controls/sliders.html";
}
}
}

36 changes: 36 additions & 0 deletions src/Library/demos/Scale/main.js
@@ -0,0 +1,36 @@
const scale_one = workbench.builder.get_object("one");
const scale_two = workbench.builder.get_object("two");
const scale_disabled = workbench.builder.get_object("disabled");

scale_one.set_range(true, 50);

scale_two.set_range(true, 50);
scale_two.set_inverted(true);
scale_two.add_mark(10.0, "right", null);
scale_two.add_mark(20.0, "right", null);
scale_two.add_mark(30.0, "right", null);
scale_two.add_mark(40.0, "right", null);
scale_two.add_mark(50.0, "right", null);
scale_two.set_increments(10.0, 10.0);

scale_disabled.set_range(true, 50);
scale_disabled.set_value(25);
scale_disabled.set_show_fill_level(25);

scale_one.connect("value_changed", () => {
let scale_value = scale_one.get_value();
if (scale_value === 50) {
console.log("Max Value Reached");
} else if (scale_value === 1) {
console.log("Min Value Reached");
}
});

scale_two.connect("value_changed", () => {
let scale_value_two = scale_two.get_value();
if (scale_value_two === 50) {
console.log("Max Value Reached");
} else if (scale_value_two === 1) {
console.log("Min Value Reached");
}
});
10 changes: 10 additions & 0 deletions src/Library/demos/Scale/main.json
@@ -0,0 +1,10 @@
{
"name": "Scale",
"category": "user_interface",
"description": "A simple sliding control",
"panels": [
"ui",
"preview"
],
"autorun": true
}

0 comments on commit b53212e

Please sign in to comment.