Skip to content

Commit

Permalink
Merge pull request #52 from finanalyst/master
Browse files Browse the repository at this point in the history
Add logo and add adjust to Scale
  • Loading branch information
jonathanstowe committed Jun 21, 2016
2 parents 77ec479 + 3446e18 commit ce23d99
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions examples/04-marked-scale.pl6
Expand Up @@ -12,11 +12,13 @@ my %texts = <blue red> Z=>
'<span foreground="blue" size="x-large">Blue text</span> is <i>cool</i>!',
'<span foreground="red" size="x-large">Red text</span> is <b>hot</b>!'
;
my $mx = 30;
my $mn = 2.5;

$app.set-content(
GTK::Simple::VBox.new(
GTK::Simple::HBox.new(
GTK::Simple::VBox.new(
my $inner = GTK::Simple::VBox.new(
my $normal-label = GTK::Simple::Label.new(:text("Normal label: %texts<blue>" ) ),
=comment
a vanilla label shows up the mark up text as text
Expand All @@ -28,10 +30,11 @@ $app.set-content(

my $bR = GTK::Simple::CheckButton.new(:label('Make Red')),
my $bB = GTK::Simple::ToggleButton.new(:label('Make Blue')),
my $bSyn = GTK::Simple::ToggleButton.new(:label('Synchronise')),
my $label-for-vertical = GTK::Simple::MarkUpLabel.new(:text('Vertical scale value is:')),
my $label-for-horizontal = GTK::Simple::MarkUpLabel.new(:text('Horizontal scale value is:')),
),
my $scale-vertical = GTK::Simple::Scale.new(:orientation<vertical>, :max(31), :min(2.4), :step(0.3), :value(21) ),
my $scale-vertical = GTK::Simple::Scale.new(:orientation<vertical>, :max($mx), :min($mn), :step(0.5), :value(21) ),
=comment
A scale widget is used to provide a numerical value
Here is the vertical form. The maximum value is at the top.
Expand Down Expand Up @@ -62,12 +65,19 @@ sub horizontal-changes($b) {
$label-for-horizontal.text = 'Number is <span foreground="green" size="large">' ~ $scale-horizontal.value ~'</span>';
}

sub sync($b) {
$scale-vertical.adjust: $mn + $scale-horizontal.value * ($mx-$mn)
}

$bB.toggled.tap: &make-blue;
$bR.toggled.tap: &make-red;
$bSyn.toggled.tap: &sync;
$scale-vertical.value-changed.tap: &vertical-changes;
=comment
Note the call-back name is value-changed, not changed for a text entry

$scale-horizontal.value-changed.tap: &horizontal-changes;

$inner.border-width = 20;
$app.border-width = 20;
$app.run;
4 changes: 4 additions & 0 deletions lib/GTK/Simple/Scale.pm6
Expand Up @@ -29,6 +29,10 @@ method value()
is gtk-property(&gtk_range_get_value, &gtk_range_set_value)
{ * }

method adjust( $value ) {
gtk_range_set_value(self.WIDGET, $value.Num)
}

method value-changed() {
$!changed_supply //= do {
my $s = Supplier.new;
Expand Down
Binary file added logotype/logo_32x32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce23d99

Please sign in to comment.