From 4bcd1470d082fca09bec5a7babd059455b1852b8 Mon Sep 17 00:00:00 2001 From: Nik Volkov Date: Sat, 10 Oct 2015 21:05:47 +0700 Subject: [PATCH] issue_10 (percents); aspect ratio --- locale/en/LC_MESSAGES/rackman.mo | Bin 1566 -> 1716 bytes locale/ru/LC_MESSAGES/rackman.mo | Bin 1889 -> 2077 bytes rackman.py | 74 ++++++++++++++++++++++++++++--- 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/locale/en/LC_MESSAGES/rackman.mo b/locale/en/LC_MESSAGES/rackman.mo index 7b7782773775ae9c5d40fc0adbba89154b7377c5..245861a1bc6c7be5f6e0cabde15efb6ee3ef51e8 100644 GIT binary patch literal 1716 zcmc(dJ8Tp&5Qfd09MA9y?-&q>2sYV^cy73eJV{WZoK8nlP^`?JvuCpLp1eMkgpLkT zA_^pw1|ce-p@W8sjs_YU3M48h5fw=Mb7x2-Dhh<mGx&&r=sackv6ySKtPGf9>M8E`ATv`cEL~eF3S?uP*)p z(!OgTO1c~1D1R$R`E4$42kYq3F>o8+KfogD%QKM9`4XgcuR%=q1`et09Y}ib9Y2DU z{~5$&-{5H7cNechK)Nj;y>Er1zU&5RKMzF7tQ*8+XW(d`f{O=SeA%%GQeP%re9gsG z5R+NQn;_MB3ncwJAnkh>B;ETUCR>D~?~h#k1VmdJ8gzB&8?8GGqp=xw0LEc7wl~r6 z)CW3C8>|IJ_mFzJ7q$yV_3VSu`H#S;j!iHc?XW|Qr)FJS-E%8Q|7VMf=??FP9dt2a z&$4IMr{hFs{P?BRs0H4|C#A6+tS_s{$Z{jBN?E^%W@3}pb%pgOA_`|3AYYekP>DFz zB4NX7j^};u_Vbm^Cjl$wo56;~}Am)59=P1HoB>^z$=LdTL7rHQ1rs9=iE@ex!o z*ujcQ&#;oLuu^J;m8_hmNya8snn=s0stT{BRK-?VxU9CYQBSx`K5XiTPC5J~9Xjo> zp%ao&*pvvJM%WZ7n)EvQ;Eh&1^d(cN4$zZmW>#pP?>yh>=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IQ8-&J+4ONcZ4cS39m~}6 zk-5m85wG?+GMdPFJ93`QdwX;F`Al>&H1Nb<@|S|DU#Gq?VuKmlOTlGE>$Ta~X!5@Q wGPvr$@fU)bk>)WUVy9D&G$Xj~zxL}vHMnKd{&O2#v;G}U^zUZo^DWuXf8e2bMgRZ+ delta 765 zcmYk)J1hi29LMoFyLaB_ocH^3ktjTZ4H1!$Q;3d&>RNJ9s8kderAA@z8i^pHkSHXm z6r!V%C^bZ)5EX@J5Z~Y4NK9__Gylwg|1&#tJF%x|_95=(4J|=$RSy}{EsJ>2uCWep zunZqDg0C3HcXaU+OYjSo7j_EsF;srNwGE4jI}35v^e|8X5BZsq!h{(^Eih^0X&cX2 z=dqmmw2d=1UPdjridtwLwXqEwZ=vdLqieFp>@m;_hc@BZ#%FlRXOJ z9xLzw^~EQsybBxOVwCtEmG^?x_<@aBOtCoYn*;+Tde#)y6VIZ)FoU(Yf?8+;RWOJ8 z!hKZUk@Xy_h_6r^y2B=X#v1&w^Ko9zDly4G1qV@gJ&r0kha5n#Xbid9psZ8=!=-PGwEYe%k5tcb!9LsL%7K+*Eo0NbkUKqTd@G^iFf`V#sfZO!!NYh10i4Z|E0u CU_8zM diff --git a/rackman.py b/rackman.py index d386d56..f7de7ed 100644 --- a/rackman.py +++ b/rackman.py @@ -17,21 +17,21 @@ -__version__ = '1.8.2' +__version__ = '1.9.0' def initial(): - global window, screen, _, COLORS, icon, config + global window, screen, _, COLORS, icon, config, tv_ratios - config = {} + config = {} # lint:ok conf_file_name = "rackman.conf" conf_path_curdir = os.path.join('./', conf_file_name) conf_path_share = os.path.join('/usr/share/rackman/', conf_file_name) - conf_path_home = os.path.join(os.path.expanduser('~'),'.config/rackman/', conf_file_name) + conf_path_home = os.path.join(os.path.expanduser('~'), '.config/rackman/', conf_file_name) conf_paths = (conf_path_share, conf_path_home, conf_path_curdir) for conf_path in conf_paths: @@ -108,6 +108,16 @@ def initial(): 'eng_name': 'Pink', }, } + + + tv_ratios = { + '1.25': '5:4', + '1.33': '4:3', + '1.50': '3:2', + '1.56': '14:9', + '1.60': '16:10', + '1.78': '16:9', + } @@ -156,7 +166,7 @@ def generate_menu(self): # opacity items.append( ('/{}'.format( _('_Opacity') ), None, None, 0, '') ) - + opacitys = range(10, 101, 10) for i in opacitys: if i == config['slave_opacity'] * 100: @@ -176,6 +186,7 @@ def generate_menu(self): items.append( ('/{}'.format( _('_Tools') ), None, None, 0, '') ) items.append( ('/{}/{}'.format( _('Tools'), _('Rotate') ), 'R', self.size_change, 1, '') ) + items.append( ('/{}/{}'.format( _('Tools'), _('Fix 100%') ), 'F', self.fix_percent, 2, '') ) return items @@ -195,7 +206,7 @@ def __init__(self): self.window.connect("destroy", lambda w: gtk.main_quit()) - tableH = gtk.Table(rows=3, columns=4, homogeneous=False) + tableH = gtk.Table(rows=5, columns=4, homogeneous=False) self.window.add(tableH) tableH.set_col_spacings(2) tableH.show() @@ -203,6 +214,8 @@ def __init__(self): menu_row = 0,1 label_row = 1,2 value_row = 2,3 + sub_label_row = 3,4 + sub_value_row = 4,5 self.lw = lw = gtk.Label( _('Width') ) @@ -247,6 +260,28 @@ def __init__(self): va.set_width_chars(11) va.show() tableH.attach(va, 3,4, *value_row) + + + self.lpr = lpr = gtk.Label( _('Percents (W x H / D)') ) + lpr.show() + tableH.attach(lpr, 0,3, *sub_label_row) + + self.vpr = vpr = gtk.Entry() + vpr.set_editable(False) + vpr.set_width_chars(25) + vpr.show() + tableH.attach(vpr, 0,3, *sub_value_row) + + + self.lar = lar = gtk.Label( _('Aspect ratio') ) + lar.show() + tableH.attach(lar, 3,4, *sub_label_row) + + self.var = var = gtk.Entry() + var.set_editable(False) + var.set_width_chars(8) + var.show() + tableH.attach(var, 3,4, *sub_value_row) self.menu_items = ( generate_menu(self) ) @@ -307,6 +342,12 @@ def metric_change(self, ret, widget): def size_change(self, ret, widget): w, h = slave.window.get_size() slave.window.resize(h, w) + + + def fix_percent(self, ret, widget): + w, h = slave.window.get_size() + slave.percent_full = (w, h) + slave.window.emit("check-resize") # обновление показателей @@ -326,6 +367,9 @@ def __init__(self, parent): self.parent = parent self.metric = ('px', 1, 0, 2) + + w, h = self.window.get_size() + self.percent_full = (w, h) self.area = gtk.DrawingArea() @@ -409,6 +453,21 @@ def resize_window(self, widget): grad1 = math.degrees( math.asin( h / gipo ) ) grad2 = 90 - grad1 + + percent_w = ( w * 100.0 / self.percent_full[0] ) + percent_h = ( h * 100.0 / self.percent_full[1] ) + percent_d = ( gipo * 100.0 / ( math.sqrt(self.percent_full[0]*self.percent_full[0] + self.percent_full[1]*self.percent_full[1]) ) ) + + if w >= h: + ratio = float(w) / h + else: + ratio = float(h) / w + + r = str( round(ratio, 3) ) + if r in tv_ratios.keys(): + ratio_tv = '({})'.format( tv_ratios[r] ) + else: + ratio_tv = '' T = Template('{:.${precision}f}{:s}') norm = T.substitute(precision=precision_norm) @@ -418,6 +477,9 @@ def resize_window(self, widget): self.parent.vh.set_text( norm.format( round(h * metric_mod, precision_norm), metric_name.split()[0] ) ) self.parent.vd.set_text( high.format( round(gipo * metric_mod, precision_high), metric_name.split()[0] ) ) self.parent.va.set_text( '{:.1f}° / {:.1f}°'.format( round(grad1,1), round(grad2,1) ) ) + + self.parent.vpr.set_text( '{:.2f}% x {:.2f}% / {:.2f}%'.format( percent_w, percent_h, percent_d ) ) + self.parent.var.set_text( '{:.3f}:1 {:s}'.format( ratio, ratio_tv ) ) return True