File: FormMainController.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 35,764 kB
  • ctags: 26,929
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (194 lines) | stat: -rw-r--r-- 7,358 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
 * FormMainController.cs
 * Copyright © 2011 kbinani
 *
 * This file is part of org.kbinani.cadencii.
 *
 * org.kbinani.cadencii is free software; you can redistribute it and/or
 * modify it under the terms of the GPLv3 License.
 *
 * org.kbinani.cadencii is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
#if JAVA

package org.kbinani.cadencii;

#else

namespace org
{
    namespace kbinani
    {
        namespace cadencii
        {

#endif

            /// <summary>
            /// メイン画面のコントローラ
            /// </summary>
#if JAVA
            public class FormMainController extends ControllerBase implements FormMainUiListener
#else
            public class FormMainController : ControllerBase, FormMainUiListener
#endif
            {
                /// <summary>
                /// x方向の表示倍率(pixel/clock)
                /// </summary>
                private float mScaleX;
                
                /// <summary>
                /// mScaleXの逆数
                /// </summary>
                private float mInvScaleX;
                
                /// <summary>
                /// 画面左端位置での、仮想画面上の画面左端から測ったピクセル数.
                /// FormMain.hScroll.ValueとFormMain.trackBar.Valueで決まる.
                /// </summary>
                private int mStartToDrawX;

                /// <summary>
                /// 画面上端位置での、仮想画面上の画面上端から図ったピクセル数.
                /// FormMain.vScroll.Value,FormMain.vScroll.Height,FormMain.vScroll.Maximum,AppManager.editorConfig.PxTrackHeightによって決まる
                /// </summary>
                private int mStartToDrawY;

                /// <summary>
                /// MIDIステップ入力モードがONかどうか
                /// </summary>
                private bool mStepSequencerEnabled = false;

                private FormMainUi ui;

                public FormMainController()
                {
                    mScaleX = 0.1f;
                    mInvScaleX = 1.0f / mScaleX;
                }

                #region FormMainUiListenerの実装

                public void navigationPanelGotFocus()
                {
                    ui.focusPianoRoll();
                }

                #endregion

                /// <summary>
                /// MIDIステップ入力モードがONかどうかを取得します
                /// </summary>
                /// <returns></returns>
                public bool isStepSequencerEnabled()
                {
                    return mStepSequencerEnabled;
                }

                /// <summary>
                /// MIDIステップ入力モードがONかどうかを設定する
                /// </summary>
                /// <param name="value"></param>
                public void setStepSequencerEnabled( bool value )
                {
                    mStepSequencerEnabled = value;
                }

                public void setupUi( FormMainUi ui )
                {
                    this.ui = ui;
                }

                /// <summary>
                /// ピアノロールの,X方向のスケールを取得します(pixel/clock)
                /// </summary>
                /// <returns></returns>
                public float getScaleX()
                {
                    return mScaleX;
                }

                /// <summary>
                /// ピアノロールの,X方向のスケールの逆数を取得します(clock/pixel)
                /// </summary>
                /// <returns></returns>
                public float getScaleXInv()
                {
                    return mInvScaleX;
                }

                /// <summary>
                /// ピアノロールの,X方向のスケールを設定します
                /// </summary>
                /// <param name="scale_x"></param>
                public void setScaleX( float scale_x )
                {
                    mScaleX = scale_x;
                    mInvScaleX = 1.0f / mScaleX;
                }

                /// <summary>
                /// ピアノロールの,Y方向のスケールを取得します(pixel/cent)
                /// </summary>
                /// <returns></returns>
                public float getScaleY()
                {
                    if ( AppManager.editorConfig.PianoRollScaleY < EditorConfig.MIN_PIANOROLL_SCALEY ) {
                         AppManager.editorConfig.PianoRollScaleY = EditorConfig.MIN_PIANOROLL_SCALEY;
                    } else if ( EditorConfig.MAX_PIANOROLL_SCALEY < AppManager.editorConfig.PianoRollScaleY ) {
                        AppManager.editorConfig.PianoRollScaleY = EditorConfig.MAX_PIANOROLL_SCALEY;
                    }
                    if ( AppManager.editorConfig.PianoRollScaleY == 0 ) {
                        return AppManager.editorConfig.PxTrackHeight / 100.0f;
                    } else if ( AppManager.editorConfig.PianoRollScaleY > 0 ) {
                        return (2 * AppManager.editorConfig.PianoRollScaleY + 5) * AppManager.editorConfig.PxTrackHeight / 5 / 100.0f;
                    } else {
                        return (AppManager.editorConfig.PianoRollScaleY + 8) * AppManager.editorConfig.PxTrackHeight / 8 / 100.0f;
                    }
                }

                /// <summary>
                /// ピアノロール画面の,ビューポートと仮想スクリーンとの横方向のオフセットを取得します
                /// </summary>
                /// <returns></returns>
                public int getStartToDrawX()
                {
                    return mStartToDrawX;
                }

                /// <summary>
                /// ピアノロール画面の,ビューポートと仮想スクリーンとの横方向のオフセットを設定します
                /// </summary>
                /// <param name="value"></param>
                public void setStartToDrawX( int value )
                {
                    mStartToDrawX = value;
                }

                /// <summary>
                /// ピアノロール画面の,ビューポートと仮想スクリーンとの縦方向のオフセットを取得します
                /// </summary>
                /// <returns></returns>
                public int getStartToDrawY()
                {
                    return mStartToDrawY;
                }

                /// <summary>
                /// ピアノロール画面の,ビューポートと仮想スクリーンとの縦方向のオフセットを設定します
                /// </summary>
                /// <param name="value"></param>
                public void setStartToDrawY( int value )
                {
                    mStartToDrawY = value;
                }
            }

#if !JAVA
        }
    }
}
#endif