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

Merge new box-model code into QtWebEngine conversion #3618

Closed

Conversation

ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Jul 21, 2020

See #3617 for PR details. This is the same source branch, but targeting the WebEngine PR branch instead of develop.

- 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.)
Comment on lines 82 to 84
<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">
Copy link
Contributor Author

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>
Copy link
Contributor Author

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.

Comment on lines -214 to -228

//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");
}
}
);

Copy link
Contributor Author

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.

Comment on lines +301 to +306
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];
Copy link
Contributor Author

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.

Comment on lines -301 to -302
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);
Copy link
Contributor Author

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.

<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)}}">
Copy link
Contributor Author

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.

border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
box-shadow: 0 0 10px #000;
box-sizing: border-box;
Copy link
Contributor Author

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 DIVs, 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.

Comment on lines 463 to 470
/* Selected item border, semi-transparent unless hovered */
.ui-selected>.tl-border {
border-color: #ff0000a8;
}

.ui-selected:hover>.tl-border {
border-color: #ff0000ff;
}
Copy link
Contributor Author

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.

- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants