Commit Graph

52 Commits

Author SHA1 Message Date
Matthew Dapena-Tretter
dfd3ba8c14 Defer component initialization until element is requested
This fixes the error snapshotting Docks described in #16864.
2018-04-02 17:10:39 -07:00
Matthew Dapena-Tretter
5af205739d Don't trigger dock handle drag enter event unless a known item is being dragged
This seems a little counterintuitive. How could a dragenter event fire
if nothing's being dragged? Well, if something's dragged into the
document (i.e. from the desktop or another window), a dragenter event
will be fired even though (as far as we're concerned), nothing is being
dragged. Rather than trying to handle this class of events specially in
the dock, we simply limit our listening to when something is being
dragged. Since we have a single source of truth for this information,
this should be resilient to future changes in logic.
2018-03-30 14:11:30 -07:00
Matthew Dapena-Tretter
7315cf8159 Defer loading of PaneContainerElement to fix snapshotting 2018-03-06 15:45:29 -08:00
Matthew Dapena-Tretter
871da3e2e1 Remove JSX 2018-03-06 15:45:29 -08:00
Matthew Dapena-Tretter
113453a219 Convert Dock to an etch component 2018-03-06 15:45:29 -08:00
Matthew Dapena-Tretter
6f194c7811 Make sure there's a single source of truth for dock hover state
Previously, the workspace's idea of the hovered dock and the docks'
themselves could be out of sync.
2018-03-01 14:56:52 -08:00
Matthew Dapena-Tretter
c69c82d05a Fix dock dragging and dropping
This fixes #16769, which described an issue whereby trying to drop into
a closed dock would cause the dock to repeatedly open and close.

I tried to describe in comments why this was happening and how we can
make sure to avoid it.

The solution adds another DOM measurement which I'm not too thrilled
about but I profiled and it didn't seem to be an issue.
2018-02-28 18:14:13 -08:00
Antonio Scandurra
8077f46fdf Programmatically detect when mouse approaches the edge of a dock
Previously, we would assign dock elements a minimum width/height of 2
pixels so that we could detect when the mouse approached the edge of a
hidden dock in order to show the chevron buttons. This, however, was
causing confusion for users, who expected that extra space to be
clickable in order to scroll editors located in the center dock.

With this commit we will instead register a global `mousemove` event on
the window right when attaching the workspace element to the DOM (the
event handler is debounced, so this shouldn't have any performance
consequence). Then, when mouse moves, we will programmatically detect
when it is approaching to the edge of a dock and show the chevron button
accordingly. This allows us to remove the `min-width` property from the
dock container element, which eliminates the confusing behavior
described above.
2018-01-12 17:12:55 +01:00
Josh Soref
e39970cd1a spelling: visibility 2017-09-10 15:46:41 +00:00
Matthew Dapena-Tretter
ca6254dd66 Add methods for observing dock visibility 2017-06-07 16:24:28 -07:00
Wliu
02258a9994 📝 Fix get{Left|Right|Bottom}Dock links 2017-06-06 23:34:47 -04:00
Jason Rudolph
09495dfc35 🔥 Remove broken Dock::getTextEditors() function
We're updating Atom to disallow editors in docks. As a result, we need
to remove Dock::getTextEditors(). Normally, we would deprecate a method
before removing it, but this method is broken and has never worked:

  atom.workspace.getLeftDock().getTextEditors()
  (unknown) Uncaught TypeError: this.paneContainer.getTextEditors is not a function
      at Dock.getTextEditors (/Applications/Atom.app/Contents/Resources/app/src/dock.js:590:37)
      at <anonymous>:1:30

Since the method is broken, we know that nobody is relying on it.
Instead of deprecating the method, we can just remove it.
2017-06-01 15:31:21 -04:00
Jason Rudolph
0b314ac1a9 🔥 Remove broken Dock::observeTextEditors(callback) fn
We're updating Atom to disallow editors in docks. As a result, we need
to remove Dock::observeTextEditors(callback). Normally, we would
deprecate a method before removing it, but this method is broken and has
never worked:

  atom.workspace.getLeftDock().observeTextEditors(console.log)
  (unknown) Uncaught TypeError: this.paneContainer.getTextEditors is not a function
      at Dock.getTextEditors (/Applications/Atom.app/Contents/Resources/app/src/dock.js:590:37)
      at Dock.observeTextEditors (/Applications/Atom.app/Contents/Resources/app/src/dock.js:396:41)
      at <anonymous>:1:30
  getTextEditors @ <embedded>:29933
  observeTextEditors @ <embedded>:29739
  (anonymous) @ VM1941:1

Since the method is broken, we know that nobody is relying on it.
Instead of deprecating the method, we can just remove it.
2017-06-01 15:26:12 -04:00
Jason Rudolph
f8ebd71200 Deprecate Dock::getActiveTextEditor() 2017-06-01 15:24:50 -04:00
Jason Rudolph
e569f8fc4d 📝 Fix odd grammar in API docs 2017-06-01 12:08:09 -04:00
Jason Rudolph
ae9f24602d 🐛 Fix #14442
Fixes error activating next/previous pane from Dock.
2017-05-17 15:28:24 -04:00
Max Brunsfeld
a61accf175 Don't change focus when hiding an unfocused dock 2017-05-02 10:34:14 -07:00
Matthew Dapena-Tretter
d40a14be29 Add tests for dock sizing behavior 2017-04-15 11:50:41 -07:00
Matthew Dapena-Tretter
f6b20cd31c Reduce dock initial size lookups
Previously, we would get the initial size every time we didn't have an
explicit one. With this commit, we only get the initial size when we
deserialize and when we go from 0 -> 1 pane items.

Also, if the dock doesn't already have an explicit size, we'll use the
preferred size of the item being dragged when peaking the dock. That
way, dropping it won't cause it to change size.
2017-04-15 11:50:19 -07:00
Matthew Dapena-Tretter
915931dddd 🐛 Make sure docks affordance can always be revealed 2017-04-13 15:52:05 -07:00
Antonio Scandurra
b8e6689abf Merge pull request #14178 from atom/fb-mdt-resize-handle-shouldnt-cover-center
Prevent the resize handle from covering the center
2017-04-13 18:17:09 +02:00
Matthew Dapena-Tretter
2ee851a218 Don't show resize handle at all for collapsed docks
They no longer have any functionality. Themes can add extra affordances
if they want.
2017-04-12 11:24:47 -07:00
Nathan Sobo
8b8218bf81 Properly restore focus to center when hiding dock via toggle 2017-04-12 09:46:18 -06:00
Matthew Dapena-Tretter
2a2d657d98 Prevent the resize handle from covering the center
Currently, the absolutely positioned element is the only thing with a
size. That means that it'll cover the center. With this change, we give
a size to the (relatively-positioned) atom-dock element so that closed
docks take up canvas space instead.

I think @simurai mentioned this problem before but I wasn't following
and then forgot about it. 😖
2017-04-11 22:38:09 -07:00
Max Brunsfeld
399b70662d Fix regression in hovered dock tracking due to workspace refactor
Also, backfill tests for showing, hiding and updating the dock toggle
buttons in response to mouse movements.
2017-04-10 14:15:31 -07:00
Nathan Sobo
9259372f23 Fix dock hiding on drag 2017-04-08 14:29:34 -06:00
Max Brunsfeld
cabeeca8b6 Publicize more Dock methods 2017-04-07 15:38:25 -07:00
Max Brunsfeld
63d27c5f0a Rename Dock.isOpen to .isVisible and Dock.open to .show 2017-04-06 17:23:53 -07:00
Nathan Sobo
f15b6d9074 Eliminate unnecessary event listener removals 2017-04-06 16:58:13 -06:00
Nathan Sobo
6f6ec70094 Allow items closed in docks to be reopened 2017-04-06 15:57:26 -06:00
Nathan Sobo
646047f563 Maintain an active pane container on the workspace
This will be used by many commands that previously only interacted with
the center of the workspace.
2017-04-06 15:30:01 -06:00
Nathan Sobo
73f04fdaed Focus the active center pane when hiding a dock 2017-04-05 20:58:05 -06:00
Nathan Sobo
88422ee4c9 Focus the active pane of docks when they are activated 2017-04-05 15:35:47 -06:00
Nathan Sobo
334290aaa7 Resize dock to fit on double-click of resize handle 2017-04-05 12:45:29 -07:00
Nathan Sobo
095dc71ba9 Rename getPreferredInitialHeight/Width to getPereferredHeight/Width 2017-04-05 12:45:29 -07:00
Max Brunsfeld
8b407bf48f Don't allow opening docks by clicking on the resize handle 2017-04-05 12:45:29 -07:00
Max Brunsfeld
caafa41f6f Open docks when activating their panes, but not when adding items 2017-04-05 12:00:38 -07:00
Matthew Dapena-Tretter
08e8975a10 Always show the dock when an item is dropped into it
Previously, we were only showing it when going from 0 -> 1 items (which
is a bug).
2017-03-27 18:17:02 -07:00
Matthew Dapena-Tretter
3b23ab44bc Add getLocation() to PaneContainer class
This allows the location to be inspected without having to jump to the
DOM and searching for a dock element.
2017-03-27 17:45:21 -07:00
Matthew Dapena-Tretter
41953ae7d6 Only show dock toggle buttons when dragging if item is allowed 2017-03-27 17:45:15 -07:00
Matthew Dapena-Tretter
f3c3917825 Don't show the dock toggle button if it's closed and empty 2017-03-27 14:20:47 -07:00
Matthew Dapena-Tretter
13f0c8a977 Docks: define handle size in CSS; measure in JS 2017-03-27 12:19:08 -07:00
Max Brunsfeld
bc872143cc Avoid duplicate search for pane container in Workspace.open 2017-03-24 15:49:35 -07:00
Max Brunsfeld
93ba6109fa Create Dock element lazily to be compatible w/ snapshotting 2017-03-24 15:29:46 -07:00
Matthew Dapena-Tretter
791457d9a7 Add remaining pane container methods and documentation to docks 2017-03-23 11:24:41 -07:00
Matthew Dapena-Tretter
37a3c9b59c Measure toggle button size instead of hardcoding it 2017-03-23 11:24:41 -07:00
Matthew Dapena-Tretter
e01bc40a78 "affordance" -> "hoverMargin" 2017-03-23 11:24:41 -07:00
Matthew Dapena-Tretter
cd62357f0f Mention dock getters in Dock docs 2017-03-20 22:39:28 -07:00
Matthew Dapena-Tretter
98e7fcc505 Prefer getElement() to view registry for Docks, PaneContainer & Pane 2017-03-20 22:39:23 -07:00
Matthew Dapena-Tretter
d854a88dbb Add workspace.toggle() method 2017-03-18 15:32:01 -07:00