Commit Graph

80 Commits

Author SHA1 Message Date
Michael Natterer 4ebec35a77 app: port GimpTextTool to GimpToolRectangle 2017-06-28 15:40:38 +02:00
Michael Natterer 2e63533602 app: add GimpDockContainer::get_dialog_factory()
and use it where possible instead of gimp_dialog_factory_get_singleton().
Also reduce using this function in some other places.
2016-11-25 13:26:08 +01:00
Massimo Valentini aa293ae9a7 Bug 675748: Text tool: text editor inhibits text...
...selection on the canvas

if the editor dialog is active do not copy to the
clipboard the text selected, copy it instead when
selected with keys <Shift>-left/right.
2016-07-16 16:28:35 +02:00
Massimo Valentini b37ca78151 Bug 768086: Inconsistent text-layer focusing from text style editor
do not place cursor when it is already there
2016-06-28 18:15:52 +02:00
Jehan a1f0197098 app: do not commit IM preedit text after switching text layer.
Whereas some IME would just cancel any preediting on IM context reset,
others would commit their preedit (for instance Ibus-Hangul).
Unfortunately it is not necessarily immediate, even after
gtk_im_context_reset() and gtk_im_context_focus_out(), so when switching
text layer, any preedit text is committed on the new layer.
Let's recreate the IM context on abort to make sure we don't share any
input between text layers.
2016-06-06 15:03:20 +02:00
Jehan 97b537d496 app: remove preedit text on abort.
The IM should be the one taking care of it by sending the proper
signals, and I would assume this should be done when we run:
gtk_im_context_focus_out ().
But it doesn't and leaves a dangling styled preedit text on leaving
a text layer, either because the IME is not properly implemented (not
reacting to the context leaving the focused widget), or GTK+2 is bugged,
or maybe we just don't understand exactly how this all works. Anyway
let's explicitly clean preedit text, not waiting for preedit-end or
commit signals on IM abort.
2016-06-06 15:03:20 +02:00
Jehan bea4b5e4db app: the preedit_end mark must be created with right gravity.
With left gravity, the mark is moved back 1 character to the left of the
cursor, whereas with right gravity, it is right after newly-inserted
text. This resulted sometimes into non-deleted preedit characters.
I don't understand all the subtleties since the problem only occurred
for the first character of a text layer, at least in my tests.
Anyway now it should be good.
2016-06-05 23:20:06 +02:00
Jehan 7b9a7439dc Bug 767269 - Japanese IM undoes too much.
Japanese IME emits the preedit-commit before preedit-end (Hangul or
Unicode don't, but we could assume other IMEs may be doing the same).
As a consequence, the undo step was not pushed, thus breaking undo
history and consistency.
The solution is to simulate preediting end then restart when a commit
happens during preediting.
2016-06-05 21:54:29 +02:00
Jehan b5934625de Bug 751333 - Crash when moving cursor with ibus "Hangul" input method.
Commit cd147a4 reintroduced the crash. The culprit was the idle function
gimp_text_tool_apply_idle() which may not have been processed when
gimp_text_tool_move_cursor() is called, resulting in inconsistencies
between the text in the text tool's pango layout and its buffer.
Force any pending text commits to be applied before moving the cursor.
2016-06-05 21:04:18 +02:00
Michael Natterer cd147a4a48 app: fix various undo- and preedit-related text tool issues
In the text tool editor code, connect to GtkIMContext::preedit-start
and introduce a boolean text_tool->preedit_active which indicates that
a preedit is going on.

Remove the new preedit-removal code from gimp_text_tool_reset_im_context()
because it was not reflecting the IM's internal state and made things
worse. Instead, added gimp_text_tool_abort_im_context() which really
gets rid of any ongoing preedit by force.

In the main text tool code, check for preedit_active and if TRUE,
apply any edits directly widhout pushing undo steps. Factored out
gimp_text_tool_apply_list() for that purpose in order not do
duplicate a lot of code.

On undo and on button_press, force-abort any ongoing preedit. This is
the right thing to do on undo, but not really on button_press, but I
don't see another way to keep states consistent.
2016-06-05 16:36:56 +02:00
Michael Natterer fe12bc8ed1 app: factor out a bunch of code in gimptexttool-editor.c
The new gimp_text_tool_im_delete_preedit() also makes sure that
text_tool->preedit_string is non-NULL when modifying the buffer,
so it can be used as indication whether or not a preedit is
going on (in order to skip undo stuff while preediting).
2016-06-05 00:04:01 +02:00
Jehan cd641fa14f app: create separate tag lists for IME preedit colors.
In particular, I don't want the preedit foreground colors to be
displayed in the text style editor UI. They are only temporary hints
and should not be taken into account as user-chosen style.
2016-06-01 17:44:03 +02:00
Jehan a86b0cf0a2 app: create a different tag for underlined text during preedit.
It still shows up as underlined during preedit, but does not toggle the
underline button in the style editor.
2016-06-01 17:43:56 +02:00
Jehan 2cfed0cb52 app: IM preedit displayed as expected.
When gtk_im_context_get_preedit_string(), we have to inspect the
returned Pango attributes, so that the preedit string can be displayed
in the expected fashion (i.e. as in other programs).
Some input methods in particular would even break the preedit strings
in several chunks of text displayed differently (for instance Japanese),
depending on the cursor position within the preedit string.
2016-06-01 17:43:38 +02:00
Jehan f3d6dd356d app: indentation cleanup.
Replace tabs with spaces.
2016-04-16 19:08:13 +01:00
Jehan 0fcfd4f7b7 Bug 751333 - Crash when moving cursor with ibus "Hangul" input method...
... and improve input method UI. IM should not use some floating overlay
frame to display the preedit text. Instead it is now directly inserted
into the text tool box, as selected text. It permits redimensionning of
the text box while typing, and push the rest of the text when inserting
in the middle (instead of superimposing an overlay box over the current
text box, making everything unreadable).
Input methods still have a few more issues, but this fixes the main UI
weirdness as well as the crash with Hangul IM.
2016-04-16 14:24:54 +01:00
Michael Natterer e58bf5138f Bug 751333 - Crash when moving cursor with ibus "Hangul" input method
Had a closer look at GtkTextView again and implemented the IM
callbacks like there. I don't know if this fixes the bug, please test.
2015-06-22 22:54:16 +02:00
Michael Natterer 7ee69c3053 Bug 737583 - Fix static placement of Chinese IME window
Call gtk_im_context_set_cursor_location() whenever we draw the text
tool cursor or start a preedit sequence.
2014-10-03 00:04:24 +02:00
Michael Natterer 843866e7e7 app: make things behave more reasonable with multiple monitors
There is now a preference option that determines whether windows
should be opened on the same monitor as before. It should be disabled
when the machine gets monitors plugged/unplugged dynamically ("laptop")
and enabled when there is a static multi-monitor setup ("wokstation").
This is merely the current simplistic policy on top of the newly added
underlying infrastructure:

- pass integer monitor numbers around in all places where we already
  pass around a GdkScreen. Pass the "current" monitor to these changed
  APIs, where "current" is either the monitor where the action-triggering
  widget is, or if that is unavailable the monitor where the mouse is.

- add gimp_widget_get_monitor() in order to easily get to the monitor,
  just like gtk_widget_get_screen().

- add screen and monitor parameters in some places that were missed
  before.

- in sessionrc, save all window positions relative to the window's
  monitor, and save the monitor separately, if it's not the screen's
  primary monitor.

- when restoring window positions, use the stored monitor when the new
  prefs options says so (use the screen's primary monitor if there is
  no stored monitor), otherwise use current monitor that is now passed
  around.
2014-05-02 03:01:23 +02:00
Michael Natterer 76b05c2afc app: make Tab, Shift+Tab and Escape move the focus back to text editing
when it was in the floating text style editor. While this doesn't fix
anything by itself, it enables fixing text style setting to behave
reasonably when there is no selection.
2012-11-09 22:06:51 +01:00
Michael Natterer 2b3e5ebd78 Bug 686523 - Text tool: text editor not shown on empty text box
gimp_text_tool_options_notify(): always show the editor, also when no
text object exists yet. There was no reason for this limitation.
2012-10-21 23:30:34 +02:00
Michael Natterer 7d280abd9a Bug 676585 - Gimp crashes when writing in Arabic and clicking right arrow
Check for pango_layout_move_cursor_visually() returning a new index of
G_MAXINT, which indicates that we moved beyond the end of the layout,
and do nothing instead of trying to access the memory there.
2012-05-23 09:44:51 +02:00
Massimo Valentini b994280473 Bug 668814: Cannot move cursor right in on canvas editor
One possible way to decrease the incompatibilities
between letter spacing in a tagged gtk_text_buffer
and in an equivalent pango_layout

Remove also a valgrind reported invalid write in
gimptextbuffer.c
2012-02-09 12:36:43 +01:00
Michael Natterer 06d5b9e9df app: fix indentation in gimptextool-editor.c 2011-12-04 19:37:35 +01:00
Michael Natterer 7c60bb5181 app: use more of the new GDK_KEY_foo key names
and move the compat defines from display-enums.h to widgets-enums.h
2011-03-29 17:24:08 +02:00
Michael Natterer ecbfb4a9e8 app: add a GimpText property and construct param to GimpTextStyleEditor
which will be used to get default values from.
2011-03-18 21:16:53 +01:00
Michael Natterer df731912a5 app: add a GimpTextStyleEditor to the text tool's editor dialog
so it's an alternative to on-screen editing for esoteric use cases
that can do everything on-screen editing is capable of.
2011-03-18 12:58:32 +01:00
Michael Natterer 54c7725417 app: GimpTextTool: remove disabled testing code 2011-03-14 14:28:08 +01:00
Michael Natterer 22db39afd2 app: fix incomplete earlier s/GtkAnchorType/GimpHandleAnchor/ change 2010-10-18 20:13:09 +02:00
Michael Natterer 8e0dd56feb app: fix crashes by not trying to navigate on a NULL layout
Add boolean return value to gimp_text_tool_ensure_layout() and check
it where needed. Also fix the new VISUAL_POSITIONS navigation code yet
again.
2010-10-14 11:01:16 +02:00
Michael Natterer 852196eb3d app: fix insert and overwrite cursors for RTL text
by using the right function to figure the location of both kinds of
cursors. Also fix crash in my last cursor movement commit: check for
error values returned by pango_layout_move_cursor_visually() and don't
try to move the cursor beyond the buffer boundaries.
2010-10-14 02:45:32 +02:00
Michael Natterer 0c7ec05035 app: honor text direction when moving the cursor
Use pango_layout_move_cursor_visually() instead of e.g. simply using
gtk_text_iter_forward_cursor_position() when "right" was pressed.
This is much more correct now but still not 100% right.
2010-10-14 01:01:33 +02:00
Michael Natterer 170f0bed00 app: use a GimpOverlayFrame for the text style editor
so it gets round corners and doesn't look so old school.
2010-06-12 23:49:55 +02:00
Michael Natterer a3b93151aa app: some #if 0'ed testing code I occasionally need for debugging
(so I don't have to constantly add/remove it, will get rid of it
before 2.8)
2010-06-03 22:16:08 +02:00
Michael Natterer 91cce1c81b app: add size control for text spans, does not work as expected yet 2010-03-28 21:38:31 +02:00
Michael Natterer 3e3613bef7 app: allow for more fine-grained baseline and kerning adjustments
In theory for now, by changing the parameters of
GimpTextProxy::change_baseline() and ::change_kerning()
from gint to gdouble.
2010-03-08 21:57:29 +01:00
Michael Natterer 2934095816 app: use gimp_text_layout_get_offsets()
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().
2010-03-07 00:11:05 +01:00
Michael Natterer 5284c9c836 app: fix text tool drawing for good this time (hopefully)
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.
2010-03-04 23:47:23 +01:00
Michael Natterer bbd2d521f1 app: rename "spacing" to "kerning" because that's what it does 2010-03-03 10:48:42 +01:00
Michael Natterer 78ea82df1f app: simplify mouse selection by using iters instead of indices
This also removes the evil code dupication added yesterday, and is
generally less and cleaner code.
2010-03-02 12:23:29 +01:00
Michael Natterer aeac58089b app: add a font selector to the text style editor
Selects fonts just fine, but has no effect on the text yet.
2010-03-02 00:12:27 +01:00
Michael Natterer 8a1a19fc32 app: argh forgot one more place
Time for a refactoring that pulls the forgotten code into one common
place.
2010-03-01 21:39:26 +01:00
Michael Natterer 3d1f677b4f app: fix cursor placement and selecting by mouse when there is manual kerning
Forgot to convert the layout coords to buffer offsets functions when
porting everything to the new iter/index conversion functions in
GimpTextBuffer.
2010-03-01 21:19:08 +01:00
Michael Natterer f8ac0c61ab app: make manual kerning / character spacing work
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.
2010-03-01 16:27:34 +01:00
Michael Natterer ff50b52c72 app: use gtk_text_buffer_delete_interactive()
instead of just gtk_text_buffer_delete() so "end-user-action" is
emitted and everything is updated.
2010-03-01 16:03:48 +01:00
Martin Nordholts 11b1300b6f app: Introduce gimp_dialog_factory_get_singleton()
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.
2010-02-28 23:23:24 +01:00
Martin Nordholts 947e28596f app: Remove gimp_dialog_factory_from_name()
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.
2010-02-28 20:02:45 +01:00
Michael Natterer 783e04013a app: make letter spacing work when there is no selection 2010-02-28 17:56:20 +01:00
Michael Natterer 84d33e4316 app: make image-coords overlay widgets work fine at any zoom factor
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.
2010-02-28 14:48:47 +01:00
Michael Natterer 1c8b01f012 app: make the text style editor aware of the image's resolution
Needed for adding proper text size controls.
2010-02-28 14:20:56 +01:00