Skip to content

Commit

Permalink
jx_layout_editor DND progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jafl committed Dec 30, 2023
1 parent 46cbbcc commit 89aebd6
Show file tree
Hide file tree
Showing 10 changed files with 335 additions and 404 deletions.
17 changes: 11 additions & 6 deletions todo-jxlayout
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
drag:
second selection target: frames & mouse offset
remove selected widgets, replace with frames
cancel: put back where they were
drop: place at last frame location

in other window, still need to show frames & deserialize to the drop location
in other window, deserialize to the drop location

align to grid - shift key to turn off

-----

create widget by cmd-dragging rectangle
after release, select widget type and then create it - sets correct container

move
drag selected widgets
serialize/deserialize if enclosure changes
enclosure only accepts drag if bounding box of all dragged items fits inside
shift
arrow keys
align to grid - shift key to turn off
accumulate into single undo
resize
like window - any edge or corner
shift key to turn off grid
undo
create/delete/move/resize/params
anything that marks document as dirty

enforce that all selected widgets have the same container
if not, ignore shift

widget options
label, if appropriate
Expand Down
41 changes: 3 additions & 38 deletions tools/jx_layout_editor/code/BaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include <jx-af/jcore/jMouseUtil.h>
#include <jx-af/jcore/jAssert.h>

static const JUtf8Byte* kDNDClassID = "BaseWidget";

/******************************************************************************
Constructor
Expand Down Expand Up @@ -75,6 +73,8 @@ BaseWidget::~BaseWidget()
/******************************************************************************
StreamOut (virtual)
Remember to keep LayoutDocument::ReadFile in sync!
******************************************************************************/

void
Expand Down Expand Up @@ -182,7 +182,7 @@ BaseWidget::HandleMouseDrag
itsWaitingForDragFlag = false;
itsClearIfNotDNDFlag = false;

auto* data = jnew LayoutSelection(itsLayout, kDNDClassID);
auto* data = jnew LayoutSelection(itsLayout, LocalToGlobal(itsStartPt));
BeginDND(pt, buttonStates, modifiers, data);
}
}
Expand Down Expand Up @@ -213,41 +213,6 @@ BaseWidget::HandleMouseUp
}
}

/******************************************************************************
GetSelectionData (virtual protected)
This is called when DND is terminated by a drop or when the target
requests the data during a drag, but only if the delayed evaluation
constructor for JXSelectionData was used.
id is the string passed to the JXSelectionData constructor.
******************************************************************************/

void
BaseWidget::GetSelectionData
(
JXSelectionData* data,
const JString& id
)
{
if (id == kDNDClassID)
{
auto* layoutData = dynamic_cast<LayoutSelection*>(data);
assert( layoutData != nullptr );

JPtrArray<BaseWidget> widgetList(JPtrArrayT::kForgetAll);
itsLayout->GetSelectedWidgets(&widgetList);
assert( !widgetList.IsEmpty() );

layoutData->SetData(widgetList);
}
else
{
JXWidget::GetSelectionData(data, id);
}
}

/******************************************************************************
GetDNDAction (virtual protected)
Expand Down
2 changes: 0 additions & 2 deletions tools/jx_layout_editor/code/BaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class BaseWidget : public JXWidget
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers) override;

void GetSelectionData(JXSelectionData* data,
const JString& id) override;
Atom GetDNDAction(const JXContainer* target,
const JXButtonStates& buttonStates,
const JXKeyModifiers& modifiers) override;
Expand Down
Loading

0 comments on commit 89aebd6

Please sign in to comment.