From: <ju...@us...> - 2008-05-15 10:56:20
|
Revision: 3063 http://urakawa.svn.sourceforge.net/urakawa/?rev=3063&view=rev Author: julienq Date: 2008-05-15 03:56:17 -0700 (Thu, 15 May 2008) Log Message: ----------- Updated selection behavior on click. Clicking on strips, blocks and strip cursors toggles the selection (easier to unselect.) Clicking on the strip label does not make it editable anymore; behaves like the block labels. Use F2 or rename to edit strip labels. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Commands/Node/Delete.cs trunk/urakawa/application/Obi/Obi/ProjectView/Block.Designer.cs trunk/urakawa/application/Obi/Obi/ProjectView/Block.cs trunk/urakawa/application/Obi/Obi/ProjectView/EditableLabel.Designer.cs trunk/urakawa/application/Obi/Obi/ProjectView/EditableLabel.cs trunk/urakawa/application/Obi/Obi/ProjectView/Strip.Designer.cs trunk/urakawa/application/Obi/Obi/ProjectView/Strip.cs trunk/urakawa/application/Obi/Obi/ProjectView/TransportBar.cs Modified: trunk/urakawa/application/Obi/Obi/Commands/Node/Delete.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Commands/Node/Delete.cs 2008-05-15 10:18:15 UTC (rev 3062) +++ trunk/urakawa/application/Obi/Obi/Commands/Node/Delete.cs 2008-05-15 10:56:17 UTC (rev 3063) @@ -12,7 +12,6 @@ private ObiNode mParent; // its original parent node private NodeSelection mAfter; // selection after deletion private int mIndex; // its original index - private ProjectView.ProjectView mView; /// <summary> @@ -21,7 +20,6 @@ public Delete(ProjectView.ProjectView view, ObiNode node, string label) : base(view) { - mView = view; mNode = node; mParent = node.ParentAs<ObiNode>(); mIndex = mNode.Index; @@ -37,7 +35,7 @@ public override void execute() { - mNode.Detach(); + mNode.Detach(); if (UpdateSelection) View.Selection = mAfter; } Modified: trunk/urakawa/application/Obi/Obi/ProjectView/Block.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ProjectView/Block.Designer.cs 2008-05-15 10:18:15 UTC (rev 3062) +++ trunk/urakawa/application/Obi/Obi/ProjectView/Block.Designer.cs 2008-05-15 10:56:17 UTC (rev 3063) @@ -40,7 +40,7 @@ this.mLabel.Name = "mLabel"; this.mLabel.Size = new System.Drawing.Size(0, 13); this.mLabel.TabIndex = 2; - this.mLabel.Click += new System.EventHandler(this.mLabel_Click); + this.mLabel.Click += new System.EventHandler(this.Label_Click); // // Block // Modified: trunk/urakawa/application/Obi/Obi/ProjectView/Block.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ProjectView/Block.cs 2008-05-15 10:18:15 UTC (rev 3062) +++ trunk/urakawa/application/Obi/Obi/ProjectView/Block.cs 2008-05-15 10:56:17 UTC (rev 3063) @@ -13,39 +13,41 @@ protected EmptyNode mNode; // the corresponding node private bool mSelected; // selected flag private ISelectableInStripView mParentContainer; // not necessarily a strip! + private bool mEntering; // entering flag (for selection/deselection) + + // Used by the designer + public Block() { InitializeComponent(); } + + /// <summary> + /// Create a new empty block from an empty node. + /// </summary> public Block(EmptyNode node, ISelectableInStripView parent): this() { mNode = node; mParentContainer = parent; mSelected = false; - node.ChangedKind += new EmptyNode.ChangedKindEventHandler(node_ChangedKind); - node.ChangedPageNumber += new NodeEventHandler<EmptyNode>(node_ChangedPageNumber); + mEntering = false; + node.ChangedKind += new EmptyNode.ChangedKindEventHandler(Node_ChangedKind); + node.ChangedPageNumber += new NodeEventHandler<EmptyNode>(Node_ChangedPageNumber); UpdateColors(); UpdateLabel(); } - public Block() { InitializeComponent(); } + /// <summary> + /// Get the tab index of the block. + /// </summary> + public int LastTabIndex { get { return TabIndex; } } - // Width of the label (including margins) - protected int LabelFullWidth { get { return mLabel.Margin.Left + mLabel.Width + mLabel.Margin.Right; } } + /// <summary> + /// The empty node for this block. + /// </summary> + public EmptyNode Node { get { return mNode; } } - // Generate the label string for this block. - protected virtual void UpdateLabel() - { - mLabel.Text = Node.BaseStringShort(); - mLabel.AccessibleName = Node.BaseString(); - Size = new Size(LabelFullWidth, Height); - } - - private void node_ChangedPageNumber(object sender, NodeEventArgs<EmptyNode> e) { UpdateLabel(); } - private void node_ChangedKind(object sender, ChangedKindEventArgs e) { UpdateLabel(); } - /// <summary> - /// The phrase node for this block. + /// The Obi node for this block. /// </summary> - public EmptyNode Node { get { return mNode; } } public ObiNode ObiNode { get { return mNode; } } /// <summary> @@ -61,8 +63,20 @@ } } + /// <summary> + /// Set the selection from the parent view + /// </summary> + public virtual NodeSelection SelectionFromView { set { Selected = value != null; } } /// <summary> + /// The strip that contains this block. + /// </summary> + public Strip Strip + { + get { return mParentContainer is Strip ? (Strip)mParentContainer : ((Block)mParentContainer).Strip; } + } + + /// <summary> /// Update the colors of the block when the state of its node has changed. /// </summary> public void UpdateColors() @@ -75,63 +89,70 @@ } /// <summary> - /// Set the selection from the parent view - /// </summary> - public virtual NodeSelection SelectionFromView { set { Selected = value != null; } } - - /// <summary> - /// Get the tab index of the block. - /// </summary> - public int LastTabIndex { get { return TabIndex; } } - - /// <summary> /// Update the tab index of the block with the new value and return the next index. /// </summary> public int UpdateTabIndex(int index) { TabIndex = index; - ++index; - return index; + return index + 1; } - /// <summary> - /// The strip that contains this block. - /// </summary> - public Strip Strip + #region ISearchable Members + + public string ToMatch() { - get { return mParentContainer is Strip ? (Strip)mParentContainer : ((Block)mParentContainer).Strip; } - + return mLabel.Text.ToLowerInvariant(); } - // Select on click and tabbing - private void Block_Click(object sender, EventArgs e) + #endregion + + + // Width of the label (including margins) + protected int LabelFullWidth { get { return mLabel.Margin.Left + mLabel.Width + mLabel.Margin.Right; } } + + // Generate the label string for this block. + // Since there is no content, the width is always that of the label's. + protected virtual void UpdateLabel() { - System.Diagnostics.Debug.Print("Click on {0}", this); - Strip.SelectedBlock = this; + mLabel.Text = Node.BaseStringShort(); + mLabel.AccessibleName = Node.BaseString(); + Size = new Size(LabelFullWidth, Height); } + // Select/deselect on click + private void Block_Click(object sender, EventArgs e) { ToggleSelection(); } + + // Select on tabbing protected void Block_Enter(object sender, EventArgs e) { - System.Diagnostics.Debug.Print("Enter {0}?", this); if (!Strip.ParentView.Focusing) { - System.Diagnostics.Debug.Print("Yes."); + mEntering = true; Strip.SelectedBlock = this; } - else - { - System.Diagnostics.Debug.Print("No."); - } } - private void mLabel_Click(object sender, EventArgs e) { Strip.SelectedBlock = this; } - #region ISearchable Members + // Select when clickin the label too. + private void Label_Click(object sender, EventArgs e) { ToggleSelection(); } - public string ToMatch() + // Update label when the page number changes + private void Node_ChangedPageNumber(object sender, NodeEventArgs<EmptyNode> e) { UpdateLabel(); } + + // Update the label when the role of the node changes + private void Node_ChangedKind(object sender, ChangedKindEventArgs e) { UpdateLabel(); } + + // Toggle selection when clicking. + private void ToggleSelection() { - return mLabel.Text.ToLowerInvariant(); + if (!mSelected || mEntering) + { + Strip.SelectedBlock = this; + } + else + { + Strip.UnselectInStrip(); + } + mEntering = false; } - - #endregion } } Modified: trunk/urakawa/application/Obi/Obi/ProjectView/EditableLabel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ProjectView/EditableLabel.Designer.cs 2008-05-15 10:18:15 UTC (rev 3062) +++ trunk/urakawa/application/Obi/Obi/ProjectView/EditableLabel.Designer.cs 2008-05-15 10:56:17 UTC (rev 3063) @@ -43,7 +43,6 @@ this.mLabel.Size = new System.Drawing.Size(35, 13); this.mLabel.TabIndex = 0; this.mLabel.Text = "label1"; - this.mLabel.Click += new System.EventHandler(this.EditableLabel_Click); // // mTextBox // @@ -91,7 +90,6 @@ this.Margin = new System.Windows.Forms.Padding(0); this.Name = "EditableLabel"; this.Size = new System.Drawing.Size(150, 52); - this.Click += new System.EventHandler(this.EditableLabel_Click); this.Leave += new System.EventHandler(this.EditableLabel_Leave); this.ResumeLayout(false); this.PerformLayout(); Modified: trunk/urakawa/application/Obi/Obi/ProjectView/EditableLabel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ProjectView/EditableLabel.cs 2008-05-15 10:18:15 UTC (rev 3062) +++ trunk/urakawa/application/Obi/Obi/ProjectView/EditableLabel.cs 2008-05-15 10:56:17 UTC (rev 3063) @@ -125,14 +125,6 @@ } /// <summary> - /// Clicking the label makes it editable. - /// </summary> - private void EditableLabel_Click(object sender, EventArgs e) - { - if (!mEditable) Editable = true; - } - - /// <summary> /// Pressing enter is like pressing OK. /// Escape is like cancel. /// </summary> Modified: trunk/urakawa/application/Obi/Obi/ProjectView/Strip.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ProjectView/Strip.Designer.cs 2008-05-15 10:18:15 UTC (rev 3062) +++ trunk/urakawa/application/Obi/Obi/ProjectView/Strip.Designer.cs 2008-05-15 10:56:17 UTC (rev 3063) @@ -61,6 +61,7 @@ this.mLabel.Name = "mLabel"; this.mLabel.Size = new System.Drawing.Size(300, 37); this.mLabel.TabIndex = 0; + this.mLabel.Click += new System.EventHandler(this.Label_Click); this.mLabel.LabelEditedByUser += new System.EventHandler(this.Label_LabelEditedByUser); this.mLabel.EditableChanged += new System.EventHandler(this.Label_EditableChanged); this.mLabel.SizeChanged += new System.EventHandler(this.Label_SizeChanged); Modified: trunk/urakawa/application/Obi/Obi/ProjectView/Strip.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ProjectView/Strip.cs 2008-05-15 10:18:15 UTC (rev 3062) +++ trunk/urakawa/application/Obi/Obi/ProjectView/Strip.cs 2008-05-15 10:56:17 UTC (rev 3063) @@ -271,6 +271,14 @@ } /// <summary> + /// Clear the selection in the strip from its contents. + /// </summary> + public void UnselectInStrip() + { + mParentView.Selection = null; + } + + /// <summary> /// Update the colors of the block when the state of its node has changed. /// </summary> public void UpdateColors() @@ -343,8 +351,15 @@ mBlocksPanel.Controls.SetChildIndex(cursor, index); cursor.Click += new EventHandler(delegate(object sender, EventArgs e) { - mParentView.SelectionFromStrip = new StripCursorSelection(mNode, mParentView, - mBlocksPanel.Controls.IndexOf((Control)cursor) / 2); + if (!cursor.Selected) + { + mParentView.SelectionFromStrip = new StripCursorSelection(mNode, mParentView, + mBlocksPanel.Controls.IndexOf((Control)cursor) / 2); + } + else + { + mParentView.Selection = null; + } } ); } @@ -361,6 +376,12 @@ } } + // Clicking on the label toggles the strip selection. Use "rename" to rename. + private void Label_Click(object sender, EventArgs e) + { + ToggleSelection(); + } + // Select the label when it is clicked (i.e. made editable) by the user. private void Label_EditableChanged(object sender, EventArgs e) { @@ -398,9 +419,15 @@ // Set verbose accessible name for the strip private void SetAccessibleName() { mLabel.AccessibleName = mNode.ToString(); } - // Toggle selection + // Toggle selection when clicking private void Strip_Click(object sender, EventArgs e) { + ToggleSelection(); + } + + // Toggle selection + private void ToggleSelection() + { if (mSelected && !mEntering) { mParentView.SelectionFromStrip = null; Modified: trunk/urakawa/application/Obi/Obi/ProjectView/TransportBar.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ProjectView/TransportBar.cs 2008-05-15 10:18:15 UTC (rev 3062) +++ trunk/urakawa/application/Obi/Obi/ProjectView/TransportBar.cs 2008-05-15 10:56:17 UTC (rev 3063) @@ -901,27 +901,30 @@ { if (mState == State.Recording) { + // record into to next phrase. mRecordingSession.NextPhrase(); } - else if (mState != State.Monitoring) + else if (mState == State.Monitoring) { - if (mState == State.Stopped) + // start recording + + } + else if (mState == State.Stopped) + { + if (mView.ObiForm.Settings.PlayOnNavigate) { - if (mView.ObiForm.Settings.PlayOnNavigate) - { - mCurrentPlaylist.CurrentPhrase = mView.Selection.Node as PhraseNode; - mCurrentPlaylist.NavigateToNextPhrase(); - } - else - { - mView.SelectNextPhrase(); - } + mCurrentPlaylist.CurrentPhrase = mView.Selection.Node as PhraseNode; + mCurrentPlaylist.NavigateToNextPhrase(); } else { - mCurrentPlaylist.NavigateToNextPhrase(); + mView.SelectNextPhrase(); } } + else + { + mCurrentPlaylist.NavigateToNextPhrase(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |