...and with them all references their widgets keep (which are a lot).
Take ownership of the widget after creating it, so it can be reliably
unrefed upon exit.
I had to remove the asserrt in tool preset constructor, because with it
it wasnt possible to initalize an empty model object for the editor.
At init time the gimp object passed to the constructor is not yet available.
currently respects the fact that FG/BG are always global and the
global brush,pattern,... settings from gimprc. This should probably
not change, but rather be overridable on a per-preset basis as
suggested.
Don't overwrite the entire context part of all tool options with
values from contextrc, or we will end up with one tool option set to a
non-default values affecting all other tool options that were at their
default value in the next gimp session.
My earlier change to using gimp_drawable_push_undo() here was a very
bad idea. Go back to using gimp_image_undo_push_drawable_mod(), but
make use of its new tile-copying feature so the problem that made me
do the earlier change is fixed too. See comments in the changed code.
The set of core GEGL ops that GIMP does not want to see falls into a
well defined set of categories. Blacklisting allows freedom in choosing
new and better categorisation for GEGL ops.
This was decided in a discussion with guiguru on irc
some time ago. However, one element is missing. The
rate slider needs to be disabled when motion only is
enabled, because it has no effect.
Need to call gimp_text_tool_ensure_layou() in gimp_text_tool_draw()
explicitely now, because we don't redundantly call the
get_cursor_rect() function any more when there is a selection.
- request "click" releases instead of trying to detect them ourselves,
but keep a minimum reasonable text layer size anyway (reduce it from
20 to 3 pixels though).
- ignore RELEASE_CANCEL when selecting, we can't undo that yet.
- properly handle RELEASE_CANCEL when creating new lext layers (don't
leave a dead overlay style editor around).
so we also correctly handle non-text and non-markup changes (e.g. via
tool options). This is not exactly the right place to call
block_drawing(), but all places which change change the actual content
(and thus un-sync buffer and layout cursor posotions) already block
drawing before the actual buffer change happens.
instead of duplicating GimpTextLayout's positioning logic in two
different incomplete ways. Also gets rid of the unrelated offset
return values of gimp_text_tool_editor_get_cursor_rect().
Earlier I claimed that drawing would work now because we make sure
that buffer and layout are always in sync. This was nonsense. In fact,
we constantly ran into the sutiation where the buffer was modified,
and we were drawing with the previous layout. It's unclear why this
didn't cause drawing artifacts, but it did cause e.g. the cursor
temporarily jumping to the next position while editing in the middle
of text (especially visible at line ends).
Several underlying problems existed: first, we now modify the buffer
from outside the text tool (from GimpTextStyleEditor) where we can't
pause the tool; second, proxy changes are handled asymetrically
(property changes are queued and processed all together in an idle
function) so we can't pause/resume drawing across the entire operation
because it has many beginnings and only one end.
Therefore:
- add gimp_text_tool_block_drawing()/unblock_drawing(), where block()
can be called as many times as needed, and a single unblock()
enables drawing again. block() also clears the layout, because it
served its purpose (it was just used to pause drawing, and we know
the buffer will change, so kill it).
- connect to GtkTextBuffer::begin-user-action and call block() from
the callback, so we undraw stuff and kill the cached layout before
any buffer change happens.
- call unblock() at the end of gimp_text_tool_apply() because then
the text and the buffer are in sync again, the tool is undrawn and
we can safely create the layout again to draw our stuff.
- also call block()/unblock() from some other places, like when a
new text layer is created.
- get rid of *all* calls to draw_tool_pause()/resume() around buffer
modifications, they are not needed any longer.
- add calls to begin/end_user_action() where they were missing.
In gimp_text_tool_connect(), set either text *or* markup on the
buffer, or the latter will always override the former (now that text
and markup are mutually exclusive in GimpText).
- in GimpText, make "text" and "markup" mutually exclusive, so that
whenever one is set to non-NULL, the other is cleared automatically.
- add gimp_text_buffer_has_markup() which returns TRUE if any char
in the buffer is tagged.
- in the text tool, only set "markup" on the text proxy if there is
actually markup in the buffer, and set "text" otherwise.
This way we don't push "text" *and* "markup" undos on each keystroke,
and undo compression works the way it did before.
- Add signal GimpText::changed() and emit it from
GObject::dispatch_properties_changed() after all notifications have
been emitted, so "changed" is emitted only once for any number of
properties set within a g_object_freeze/thaw_notify() pair.
- Connect GimpTextLayer to "changed" instead of "notify" so we aviod
lots of expensive re-rendering when multiple properties are set
at once.
- Connect GimpTextTool to "notify" *and* "changed", and move some
common code to the "changed" callback (e.g. we don't need to
re-frame the item for each set property).
so all hovering is undrawn. oper_update() is called with proximity ==
FALSE when the pointer leaves the canvas, either to the outside or
into an overlay widget, so this is exactly the right thing to do (and
is probably missing from a lot of other tools too).
Add gimp_text_buffer_get_iter_at_index() which does the reverse thing
than the already existing function gimp_text_buffer_get_iter_index().
Use the new function when cursor-navigation lines. Add "gboolean
layout_index" to both functions, which if TRUE indicates that the
passed in/out index is an index into the PangoLayout's content rather
than the text buffer's. When dealing with layout indices, take into
account the additional characters we insert into the serialized markup
(and thus the layout) for each character that is tagged with spacing.
Instead of including dialogs/dialogs.h everywhere, introduce
gimp_dialog_factory_get_singleton(). The dialog factory singleton is
still initialized by dialogs.c though.
Right now the assumption is that we never will have another dialog
factory instance around. There were so many problems before when we
had four of them, so let's just keep one of them around.
We only have one dialog factory now, and
gimp_dialog_factory_from_name() doesn't provide compile-time type
safety, so use global_dialog_factory directly instead.
Use gtk_text_buffer_begin_user_action() and end_user_action() to group
all text buffer operations triggered by a single editing operation.
Connect to the buffer's "end-user-action" signal instead of to
"changed", "apply-tag" and "remove-tag" separately, so we only update
the text proxy once per user editing.
Add anchor and spacing parameters to the shell overlay API, so
overlays can be positioned on each side of a point in image space,
with configurable spacing in display space.
Add a list of available baseline tags to GimpTextBuffer and
automatically create baseline tags as needed. They get serialized as
<span rise="value">, so add attribute and value parameters to the
buffer's tag_to_name() and name_to_tag() functions. Properly managing
the rise's amount is a TODO, currently each keystroke changes the
baseline by 1024 pango units, which might be whatever depending on the
output grid.
- create a GimpTextStyleEditor on the canvas when editing text.
- sync "text" and "markup" between proxy and text, not only "text.
- connect to chages to text marks on the buffer.
Pull all text buffer utility functions as methods and use
GimpTextBuffer all over the place instead of GtkTextBuffer.
Some actually usefuly features coming soon...
Set "selecting" to TRUE only when we are definitely in selecting mode
(when there is actually a text layer to click on). This commit also
makes the setting of the "selecting" state much simpler and obvious.
Switch to a completely new PangoLayout managing stategy: The drawing
code relies on text_tool->layout being a view on text_tool->text_buffer,
if they get out of sync, drawing is b0rk.
Therefore, split the update_layout() function into clear_layout()
(which kill the layout) and ensure_layout() (which creates the layout
if it doesn't exist).
Whenever the buffer gets modified, pause the draw tool before the
modification so the old cursor/selection undraw, then clear the
layout. Resuming the draw tool will automatically re-create the layout
for the buffer's new contents.
Also switch off any clipping for cursor and selection, so we can at
least see that our input has some effect, even if we don't actually
see the edited text because it's out-of-layer.
Apply the fix for Xlib evilness (non-filled rectangles and circles are
drawn one pixel larger) only for non-filled things, filled drawing is
right by default.
so it's correct for all kinds of mixed text directions. Still looks
like crap because all the rectangles are separate, but should be
logically correct now.
and get rid of the brainfuck idea that app/ has to use _gimp_unit_foo()
functions, passing a gimp pointer. Instead, simply use the libgimpbase
API all over the place. Should we ever allow more than one gimp instance,
they will simply have to share one unit database.
- when the layer becomes modified, completely shut down the text tool
completely instead of leaving it in some bastard hybrid
half-attached state.
- when re-editing a modified layer (like after confirming the edit in
the dialog), push a *drawable* undo, not a drawable_mod undo because
the latter only refs the layer's tiles and doesn't copy them, so when
the text layer re-render happens to not change the layer's size, it
would overwrite the modified pixels without any chance of ever going
back.
Unrelated:
- in button_press(), fix my recent fix for the condition that triggers a
mouse-select and set the "seleting" state to FALSE when the
condition is not met.
- in confirm_response(), don't check if the proxy exists because its
existence is an invariant.
- drop the layout in gimp_text_tool_halt()
- reinitialize the tool completely when clicking another display
- therefore, have to recreate the layout in button_press() instead
of bailing out if it doesn't exist
Take the X position of the lines into account when navigating up and
down by lines, so we end up at the right x-pos also for centered and
right-aligned lines.
- hide the generated "empty" menu item in the IM submenu
- pause/resume the text tool around all selection/cursor/buffer changes
(fixes most drawing artifacts)
This has several advantages:
- it's always readable, no matter how sick font/colors are.
- it does not mess up the buffer, which is a model that should not
contain temporary edit states.
- preediting does not clutter undo.
- it fixes the remaining bugs in the old preediting code because that
code is completely gone now.
- Reset the IM context in much more situations, like on button_press
and when the text editor is initialized and halted (pretty much what
GtkTextView does).
- As a consequence, halt the rectangle text tool after the text tool
in control() because cancelling the IM preedit might cause a
re-framing of the layer because it resized.
- pause()/resume() the draw tool around gimp_text_tool_halt() so we
definitely avoid drawing atrifacts when the text tool is shut down
in the middle of an IM preedit. That pause/resume pair should have
been there from the beginning actually.
- most importantly, when the text changes and we set the buffer (as
happens when undoing), block the "changed" signal on the *buffer*
and not on the proxy (which doesn't even have a "changed"
signal). This was apparently something that happened during the
on-canvas editor merging.
- don't update the proxy when the layout changes, that's the wrong way
around. Instead, update the layout whenever the proxy changes,
remove lots of calls to update_layout() from the text editor and let
the "changed" callback on the buffer do its job of updating
everything.
Like that we start selecting on the very first click on an unframed
text layer alreadyand that we ignore clicks in dead space which had
unexpected results before. Also update all comments and move them
into the function.
Feed them into the text editor's IM context and into the proxy text
view's key bindings. Fixes input methods (e.g. entering of unicode
sequences seems to work flawlessly now).
There is no reason to recreate the layout when the cursor or selection
bound move, so remove the entire callback and all the signal
blocking/unblocking.
In button_press(), don't frame the item again and switch to selecting
mode on double and triple click events, we already did that when
receiving the normal button-press. Also clarify a comment.
- remove the button again.
- add a "box-mode" property to GimpTextOptions and a combo box.
- let the normal options -> proxy -> text mechanism do the setting.
- make sure we update the rectangle in some more situations.
- add utility function gimp_text_tool_frame_item().
Add a "Dynamic Text Box" button to the tool options which sets the
text box' mode back to dynamically resizing with the text. This badly
needs UI review but is at least possible now.
Port over the patch I did for GtkTextView and move *to* the end of the
selection and not *from* it when there is a selection and we are
moving by characters.
- bail out and don't warn like crazy in draw() when there is no text.
- fix crash in button_press() when clicking a modified text layer
bring up the confirm dialog and thus didn't set text_tool->text.
- pull setting the right text on text_tool->text_buffer into
gimp_text_tool_canvas_editor() (fixes editing after confirming a
modified text layer edit).
- add lots of missing calls to gimp_text_tool_set_layer() so the
tool will actually start editing.
- Add gimp_text_tool_halt() to shut down the tool and call it
from gimp_tool_control(HALT).
- call control(HALT) when escape is pressed to reset the tool
(can finally switch to other tools again now).
- fix button_press() to handle clicks on already existing
text layers well.
- also button_press(): fix the condition that sets the previously
existing text on the canvas editor so we don't end up with weird
ui states where displayed and internally used text differ.
- remove some redundant code.