-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Widget highlighting and shortcut system implementation #7488
Open
szeli1
wants to merge
81
commits into
LMMS:master
Choose a base branch
from
szeli1:widget_highlighting_and_improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,226
−256
Open
Changes from all commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
97b682f
InteractiveModelView_class_implementation
szeli1 36f1259
InteractiveModelView_fixing_errors
szeli1 884964c
StringPairDrag_implementing_stringpair_enum
szeli1 a61b4bf
CMakeLists_adding_new_class
szeli1 05aedb8
FileBrowser_implementing_stringpair_enum
szeli1 d31683a
PluginBrowser_implementing_stringpair_enum
szeli1 b8fe07e
AutomationClipView_implementing_stringpair_enum
szeli1 c6d0b6b
Track_adding_comment
szeli1 93da665
ClipView_implementing_stringpair_enum
szeli1 55f87e9
TrackView_implementing_stringpair_enum
szeli1 c2c2e6e
Clipboard_adding_new_enum_items
szeli1 a278b5c
InteractiveModelView_static_list_declaration
szeli1 0835867
SampleClipView_implementing_stringpair_enum
szeli1 19eb5a0
AutomationEditor_implementing_stringpair_enum
szeli1 83ffcaf
PatternEditor_implementing_sringpair_enum
szeli1 460b583
TrackContainerView_implementing_stringpair_enum
szeli1 6bb6576
EnvelopeAndLfoView_implementing_stringpair_enum
szeli1 3884277
InsrumentTrackWindow_implementing_stringpair_enum
szeli1 d5d87b2
PianoView_implementing_stringpair_enum
szeli1 31ef8a0
AutomationTraclView_implementing_stringpair_enum
szeli1 6b6020b
TrackContentWidget_implementing_stringpair_enum
szeli1 72f4edc
SampleTrackView_implementing_stringpair_enum
szeli1 2042f06
TrackOpeartionsWidget_implementing_stingpair_enum
szeli1 ad346d7
AutomatableButton_implemening_stringpair_enum
szeli1 6b05a09
FloatModelEditorBase_implementing_stringpair_enum
szeli1 e1e1718
Graph_implementing_stringpair_enum
szeli1 05bf3f7
Patman_implementing_stringpair_enum
szeli1 9e14b85
SlicerTView_implementing_stringpair_enum
szeli1 e570f6a
Vestige_implementing_stringpair_enum
szeli1 abb3866
ZynAddSubFx_implementing_stringpair_enum
szeli1 ca9373a
AudioFileProcessorView_implementing_stringpair_enum
szeli1 bab9b37
IntractiveModelView_implementing_SimpleTextFloat
szeli1 febe6b0
FloatModelEditorBase_implementing_InteractiveModelView
szeli1 6f50a10
SimpleTextFloat_Implementing_new_function
szeli1 5293080
Clipboard_fixed_bug
szeli1 a8342f8
InteractiveModelView_changed_processPaste
szeli1 053bb0f
FloatModelEditorBase_reimplemening_processPaste
szeli1 6d5a6c8
style_implementing_InteractiveModelView
szeli1 701243e
InteraciteveModelView_implementing_highlighting
szeli1 61b42b1
Clipboard_style_change
szeli1 53630dc
StringPairDrag_adding_auto_widget_highlighting
szeli1 7b86c23
FloatModelEditorBase_implementing_widget_highlighting
szeli1 1ee53f6
BarModelEditor_implementing_widget_highlighting
szeli1 cc38ff9
Knob_implementing_widget_highlighting
szeli1 98c28bd
InteractiveModelView_fixed_SimpleTextFloat_position
szeli1 6c5d940
FloatModelEditorBase_changed_function_order
szeli1 c6b34ab
InteractiveModelView_fixing_issues
szeli1 67e93eb
ClipView_implementing_InteractiveModelView
szeli1 d7dde0d
Rubberband_changing_inheritance
szeli1 7bd3571
AutomationClipView_implementing_InteractiveModelView
szeli1 36eaa37
SampleClipView_implementing_InteractiveModelView
szeli1 0aeb7bb
FloatModelEditorBase_changing_function_order
szeli1 42bd0e0
MidiClipView_implemented_highlighting
szeli1 a8c1820
PatternClipView_implementing_clip_highlighting
szeli1 7433b3f
PianoView_changing_focus_code
szeli1 e337969
Clipboard_removeing_array
szeli1 111d321
StringPairDrag_replacing_clipboard_array
szeli1 a7280c8
AutomatableModelView_renaming_function
szeli1 ee284c7
PianoView_renaming_function
szeli1 1b31b25
FloatModelEditorBase_renaming_function
szeli1 ba25d44
StringPairDrag_format_changes
szeli1 7d8f655
ClipView_separating_processPaste
szeli1 dcd50b6
InteractiveModelView_separating_processPaste
szeli1 8ca4596
AutomationClipView_separating_processPaste
szeli1 9ca52f3
SampleClipView_separating_processPate
szeli1 00dc936
FloatModelEditorBase_separating_processPaste
szeli1 2ab4e2f
TrackContentWidget_replacing_mimeData_with_key_value_pairs
szeli1 703e37a
InteractiveModelView_fixing_focusing_issues
szeli1 7f8e294
InteractiveModelView_removing_unused_code
szeli1 957c33d
MainWindow_adding_InteractiveModelView_focus_helper_functions
szeli1 ca37609
PianoView_fixing_merge_conflict
szeli1 c0cdcf7
InteractiveModelView_changing_shortcut_class_to_struct
szeli1 c409413
InteractiveModelView_updating_highlight_timer
szeli1 42a099e
FloatModelEditorBase_making_shortcut_array_static
szeli1 ee5ac8c
InteractiveModelView_changing_method
szeli1 17fdab5
ClipView_making_shortcut_array_static
szeli1 5cd61a6
AutomationClipView_making_shortcut_array_static
szeli1 2012037
MainWindow_remove_qDebug
szeli1 c3c9d86
Lv2Instrument_updating_StringPair_usage
szeli1 9aad0cf
Lv2Instrument_fixing_error
szeli1 7ef78cd
AutomationClipView_fixing_shortcuts
szeli1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/* | ||
* InteractiveModelView.h - TODO | ||
* | ||
* Copyright (c) 2024 szeli1 <TODO/at/gmail/dot/com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program 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. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#ifndef LMMS_GUI_INTERACTIVE_MODEL_VIEW_H | ||
#define LMMS_GUI_INTERACTIVE_MODEL_VIEW_H | ||
|
||
#include <list> | ||
#include <memory> | ||
#include <vector> | ||
|
||
#include <QApplication> | ||
#include <QWidget> | ||
#include <QColor> | ||
|
||
#include "Clipboard.h" | ||
#include "lmms_export.h" | ||
#include "ModelView.h" | ||
|
||
class QColor; | ||
class QMimeData; | ||
class QPainter; | ||
class QTimer; | ||
|
||
namespace lmms::gui | ||
{ | ||
|
||
class SimpleTextFloat; | ||
|
||
class LMMS_EXPORT InteractiveModelView : public QWidget | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QColor highlightColor READ getHighlightColor WRITE setHighlightColor) | ||
public: | ||
InteractiveModelView(QWidget* widget); | ||
~InteractiveModelView() override; | ||
|
||
//! highlight every InteractiveModelView that accepts dataType | ||
static void startHighlighting(Clipboard::StringPairDataType dataType); | ||
static void stopHighlighting(); | ||
static void showMessage(QString& message); | ||
static void hideMessage(); | ||
|
||
static QColor getHighlightColor(); | ||
static void setHighlightColor(QColor& color); | ||
|
||
// returns true if successful | ||
bool HandleKeyPress(QKeyEvent* event); | ||
protected: | ||
struct ModelShortcut | ||
{ | ||
ModelShortcut() {} | ||
ModelShortcut(Qt::Key key, Qt::KeyboardModifier modifier, unsigned int times, QString description, bool shouldLoop) : | ||
key(key), | ||
modifier(modifier), | ||
times(times), | ||
shortcutDescription(description), | ||
shouldLoop(shouldLoop) | ||
{ | ||
} | ||
|
||
bool operator==(ModelShortcut& rhs) | ||
{ | ||
return key == rhs.key | ||
&& modifier == rhs.modifier | ||
&& times == rhs.times | ||
&& shouldLoop == rhs.shouldLoop; | ||
} | ||
|
||
void reset() | ||
{ | ||
key = Qt::Key_F35; | ||
modifier = Qt::NoModifier; | ||
times = 0; | ||
shortcutDescription = ""; | ||
shouldLoop = false; | ||
} | ||
|
||
Qt::Key key = Qt::Key_F35; | ||
Qt::KeyboardModifier modifier = Qt::NoModifier; | ||
//! how many times do the keys need to be pressed to activate this shortcut | ||
unsigned int times = 0; | ||
//! what the shortcut does | ||
QString shortcutDescription = ""; | ||
//! should it loop back if m_times is reached | ||
bool shouldLoop = false; | ||
}; | ||
|
||
void keyPressEvent(QKeyEvent* event) override; | ||
void enterEvent(QEvent* event) override; | ||
void leaveEvent(QEvent* event) override; | ||
|
||
//! return the avalible shortcuts for the widget | ||
virtual const std::vector<ModelShortcut>& getShortcuts() = 0; | ||
//! called when a shortcut from `getShortcuts()` is pressed | ||
virtual void processShortcutPressed(size_t shortcutLocation, QKeyEvent* event) = 0; | ||
//! called when a shortcut message needs to be displayed | ||
//! shortcut messages can be generated with `buildShortcutMessage()` (but it can be unoptimized to return `buildShortcutMessage()`) | ||
virtual QString getShortcutMessage() = 0; | ||
//! return true if the widget supports pasting / dropping `dataType` (used for StringPairDrag and Copying) | ||
virtual bool canAcceptClipboardData(Clipboard::StringPairDataType dataType) = 0; | ||
//! should implement dragging and dropping widgets or pasting from clipboard | ||
//! should return if `QDropEvent` event can be accepted | ||
//! force implement this method | ||
virtual bool processPasteImplementation(Clipboard::StringPairDataType type, QString& value) = 0; | ||
//! calls `processPasteImplementation()` to process paste | ||
bool processPaste(const QMimeData* mimeData); | ||
//! override this if the widget requires custom updating code | ||
virtual void overrideSetIsHighlighted(bool isHighlighted); | ||
|
||
//! draws the highlight automatically for the widget if highilighted | ||
void drawAutoHighlight(QPainter* painter); | ||
//! builds a string from `getShortcuts()` | ||
QString buildShortcutMessage(); | ||
|
||
bool getIsHighlighted() const; | ||
void setIsHighlighted(bool isHighlighted); | ||
private slots: | ||
inline static void timerStopHighlighting() | ||
{ | ||
stopHighlighting(); | ||
} | ||
private: | ||
bool doesShortcutMatch(const ModelShortcut* shortcut, QKeyEvent* event) const; | ||
bool doesShortcutMatch(const ModelShortcut* shortcutA, const ModelShortcut* shortcutB) const; | ||
|
||
|
||
bool m_isHighlighted; | ||
|
||
ModelShortcut m_lastShortcut; | ||
unsigned int m_lastShortcutCounter; | ||
|
||
static std::unique_ptr<QColor> s_highlightColor; | ||
static QTimer* s_highlightTimer; | ||
static SimpleTextFloat* s_simpleTextFloat; | ||
static std::list<InteractiveModelView*> s_interactiveWidgets; | ||
}; | ||
|
||
} // namespace lmms::gui | ||
|
||
#endif // LMMS_GUI_INTERACTIVE_MODEL_VIEW_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name could probably be shortened to just
DataType
or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which one is better:
KeyType
orPairType
orPairDataType
or maybeCarriedDataType
? I thinkDataType
doesn't say anything about theStringPairDrag
system and it could be confusing because there is also aDefault
mime type, but I guess this can be fixed with a comment.I would like to get a finalized name because this change would effect 30 files.