-
Notifications
You must be signed in to change notification settings - Fork 549
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
Merge new box-model code into QtWebEngine conversion #3618
Merge new box-model code into QtWebEngine conversion #3618
Conversation
- Remove border styling from clip, transition objects - Remove box-sizing: border-box, which made objects' DOM size unreliable - Create new CSS class .tl-border, to hold border styling - Insert new div.tl-border container just inside each clip/transition - Remove sizing-bug "fudge factors" (like bounding_box_padding) - Implement all highlight/hover styling in pure CSS (with `:hover`), eliminating `mouseover` event handlers - Apply selected-item border styling to transitions, as well as clips
(I hate when it has a point.)
src/timeline/index.html
Outdated
<div ng-hide tl-clip ng-repeat="clip in project.clips" id="clip_{{clip.id}}" ng-click="selectClip(clip.id, true, $event)" ng-right-click="showClipMenu(clip.id, $event)" class="clip timeline_obj droppable" ng-class="getClipStyle(clip)" style="width:{{(clip.end - clip.start) * pixelsPerSecond}}px; left:{{clip.position * pixelsPerSecond}}px; top:{{getTrackTop(clip.layer)}}px;z-index:{{1000 + $index}};"> | ||
<div id="clip_border_{{clip.id}}" class="clip_border tl-border"> | ||
<div class="clip_top"> |
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.
As small a thing as it is, inserting the extra <div class="tl-border">
is the big thing that makes all the difference.
By moving the borders to that <div>
and unsetting box-sizing:border-box
on the outer <div tl-clip>
, the borders no longer alter the dimensions/placement of the main <div tl-clip>
, which means all of the sizing/placement math becomes predictable and repeatable.
<div class="clip_top"> | ||
<div tl-clip-menu class="clip_menu" ng-show="!enable_razor" ng-mousedown="showClipMenu(clip.id, $event)" tooltip-enable="!enable_razor" tooltip="{{clip.title}}" tooltip-placement="bottom" tooltip-popup-delay="400"></div> | ||
<div tl-clip-menu class="clip_menu menu_button" ng-show="!enable_razor" ng-mousedown="showClipMenu(clip.id, $event)" tooltip-enable="!enable_razor" tooltip="{{clip.title}}" tooltip-placement="bottom" tooltip-popup-delay="400"></div> |
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.
All of the menus were using the same styling, so I created a shared .menu_button { }
CSS stanza and applied it to all of them, eliminating the duplicated CSS.
|
||
//handle hover over on the clip | ||
element.hover( | ||
function () { | ||
if (!dragging) { | ||
element.addClass("highlight_clip", 200, "easeInOutCubic"); | ||
} | ||
}, | ||
function () { | ||
if (!dragging) { | ||
element.removeClass("highlight_clip", 200, "easeInOutCubic"); | ||
} | ||
} | ||
); | ||
|
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.
I knew I really wanted to get rid of this, because it was fighting with the rest of the CSS rules. You could even see it happening in the UI, clips would get into a state where mousing between them would cause borders to flash, or disappear momentarily and reappear — all sorts of issues. Plus, :hover
styling is at this point a basic CSS feature, there's no reason it couldn't be used to create the hover effects without needing to add any extra JavaScript code.
var [nearby_offset, snapline_position] | ||
= scope.getNearbyPosition( | ||
[bounding_box.left, bounding_box.right], | ||
10.0, bounding_box.selected_ids); | ||
// var nearby_offset = results[0]; | ||
// var snapline_position = results[1]; |
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.
Heh, forgot I even did that. Our JS code creates way too many temporary variables, as it's tossing around data. This eliminates one temporary array, which is something.
var bounding_box_padding = 3; // not sure why this is needed, but it helps line everything up | ||
var results = scope.getNearbyPosition([bounding_box.left, bounding_box.right + bounding_box_padding], 10.0, bounding_box.selected_ids); |
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.
Doing away with box-sizing: border-box
let me eliminate the bounding_box_padding
adjustment to the lasso processing, which was only there (whether that comment knew it or not) to correct for the borders being included as part of the object dimensions.
src/timeline/index.html
Outdated
<div ng-repeat="layer in project.layers.slice().reverse()" id="track_{{layer.number}}" ng-right-click="showTimelineMenu($event, layer.number)" class="{{getTrackStyle(layer.lock)}}" style="width:{{getTimelineWidth(1024)}}px;"> | ||
<div ng-repeat="layer in project.layers.slice().reverse()" id="track_{{layer.number}}" ng-right-click="showTimelineMenu($event, layer.number)" class="{{getTrackStyle(layer.lock)}}"> |
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.
Another unexpected optimization: I noticed we were forcing the width
of every track DIV
with inline styling. But they're all in a container that's also forced with the exact same width. So I just added width: 100%
to the track CSS, removed the inline styling, and let the container dictate the width of the tracks.
src/timeline/media/css/main.css
Outdated
border-top-right-radius: 8px; | ||
border-bottom-right-radius: 8px; | ||
box-shadow: 0 0 10px #000; | ||
box-sizing: border-box; |
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.
Ironically, the problem with vertical placement of the clips/transitions was the lack of border-box
sizing on the track DIV
s, which weren't the same size we expected them to be due to their borders pushing them out of place. We don't actually care about the size of the tracks themselves, we just care that they're in the positions we expect them to be. So, using box-sizing: border-box
ensures that the (bordered) track containers will be the same size as the (now-unbordered) draggables, and they line up correctly.
src/timeline/media/css/main.css
Outdated
/* Selected item border, semi-transparent unless hovered */ | ||
.ui-selected>.tl-border { | ||
border-color: #ff0000a8; | ||
} | ||
|
||
.ui-selected:hover>.tl-border { | ||
border-color: #ff0000ff; | ||
} |
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.
Because the <div tl-track>
is a container for <div class="tl-border">
, which is in turn a container for all of the rest of its contents, my initial attempts at dicking around with setting opacity
to create hover effects all failed. I couldn't change the opacity of the border <div>
without everything inside it also becoming semi-transparent. So, I finally hit on the idea of just assigning semi-transparent colors to the borders, in the non-hovered state.
ngClass supports an object as argument, each key for which the value evaluates to true will be used as a class name.
…bengine-box-model
- New 32x32 cursors (which fit new Chrome/Firefox restrictions) will show the dashed line only when hovering over clips/transitions, just the "knife" part otherwise - New reveal logic relies on setting a class on the body element, seems to style things appropriately. Some UI elements (resize handles, the playhead) will show other cursors, if still active in razor mode. - The (re-laid-out) debug panel now includes a razor mode toggle.
643debb
to
3423bf7
Compare
See #3617 for PR details. This is the same source branch, but targeting the WebEngine PR branch instead of
develop
.