Repository navigation
More qtFRED fixes - #8036
More qtFRED fixes#8036The-E wants to merge 12 commits into
Conversation
object_moved() set the Docked_already_handled flag on all objects before it called dock_move_docked_objects(). Thus that function returned immediately, and the docked partners of a moved ship stayed in place. FRED2 removes the flag. QtFRED now does the same. Some paths did not call object_moved() at all: - The transform toolbar did not call it. - A cancelled drag restored only the marked objects. - The Orient editor called it only when the position changed, not for a rotation. - An undock with "move ships when undocking" moved one ship, but not its other docked partners. The partners now move after the undock, so that the ship that stays does not move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A click and a box selection in the viewport ignore the objects that Lock Marked Objects locked. Other selection commands still marked the locked objects, so the user could then move or change them. Now these commands skip the locked objects: - Next and previous object. Before, a locked object also stopped the cycle. - Select All and Invert Selection in the Scene Browser. - Group selection. - The Select Wing commands: Mark Wing in the menu, and Select Wing in the context menu and in the context toolbar. A selection by name still marks a locked object, for example in the Scene Browser tree, with Next and Prev in the editor dialogs, or in a context menu. FRED2 does the same. A check in Editor::markObject() would break the callers that expect the mark to succeed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The QtFRED projection matrix used a field of view of 0.485, but the g3 view matrix used 0.5. The labels, the mouse picking, and Zoom Extents use the g3 view matrix, so they did not align with the rendered objects. The offset increased at the edges of the viewport. The new constant EDITOR_DEFAULT_FOV in missioneditor/common.h replaces the two copies of FRED_DEFAULT_HTL_FOV and the 0.5 literals: - QtFRED: the projection matrix, the view matrix that FredRenderer sets before and after it draws the scene, Zoom Extents, and the frame that the briefing map gives back to the main viewport. - FRED2: the projection and view matrices (already 0.485), Zoom Extents, and the frame at initialization. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The boxes were not usable (wiki scp-fs2open#31). updateUI() runs on each idle tick and calls ensureViewportFocus(). That function keeps the focus only on the children of a QDockWidget, and the transform toolbar is a QToolBar. Thus the viewport took the focus from a box immediately, and the focus loss applied a value that the user did not finish. Now a box keeps the focus while the user types. Enter applies the value and gives the focus back to the viewport. Escape and all other focus changes discard the value. A change of the current object or of the mode also gives the focus back. Enter applies the value only if the object and the mode did not change after the box got the focus. An edit of one box wrote all three boxes to the marked objects (wiki scp-fs2open#10). The boxes showed one decimal, so the other two axes changed to rounded values. Now: - Only the axis of the edited box changes. A rotation changes only one angle of each object. - Enter with an unchanged value does not write the rounded value. With more than one marked object and Local OFF, Enter sets the value on all the marked objects, also if it did not change. - The boxes show two decimals. A click in the viewport now takes the focus. RenderWindow forwards the mouse events with sendEvent(), and Qt does not move the focus for such events. While a box has the focus, it also gets the keypad keys of the camera controls. The box shows these digits, but they have no effect until the user pushes Enter. Wiki scp-fs2open#11 (the selected text stays highlighted) is not reproduced. QLineEdit removes the selection on each focus change, except a window or popup change. This commit does not change that behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
applyVisuals() set only the background color of an annotated SEXP tree row. The text kept the color of the theme, so light text on a light annotation color (or dark text on a dark one) was unreadable. Now the text is black or white, with the rule that FRED2 uses. The rule moves to the new shared function annotation_text_is_dark(), so that the two editors show the same text color. The Events editor also gave a color to annotations that have only a note. For "no color", the model uses white (255, 255, 255). But the dialog stored white as a valid color, so these rows were white, also in dark mode. Now such a row has no color. applyVisuals() removes the background and text colors, so the row uses the theme colors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seven places had a copy of the loop that calls object_moved() for each marked object. The new function marked_objects_moved() holds this loop. It returns the number of marked objects, so Level Object and Align Object do not need their own counters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
select_next_object() and select_previous_object() were near copies. The previous version copied the object list into an array to step back, and each version had its own loop to skip locked objects. Now both call select_adjacent_object(), which steps through the circular object list in either direction. The behavior does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Select Wing commands called mark_wing() and then unmarkLockedObjects(). Thus each locked ship was marked and then unmarked, and the marking signals went out two times. Also the FredView::selectWing() wrapper had no other purpose. Now mark_wing() has a LockedObjects argument with no default value. The Select Wing commands pass Skip. A selection by name, for example in the Wing Editor, and the new wing after Form Wing pass Include. unmarkLockedObjects() and selectWing() are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The projection matrix computed its field of view from the editor constant, and the g3 view matrix used the same constant. Thus two calculations had to stay equal. In FRED2, both also had to check Briefing_dialog. g3_set_view_matrix() already sets Proj_fov from its zoom, and the game gives Proj_fov to gr_set_proj_matrix(). The editors now do the same. Each editor frame sets the g3 view matrix before it enables the projection, so the result does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The transform toolbar code was about 450 lines of FredView.cpp, with its own state: the edit record of the boxes, the Local preference of each mode, and the dirty flags of the IFF and layer lists. Now the new class TransformToolBar owns the widgets, this state, the event filter of the boxes, and the Local settings. FredView creates the class, calls update() on each idle tick, and tells it when the layers change. FredView.cpp goes from 3194 to 2719 lines. Other changes: - The three boxes and their labels are arrays, so the per-axis code is a loop. - The sync of the camera speed combo boxes moves from onUpdateViewSpeeds() into the class. - update() calls one function for each widget group. The behavior does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QToolBar puts the tops of its widgets on one line. With the Fusion style, a spin box is taller than a combo box, so the X/Y/Z boxes went lower than the other widgets. The Local button was 1 pixel shorter. Now the boxes and the Local button have the height of the combo boxes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A step with the mouse wheel, the arrow buttons, or the Up, Down, Page Up, and Page Down keys changed only the box. The user had to push Enter to apply it. Now each step that changes the value applies it to the object at once. Typed text still needs Enter. A small QDoubleSpinBox subclass reports each step from stepBy(). The step applies to the current object, also if the box did not have the focus: the box always shows the value of the current object. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dustinspace217
left a comment
There was a problem hiding this comment.
Read at 1abd8a1. I did not build it or try it in the editor, so the items below are from the code only.
Each of the five fixes does what the description says:
- Docked ships:
object_moved()now clearsDocked_already_handledthe way FRED's does, and the toolbar, a cancelled drag, the Orient editor and undocking all call it. - Locked objects: next/previous, Select All, Invert, groups and Select Wing now skip them.
- Label offset: the projection comes out the same numbers as before, and every caller runs after the frame's view matrix is set. The game is untouched.
- Toolbar boxes and annotation text: as described.
Two small things, neither blocking:
- A locked object can still be moved from the toolbar boxes (inline).
- The undock fix is qtFRED only. FRED's
initialstatus.cpp(around line 981) still moves one ship and never callsobject_moved(), and FRED'smark_wingdoes not skip locked ships. If the two editors should stay in step, those are the spots.
Worth a hand test, since I could not: hold a box's arrow button down and check that auto-repeat keeps going (the range is reset on every idle tick), and roll the wheel over a box with several ships marked and Local off, which sets that axis to one value on all of them at once.
| if (!editIsCurrent()) return; | ||
|
|
||
| const int curObj = _editor->currentObject; | ||
| if (!query_valid_object(curObj)) return; |
There was a problem hiding this comment.
There is no Locked_from_editing check here. A locked object picked by name in the Scene Browser becomes the current object, and the boxes then move it. Keyboard movement refuses the same case (EditorViewport.cpp:445). The old toolbar had the same gap, so this is not new.
Edited: I first called this the one way left to move a locked object. It isn't: the Orient editor, and dragging or keyboard-moving another marked object, also move a locked object that was marked by name. That comes from selection by name marking locked objects, so it's outside this PR.
This PR fixes more issues that were never reported to the SCP. Like #8030, it is based on the description of fixes in the OFP fork, but no code from OFP was used in development; these are clean-slate reimplementations. This PR does not depend on #8030.
Full list of included changes:
Viewport and selection
object_moved()set the "already handled" dock flag on all objects instead of clearing it, so the dock code returned at once.object_moved(): the transform toolbar, a cancelled drag, a rotation-only change in the Orient editor, and an undock with "move ships when undocking" (the other partners of the moved ship stayed behind).Proj_fov), the same as the game. QtFRED and FRED2 share this code.Restructuring (no behavior change)
TransformToolBar. FredView.cpp goes from 3194 to 2719 lines.marked_objects_moved(), replaces seven copies of the loop that moves the docked partners of the marked objects.mark_wing()has an explicit argument that tells if it includes locked ships.🤖 Generated with Claude Code