Skip to content
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

Refactor the drawing of TCO's; Get rid of hardcoded colors in TCOs; Even out the color scheme #2574

Merged
merged 1 commit into from
Mar 3, 2016

Conversation

Umcaruje
Copy link
Member

Per HDDigitizerMusic#8

Fixes #2148

This PR does several things:

  1. Fixes incorrect rendering of TCO's: they was a one pixel gap between the grid and the TCOs. Also fix the incorect rendering of the bar-lines on Instrument pattern TCO's:
    Before & after
    screenshot from 2016-02-16 22 36 26 screenshot from 2016-02-16 22 36 48
  2. Adds a Boolean qproperty-gradient that allows themers to get rid of the hardcoded gradients on TCO's.
  3. Removes all of the hard coded colors, so now you can change the color of a muted and selected TCO, as well as the shadow of the text.
  4. Evens out the muted and selected colors, so they all are the same.
  5. Implements missing muted foreground color for automation patterns.
  6. All pattern text stays the same color when the pattern is muted, for better readability.

Comparison:

Old
screenshot from 2016-02-16 22 30 25

New
screenshot from 2016-02-16 23 27 32

New with gradients off
screenshot from 2016-02-16 23 28 28

@IvanMaldonado
Copy link
Contributor

@Umcaruje I don't have words to express my gratitude on the work you have done so far.
So many ideas for new themes with the new posibilites I can't wait for 1.2 to come out! Thanks!

@Umcaruje
Copy link
Member Author

@zonkmachine @tresf @michaelgregorius can I get some testing/review on this one?

