Ajout des tirettes ds l'ui

This commit is contained in:
tzim 2013-04-16 09:33:37 +00:00
parent 4eff5d3d04
commit d897ecc4ab
4 changed files with 140 additions and 96 deletions

View file

@ -1,5 +1,6 @@
using System;
using Gtk;
using System.Collections.Generic;
namespace DMX2
@ -94,7 +95,7 @@ namespace DMX2
void AddSeqUI (Sequenceur s)
{
seqUiVbox.Add(s.GetUI());
seqUiVbox.PackStart(s.GetUI(),false,false,0);
seqUiVbox.ShowAll();
}

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Gtk;
namespace DMX2
@ -6,24 +7,34 @@ namespace DMX2
[System.ComponentModel.ToolboxItem(true)]
public partial class SeqLinUI : SequenceurUI
{
bool fullUpdFlag = true;
SequenceurLineaire sequenceur;
public SeqLinUI (SequenceurLineaire s ) : base (s)
{
this.Build ();
titreLabel.Text = s.Name;
sequenceur = s;
Update();
}
public override void Update ()
{
throw new System.NotImplementedException ();
if(fullUpdFlag) FullUpdate();
UpdateValues();
}
protected void OnCircuitsActionActivated (object sender, EventArgs e)
{
var dlg = new SelSeqCircuits ((Sequenceur as SequenceurLineaire).Circuits);
var dlg = new SelSeqCircuits (sequenceur.Circuits);
if ((ResponseType)dlg.Run () == ResponseType.Ok) {
(Sequenceur as SequenceurLineaire).ChangeCircuits(dlg.GetResultList());
sequenceur.ChangeCircuits(dlg.GetResultList());
}
dlg.Destroy();
//TODO : a retirer plus tard
FullUpdate();
}
protected void OnCloseActionActivated (object sender, EventArgs e)
@ -32,15 +43,104 @@ namespace DMX2
}
Dictionary<Circuit,VScale> tirettes = new Dictionary<Circuit, VScale>();
static VScale NouvelleTirette ()
{
VScale tirette = new VScale (null);
tirette.WidthRequest = 25;
tirette.HeightRequest = 150;
tirette.CanFocus = true;
tirette.Inverted = true;
tirette.Adjustment.Upper = 100;
tirette.Adjustment.PageIncrement = 10;
tirette.Adjustment.StepIncrement = 1;
tirette.DrawValue = true;
tirette.Digits = 0;
return tirette;
}
static Label NouveauLabel ()
{
Label l = new Label();
l.WidthRequest = 50;
l.HeightRequest = 66;
l.Xalign = 1F;
l.Yalign = 0F;
l.UseMarkup = true;
l.Angle = 65;
return l;
}
int lastKnownWidth =0;
object circuitKey = new object();
protected void FullUpdate ()
{
fullUpdFlag=true;
// TODO : ici : Remise a plat de l'UI , Ajout/agencement des tirettes et descriptions
lastKnownWidth = zoneWid.Allocation.Width;
foreach (Widget wid in new List<Widget>(zoneWid.Children))
zoneWid.Remove (wid);
tirettes.Clear();
int xpos=10, ypos=0;
VScale tirette; Fixed.FixedChild fx;
Label label;
foreach (Circuit c in sequenceur.Circuits) {
tirettes[c] = tirette = NouvelleTirette();
zoneWid.Add(tirette);
fx = ( zoneWid[tirette] as Fixed.FixedChild);
fx.X = xpos; fx.Y = ypos;
tirette.Show();
tirette.ValueChanged += TiretteActionee;
tirette.Data.Add(circuitKey,c);
label = NouveauLabel();
zoneWid.Add(label);
fx = ( zoneWid[label] as Fixed.FixedChild);
fx.X = xpos-30;
fx.Y = ypos+150;
label.LabelProp = "<small>" + c.ShortName + "</small>";
label.Show();
xpos+=30;
if(lastKnownWidth < xpos +30)
{
xpos =10; ypos+= 215;
}
}
fullUpdFlag=false;
}
void TiretteActionee (object sender, EventArgs e)
{
VScale t = sender as VScale;
Circuit c = t.Data[circuitKey] as Circuit;
}
protected void UpdateValues()
{
// TODO : ici : maj du temps, des progressbar et des tirettes
}
protected void OnZoneWidSizeAllocated (object o, SizeAllocatedArgs args)
{
if (!fullUpdFlag) {
if(lastKnownWidth != args.Allocation.Width)
FullUpdate ();
}
}
}
}

View file

@ -68,7 +68,7 @@ namespace DMX2
public void ChangeCircuits (System.Collections.Generic.List<Circuit> list)
{
foreach (var c in circuitsSeq) {
foreach (var c in circuitsSeq.ToArray()) {
if(!list.Contains(c))
RetireCircuit(c);
}
@ -115,6 +115,7 @@ namespace DMX2
Dictionary<Circuit,int> valeurscourantes = new Dictionary<Circuit, int>();
Dictionary<Circuit,int> valeursinitiales = new Dictionary<Circuit, int>();
Dictionary<Circuit,bool> valeurschangees = new Dictionary<Circuit, bool>();
public SequenceurLineaire ()
{
@ -132,24 +133,35 @@ namespace DMX2
return valeurscourantes[c];
}
public void ChangeCircuit (Circuit c, int value)
{
valeurschangees[c]=true;
valeurscourantes[c]= value;
}
public bool EstChange (Circuit c)
{
return valeurschangees.ContainsKey(c);
}
public override void Tick (TimeSpan time)
{
timeStamp += time;
if (enTransition) {
if(timeStamp<effetcourrant.Duree){
foreach( Circuit c in circuitsSeq)
{
if(valeurscourantes[c] != effetcourrant[c])
{
if (timeStamp < effetcourrant.Transition) {
foreach (Circuit c in circuitsSeq) {
if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey(c)) {
valeurscourantes [c] = (effetcourrant [c] - valeursinitiales [c]) * effetcourrant.Duree.Milliseconds / time.Milliseconds + valeursinitiales [c];
}
}
}
else
{
} else {
FinDeTransition ();
}
}
if (timeStamp >= effetcourrant.Duree) {
int index = effets.IndexOf(effetcourrant) +1;
if (index < effets.Count) ChangeEffet(index);
}
}
void FinDeTransition ()
@ -160,9 +172,10 @@ namespace DMX2
}
public void ChangeEffet(Effet effet)
public void ChangeEffet(int index)
{
effetcourrant = effet;
effetcourrant = effets[index];
valeurschangees.Clear();
valeursinitiales = new Dictionary<Circuit, int>(valeurscourantes);
enTransition = true;
timeStamp = TimeSpan.Zero;

View file

@ -180,9 +180,8 @@
<property name="CanFocus">True</property>
<property name="Position">583</property>
<child>
<widget class="Gtk.ScrolledWindow" id="scrolledwindow1">
<widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow">
<property name="MemberName" />
<property name="CanFocus">True</property>
<property name="ShadowType">In</property>
<child>
<widget class="Gtk.Viewport" id="GtkViewport">
@ -191,6 +190,7 @@
<child>
<widget class="Gtk.VBox" id="seqUiVbox">
<property name="MemberName" />
<property name="ShowScrollbars">True</property>
<property name="Spacing">6</property>
<child>
<placeholder />
@ -208,7 +208,6 @@
</widget>
<packing>
<property name="Resize">False</property>
<property name="Shrink">False</property>
</packing>
</child>
<child>
@ -448,7 +447,7 @@
</widget>
</child>
</widget>
<widget class="Gtk.Bin" id="DMX2.SeqLinUI" design-size="618 414">
<widget class="Gtk.Bin" id="DMX2.SeqLinUI" design-size="618 410">
<action-group name="Default">
<action id="goBackAction">
<property name="Type">Action</property>
@ -514,8 +513,6 @@
</action>
</action-group>
<property name="MemberName" />
<property name="HeightRequest">270</property>
<property name="Visible">False</property>
<child>
<widget class="Gtk.Frame" id="frame1">
<property name="MemberName" />
@ -741,84 +738,17 @@
</packing>
</child>
<child>
<widget class="Gtk.Fixed" id="fixed3">
<widget class="Gtk.Fixed" id="zoneWid">
<property name="MemberName" />
<property name="HeightRequest">250</property>
<property name="HeightRequest">0</property>
<property name="HasWindow">False</property>
<child>
<widget class="Gtk.VScale" id="vscale5">
<property name="MemberName" />
<property name="WidthRequest">25</property>
<property name="HeightRequest">150</property>
<property name="CanFocus">True</property>
<property name="Inverted">True</property>
<property name="Upper">100</property>
<property name="PageIncrement">10</property>
<property name="StepIncrement">1</property>
<property name="Value">51</property>
<property name="DrawValue">True</property>
<property name="Digits">0</property>
<property name="ValuePos">Top</property>
</widget>
<packing>
<property name="X">15</property>
</packing>
</child>
<child>
<widget class="Gtk.VScale" id="vscale6">
<property name="MemberName" />
<property name="WidthRequest">25</property>
<property name="HeightRequest">150</property>
<property name="CanFocus">True</property>
<property name="Inverted">True</property>
<property name="Upper">100</property>
<property name="PageIncrement">10</property>
<property name="StepIncrement">1</property>
<property name="Value">28</property>
<property name="DrawValue">True</property>
<property name="Digits">0</property>
<property name="ValuePos">Top</property>
</widget>
<packing>
<property name="X">45</property>
</packing>
</child>
<child>
<widget class="Gtk.Label" id="label7">
<property name="MemberName" />
<property name="WidthRequest">50</property>
<property name="HeightRequest">66</property>
<property name="Xalign">1</property>
<property name="Yalign">0</property>
<property name="LabelProp" translatable="yes">&lt;small&gt;Ras. Rouge&lt;/small&gt;</property>
<property name="UseMarkup">True</property>
<property name="Angle">65</property>
</widget>
<packing>
<property name="X">-20</property>
<property name="Y">150</property>
</packing>
</child>
<child>
<widget class="Gtk.Label" id="label8">
<property name="MemberName" />
<property name="WidthRequest">50</property>
<property name="HeightRequest">66</property>
<property name="Xalign">1</property>
<property name="Yalign">0</property>
<property name="LabelProp" translatable="yes">&lt;small&gt;Face J&lt;/small&gt;</property>
<property name="UseMarkup">True</property>
<property name="Angle">65</property>
</widget>
<packing>
<property name="X">10</property>
<property name="Y">150</property>
</packing>
</child>
<signal name="SizeAllocated" handler="OnZoneWidSizeAllocated" />
</widget>
<packing>
<property name="Position">1</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
</widget>