@@ -87,6 +87,9 @@ namespace lsp
8787 prop::Integer sMousePressed ; // Note pressed with mouse
8888 prop::Integer sSelectionStart ;// First note in selection range
8989 prop::Integer sSelectionEnd ; // Last note in selection range
90+ prop::Boolean sEditable ; // Editable (allows key press by mouse)
91+ prop::Boolean sSelectable ; // Selectable (allows selections)
92+ prop::Boolean sClearSelection ;// Clear selection on mouse key press
9093
9194 LSP_TK_STYLE_DEF_END
9295 }
@@ -130,6 +133,14 @@ namespace lsp
130133 PC_1 = style::PIANO_INACTIVE,
131134 };
132135
136+ enum work_mode_t
137+ {
138+ WMODE_OFF,
139+ WMODE_PRESS,
140+ WMODE_SELECT,
141+ WMODE_IGNORE
142+ };
143+
133144 typedef struct layout_t
134145 {
135146 ssize_t nFirst; // First note
@@ -145,13 +156,15 @@ namespace lsp
145156 float fTop ; // Top
146157 float fWidth ; // Width
147158 float fHeight ; // Height
148- uint32_t nKey; // Key
159+ int32_t nKey; // Key
149160 } key_t ;
150161
151162 protected:
152163 lltl::darray<key_t > vKeys;
153164 key_t vSplit[2 ];
154165 ssize_t nCurrNote; // Currently selected note
166+ size_t nMBState; // Mouse button state
167+ work_mode_t enWorkMode; // Current work mode
155168
156169 style::PianoKeyColors vKeyColors[style::PIANOKEY_TOTAL];
157170 style::PianoColors vColors[style::PIANO_TOTAL];
@@ -168,9 +181,13 @@ namespace lsp
168181 prop::Integer sMousePressed ; // Note pressed with mouse
169182 prop::Integer sSelectionStart ;// First note in selection range
170183 prop::Integer sSelectionEnd ; // Last note in selection range
184+ prop::Boolean sEditable ; // Editable (allows key press by mouse)
185+ prop::Boolean sSelectable ; // Selectable (allows selections)
186+ prop::Boolean sClearSelection ;// Clear selection on mouse key press
171187
172188 protected:
173189 static status_t slot_on_submit (Widget *sender, void *ptr, void *data);
190+ static status_t slot_on_change (Widget *sender, void *ptr, void *data);
174191
175192 protected:
176193 void do_destroy ();
@@ -179,6 +196,8 @@ namespace lsp
179196 void compute_layout (layout_t * layout, bool natural);
180197 void draw_key (ws::ISurface *s, const key_t * key, bool black, ssize_t sel_first, ssize_t sel_last);
181198 void draw_split (ws::ISurface *s, const key_t * key, const lsp::Color & c, size_t angle, float split);
199+ key_t *find_key (ssize_t x, ssize_t y);
200+ void handle_note_press (ssize_t note);
182201
183202 protected:
184203 virtual void property_changed (Property *prop) override ;
@@ -250,14 +269,19 @@ namespace lsp
250269 LSP_TK_PROPERTY (Integer, mouse_pressed, &sMousePressed );
251270 LSP_TK_PROPERTY (Integer, selection_start, &sSelectionStart );
252271 LSP_TK_PROPERTY (Integer, selection_end, &sSelectionEnd );
272+ LSP_TK_PROPERTY (Boolean, editable, &sEditable );
273+ LSP_TK_PROPERTY (Boolean, selectable, &sSelectable );
274+ LSP_TK_PROPERTY (Boolean, clear_selection, &sClearSelection );
253275
254276 public:
255277 virtual status_t on_mouse_down (const ws::event_t *e) override ;
278+ virtual status_t on_mouse_move (const ws::event_t *e) override ;
256279 virtual status_t on_mouse_up (const ws::event_t *e) override ;
257280 virtual void draw (ws::ISurface *s, bool force) override ;
258281
259282 public:
260283 virtual status_t on_submit ();
284+ virtual status_t on_change ();
261285 };
262286
263287 } /* namespace tk */
0 commit comments