qproperty-fgColor: rgb( 187, 227, 236 );
qproperty-fgMutedColor: rgb( 128, 128, 128 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of no implication to you... I'm not a fan of the fgFoo tag, personally because normally in css fg is synonymous with foreground which is synonymous with color which is synonymous with textColor. In this case, it's the gradient/overlay, right? Long term, I think we need to cleanup our naming conventions a bit, but you've at least kept it consistent. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is the color of the drawn notes/automation/waveform when a pattern is muted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this. Maybe we can avoid a lot of this by using the background-color property in CSS. So, fgColor becomes color and color becomes background-color.

Also we could avoid the muted and selected properties by adding custom css pseudo class selectors like
AutomationPatternView:muted or AutomationPatternView:selected

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is :muted a valid selector? If so, that may certainly help. I'm glad you're thinking about it thought because we do need to cleanup and standardize the style.css eventually, and you've quickly become the most active dev looking at that file. 👍

@tresf
Copy link
Member

tresf commented Feb 19, 2016

Although you didn't write it, this draw code is bloated in my opinion. Although not fair to pick on you about it, this may be our best chance to clean it up and make it consistent. I left an example of what I mean here: #2574 (comment) but just about every draw function could benefit from some cleanup.


p.fillRect( QRectF( x1, 0.0f, x2-x1, it.value() ),
lin2grad );
if ( gradient() ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I quite prefer if () { to if () <newline> {, we should try to be consistent with the styling of the current file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok, will fix.

@Umcaruje
Copy link
Member Author

@tresf I simplified the code, and also refactored it, so now all patterns draw in the same way/order. I also fixed the problem where the text was getting drawn over the pattern borders. I also commented the code in some places.

Inspired by #2579, I will implement static text drawing on the patterns, since their text doesn't change so often, which should speed up the gui.

@Umcaruje Umcaruje changed the title Get rid of hardcoded colors in TCOs; Make TCO gradient configurable; Even out the color scheme Refactor the drawing of TCO's; Get rid of hardcoded colors in TCOs; Even out the color scheme Feb 20, 2016
@@ -21,12 +21,12 @@
* Boston, MA 02110-1301 USA.
*
*/
#include "AutomationPatternView.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Umcaruje moving this up like this... is this just a "THIS IS MY HEADER!!" convention? This is new to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its in https:/LMMS/lmms/wiki/Coding-conventions

The exception is that in a source file, the first included file should always be its header.

@tresf
Copy link
Member

tresf commented Feb 20, 2016

@tresf I simplified the code, and also refactored it, so now all patterns draw in the same way/order. I also fixed the problem where the text was getting drawn over the pattern borders. I also commented the code in some places.

I think this is in a very good state now. Since we use similar methods to draw it simplifies the code as well as the maintenance of it.

Inspired by #2579, I will implement static text drawing on the patterns, since their text doesn't change so often, which should speed up the gui.

Good catch.

Have we put any thought into consolidation? If we can consolidate the paint-event code, we may be able to make subclass-specific paint functions that pertain exactly to that particular class and handle everything else in the inherited class. Likely not worth it this time around, but I wanted to mention it.... if we can draw all Track objects the same and then tweak the drawing of each subclass for its own particular type, it would further simplify this. I've never done this in C++, so what I'm saying it purely hypothetical. 🍻

@Umcaruje
Copy link
Member Author

Have we put any thought into consolidation? If we can consolidate the paint-event code, we may be able to make subclass-specific paint functions that pertain exactly to that particular class and handle everything else in the inherited class. Likely not worth it this time around, but I wanted to mention it.... if we can draw all Track objects the same and then tweak the drawing of each subclass for its own particular type, it would further simplify this. I've never done this in C++, so what I'm saying it purely hypothetical.

The thing is, in PatternView we don't just draw the pattern, we also draw the BB editor (which is bad imo, but I won't be fixing that). Also the drawing of the bar-lines also differs from pattern to pattern, and the only thing connecting them all is the drawing of the fill, borders and text. It might be a good idea to consolidate, but that is out of the scope of this PR.

@tresf
Copy link
Member

tresf commented Feb 20, 2016

👍

{
p.setFont( pointSize<7>( p.font() ) );

p.setPen( QColor( 0, 0, 0 ) );
p.setPen( textShadowColor() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for fixing future code too.

@Umcaruje
Copy link
Member Author

Update: QStaticText implemented. I also turned on antialiasing on the pattern text, which should make it a lot clearer (cc @musikBear). I also made the B&B patterns render to a pixmap like the other ones.
Also aligned up the sample tracks so they render perfectly in the center.

Comparison between old and new text:
screenshot from 2016-02-26 23 47 17
screenshot from 2016-02-26 23 43 40

What's left to do: refactor the bar-line drawing code and also make sample tracks render to a pixmap.

@Umcaruje Umcaruje force-pushed the gradients branch 3 times, most recently from 6d7eb28 to d22cc82 Compare February 26, 2016 23:10
@Umcaruje
Copy link
Member Author

@LMMS/developers I need a little help here. I reworked the BBTCOView to paint to a QPixmap, like PatternView and AutomationPatternView do, but I ran into a problem:
screenshot from 2016-02-27 00 06 39
When I add a new TCO, it gets grayed out, as if some values are not initialized. The TCO gets normal color when I resize it, select it, or do any of the actions in the context menu. I made the BBTCOView behave the same way PatternView does (m_needsUpdate becomes true in the same spots), but it just won't behave the same way (maybe some signals and slots are missing).

Anyways, if someone here with a greater Qt Knowledge than me could help out, that'd be great.

@tresf
Copy link
Member

tresf commented Feb 27, 2016

Is there a chance your new code checks m_needsUpdate before it's ever initialized? It looks like the first draw may be getting missed because it's never set after first paint, but that's just a quick glance.

@Umcaruje Umcaruje force-pushed the gradients branch 2 times, most recently from aa73d52 to db46bed Compare February 28, 2016 10:49
@Fastigium
Copy link
Contributor

@Umcaruje To fix #2148, try adding this to the constructor of BBTCOView:

connect( _tco->getTrack(), SIGNAL( dataChanged() ), this, SLOT( update() ) );

Signals/slots after all, but not between Pattern and BBTCOView. Turns out Pattern's updateBBTrack() method I mentioned makes the BBTrack that the Pattern belongs to emit a dataChanged() signal, and it's no problem to connect a BBTCOView to its track. I was a bit misled because there was no emit keyword, but today I learned signals always emit when called, with or without emit before them 😊

@Umcaruje
Copy link
Member Author

@Fastigium it works! Thanks a lot.

@Umcaruje Umcaruje force-pushed the gradients branch 4 times, most recently from e545bfb to f96a4ea Compare February 29, 2016 15:51
@tresf
Copy link
Member

tresf commented Feb 29, 2016

The diffs are outdated, so I'll reply in the PR comments directly...

virtual void is like that in Pattern.cpp as well

Sorry, my own misunderstanding of it. This article explains it: http://www.qtcentre.org/threads/864-diffrence-between-void-and-virtual-void, but it's fine as-is.

I don't quite understand. I should define a private member variable m_needsUpdate in TrackContentObjectView, and then make functions that allow the child classes to access that variable?

Yes, exactly. But, from a design perspective this would also assume you have a use for it inside TCOV by consolidating your common paintEvent code (well, assuming you encapsulate the variable... you could also simply make it public and expose it to all sub-classes).... and then each variation to paintEvent can first call the super-class first, then subsequent code (foo() would first call super::foo()) and then add any additional logic afterward. Of course, this conversation really is a duplicate of #2574 (comment), so feel free to tell me to stop any any time. 😄

@Umcaruje
Copy link
Member Author

Well, I implemented it so that m_needsUpdate is now a member variable of TrackContentObjectView. I implemented getter and setter functions needsUpdate() and setNeedsUpdate().

This is pretty much where I draw the line. I'd want to work on some new issues now and this code is in a much better state than before. As I said previously, complete consolidation of the code is currently out of the scope of this PR :)

@tresf
Copy link
Member

tresf commented Feb 29, 2016

@Umcaruje well I don't think it harms to have an external API to force the redraw and agreed, out of scope.

I don't have a chance to compile and test this for a few days, so if someone else can give it the OK, that would be great.

@tresf
Copy link
Member

tresf commented Mar 1, 2016

Things look good from here. Good to merge. These Piano roll "notches" in the BBEditor... are they a new feature? I don't remember them before.

image

image

Also, unrelated to your PR, and I think already reported, but the clone pattern button doesn't impact the last BB track.

@Umcaruje
Copy link
Member Author

Umcaruje commented Mar 1, 2016

These Piano roll "notches" in the BBEditor... are they a new feature? I don't remember them before.

They exist on the LMMS 1.1.3 I have installed on my PC:
screenshot from 2016-03-01 23 49 46

@Umcaruje
Copy link
Member Author

Umcaruje commented Mar 1, 2016

Oh, don't merge yet: I just noticed the mute icons are misaligned from your pic:
screenshot from 2016-03-01 23 53 46

I'll fix that tommorow, and then this will be ready to merge :)

@Umcaruje
Copy link
Member Author

Umcaruje commented Mar 2, 2016

gifrecord_2016-03-02_215028

The 'muted' pixmaps are now properly aligned, and also stay in place when you resize the track width. I also reduced their size to 14x14 so they don't clash with the text.

This is good to merge now 👍

…ake TCO gradient configurable; Even out the color scheme

Thanks to @Fastigium for helping with the BB Pattern redraw problem
@tresf
Copy link
Member

tresf commented Mar 2, 2016

👍

Umcaruje added a commit that referenced this pull request Mar 3, 2016
Refactor the drawing of TCO's; Get rid of hardcoded colors in TCOs; Even out the color scheme
@Umcaruje Umcaruje merged commit 020b4dd into LMMS:master Mar 3, 2016
@IvanMaldonado
Copy link
Contributor

I know this is not the place to post this, but I didn't want to open a issue to inform a minor problem.

captura de pantalla_2016-03-03_16-32-04

I noticed there is a property in the style.css that should be moved.

@Umcaruje
Copy link
Member Author

Umcaruje commented Mar 3, 2016

I noticed there is a property in the style.css that should be moved

Why?

@Umcaruje Umcaruje deleted the gradients branch March 3, 2016 22:48
@IvanMaldonado
Copy link
Contributor

I take every comment as a section, and the graphics that are changed by QToolButton are the same graphics changed by the properties under "all tool buttons" and it is currently under "smaller toolbars" besides QToolBar's properties.

2

Red: QToolButton
Blue: QToolBar

@Umcaruje
Copy link
Member Author

Umcaruje commented Mar 3, 2016

Then the comment should be moved, and not the property. Cuz, you see, we are overriding the colors on hover and also the border and other stuff. If that property was moved where you suggest, the look of the buttons wouldn't change.

@IvanMaldonado
Copy link
Contributor

My bad, I meant to say "the object", not "the property".

This is how it should look:

3

@Umcaruje
Copy link
Member Author

Umcaruje commented Mar 3, 2016

No it shouldn't look like that, you just made the play and stop buttons square again...

@Umcaruje
Copy link
Member Author

Umcaruje commented Mar 3, 2016

Anyways, this conversation is entirely pointless on this PR and has 0 relevance to it.

Issue a Pull Request or open an issue about this if you want, I'm locking this.

@LMMS LMMS locked and limited conversation to collaborators Mar 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants