.
1 /*
2 Copyright (C) 2014 Johan Mattsson
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 3 of the
7 License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 */
14
15 namespace BirdFont {
16
17 public class BackgroundSelection : GLib.Object {
18
19 public string? assigned_glyph;
20 public BackgroundImage? image;
21 public BackgroundImage parent_image;
22
23 public double x {
24 get {
25 return x_img * parent_image.img_scale_x + parent_image.img_middle_x;
26 }
27
28 set {
29 x_img = value / parent_image.img_scale_x - parent_image.img_middle_x;
30 }
31 }
32
33 public double y {
34 get {
35 return y_img * parent_image.img_scale_y + parent_image.img_middle_y;
36 }
37
38 set {
39 y_img = (value - parent_image.img_middle_y) / parent_image.img_scale_y;
40 }
41 }
42
43 public double w {
44 get {
45 return width * parent_image.img_scale_x;
46 }
47
48 set {
49 width = value / parent_image.img_scale_x;
50 }
51 }
52
53 public double h {
54 get {
55 return height * parent_image.img_scale_y;
56 }
57
58 set {
59 height = value / parent_image.img_scale_y;
60 }
61 }
62
63 private double height;
64 private double width;
65 private double x_img;
66 private double y_img;
67
68 public BackgroundSelection (BackgroundImage? img, BackgroundImage parent_img,
69 double x, double y, double w, double h) {
70
71 assigned_glyph = null;
72 parent_image = parent_img;
73 image = img;
74 this.x = x;
75 this.y = y;
76 this.w = w;
77 this.h = h;
78 }
79 }
80
81 }
82