Commit Graph

55 Commits

Author SHA1 Message Date
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
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
54c7725417 app: GimpTextTool: remove disabled testing code 2011-03-14 14:28:08 +01:00
22db39afd2 app: fix incomplete earlier s/GtkAnchorType/GimpHandleAnchor/ change 2010-10-18 20:13:09 +02:00
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
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
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
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
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
91cce1c81b app: add size control for text spans, does not work as expected yet 2010-03-28 21:38:31 +02:00
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
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
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
bbd2d521f1 app: rename "spacing" to "kerning" because that's what it does 2010-03-03 10:48:42 +01:00
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
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
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
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
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
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
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
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
783e04013a app: make letter spacing work when there is no selection 2010-02-28 17:56:20 +01:00
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
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
d88949547d app: make the change_spacing() call only act on the cursor position
if there is no selection, instead of on the rest of the buffer.
2010-02-28 13:58:08 +01:00
1e26bb1348 app: support baseline changing via Alt+Up and Alt+Down
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.
2010-02-27 18:00:39 +01:00
4171d9c774 app: add signals bindings to change baseline and spacing
Bind them to Alt+up/down/left/right and connect to the signals in
the text tool editor. The callbacks do nothing yet.
2010-02-27 13:14:28 +01:00
8af94be7a0 app: move the style overlay a few pixels
so it intersects less with the rectangle handles.
2010-02-26 19:56:53 +01:00
6c556698e5 app: add gimp_text_buffer_insert() and use it
Does nothing special yet, but will soon apply the currently active
tags to the inserted text.
2010-02-26 02:34:01 +01:00
ebfbc5a030 app: make sure the style editor moves with the text layer 2010-02-26 02:10:03 +01:00
9cff2365b1 app: enable editing text styles
- 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.
2010-02-26 01:36:31 +01:00
dbe54e3f05 app: rename GimpTextTool::text_buffer to just ::buffer 2010-02-25 17:49:33 +01:00
0b4bdc5613 app: add GimpTextBuffer, a GtkTextBuffer subclass
Pull all text buffer utility functions as methods and use
GimpTextBuffer all over the place instead of GtkTextBuffer.
Some actually usefuly features coming soon...
2010-02-25 17:41:10 +01:00
261bb2c598 app: configure the IM overlay's opacity explicitely 2010-02-24 01:37:15 +01:00
97db8b9b42 app: add function gimp_text_tool_editor_get_iter_index()
which returns the byte index at a GtkTextIter, and use it all over the
place.
2010-02-24 00:18:50 +01:00
f9bee0d42f app: fix XOR cursor drawing artifacts
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.
2010-02-23 23:22:03 +01:00
6224e3d5f7 app: pause/resume the draw tool at some more reasonable places 2010-02-23 10:27:35 +01:00
4295b1712c app: keep the "use-editor" setting consistent
When the editor is closed explicitely, set "use-editor" to FALSE
2010-02-21 18:59:51 +01:00
5150f3c8f6 app: when connecting the text object, also set its text on the buffer
and don't do it in editor_start(), which caused an undo to be pushed.
2010-02-21 02:00:57 +01:00
9a3dbbb6ef app: consistent IM callback names 2010-02-20 23:33:58 +01:00
b5b6d37742 app: move the entire mouse-selection apparatus to gimptexttool-editor.[ch] 2010-02-20 23:20:18 +01:00
6c3e385cac app: fix line navigation for lines that are not left-aligned
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.
2010-02-20 22:18:38 +01:00
c91b026384 app: re-add gimp_text_tool_editor_get_text()
Return the entire buffer and use it in even more places than before to
get rid code duplication.
2010-02-20 19:25:07 +01:00
ec0f3bdcb8 app: buncha more text tool fixes
- 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)
2010-02-20 16:18:41 +01:00
2e0f4e8938 app: make the preedit overlay better readable (text/base instead of fg/bg) 2010-02-20 15:37:54 +01:00
4704c18739 app: implement IM preedit using an overlay widget
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.
2010-02-20 15:15:53 +01:00
a8a732f753 app: fix IM context reset
- 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.
2010-02-19 20:13:25 +01:00
a8548fa7fd app: remove member text_tool->preedit_len
because it is always strlen(text_tool->preedit_string)
2010-02-19 20:13:24 +01:00
5feec1dd9f app: some signal handling/updating fixes that also make undo mostly work
- 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.
2010-02-19 20:13:21 +01:00