diff --git a/AUTHORS.txt b/AUTHORS.txt
index 000f7bd1c..4f005addd 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -9,8 +9,8 @@ AUTHOR
THANKFULNESS
===================================
- Some people don't contribute to this project in a directly way but
- their work are indispensable:
+ Some people didn't contribute to the project in a direct way,
+ but their work was indispensable to make it real:
------------------------------------------------------------------
Álvaro González: For the other routine to generate optimised
@@ -56,7 +56,8 @@ THANKFULNESS
Jerry Coffin and HenkJan Wolthuis: For the hash table routines.
- Johan Halmén and Anders "Trezker" Andersson for mapgen.
+ Johan Halmén and Anders "Trezker" Andersson for mapgen (included in
+ old ASE versions).
@@ -98,8 +99,8 @@ THANKFULNESS
Salvador Eduardo Tropea: For the SETEdit editor (although I don't
- use it anymore, but the first months in Linux without it would be
- impossible :-)
+ use it anymore, the first months in Linux without it would have been
+ impossibles)
Shawn Hargreaves: And hundreds of people who helped in the Allegro
diff --git a/ChangeLog b/ChangeLog
index 4f15a7bf6..0d57d068a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,62 @@
+2008-02-29 David A. Capello
+
+ * src/widgets/fileview.c: Added incremental search.
+
+ * src/core/file_system.c (fileitem_insert_child_sorted):
+ Fixed. Now the file-system has a readed-version, so we can updated
+ outdated file-items with the new children list.
+
+2008-02-28 David A. Capello
+
+ * src/jinete/jbox.c, src/jinete/jpanel.c: Fixed some bugs when
+ access to widget-visibility properties (when layout widgets, we
+ have to check the JI_HIDDEN flag directly instead of calling
+ jwidget_is_visible/hidden routines).
+
+2008-02-27 David A. Capello
+
+ * src/commands/cmd_duplicate_layer.c (duplicate_layer): Fixed a
+ problem where the images weren't duplicated (this bug was
+ introduced when the stock changed from the Layers to the Sprite).
+
+2008-02-22 David A. Capello
+
+ * src/jinete/jwidget.c (jwidget_get_drawable_region): Fixed a bug:
+ when clipping the drawable-region with the children regions, it
+ was considering hidden children too.
+
+2008-02-21 David A. Capello
+
+ * src/*: Refactoring color_bar->colorbar, status_bar->statusbar,
+ tool_bar->toolbar, menu_bar->menubar, tabs_bar->tabsbar.
+
+ * src/modules/tools.c (apply_grid): Added 'flexible' parameter.
+
+ * src/commands/cmd_grid.c: Added show_grid and snap_to_grid
+ commands.
+
+ * src/jinete/jwidget.c (jwidget_set_text_soft): Added.
+
+2008-02-20 David A. Capello
+
+ * data/jids/mapgen.jid, src/commands/cmd_mapgen.c,
+ src/util/mapgen.c, src/dialogs/dmapgen.c: Removed.
+
+ * src/jinete/jwidget.c (widget_msg_proc): Do more work to handle
+ redirection of each message.
+
+ * src/jinete/jmanager.c: Simplified the destination list for every
+ message.
+
+ * src/jinete/jmessage.h (struct jmessage_key): Added fields:
+ repeat, propagate_to_children, propagate_to_parent.
+
+ * src/jinete/jbase.h: Added JM_SETCURSOR. Removed JM_CHAR.
+
+2008-02-18 David A. Capello
+
+ * src/core/file_system.c (get_key_for_pidl): Fixed.
+
2008-02-12 David A. Capello
* src/raster/dirty.c: Optimized.
diff --git a/FAQ.txt b/FAQ.txt
deleted file mode 100644
index 6b9794b0c..000000000
--- a/FAQ.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-========================================
-Frequently Asked Questions
-========================================
-
-1. ¿How I can add new convolutions matrices?
-2. ¿How I can change the screen layout?
-3. ¿How I can load my palette in ASE that are in a 768 bytes file?
-4. ¿How I can add a new frame?
-
-
-1. ¿How I can add new convolutions matrices?
-----------------------------------------------------------------------
-
- Add a "convmatr.usr" file in the configuration directory
- ("ase/data" for Windows or "~/.ase" for Unix) with the same format
- of "convmatr.def" (you'll find it in the data directory too). When
- ASE start it loads all "convmatr.usr", "convmatr.gen", and
- "convmatr.def" files ("user", "generated", and "default" matrices
- respectively).
-
-
-2. ¿How I can change the screen layout?
-----------------------------------------------------------------------
-
- If you want to try other screen layout (other organization for the
- controls (widgets) in the main window), you can modify the
- "data/jids/main.jid" file. I recommend you make a backup copy so
- you can back to the original layout. Also, there are some
- alternative layouts already, to try them, you should modify:
-
-
-
- By:
-
-
-
- And then (for example) modify some name="main_window_alt1" to
- name="main_window".
-
-
-3. ¿How I can load my palette in ASE that are in a 768 bytes file?
-----------------------------------------------------------------------
-
- If you palette is in a raw binary file of 768 bytes, the entries
- are in order RGB and the range of each entry is 0-63, you can
- rename it with the .col extension, and load like an original .col
- Animator file.
-
-
-4. ¿How I can add a new frame?
-----------------------------------------------------------------------
-
- Press (or "Frame/New" menu).
-
-
-----------------------------------------------------------------------
- Copyright (C) 2003-2005 by David A. Capello
diff --git a/LEGAL.txt b/LEGAL.txt
index 1b35214ea..28b51fe0a 100644
--- a/LEGAL.txt
+++ b/LEGAL.txt
@@ -3,8 +3,8 @@ LEGAL ISSUES
===================================
- ASE is distributed under GPL license.
-- Allegro is giftware license (similar to MIT license).
- Jinete is under BSD license.
+- Allegro is giftware license (similar to MIT license).
- ALFONT is under LGPL terms.
- quantize.c is copyright by Ben Davis (you need his authorization to
use his code in your own program).
diff --git a/NEWS-es.txt b/NEWS-es.txt
deleted file mode 100644
index b4abc909c..000000000
--- a/NEWS-es.txt
+++ /dev/null
@@ -1,255 +0,0 @@
-===================================
-NOTICIAS
-===================================
-
-0.5
----
-
-- Se agregaron funcionalidades solicitadas por Carl Olsson:
- + mejor soporte cuando "Ajustar a Grilla" está activado para
- las herramientas de dibujo que se controlan con cajas (como
- rectángulo, elipse, etc).
- + al manejar una selección flotante (al pegar el portapapeles)
- la opción "Ajustar a Grilla" tiene efecto sobre el movimiento
- de la imagen.
- + agregado movimiento a nivel de subpixel para los cursores con
- demasiado zoom en el editor, para saber dónde estamos dentro
- del pixel.
-- Soporte para grabar archivos GIF por defecto.
-- Arreglada la compilación con Allegro 4.2.1 (y arreglado un bug en
- Allegro con key_shifts).
-- Ahora el estado ventana/pantalla-completa es guardado por
- la aplicación (gracias a Manuel De Miguel Moreno por reportarlo).
-
-0.4
----
-
-- Modo consola ya no existe.
-- Cambiado el atajo de teclado para el Editor de Película: tecla TAB.
-- Nueva característica: Cada cuadro de animación tiene duración.
-- Nuevo Editor de Paleta (tecla F4).
-- Ahora los sprites soportan multiples paletas: Cada cuadro puede
- tener su propia palette de colores.
-- Agregado soporte para cargar archivos GIF (por Elias Pschernig).
-- Agregado una combo-box al cuadro de selección de archivos para
- manejar bookmarks ("Favoritos").
-- Hay rotación!!! Ahora puede rotar y escalar al pegar desde el
- clipboard (portapapeles).
-
-0.3.1
------
-
-- Arreglada la creación de archivos de sesión cuando una excepción
- (error fatal) ocurre bajo Windows.
-- Agregados los ficheros es.po y tips.es.
-
-0.3
----
-
-- Agregado la administración de sesiones (si ocurre algún fallo la
- sesión es guardada automáticamente).
-- Se agregó una herramienta para dibujar texto (finalmente).
-- Más documentación y tips.
-- Mejorado el proceso para agregar cuadros de animación.a
-- Se arreglaron algunos bugs importantes.
-- Se agregó la utilidad mapgen (código original por Johan Halmén y
- Anders Andersson).
-- Soporte para el lenguage Español (ahora funciona en Windows también).
-- Código interno mejorado (principalmente las partes de la GUI, y los
- nombres de las funciones).
-
-0.2.4
------
-
-- Undo más estable: con límites y sin el extraño comportamiento del
- rehacer-después-de-sobreescribir-el-deshacer.
-- Nueveo filtro por mediana para reducir el ruido de las imágenes.
-- Actualizado el soporte alternativo para leer y escribir archivos
- JPEG mediante la librería JPGalleg 2.3, gracias a Angelo Mottola por esto.
-- Se arreglaron algunos problemas con el teclado: la tecla Alt ya no puede
- ser utilizada para atajos del teclado. Alguna combinaciones cambiaron:
- + <~> a <`> (abre el editor de película)
- + a > (enmascara por color)
- + a (cierra el editor actualx)
-- Agregado Cortar, Copiar, Pegar!
-- Agregado AutoCrop (antes conocido como Trim).
-
-0.2.3
------
-
-- Se arregló la rutina para grabar archivos JPG.
-- Arregladas y mejoradas varias partes de la GUI.
-
-0.2.2
------
-
-- Se agregó algo de documentación para escribir scripts en Lua.
-- El Editor de Película (The Film Editor) fue mejorado.
-- Arreglados algunos errores con el cursor gráfico, algunons problemas
- con el teclado y varios bugs menores.
-- Nuevos tips con texto e imágenes. Esto será muy útil para los
- principiantes.
-- La función del papel cebolla (onionskin) está lista.
-- Agregado (de modo opcional) el fusionado de colores ordenado para
- dibujar imágenes RGB en 8 bpp.
-- Nuevas acciones: Merge Down, New Frame, Copy Frame, cambiar Image
- Type!, Load Script File.
-- Optimizado la velocidad de dibujado en modo alicatado (tiled).
-
-0.2.1
------
-
-- Arreglada la versión de Windows: el spray y algunos errores
- guardando nombres de ficheros en el archivo de configuración.
-- Agregado soporte libintl y la traducción al Español del programa
- (sólo para Linux, pero tengo planes de hacer esto andar en Windows).
-- Más soporte undo: insertar/remover capas y modificaciones en la
- máscara.
-- Los filtros Matriz de Convolución y Curva de Color están de vuelta.
-- Se agregaron más operaciones básicas (con soporte de undo): aplanar
- capas, duplicar capa, duplicar sprite, flip horizontal/vertical,
- recortar cuadro.
-- Nuevo formato .ASE (en estado alpha, por favor pruébelo!).
-- Rutinas para script más simples: ahora hay una capa de rutinas de
- alto nivel (fáciles de usar y comprender), y un juego de rutinas de
- bajo nivel (para scripts internos o trabajos más específicos).
-- Se removió todo el código relacionado con interpolación entre
- key-frames (cuadros claves): sí, luego de estar pensando un largo
- rato, esto hace muy complicada la edición de la animación (así la
- "elegante interpolación spline" fue eliminada).
-- El editor de sprites fue optimizado para ser más rápido al mover el
- scroll.
-- El Editor de Película (The Film Editor) está casi listo para
- controlar capas y cuadros.
-- Arreglados los filtros usando máscaras con capas desplazadas.
-- Soporte para aplicar filtros a varias cuadros/capas al mismo tiempo.
-- Diferentes disposiciones de la pantalla fueron agregadas en main.jid
- (mire FAQ.txt para saber como cambiar entre ellas).
-- La barra de herramientas está devuelta!
-
-0.2
----
-
-- Arreglados varios bugs.
-- Soporte opcional para archivos JPEG con la librería JPGalleg 2.0.
-- Agregados modos de dibujado: Opaque (opaco/normal), Glass
- (vidrio/transparente), Semi (patrón).
-- Agregados los tipos de brochas: Circle (círculo), Square (cuadrado),
- Line (línea).
-- Implementado un sistema de "paleta-falsa" para hacer al GUI
- utilizable con cualquier paleta de colores (principalmente para
- evitar las situaciones de "pantalla negra" al abrir sprites con
- paletas "feas").
-- El editor de la paleta de colores tiene mejoras (como la posibilidad
- de mover los colores seleccionados).
-- El archivo "menus" cambió un poco. Algunos atajos del teclado se
- modificaron (y otro nuevos se agregaron), puede verlos en el archivo
- "docs/QuickHelp.html". De todos modos, intenté dejar la
- compatibilidad con los comandos más usados.
-- Soporte completo de scripts con Lua-5.0. Los sprites y el GUI son
- controlables desde los mismos scripts, para darle una idea, varias
- acciones en los menús están programadas directamente con scripts.
-- Control de selección completo (regiones de máscara). Puede
- seleccionar areas irregulares (agregar, substraer, cruzar, y
- seleccionar por color), guardar y cargarlas en el viejo formato .MSK
- del Animator Pro.
-- Soporte para editores multiples. Ahora puede editar una imágen con
- zoom y ver los resultados en otros editores (actualizados en tiempo
- real). - Nuevo núcleo de para controlar gráficos. Todo lo
- relacionado a sprite/imágenes/capas/propiedades/key fue
- reprogramado. El cambio más importante, se hizo al nivel de
- propiedad/keyframes (cada propiedad puede tener interpolación lineal
- o con curvas beziers, además de una bandera de finalización de la
- curva para hacer movimientos circulares o patrones de movimientos).
- - Nuevo GUI. Tanto los gráficos como el código interno fueron
- reestructurados completamente, hice una nueva librería de GUI:
- Jinete.
-
-0.1.2
------
-
-- Nuevo efecto RLE Gaussian Blur (desde el código de The GIMP).
-- Los modos de mezcla (blender modes) están devuelta: Normal,
- Multiply, Screen, Overlay, Hard Light, Darken, Lighten, Addition,
- Subtract, Difference, Hue, Saturation, Color, Luminosity.
-- Mejor GUI: con colores, ahora debería de ser menos aburrido :-)
-- Agregado un diálogo para seleccionar *cualquier* modo de video
- gráfico (esto podría ser útil para modos de video con ventanas).
-- Nuevamente se volvió a los makefiles al estilo Allegro. Bueno,
- bueno, el estilo GNU fue el peor cambio en ASE, pero ahora está
- arreglado :-)
-- Eliminada la capacidad de cargar archivos .DLL o .so de
- plug-ins. Luego de semanas pensándolo, decidí por sacar esta
- característica ya que es muy complicado de hacer un buen sistema
- para agregar nuevos plug-ins con la implementación del menú
- actual. La mayoría de usuarios son solo "usuarios" y no copiarán el
- plug-in y modificarán luego el archivo "menus" para agregar el
- script que llame a la acción del plug-in. Además, esto me salva de
- miles de dolores de cabezas :-)
-- Agregada la aplicación de filtros multiples: Ahora, se puede aplicar
- los efectos a cada capa, a cada cuadro de animación, o ambos.
-- Agregado la lista de archivos usados recientemente ("Recent Files").
-- Nuevas rutinas en los scripts para manejar "paths" (rutas).
-- Nuevo tipo de selección: "shrink", para encoger la selección a los
- límites de la capa bitmap actual.
-- Nueva acción "trim_sprite".
-
-0.1.0
------
-
-- Eliminada la herramienta `move' para mover capas (era redundante).
-- Nueva interface para cargar Plug-Ins en forma dinámica (DLL, .so).
-- Nuevo soporte completo para cargar/guardar archivos JPEG (RGB/grayscale):
- a través de la Independent JPEG Group's JPEG Library.
-- Nuevas acciones:
- + trim_layer_bitmap: recorta la capa actual por los límites de la selección.
- + merge_down: para mezclar la capa activa con la próxima.
- + make_undo_animation: para crear una animación desde la operaciones
- para deshacer (para ver la progresión del gráfico).
- + undo_history: para deshacer/rehacer varias operaciones a la vez.
- + color_curve: para hacer efectos de conversión de color pixel por pixel.
-- Mejorado el comando `Reemplazar Color' (con `tolerancia' y `vista previa').
-- Una nueva barra-de-capas optimizada, para manejar sobre todo
- las propiedades y los cuadros claves.
-- Varias cosas reescritas a Plug-Ins:
- + los formatos de archivos,
- + las acciones de los menús (también, ahora estas acciones pueden ser
- utilizadas desde los "guiones" o "scripts").
-- Reemplazado el viejo sistema de "profundidad de color" por el nuevo
- "tipo de imagen". Desde ahora, una imagen puede ser:
- RGB (rojo, verde, azul), Grayscale (escala de grises), o Indexed
- (256 colores).
-- Nueva Libreria ASE, con un nuevo diseño para manejar:
- imágenes, capas, bitmaps, propiedades, cuadros claves, etc.
-- Código fuente al estilo GNU: con configure.in, Makefile.am, etc.
-
-0.0.7
------
-
-- Nuevas rutinas para "guionado" (script): request(), apply_filter(),
- load_sprite(), y save_sprite().
-- Soporte para cargar archivos FLI/FLC y guardar FLC. Sí! Ahora con ASE
- puede hacer animaciones FLC con un buen rendimiento de compresión.
-- Agregada la posibilidad de cargar/guardar secuencias de bitmaps:
- como por ejemplo ani00.pcx, ani01.pcx, ani02.pcx, etc.
-- Más funcionalidad para `deshacer'. Reescribí todo el sistem de `undo'
- por completo.
-- Nueva herramienta de selección rectangular. Ahora puede cortar, copiar,
- pegar, y borrar.
-- Nueva compresión RLE para 8 bpp en los archivos .ase.
-- Soporte para cargar ficheros .ase de las versiones `0.0.6' y
- `0.0.7 CVS (fases importante)': Le recomiendo que actualice todos sus
- archivos .ase a la nueva versión `0.0.7' release.
-- Nuevas propiedades para los cuadros claves (keyframes): ahora cada keyframe
- tiene su propia posición y valor alpha, con esto puede hacer animaciones de
- objetos moviendo sólo los keyframes (todos los cuadros intermedios serán
- calculados automáticamente).
-- Ahora el programa recuerda la configuración (a través de `ase.cfg').
-- Agregado un nuevo modo para dibujar "mosaicado" (tiled).
-- Nuevo modo de edición en pantalla completa. Con la barra de capas
- (layer-bar) a la que se le puede cambiar el tamaño.
-- Agregada la opción para dibujar un cuadro previo en modo transparente.
-- Eliminada la propiedad de `fondo' de las capas: desde ahora, una capa
- será transparente siempre. Con esto son arreglados una tonelada de problemas
- con las rutinas para cargar/guardar archivos de las versiones anteriores.
-- Nuevo comando `reload_menus' (para recargar los menús).
diff --git a/NEWS.txt b/NEWS.txt
index 9186de61d..57b4d3f3d 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -6,21 +6,25 @@ NEWS
---
+ Added support to load and save PNG files (through 'libpng').
++ Rewritten the color-selector dialog.
+ Replaced the "List" menu with the tabs selector.
-+ Better file selector with thumbnails.
- + In Windows: now you can navigate through Desktop, My Documents,
- My Computer, etc.
++ Rewritten the File Selector:
+ + Preview support.
+ + Incremental search.
+ + History of navigation (Back/Forward).
+ + In Windows: you can visit Desktop, My Documents and My Computer
+ locations.
+ Optimized the loading/saving operations (using threads).
+ Restructured all the menus (more user friendly options).
-+ New XML format for the menus.
+ Enhanced GUI:
+ more borders for windows and more spacing between widgets.
+ better mouse behavior (now in Windows the mouse is captured).
+ Finally screen scaling supported (with double-buffering). This means
that you can use a screen of 320x240 between a window of 640x480
- (screen-scaling x2). This is the new default video mode for ASE.
+ (screen-scaling x2).
+ Fixed other minor problems when you drawn in 'tiled mode' or 'paste'
the clipboard.
++ New XML format for the menus and keyboard shortcuts.
- Removed a lot of complex functionality:
- Removed mask-repositories (you can use .msk files instead).
- Removed menu scripting customization.
@@ -29,6 +33,7 @@ NEWS
- Removed draw-text (it'll return in next versions).
- Removed layer-sets (the Film-Editor can't handle them right at the
moment)
+ - Removed mapgen.
- Removed linked-cels (were complex for the end-user).
- Also the scripting support is broken, next versions of ASE will
contain a better set of routines to create scripts.
diff --git a/README-es.txt b/README-es.txt
deleted file mode 100644
index cffb5a78d..000000000
--- a/README-es.txt
+++ /dev/null
@@ -1,167 +0,0 @@
-
- ASE - Allegro Sprite Editor
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 por David A. Capello
- ---------------------------------------------------------------------
- Mire el fichero "AUTHORS.txt" para la lista completa de colaboradores
-
-
-===================================
-COPYRIGHT
-===================================
-
- Este programa es software libre. Puede redistribuirlo y/o modificarlo bajo
- los términos de la Licencia Pública General GNU según es publicada por la
- Free Software Foundation, bien de la versión 2 de dicha Licencia o bien
- (según su elección) de cualquier versión posterior.
-
- Este programa es distribuido con la esperanza de que sea útil, pero SIN
- GARANTIA ALGUNA, incluso sin la garantía implícita de COMERCIALIZACIÓN o
- IDONEIDAD PARA UN PROPÓSITO PARTICULAR. Véase la Licencia Pública General
- de GNU para más detalles.
-
- Debería haber recibido una copia de la Licencia Pública General junto con
- este programa. Si no ha sido así, escriba a la Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-===================================
-INTRODUCCIÓN
-===================================
-
- ASE es un programa especialmente diseñado para crear sprites
- animados con mucha facilidad y que luego puedan ser utilizados en un
- video juego. Este programa le permitirá crear desde imágenes
- estáticas, a personajes con movimiento, texturas, patrones, fondos,
- logos, paletas de colores, y cualquier otra cosa que se le ocurra.
-
-
-===================================
-CARACTERÍSTICAS
-===================================
-
- ASE le ofrece la posibilidad de:
-
- - Editar sprites con capas y cuadros de animación.
-
- - Editar imágenes RGB (con Alpha), escala de grises (también con
- Alpha), e imágenes con paleta de 256 colores o "indexadas".
-
- - Controlar paletas de 256 colores completamente.
-
- - Aplicar filtros para diferentes efectos (matriz de convolución,
- curva de color, etc.).
-
- - Cargar y guardar sprites en los formatos .BMP, .PCX, .TGA, .JPG,
- .GIF, .FLC, .FLI, .ASE (el formato especial de ASE).
-
- - Utilizar secuencia de bitmaps (ani00.pcx, ani01.pcx, etc.) para
- guardar las animaciones.
-
- - Herramientas de dibujo (puntos, pincel, brocha real, relleno, línea,
- rectángulo, elipse), modos de dibujo (opaco, vidrio), y tipos de
- brochas (círculo, cuadrado, línea).
-
- - Soporte de máscaras (selecciones).
-
- - Soporte para deshacer/rehacer cada operación.
-
- - Soporte para editores multiples.
-
- - Dibujar con una rejilla personalizable.
-
- - Único modo de dibujo alicatado para dibujar patrones y texturas en
- segundos.
-
- - Guardar y cargar sesiones completas de trabajo (en ficheros `.ses').
-
- - Capacidad de hacer `scripts' (guiones) con el lenguaje Lua
- (http://www.lua.org).
-
-
-===================================
-CONFIGURACIÓN
-===================================
-
- En plataformas Windows y DOS:
-
- ase.cfg - Configuración
- data/matrices - Matrices de convolución
- data/menus - Menús
- data/scripts/* - Scripts o "guiones"
-
- En plataformas Unix, el archivo de configuratión es ~/.aserc, y los
- archivos de datos (en data/) son buscados en estos lugares (por
- orden de preferencia):
-
- $HOME/.ase/
- /usr/local/share/ase/
- data/
-
- Mire "src/core/dirs.c" para más información.
-
-
-===================================
-MODO VERBOSO
-===================================
-
- Cuando ejecuta "ase" con el parámetro "-v", en las plataformas
- Windows y DOS los errores son escritos en STDERR y un archivo
- "logXXXX.txt" en el directorio "ase/" es creado con el mismo
- contenido.
-
- En otras plataformas (como Unix), ese archivo de registro no es
- creado, ya que la utilización de STDERR es mucho más común.
-
- Mire "src/core/core.c" para más información.
-
-
-===================================
-ACTUALIZACIONES
-===================================
-
- Los últimos paquetes tanto binarios como el de código fuente, los
- puede encontrar desde:
-
- http://sourceforge.net/project/showfiles.php?group_id=20848
-
- También, si desea obtener la última versión en desarrollo de ASE desde el
- repositorio SVN, la cual por sierto es la más propensa a tener errores pero
- es la que más actualizada está con respecto a las herramientas, la puede
- explorar archivo por archivo en esta dirección:
-
- http://ase.svn.sourceforge.net/viewvc/ase/
-
- O la puede bajar completamente a su disco con un programa que controle SVN,
- de la siguiente forma:
-
- svn checkout svn co https://ase.svn.sourceforge.net/svnroot/ase/trunk ase
-
- AVISO: Cuando obtenga la versión SVN, no borre los directorios .svn
- ni el contenido dentro de ellos, ya que es para uso interno del
- programa svn.
-
-
-===================================
-CRÉDITOS
-===================================
-
- Mire el archivo "AUTHORS.txt".
-
-
-===================================
-INFORMACIÓN DE CONTACTO
-===================================
-
- Para pedir ayuda, reportar bugs, mandar parches, etc., utilice la
- lista de correo ase-help:
-
- ase-help@lists.sourceforge.net
- http://lists.sourceforge.net/lists/listinfo/ase-help/
-
- Para más información visite la página oficial del proyecto:
-
- http://ase.sourceforge.net
-
-
- ----------------------------------------------------------------------------
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 por David A. Capello
diff --git a/README.txt b/README.txt
index 82d6c199d..75efda3e6 100644
--- a/README.txt
+++ b/README.txt
@@ -1,12 +1,25 @@
ASE - Allegro Sprite Editor
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 by David A. Capello
+ Copyright (C) 2001-2008 by David A. Capello
--------------------------------------------------------------------
See the "AUTHORS.txt" file for a complete list of contributors
+===================================
+INTRODUCTION
+===================================
+
+ ASE is a program specially designed with facilities to create
+ animated sprites that can be used in computer games. You can
+ create static images, characters with movement, textures,
+ patterns, backgrounds, logos, color palettes, tiles, etc.
+
+ What makes ASE different? It focuses on pixel editing, to do
+ pixel-art. Indeed, it isn't a photo retouching tool or a vector
+ graphics editor. Mainly it is a tool to create tiny animations
+ pixel-by-pixel.
===================================
-COPYRIGHT
+LICENSE
===================================
This program is free software; you can redistribute it and/or modify it
@@ -23,138 +36,63 @@ COPYRIGHT
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-===================================
-INTRODUCTION
-===================================
-
- ASE is a program specially designed with facilities to create
- animated sprites that can be used in some video game. This program
- let you create from static images, to characters with movement,
- textures, patterns, backgrounds, logos, color palettes, and any
- other thing that you think.
-
-
===================================
FEATURES
===================================
- ASE gives to you the possibility to:
-
- - Edit sprites with layers and animation frames.
-
- - Edit RGB (with Alpha), Grayscale (with Alpha also) and Indexed
- images.
-
- - Control 256 color palettes completely.
-
- - Apply filters for different color effects (convolution matrix,
- color curve, etc.).
-
- - Load and save sprites in these formats: .BMP, .PCX, .TGA, .JPG,
- .GIF, .FLC, .FLI, and .ASE (ASE's special format).
-
- - Use bitmap's sequences (ani00.pcx, ani01.pcx, etc.) to save
- animations.
-
- - Drawing tools (dots, pencil, real-brush, floodfill, line, rectangle,
- ellipse), drawing modes (opaque, glass), and brushes types (circle,
- square, line).
-
- - Mask (selections) support.
-
- - Undo/Redo support for every operation.
-
- - Multiple editor support.
-
- - Draw with a customizable grid.
-
- - Unique tiled drawing mode to draw patterns and textures in seconds.
-
- - Scripting capabilities with Lua language (http://www.lua.org).
-
+ With ASE you'll be able to:
+ * Edit sprites with layers and frames.
+ * Edit RGB (with Alpha), Grayscale and Indexed images (256 color palettes).
+ * Load/save sprites in these formats: .GIF, .FLC, .FLI, .PNG,
+ .BMP, .PCX, .TGA, .JPG, and .ASE (ASE's special format).
+ * Load/save animations in sequence of bitmaps (frm00.pcx, frm01.pcx, ...).
+ * Tiled drawing mode to draw patterns and textures.
+ * Undo/Redo support for every operation.
+ * Multiple editor support.
+ * Show-grid/Snap-to-Grid
===================================
CONFIGURATION FILES
===================================
- In Windows and DOS platforms:
+ In Windows 98/2K/XP/Vista:
- ase.cfg - Configuration
- data/matrices - Convolutions matrices
- data/menus - Menus
- data/scripts/* - Scripts
+ ase-VERSION.cfg - Program configuration
+ data/convmatr.def - Convolutions matrices
+ data/gui-en.xml - Menu definition and keyboard shortcuts
+ examples/* - Examples of some sprites made with ASE
- In Unix platforms, the configuration file is ~/.aserc, and the data/
- files are searched in these locations (in order of preference):
+ In GNU/Linux, the configuration file is ~/.aserc-VERSION, and
+ the data/ files are searched in these locations (in priority
+ order):
$HOME/.ase/
/usr/local/share/ase/
data/
- See "src/core/dirs.c" for more information.
-
-
-===================================
-VERBOSE MODE
-===================================
-
- When run "ase" with "-v" parameter, in Windows and DOS platforms the
- errors will be written in STDERR and a "logXXXX.txt" file in "ase/"
- directory is created with the same content.
-
- In others platforms (like Unix), that log file isn't created,
- because the use of STDERR is more common.
-
- See "src/core/core.c" for more information.
-
-
-===================================
-UPDATES
-===================================
-
- The last packages of binaries and source code, you can found them
- from:
-
- http://sourceforge.net/project/showfiles.php?group_id=20848
-
- Also, if you want to get the last development version of ASE from
- the SVN repository, which is the version more prone to have errors,
- but is the more updated in the tools area, you can browse it file by
- file in this address:
-
- http://ase.svn.sourceforge.net/viewvc/ase/
-
- Or you can download it completelly to your disk with a program which
- control SVN, as follow-up:
-
- svn checkout svn co https://ase.svn.sourceforge.net/svnroot/ase/trunk ase
-
- WARNING: When you obtain the SVN version, don't remove the .svn
- directories, they are for exclusive use of the svn program.
-
-
-===================================
-CREDITS
-===================================
-
- See the "AUTHORS.txt" file.
-
-
===================================
CONTACT INFO
===================================
- To request help, report bugs, send patches, etc., you can use the
- ase-help mailing list:
+ To request help you can use the Allegro Sprite Editor group or
+ the SourceForge forums:
+ http://groups.google.com/group/aseprite
+ http://sourceforge.net/forum/?group_id=20848
- ase-help@lists.sourceforge.net
- http://lists.sourceforge.net/lists/listinfo/ase-help/
+ We recommend you to use the SourceForge tracker to do specific
+ reporting of some issues like:
+ * Bugs:
+ http://sourceforge.net/tracker/?group_id=20848&atid=120848&func=add
+ * Request features:
+ http://sourceforge.net/tracker/?group_id=20848&atid=370848&func=add
+ * Patches:
+ http://sourceforge.net/tracker/?group_id=20848&atid=320848&func=add
+ * Support request:
+ http://sourceforge.net/tracker/?group_id=20848&atid=220848&func=add
For more information, visit the official page of the project:
-
- http://ase.sourceforge.net
-
+ http://www.aseprite.org/
+ http://www.aseprite.org/wiki/
----------------------------------------------------------------------------
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 by David A. Capello
+ Copyright (C) 2001-2008 by David A. Capello
diff --git a/TODO.txt b/TODO.txt
index 83c5974d8..1677359eb 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,15 +1,22 @@
High priority work
------------------
+- tooltips for color-bar.
+- add two DrawClick2:
+ - DrawClick2FreeHand
+ - DrawClick2Shape
+- the user_data of hook_signal should be void*.
+
- search for TODO;
-- rename jcombox.c to jcombobox.c
- remove the jfilesel.c
+- fix the sprite-properties dialog when select the constant
+ frame length.
- fix copyright years (2001-2008)
- fix a bug in the film editor when move the separator (panel) outside
the screen (to left or right)
+ + rewrite the film editor.
- 'jfile.c' should use 'jxml.c', because there are duplicate code:
two (precarious) XML parsers.
-- the user_data of hook_signal should be void*.
- ver por el nuevo load_font de Allegro.
- complete palette operations, and palette editor (it needs a slider
or something to move between palette changes);
@@ -52,11 +59,10 @@ Wish-list
---------
- dacap wish-list:
- + keyboard shortcuts for snap-to-grid and view-grid
- + different snap-to-grid for paste operation
- + better dialogs: widder buttons, more borders.
+ better film editor
+ + rewrite it in one widget.
+ "middle mouse button" for the film editor.
+ + added starred file-items in the file-selector.
- manuq wish-list:
+ layer-with-constant-cel
- Mateusz Czaplinski ideas:
diff --git a/WARNING.txt b/WARNING.txt
index 9afe1a80e..f99b006ed 100644
--- a/WARNING.txt
+++ b/WARNING.txt
@@ -7,17 +7,6 @@
See README.txt and COPYING files for more information.
Remember to report "bugs" and errors to:
- ase-help@lists.sourceforge.net
-
-======================================================================
- ADVERTENCIA SOBRE ALLEGRO-SPRITE-EDITOR
-======================================================================
-
- ESTE PROGRAMA ES DISTRIBUIDO SIN GARANTIA ALGUNA !!!
-
- Mire los ficheros README-es.txt y COPYING para mayor
- información. Recuerde reportar errores y "bugs" a:
-
- ase-help@lists.sourceforge.net
+ aseprite@googlegroups.com
======================================================================
diff --git a/config.h b/config.h
index e3ff33701..37474398d 100644
--- a/config.h
+++ b/config.h
@@ -25,7 +25,7 @@
/* general information */
#define PACKAGE "ase"
-#define VERSION "0.6 BETA 2"
+#define VERSION "0.6-beta2"
#define WEBSITE "http://www.aseprite.org/"
#define BUGREPORT "aseprite@googlegroups.com"
#define COPYRIGHT "Copyright (C) 2001-2008 David A. Capello"
diff --git a/data/fonts/anipro.pcx b/data/fonts/anipro_fixed.pcx
similarity index 100%
rename from data/fonts/anipro.pcx
rename to data/fonts/anipro_fixed.pcx
diff --git a/data/fonts/anipro2.pcx b/data/fonts/anipro_variable.pcx
similarity index 100%
rename from data/fonts/anipro2.pcx
rename to data/fonts/anipro_variable.pcx
diff --git a/data/fonts/default.pcx b/data/fonts/ase1.pcx
similarity index 100%
rename from data/fonts/default.pcx
rename to data/fonts/ase1.pcx
diff --git a/data/fonts/verdana10.pcx b/data/fonts/ase2.pcx
similarity index 100%
rename from data/fonts/verdana10.pcx
rename to data/fonts/ase2.pcx
diff --git a/data/fonts/default2.pcx b/data/fonts/default2.pcx
deleted file mode 100644
index f9a69c551..000000000
Binary files a/data/fonts/default2.pcx and /dev/null differ
diff --git a/data/fonts/lcd8.pcx b/data/fonts/lcd8.pcx
deleted file mode 100644
index a5588f2a5..000000000
Binary files a/data/fonts/lcd8.pcx and /dev/null differ
diff --git a/data/fonts/mssansserif8.pcx b/data/fonts/mssansserif8.pcx
deleted file mode 100644
index 48f0af064..000000000
Binary files a/data/fonts/mssansserif8.pcx and /dev/null differ
diff --git a/data/fonts/mssansserif8bold.pcx b/data/fonts/mssansserif8bold.pcx
deleted file mode 100644
index 66d7b2a9b..000000000
Binary files a/data/fonts/mssansserif8bold.pcx and /dev/null differ
diff --git a/data/fonts/tahoma8.pcx b/data/fonts/tahoma8.pcx
deleted file mode 100644
index 09594eeba..000000000
Binary files a/data/fonts/tahoma8.pcx and /dev/null differ
diff --git a/data/fonts/terminal10.pcx b/data/fonts/terminal10.pcx
deleted file mode 100644
index b1e233b39..000000000
Binary files a/data/fonts/terminal10.pcx and /dev/null differ
diff --git a/data/fonts/terminal8.pcx b/data/fonts/terminal8.pcx
deleted file mode 100644
index 2afec500b..000000000
Binary files a/data/fonts/terminal8.pcx and /dev/null differ
diff --git a/data/fonts/verdana8.pcx b/data/fonts/verdana8.pcx
deleted file mode 100644
index e58edf716..000000000
Binary files a/data/fonts/verdana8.pcx and /dev/null differ
diff --git a/data/fonts/verdana8bold.pcx b/data/fonts/verdana8bold.pcx
deleted file mode 100644
index f9a69c551..000000000
Binary files a/data/fonts/verdana8bold.pcx and /dev/null differ
diff --git a/data/fonts/verdana9.pcx b/data/fonts/verdana9.pcx
deleted file mode 100644
index ed683fbe6..000000000
Binary files a/data/fonts/verdana9.pcx and /dev/null differ
diff --git a/data/gui-en.xml b/data/gui-en.xml
index 8ca64166c..d4162d20f 100644
--- a/data/gui-en.xml
+++ b/data/gui-en.xml
@@ -5,11 +5,8 @@
-
-
-
@@ -26,16 +23,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -56,6 +43,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -63,13 +62,14 @@
-
+
-
+
+
+
-
@@ -95,7 +95,6 @@
-
-
@@ -189,6 +169,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -216,7 +220,6 @@
-
@@ -224,9 +227,13 @@
-
+
+
+
+
+
diff --git a/data/jids/celprop.jid b/data/jids/celprop.jid
index 759271b1a..c4f7aca36 100644
--- a/data/jids/celprop.jid
+++ b/data/jids/celprop.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/colcurv.jid b/data/jids/colcurv.jid
index 87d21895f..00d183823 100644
--- a/data/jids/colcurv.jid
+++ b/data/jids/colcurv.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/colsel.jid b/data/jids/colsel.jid
index cbe64c92a..41985f6ea 100644
--- a/data/jids/colsel.jid
+++ b/data/jids/colsel.jid
@@ -1,5 +1,5 @@
-
+
@@ -33,7 +33,7 @@
-
+
diff --git a/data/jids/confscr.jid b/data/jids/confscr.jid
index c58636177..26532b05d 100644
--- a/data/jids/confscr.jid
+++ b/data/jids/confscr.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/convmatr.jid b/data/jids/convmatr.jid
index 249d3472e..a96307351 100644
--- a/data/jids/convmatr.jid
+++ b/data/jids/convmatr.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/drawtext.jid b/data/jids/drawtext.jid
index e6e21a56d..342009309 100644
--- a/data/jids/drawtext.jid
+++ b/data/jids/drawtext.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/dupspr.jid b/data/jids/dupspr.jid
index a5b40a818..2ea885a25 100644
--- a/data/jids/dupspr.jid
+++ b/data/jids/dupspr.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/filesel.jid b/data/jids/filesel.jid
index 17c485bbc..50128377c 100644
--- a/data/jids/filesel.jid
+++ b/data/jids/filesel.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/frlen.jid b/data/jids/frlen.jid
index b566f50cd..8862d2101 100644
--- a/data/jids/frlen.jid
+++ b/data/jids/frlen.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/imgtype.jid b/data/jids/imgtype.jid
index 8fc37700b..cf3ff4741 100644
--- a/data/jids/imgtype.jid
+++ b/data/jids/imgtype.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/invrtcol.jid b/data/jids/invrtcol.jid
index 1099f33b4..6f3be346a 100644
--- a/data/jids/invrtcol.jid
+++ b/data/jids/invrtcol.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/main.jid b/data/jids/main.jid
index 75e1c8f4b..89b511fb9 100644
--- a/data/jids/main.jid
+++ b/data/jids/main.jid
@@ -1,59 +1,17 @@
-
+
-
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/data/jids/mapgen.jid b/data/jids/mapgen.jid
deleted file mode 100644
index a5d6fe9b5..000000000
--- a/data/jids/mapgen.jid
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/jids/median.jid b/data/jids/median.jid
index 99fbd78c6..ab91dd7c0 100644
--- a/data/jids/median.jid
+++ b/data/jids/median.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/newlay.jid b/data/jids/newlay.jid
index f37e0c564..56d3a199b 100644
--- a/data/jids/newlay.jid
+++ b/data/jids/newlay.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/newspr.jid b/data/jids/newspr.jid
index 95e87727e..4dd658eb3 100644
--- a/data/jids/newspr.jid
+++ b/data/jids/newspr.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/options.jid b/data/jids/options.jid
index 9df25d0d1..8d338d718 100644
--- a/data/jids/options.jid
+++ b/data/jids/options.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/paledit.jid b/data/jids/paledit.jid
index 10f54717c..e1af5fc98 100644
--- a/data/jids/paledit.jid
+++ b/data/jids/paledit.jid
@@ -1,5 +1,5 @@
-
+
@@ -33,7 +33,7 @@
-
+
diff --git a/data/jids/playfli.jid b/data/jids/playfli.jid
index fc27881d6..93ac74e83 100644
--- a/data/jids/playfli.jid
+++ b/data/jids/playfli.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/pntprop.jid b/data/jids/pntprop.jid
index d19dd5932..0538a89a1 100644
--- a/data/jids/pntprop.jid
+++ b/data/jids/pntprop.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/replcol.jid b/data/jids/replcol.jid
index 9556fa002..c122a86a6 100644
--- a/data/jids/replcol.jid
+++ b/data/jids/replcol.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/sprprop.jid b/data/jids/sprprop.jid
index c1ea413f9..ff38383ca 100644
--- a/data/jids/sprprop.jid
+++ b/data/jids/sprprop.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/data/jids/toolconf.jid b/data/jids/toolconf.jid
index 3067961fa..3e51bc572 100644
--- a/data/jids/toolconf.jid
+++ b/data/jids/toolconf.jid
@@ -1,5 +1,5 @@
-
+
diff --git a/makefile.lst b/makefile.lst
index 6df20c7cf..d4a75224f 100644
--- a/makefile.lst
+++ b/makefile.lst
@@ -3,7 +3,7 @@
######################################################################
# ASE
-ASE = ase$(EXE)
+ASE = aseprite$(EXE)
COMMON_SOURCES = \
src/commands/cmd_about.c \
@@ -23,17 +23,19 @@ COMMON_SOURCES = \
src/commands/cmd_drawing_tools.c \
src/commands/cmd_duplicate_layer.c \
src/commands/cmd_duplicate_sprite.c \
+ src/commands/cmd_exchange_colors.c \
src/commands/cmd_exit.c \
+ src/commands/cmd_eyedropper_tool.c \
src/commands/cmd_film_editor.c \
src/commands/cmd_flatten_layers.c \
src/commands/cmd_flip.c \
src/commands/cmd_frame_properties.c \
src/commands/cmd_goto_frame.c \
+ src/commands/cmd_grid.c \
src/commands/cmd_invert_mask.c \
src/commands/cmd_layer_properties.c \
src/commands/cmd_link_cel.c \
src/commands/cmd_load_mask.c \
- src/commands/cmd_mapgen.c \
src/commands/cmd_mask_all.c \
src/commands/cmd_mask_by_color.c \
src/commands/cmd_merge_down_layer.c \
@@ -83,7 +85,6 @@ COMMON_SOURCES = \
src/core/modules.c \
src/dialogs/canvasze.c \
src/dialogs/colsel.c \
- src/dialogs/dmapgen.c \
src/dialogs/dpaledit.c \
src/dialogs/drawtext.c \
src/dialogs/filesel.c \
@@ -125,6 +126,7 @@ COMMON_SOURCES = \
src/jinete/jcombobox.c \
src/jinete/jdraw.c \
src/jinete/jentry.c \
+ src/jinete/jgrid.c \
src/jinete/jfile.c \
src/jinete/jfilesel.c \
src/jinete/jfont.c \
@@ -194,7 +196,6 @@ COMMON_SOURCES = \
src/util/crop.c \
src/util/filetoks.c \
src/util/hash.c \
- src/util/mapgen.c \
src/util/misc.c \
src/util/msk_file.c \
src/util/pic_file.c \
@@ -204,6 +205,7 @@ COMMON_SOURCES = \
src/util/thmbnail.c \
src/widgets/colbar.c \
src/widgets/colbut.c \
+ src/widgets/colsel2.c \
src/widgets/colview.c \
src/widgets/curvedit.c \
src/widgets/editor/click.c \
diff --git a/makefile.mgw b/makefile.mgw
index 151039d65..21d6383c2 100644
--- a/makefile.mgw
+++ b/makefile.mgw
@@ -57,7 +57,7 @@ include makefile.gcc
default: all
-all: $(ASE)
+all: $(ASE) test
clean:
-rm -f $(ALL_OBJS) $(THIRD_PARTY_LIBS)
diff --git a/misc/deps.sh b/misc/deps.sh
index 667137671..a8f080a25 100644
--- a/misc/deps.sh
+++ b/misc/deps.sh
@@ -4,7 +4,6 @@ GCC="gcc -MM"
CFLAGS="-I. \
-Isrc \
-Ithird_party/lua/include \
- -Ithird_party/gfli \
-Ithird_party/intl \
-Ithird_party/libpng \
-Ithird_party/zlib \
@@ -23,6 +22,7 @@ $GCC $CFLAGS \
src/dialogs/*.c \
src/effect/*.c \
src/file/*.c \
+ src/file/*/*.c \
src/intl/*.c \
src/jinete/*.c \
src/modules/*.c \
diff --git a/misc/dist.sh b/misc/dist.sh
index e9a0c7b56..946ca32f4 100644
--- a/misc/dist.sh
+++ b/misc/dist.sh
@@ -1,7 +1,7 @@
#! /bin/sh
dir="`pwd`"
-version=0.6beta
+version=0.6-beta2
distdir=ase-$version
freetype_files="third_party/freetype/ChangeLog \
@@ -33,10 +33,6 @@ freetype_files="third_party/freetype/ChangeLog \
third_party/freetype/src/type1/*.[ch] \
third_party/freetype/src/winfonts/*.[ch]"
-gfli_files="third_party/gfli/*.[ch] \
- third_party/gfli/README \
- third_party/gfli/TODO"
-
jpeg_files="third_party/jpeg/*.[ch] \
third_party/jpeg/*.log \
third_party/jpeg/*.doc \
@@ -73,8 +69,7 @@ zlib_files="third_party/zlib/*.[ch] \
third_party/zlib/*.txt \
third_party/zlib/README"
-ase_files="all.h \
- config.h \
+ase_files="config.h \
ChangeLog \
COPYING \
fix.bat \
@@ -115,6 +110,8 @@ ase_files="all.h \
src/dialogs/*.[ch] \
src/effect/*.[ch] \
src/file/*.[ch] \
+ src/file/fli/*.[ch] \
+ src/file/fli/README \
src/file/gif/*.[ch] \
src/intl/*.[ch] \
src/jinete/*.[ch] \
@@ -126,6 +123,7 @@ ase_files="all.h \
src/raster/x86/*.s \
src/script/*.[ch] \
src/script/*.py \
+ src/test/*.[ch] \
src/test/jinete/*.[ch] \
src/test/jinete/*.jid \
src/test/jinete/*.pcx \
@@ -148,7 +146,6 @@ mkdir "$dir/$distdir"
cp --parents \
$freetype_files \
- $gfli_files \
$jpeg_files \
$libart_files \
$libpng_files \
@@ -172,7 +169,11 @@ fi
function def_common_files()
{
txt_files=" \
-$1/*.txt \
+$1/AUTHORS.txt \
+$1/LEGAL.txt \
+$1/NEWS.txt \
+$1/README.txt \
+$1/WARNING.txt \
$1/COPYING \
$1/data/convmatr.def \
$1/data/jids/*.jid \
@@ -202,17 +203,17 @@ if [ ! -f $distdir-win32.zip ] ; then
cd "$dir/.."
make -f makefile.mgw CONFIGURED=1 clean
make -f makefile.mgw CONFIGURED=1
-strip -s ase.exe
+strip -s aseprite.exe
def_common_files .
mkdir "$dir/$distdir-win32"
-cp -r --parents $txt_files $bin_files ase.exe "$dir/$distdir-win32"
+cp -r --parents $txt_files $bin_files aseprite.exe "$dir/$distdir-win32"
cd "$dir"
cp alleg42.dll "$dir/$distdir-win32"
def_common_files $distdir-win32
zip -9 $distdir-win32.zip $txt_files
zip -9 $distdir-win32.zip $bin_files \
- $distdir-win32/ase.exe \
+ $distdir-win32/aseprite.exe \
$distdir-win32/alleg42.dll
rm -fr $distdir-win32
diff --git a/src/commands/cmd_about.c b/src/commands/cmd_about.c
index 25c2580ea..bc6d9fbe7 100644
--- a/src/commands/cmd_about.c
+++ b/src/commands/cmd_about.c
@@ -65,17 +65,17 @@ static void cmd_about_execute(const char *argument)
jwidget_magnetic(button1, TRUE);
jwidget_set_border(box1, 4, 4, 4, 4);
- jwidget_add_childs(box1, label1, label2, separator1, NULL);
+ jwidget_add_children(box1, label1, label2, separator1, NULL);
if (textbox) {
jview_attach(view, textbox);
jwidget_expansive(view, TRUE);
jwidget_set_min_size(view, JI_SCREEN_W/3, JI_SCREEN_H/4);
- jwidget_add_childs(box1, view, separator2, NULL);
+ jwidget_add_children(box1, view, separator2, NULL);
}
jwidget_expansive(box3, TRUE);
jwidget_expansive(box4, TRUE);
- jwidget_add_childs(box2, box3, button1, box4, NULL);
- jwidget_add_childs(box1, label3, label4, NULL);
+ jwidget_add_children(box2, box3, button1, box4, NULL);
+ jwidget_add_children(box1, label3, label4, NULL);
jwidget_add_child(box1, box2);
jwidget_add_child(window, box1);
diff --git a/src/commands/cmd_advanced_mode.c b/src/commands/cmd_advanced_mode.c
index 264c8e93b..a3f2dfb6a 100644
--- a/src/commands/cmd_advanced_mode.c
+++ b/src/commands/cmd_advanced_mode.c
@@ -31,18 +31,18 @@ static void cmd_advanced_mode_execute(const char *argument)
advanced_mode = !advanced_mode;
if (advanced_mode) {
- jwidget_hide(app_get_tool_bar());
- jwidget_hide(app_get_menu_bar());
- jwidget_hide(app_get_status_bar());
- jwidget_hide(app_get_color_bar());
- jwidget_hide(app_get_tabs_bar());
+ jwidget_hide(app_get_toolbar());
+ jwidget_hide(app_get_menubar());
+ jwidget_hide(app_get_statusbar());
+ jwidget_hide(app_get_colorbar());
+ jwidget_hide(app_get_tabsbar());
}
else {
- jwidget_show(app_get_tool_bar());
- jwidget_show(app_get_menu_bar());
- jwidget_show(app_get_status_bar());
- jwidget_show(app_get_color_bar());
- jwidget_show(app_get_tabs_bar());
+ jwidget_show(app_get_toolbar());
+ jwidget_show(app_get_menubar());
+ jwidget_show(app_get_statusbar());
+ jwidget_show(app_get_colorbar());
+ jwidget_show(app_get_tabsbar());
}
jwindow_remap(app_get_top_window());
diff --git a/src/commands/cmd_clear.c b/src/commands/cmd_clear.c
index 7dfca8d6b..3364be090 100644
--- a/src/commands/cmd_clear.c
+++ b/src/commands/cmd_clear.c
@@ -19,12 +19,10 @@
#include "config.h"
#include "commands/commands.h"
-#include "core/app.h"
#include "modules/gui.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#include "util/misc.h"
-#include "widgets/colbar.h"
static bool cmd_clear_enabled(const char *argument)
{
@@ -37,7 +35,7 @@ static void cmd_clear_execute(const char *argument)
Sprite *sprite = current_sprite;
/* clear the mask */
- ClearMask(color_bar_get_color(app_get_color_bar(), 1));
+ ClearMask(color_mask());
/* refresh the sprite */
update_screen_for_sprite(sprite);
diff --git a/src/commands/cmd_configure_tools.c b/src/commands/cmd_configure_tools.c
index f5cd4dea9..181f73ec4 100644
--- a/src/commands/cmd_configure_tools.c
+++ b/src/commands/cmd_configure_tools.c
@@ -258,7 +258,7 @@ static int brush_type_change_hook(JWidget widget, int user_data)
set_brush_type(type);
jwidget_dirty((JWidget)user_data);
- status_bar_set_text(app_get_status_bar(), 250,
+ statusbar_set_text(app_get_statusbar(), 250,
"Brush type: %s",
type == BRUSH_CIRCLE ? "Circle":
type == BRUSH_SQUARE ? "Square":
@@ -273,7 +273,7 @@ static int brush_mode_change_hook(JWidget widget, int user_data)
set_brush_mode(mode);
- status_bar_set_text(app_get_status_bar(), 250,
+ statusbar_set_text(app_get_statusbar(), 250,
"Brush mode: %s",
mode == DRAWMODE_OPAQUE ? "Opaque":
mode == DRAWMODE_GLASS ? "Glass":
diff --git a/src/commands/cmd_duplicate_layer.c b/src/commands/cmd_duplicate_layer.c
index ab1dfcb95..26f0d3c03 100644
--- a/src/commands/cmd_duplicate_layer.c
+++ b/src/commands/cmd_duplicate_layer.c
@@ -53,8 +53,15 @@ static Layer *duplicate_layer(void)
if (!sprite || !sprite->layer)
return NULL;
+ /* open undo */
+ if (undo_is_enabled(sprite->undo))
+ undo_open(sprite->undo);
+
layer_copy = layer_new_copy(sprite->layer);
if (!layer_copy) {
+ if (undo_is_enabled(sprite->undo))
+ undo_close(sprite->undo);
+
console_printf("Not enough memory");
return NULL;
}
@@ -62,10 +69,9 @@ static Layer *duplicate_layer(void)
sprintf(buf, "%s %s", layer_copy->name, _("Copy"));
layer_set_name(layer_copy, buf);
- if (undo_is_enabled(sprite->undo)) {
- undo_open(sprite->undo);
+ /* add the new layer in the sprite */
+ if (undo_is_enabled(sprite->undo))
undo_add_layer(sprite->undo, (Layer *)sprite->layer->parent, layer_copy);
- }
layer_add_layer((Layer *)sprite->layer->parent, layer_copy);
diff --git a/src/commands/cmd_mapgen.c b/src/commands/cmd_exchange_colors.c
similarity index 62%
rename from src/commands/cmd_mapgen.c
rename to src/commands/cmd_exchange_colors.c
index b927bff14..85d5f78ed 100644
--- a/src/commands/cmd_mapgen.c
+++ b/src/commands/cmd_exchange_colors.c
@@ -18,21 +18,28 @@
#include "config.h"
-#include "jinete/jinete.h"
+#include
+
+#include "jinete/jbase.h"
#include "commands/commands.h"
#include "core/app.h"
-#include "modules/sprites.h"
-#include "raster/sprite.h"
+#include "widgets/colbar.h"
-/* static void cmd_mapgen_execute(const char *argument) */
-/* { */
-/* } */
+static void cmd_exchange_colors_execute(const char *argument)
+{
+ JWidget colorbar = app_get_colorbar();
+ color_t fg = colorbar_get_fg_color(colorbar);
+ color_t bg = colorbar_get_bg_color(colorbar);
-/* Command cmd_mapgen = { */
-/* CMD_MAPGEN, */
-/* cmd_mapgen_enabled, */
-/* NULL, */
-/* cmd_mapgen_execute, */
-/* NULL */
-/* }; */
+ colorbar_set_fg_color(colorbar, bg);
+ colorbar_set_bg_color(colorbar, fg);
+}
+
+Command cmd_exchange_colors = {
+ CMD_EXCHANGE_COLORS,
+ NULL,
+ NULL,
+ cmd_exchange_colors_execute,
+ NULL
+};
diff --git a/src/commands/cmd_eyedropper_tool.c b/src/commands/cmd_eyedropper_tool.c
new file mode 100644
index 000000000..3f1e644ee
--- /dev/null
+++ b/src/commands/cmd_eyedropper_tool.c
@@ -0,0 +1,66 @@
+/* ASE - Allegro Sprite Editor
+ * Copyright (C) 2001-2008 David A. Capello
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+
+#include
+
+#include "jinete/jinete.h"
+
+#include "commands/commands.h"
+#include "core/app.h"
+#include "modules/editors.h"
+#include "modules/sprites.h"
+#include "raster/sprite.h"
+#include "raster/image.h"
+#include "widgets/colbar.h"
+#include "widgets/editor.h"
+
+static void cmd_eyedropper_tool_execute(const char *argument)
+{
+ JWidget widget;
+ Editor *editor;
+ color_t color;
+ int x, y;
+
+ widget = jmanager_get_mouse();
+ if (!widget || widget->type != editor_type())
+ return;
+
+ editor = editor_data(widget);
+ if (!editor->sprite)
+ return;
+
+ /* pixel position to get */
+ screen_to_editor(widget, jmouse_x(0), jmouse_y(0), &x, &y);
+
+ /* get the color from the image */
+ color = color_from_image(editor->sprite->imgtype,
+ sprite_getpixel(editor->sprite, x, y));
+
+ /* set the color of the color-bar */
+ colorbar_set_fg_color(app_get_colorbar(), color);
+}
+
+Command cmd_eyedropper_tool = {
+ CMD_EYEDROPPER_TOOL,
+ NULL,
+ NULL,
+ cmd_eyedropper_tool_execute,
+ NULL
+};
diff --git a/src/commands/cmd_goto_frame.c b/src/commands/cmd_goto_frame.c
index 555c9897b..2ee72ebcb 100644
--- a/src/commands/cmd_goto_frame.c
+++ b/src/commands/cmd_goto_frame.c
@@ -39,7 +39,7 @@ static void cmd_goto_first_frame_execute(const char *argument)
current_sprite->frame = 0;
update_screen_for_sprite(current_sprite);
- editor_update_status_bar_for_standby(current_editor);
+ editor_update_statusbar_for_standby(current_editor);
}
/* ======================== */
@@ -59,7 +59,7 @@ static void cmd_goto_previous_frame_execute(const char *argument)
current_sprite->frame = current_sprite->frames-1;
update_screen_for_sprite(current_sprite);
- editor_update_status_bar_for_standby(current_editor);
+ editor_update_statusbar_for_standby(current_editor);
}
/* ======================== */
@@ -79,7 +79,7 @@ static void cmd_goto_next_frame_execute(const char *argument)
current_sprite->frame = 0;
update_screen_for_sprite(current_sprite);
- editor_update_status_bar_for_standby(current_editor);
+ editor_update_statusbar_for_standby(current_editor);
}
/* ======================== */
@@ -96,7 +96,7 @@ static void cmd_goto_last_frame_execute(const char *argument)
current_sprite->frame = current_sprite->frames-1;
update_screen_for_sprite(current_sprite);
- editor_update_status_bar_for_standby(current_editor);
+ editor_update_statusbar_for_standby(current_editor);
}
Command cmd_goto_first_frame = {
diff --git a/src/commands/cmd_grid.c b/src/commands/cmd_grid.c
new file mode 100644
index 000000000..5b1f5c158
--- /dev/null
+++ b/src/commands/cmd_grid.c
@@ -0,0 +1,63 @@
+/* ASE - Allegro Sprite Editor
+ * Copyright (C) 2001-2008 David A. Capello
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+
+#include
+
+#include "commands/commands.h"
+#include "core/app.h"
+#include "modules/editors.h"
+#include "modules/tools.h"
+#include "widgets/statebar.h"
+
+static void cmd_show_grid_execute(const char *argument)
+{
+ set_view_grid(get_view_grid() ? FALSE: TRUE);
+ refresh_all_editors();
+}
+
+static void cmd_snap_to_grid_execute(const char *argument)
+{
+ char buf[512];
+
+ set_use_grid(get_use_grid() ? FALSE: TRUE);
+ refresh_all_editors();
+
+ usprintf(buf, _("Snap to grid: %s"),
+ get_use_grid() ? _("On"):
+ _("Off"));
+
+ statusbar_set_text(app_get_statusbar(), 250, buf);
+}
+
+Command cmd_show_grid = {
+ CMD_SHOW_GRID,
+ NULL,
+ NULL,
+ cmd_show_grid_execute,
+ NULL
+};
+
+Command cmd_snap_to_grid = {
+ CMD_SNAP_TO_GRID,
+ NULL,
+ NULL,
+ cmd_snap_to_grid_execute,
+ NULL
+};
diff --git a/src/commands/cmd_new_file.c b/src/commands/cmd_new_file.c
index b02fa4377..28e8fb141 100644
--- a/src/commands/cmd_new_file.c
+++ b/src/commands/cmd_new_file.c
@@ -27,6 +27,7 @@
#include "commands/commands.h"
#include "console/console.h"
#include "core/app.h"
+#include "core/cfg.h"
#include "dialogs/colsel.h"
#include "modules/color.h"
#include "modules/gui.h"
@@ -37,13 +38,6 @@
#include "script/functions.h"
#include "util/misc.h"
-static const char *bg_table[] = {
- "mask",
- "rgb{0,0,0}",
- "rgb{255,255,255}",
- "rgb{255,0,255}"
-};
-
static int _sprite_counter = 0;
/**
@@ -55,7 +49,13 @@ static void cmd_new_file_execute(const char *argument)
int imgtype, w, h, bg;
char buf[1024];
Sprite *sprite;
- char *color;
+ color_t color;
+ color_t bg_table[] = {
+ color_mask(),
+ color_rgb(0, 0, 0, 255),
+ color_rgb(255, 255, 255, 255),
+ color_rgb(255, 0, 255, 255)
+ };
/* load the window widget */
window = load_widget("newspr.jid", "new_sprite");
@@ -94,6 +94,8 @@ static void cmd_new_file_execute(const char *argument)
jwindow_open_fg(window);
if (jwindow_get_killer(window) == ok) {
+ bool ok = FALSE;
+
/* get the options */
if (jwidget_is_selected(radio1)) imgtype = IMAGE_RGB;
else if (jwidget_is_selected(radio2)) imgtype = IMAGE_GRAYSCALE;
@@ -107,23 +109,24 @@ static void cmd_new_file_execute(const char *argument)
h = MID(1, h, 9999);
/* select the color */
- color = NULL;
+ color = color_mask();
if (bg >= 0 && bg <= 3) {
- color = jstrdup(bg_table[bg]);
+ color = bg_table[bg];
+ ok = TRUE;
}
else {
- const char *default_color =
- get_config_string("NewSprite",
- "BackgroundCustom",
- "rgb{0,0,0}");
+ color = get_config_color("NewSprite",
+ "BackgroundCustom",
+ color_rgb(0, 0, 0, 255));
- color = ji_color_select(imgtype, default_color);
- if (color)
- set_config_string("NewSprite", "BackgroundCustom", color);
+ if (ji_color_select(imgtype, &color)) {
+ set_config_color("NewSprite", "BackgroundCustom", color);
+ ok = TRUE;
+ }
}
- if (color) {
+ if (ok) {
/* save the configuration */
set_config_int("NewSprite", "Type", imgtype);
set_config_int("NewSprite", "Width", w);
@@ -152,8 +155,6 @@ static void cmd_new_file_execute(const char *argument)
/* show the sprite to the user */
sprite_show(sprite);
}
-
- jfree(color);
}
}
diff --git a/src/commands/cmd_open_file.c b/src/commands/cmd_open_file.c
index 6514621e7..f051a3deb 100644
--- a/src/commands/cmd_open_file.c
+++ b/src/commands/cmd_open_file.c
@@ -162,8 +162,8 @@ static void cmd_open_file_execute(const char *argument)
data->fop = fop;
/* add the progress bar */
- if (app_get_status_bar())
- data->progress = progress_new(app_get_status_bar());
+ if (app_get_statusbar())
+ data->progress = progress_new(app_get_statusbar());
else
data->progress = NULL;
diff --git a/src/commands/cmd_play_animation.c b/src/commands/cmd_play_animation.c
index 5aeb82f81..85cc67726 100644
--- a/src/commands/cmd_play_animation.c
+++ b/src/commands/cmd_play_animation.c
@@ -27,6 +27,7 @@
#include "modules/gui.h"
#include "modules/palette.h"
#include "modules/sprites.h"
+#include "modules/tools.h"
#include "raster/sprite.h"
#include "widgets/editor.h"
@@ -49,10 +50,14 @@ static void cmd_play_animation_execute(const char *argument)
Sprite *sprite = current_sprite;
int old_frame, msecs;
bool done = FALSE;
+ bool onionskin = get_onionskin();
if (sprite->frames < 2)
return;
+ /* desactivate the onion-skin */
+ set_onionskin(FALSE);
+
jmouse_hide();
old_frame = sprite->frame;
@@ -92,6 +97,8 @@ static void cmd_play_animation_execute(const char *argument)
gui_feedback();
}
+ set_onionskin(onionskin);
+
/* if right-click or ESC */
if (mouse_b == 2 || (keypressed() && (readkey()>>8) == KEY_ESC))
/* return to the old frame position */
diff --git a/src/commands/cmd_preview.c b/src/commands/cmd_preview.c
index e9c8f3aba..2d8a385c5 100644
--- a/src/commands/cmd_preview.c
+++ b/src/commands/cmd_preview.c
@@ -104,8 +104,8 @@ static void preview_sprite(int flags)
bmp = create_bitmap(sprite->w, sprite->h);
if (bmp) {
/* print a informative text */
- status_bar_set_text(app_get_status_bar(), 1, _("Rendering..."));
- jwidget_flush_redraw(app_get_status_bar());
+ statusbar_set_text(app_get_statusbar(), 1, _("Rendering..."));
+ jwidget_flush_redraw(app_get_statusbar());
jmanager_dispatch_messages(ji_get_default_manager());
jmouse_set_cursor(JI_CURSOR_NULL);
@@ -157,8 +157,8 @@ static void preview_sprite(int flags)
outh = (double)bmp->h * (double)scale;
stretch_blit(bmp, ji_screen, 0, 0, bmp->w, bmp->h, 0, 0, outw, outh);
- rectfill_exclude(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1,
- 0, 0, outw-1, outh-1, bg_color);
+ jrectexclude(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1,
+ 0, 0, outw-1, outh-1, bg_color);
}
/* draw in normal size */
else {
@@ -207,7 +207,7 @@ static void preview_sprite(int flags)
Command *command;
JMessage msg;
- msg = jmessage_new_key_related(JM_CHAR, readkey_value);
+ msg = jmessage_new_key_related(JM_KEYPRESSED, readkey_value);
command = command_get_by_key(msg);
jmessage_free(msg);
diff --git a/src/commands/cmd_save_file.c b/src/commands/cmd_save_file.c
index 83e3a9886..127d0776e 100644
--- a/src/commands/cmd_save_file.c
+++ b/src/commands/cmd_save_file.c
@@ -45,10 +45,10 @@ static void cmd_save_file_execute(const char *argument)
recent_file(current_sprite->filename);
sprite_mark_as_saved(current_sprite);
- if (app_get_status_bar())
- status_bar_set_text(app_get_status_bar(),
- 1000, "File %s, saved.",
- get_filename(current_sprite->filename));
+ if (app_get_statusbar())
+ statusbar_set_text(app_get_statusbar(),
+ 1000, "File %s, saved.",
+ get_filename(current_sprite->filename));
}
else {
/* TODO if the user cancel we shouldn't unrecent the file */
diff --git a/src/commands/cmd_sprite_properties.c b/src/commands/cmd_sprite_properties.c
index b6c7c98b2..59c664ecd 100644
--- a/src/commands/cmd_sprite_properties.c
+++ b/src/commands/cmd_sprite_properties.c
@@ -46,7 +46,6 @@ static void cmd_sprite_properties_execute(const char *argument)
Sprite *sprite = current_sprite;
char *imgtype_text;
char buf[256];
- char *tmp;
/* load the window widget */
window = load_widget("sprprop.jid", "sprite_properties");
@@ -96,9 +95,9 @@ static void cmd_sprite_properties_execute(const char *argument)
jwidget_set_text(frames, buf);
/* background color */
- tmp = color_from_image(sprite->imgtype, sprite->bgcolor);
- bgcolor_button = color_button_new(tmp, current_sprite->imgtype);
- jfree(tmp);
+ bgcolor_button = color_button_new(color_from_image(sprite->imgtype,
+ sprite->bgcolor),
+ current_sprite->imgtype);
jwidget_add_child(bgcolor_box, bgcolor_button);
@@ -107,6 +106,7 @@ static void cmd_sprite_properties_execute(const char *argument)
for (;;) {
load_window_pos(window, "SpriteProperties");
+ jwidget_show(window);
jwindow_open_fg(window);
save_window_pos(window, "SpriteProperties");
diff --git a/src/commands/commands.c b/src/commands/commands.c
index 0ef1825d3..4d5dcb345 100644
--- a/src/commands/commands.c
+++ b/src/commands/commands.c
@@ -36,7 +36,6 @@ extern Command cmd_close_file;
extern Command cmd_close_all_files;
extern Command cmd_screen_shot;
extern Command cmd_record_screen;
-extern Command cmd_about;
extern Command cmd_exit;
/* edit */
extern Command cmd_undo;
@@ -49,17 +48,6 @@ extern Command cmd_flip_horizontal;
extern Command cmd_flip_vertical;
extern Command cmd_replace_color;
extern Command cmd_invert_color;
-/* view */
-extern Command cmd_refresh;
-extern Command cmd_configure_screen;
-extern Command cmd_advanced_mode;
-extern Command cmd_make_unique_editor;
-extern Command cmd_split_editor_vertically;
-extern Command cmd_split_editor_horizontally;
-extern Command cmd_close_editor;
-extern Command cmd_preview_tiled, preview;
-extern Command cmd_preview_normal, preview;
-extern Command cmd_preview_fit_to_screen, preview;
/* sprite */
extern Command cmd_sprite_properties;
extern Command cmd_duplicate_sprite;
@@ -100,6 +88,19 @@ extern Command cmd_invert_mask;
extern Command cmd_mask_by_color;
extern Command cmd_load_mask;
extern Command cmd_save_mask;
+/* view */
+extern Command cmd_refresh;
+extern Command cmd_configure_screen;
+extern Command cmd_advanced_mode;
+extern Command cmd_make_unique_editor;
+extern Command cmd_split_editor_vertically;
+extern Command cmd_split_editor_horizontally;
+extern Command cmd_close_editor;
+extern Command cmd_show_grid;
+extern Command cmd_snap_to_grid;
+extern Command cmd_preview_tiled;
+extern Command cmd_preview_normal;
+extern Command cmd_preview_fit_to_screen;
/* tools */
extern Command cmd_configure_tools;
extern Command cmd_marker_tool;
@@ -111,14 +112,18 @@ extern Command cmd_floodfill_tool;
extern Command cmd_line_tool;
extern Command cmd_rectangle_tool;
extern Command cmd_ellipse_tool;
+extern Command cmd_eyedropper_tool;
+extern Command cmd_exchange_colors;
extern Command cmd_film_editor;
extern Command cmd_palette_editor;
extern Command cmd_convolution_matrix;
extern Command cmd_color_curve;
extern Command cmd_despeckle;
extern Command cmd_run_script;
-extern Command cmd_tips;
extern Command cmd_options;
+/* help */
+extern Command cmd_tips;
+extern Command cmd_about;
/* internal */
extern Command cmd_select_file;
@@ -132,7 +137,6 @@ static Command *commands[] = {
&cmd_close_all_files,
&cmd_screen_shot,
&cmd_record_screen,
- &cmd_about,
&cmd_exit,
/* edit */
&cmd_undo,
@@ -145,17 +149,6 @@ static Command *commands[] = {
&cmd_flip_vertical,
&cmd_replace_color,
&cmd_invert_color,
- /* view */
- &cmd_refresh,
- &cmd_configure_screen,
- &cmd_advanced_mode,
- &cmd_make_unique_editor,
- &cmd_split_editor_vertically,
- &cmd_split_editor_horizontally,
- &cmd_close_editor,
- &cmd_preview_tiled,
- &cmd_preview_normal,
- &cmd_preview_fit_to_screen,
/* sprite */
&cmd_sprite_properties,
&cmd_duplicate_sprite,
@@ -196,6 +189,19 @@ static Command *commands[] = {
&cmd_mask_by_color,
&cmd_load_mask,
&cmd_save_mask,
+ /* view */
+ &cmd_refresh,
+ &cmd_configure_screen,
+ &cmd_advanced_mode,
+ &cmd_make_unique_editor,
+ &cmd_split_editor_vertically,
+ &cmd_split_editor_horizontally,
+ &cmd_close_editor,
+ &cmd_show_grid,
+ &cmd_snap_to_grid,
+ &cmd_preview_tiled,
+ &cmd_preview_normal,
+ &cmd_preview_fit_to_screen,
/* tools */
&cmd_configure_tools,
&cmd_marker_tool,
@@ -207,6 +213,8 @@ static Command *commands[] = {
&cmd_line_tool,
&cmd_rectangle_tool,
&cmd_ellipse_tool,
+ &cmd_eyedropper_tool,
+ &cmd_exchange_colors,
&cmd_film_editor,
&cmd_palette_editor,
&cmd_convolution_matrix,
@@ -214,10 +222,11 @@ static Command *commands[] = {
&cmd_despeckle,
/* { CMD_DRAW_TEXT, NULL, NULL, NULL, NULL }, */
/* { CMD_PLAY_FLIC, NULL, NULL, NULL, NULL }, */
- /* { CMD_MAPGEN, NULL, NULL, NULL, NULL }, */
&cmd_run_script,
- &cmd_tips,
&cmd_options,
+ /* help */
+ &cmd_tips,
+ &cmd_about,
/* internal */
&cmd_select_file,
NULL
diff --git a/src/commands/commands.h b/src/commands/commands.h
index eca85d3a0..9c5417d65 100644
--- a/src/commands/commands.h
+++ b/src/commands/commands.h
@@ -30,7 +30,6 @@
#define CMD_CLOSE_ALL_FILES "close_all_files"
#define CMD_SCREEN_SHOT "screen_shot"
#define CMD_RECORD_SCREEN "record_screen"
-#define CMD_ABOUT "about"
#define CMD_EXIT "exit"
/* edit */
#define CMD_UNDO "undo"
@@ -43,17 +42,6 @@
#define CMD_FLIP_VERTICAL "flip_vertical"
#define CMD_REPLACE_COLOR "replace_color"
#define CMD_INVERT_COLOR "invert_color"
-/* view */
-#define CMD_REFRESH "refresh"
-#define CMD_CONFIGURE_SCREEN "configure_screen"
-#define CMD_ADVANCED_MODE "advanced_mode"
-#define CMD_MAKE_UNIQUE_EDITOR "make_unique_editor"
-#define CMD_SPLIT_EDITOR_VERTICALLY "split_editor_vertically"
-#define CMD_SPLIT_EDITOR_HORIZONTALLY "split_editor_horizontally"
-#define CMD_CLOSE_EDITOR "close_editor"
-#define CMD_PREVIEW_TILED "preview_tiled"
-#define CMD_PREVIEW_NORMAL "preview_normal"
-#define CMD_PREVIEW_FIT_TO_SCREEN "preview_fit_to_screen"
/* sprite */
#define CMD_SPRITE_PROPERTIES "sprite_properties"
#define CMD_DUPLICATE_SPRITE "duplicate_sprite"
@@ -94,6 +82,19 @@
#define CMD_MASK_BY_COLOR "mask_by_color"
#define CMD_LOAD_MASK "load_mask"
#define CMD_SAVE_MASK "save_mask"
+/* view */
+#define CMD_REFRESH "refresh"
+#define CMD_CONFIGURE_SCREEN "configure_screen"
+#define CMD_ADVANCED_MODE "advanced_mode"
+#define CMD_MAKE_UNIQUE_EDITOR "make_unique_editor"
+#define CMD_SPLIT_EDITOR_VERTICALLY "split_editor_vertically"
+#define CMD_SPLIT_EDITOR_HORIZONTALLY "split_editor_horizontally"
+#define CMD_CLOSE_EDITOR "close_editor"
+#define CMD_SHOW_GRID "show_grid"
+#define CMD_SNAP_TO_GRID "snap_to_grid"
+#define CMD_PREVIEW_TILED "preview_tiled"
+#define CMD_PREVIEW_NORMAL "preview_normal"
+#define CMD_PREVIEW_FIT_TO_SCREEN "preview_fit_to_screen"
/* tools */
#define CMD_CONFIGURE_TOOLS "configure_tools"
#define CMD_MARKER_TOOL "marker_tool"
@@ -105,6 +106,8 @@
#define CMD_LINE_TOOL "line_tool"
#define CMD_RECTANGLE_TOOL "rectangle_tool"
#define CMD_ELLIPSE_TOOL "ellipse_tool"
+#define CMD_EYEDROPPER_TOOL "eyedropper_tool"
+#define CMD_EXCHANGE_COLORS "exchange_colors"
#define CMD_FILM_EDITOR "film_editor"
#define CMD_PALETTE_EDITOR "palette_editor"
#define CMD_CONVOLUTION_MATRIX "convolution_matrix"
@@ -112,10 +115,11 @@
#define CMD_DESPECKLE "despeckle"
/* #define CMD_DRAW_TEXT "draw_text" */
/* #define CMD_PLAY_FLIC "play_flic" */
-/* #define CMD_MAPGEN "mapgen" */
#define CMD_RUN_SCRIPT "run_script"
-#define CMD_TIPS "tips"
#define CMD_OPTIONS "options"
+/* help */
+#define CMD_TIPS "tips"
+#define CMD_ABOUT "about"
/* internal commands */
#define CMD_SELECT_FILE "select_file"
diff --git a/src/commands/fx/cmd_replace_color.c b/src/commands/fx/cmd_replace_color.c
index d2bb94ded..3d5d2a165 100644
--- a/src/commands/fx/cmd_replace_color.c
+++ b/src/commands/fx/cmd_replace_color.c
@@ -104,13 +104,13 @@ static void cmd_replace_color_execute(const char *argument)
preview = preview_new(effect);
button_color1 = color_button_new
- (get_config_string("ReplaceColor", "Color1",
- color_bar_get_color(app_get_color_bar(), 0)),
+ (get_config_color("ReplaceColor", "Color1",
+ colorbar_get_fg_color(app_get_colorbar())),
current_sprite->imgtype);
button_color2 = color_button_new
- (get_config_string("ReplaceColor", "Color2",
- color_bar_get_color(app_get_color_bar(), 1)),
+ (get_config_color("ReplaceColor", "Color2",
+ colorbar_get_bg_color(app_get_colorbar())),
current_sprite->imgtype);
target_button = target_button_new(current_sprite->imgtype, FALSE);
@@ -171,7 +171,7 @@ static int button_1_select_hook(JWidget widget, int user_data)
{
JWidget w = user_data == 1 ? button_color1: button_color2;
- color_button_set_color(w, color_bar_get_color(app_get_color_bar(), 0));
+ color_button_set_color(w, colorbar_get_fg_color(app_get_colorbar()));
color_change_hook(w, user_data);
return TRUE;
@@ -181,7 +181,7 @@ static int button_2_select_hook(JWidget widget, int user_data)
{
JWidget w = user_data == 1 ? button_color1: button_color2;
- color_button_set_color(w, color_bar_get_color(app_get_color_bar(), 1));
+ color_button_set_color(w, colorbar_get_bg_color(app_get_colorbar()));
color_change_hook(w, user_data);
return TRUE;
@@ -192,7 +192,7 @@ static int color_change_hook(JWidget widget, int user_data)
char buf[64];
sprintf(buf, "Color%d", user_data);
- set_config_string("ReplaceColor", buf, color_button_get_color(widget));
+ set_config_color("ReplaceColor", buf, color_button_get_color(widget));
make_preview();
return FALSE;
@@ -222,16 +222,16 @@ static int preview_change_hook(JWidget widget, int user_data)
static void make_preview(void)
{
Effect *effect = preview_get_effect(preview);
- const char *from, *to;
+ color_t from, to;
int fuzziness;
- from = get_config_string("ReplaceColor", "Color1", "mask");
- to = get_config_string("ReplaceColor", "Color2", "mask");
+ from = get_config_color("ReplaceColor", "Color1", color_mask());
+ to = get_config_color("ReplaceColor", "Color2", color_mask());
fuzziness = get_config_int("ReplaceColor", "Fuzziness", 0);
set_replace_colors(get_color_for_image(effect->dst->imgtype, from),
- get_color_for_image(effect->dst->imgtype, to),
- MID(0, fuzziness, 255));
+ get_color_for_image(effect->dst->imgtype, to),
+ MID(0, fuzziness, 255));
if (jwidget_is_selected(check_preview))
preview_restart(preview);
diff --git a/src/core/app.c b/src/core/app.c
index 661989799..1e6243106 100644
--- a/src/core/app.c
+++ b/src/core/app.c
@@ -18,6 +18,7 @@
#include "config.h"
+#include
#include
/* #include */
#include
@@ -74,20 +75,22 @@ typedef struct Option
static char *exe_name; /* name of the program */
static JWidget top_window = NULL; /* top level window (the desktop) */
-static JWidget box_menu_bar = NULL; /* box where the menu bar is */
-static JWidget box_color_bar = NULL; /* box where the color bar is */
-static JWidget box_tool_bar = NULL; /* box where the tools bar is */
-static JWidget box_status_bar = NULL; /* box where the status bar is */
-static JWidget box_tabs_bar = NULL; /* box where the tabs bar is */
-static JWidget menu_bar = NULL; /* the menu bar widget */
-static JWidget status_bar = NULL; /* the status bar widget */
-static JWidget color_bar = NULL; /* the color bar widget */
-static JWidget tool_bar = NULL; /* the tool bar widget */
-static JWidget tabs_bar = NULL; /* the tabs bar widget */
+static JWidget box_menubar = NULL; /* box where the menu bar is */
+static JWidget box_colorbar = NULL; /* box where the color bar is */
+static JWidget box_toolbar = NULL; /* box where the tools bar is */
+static JWidget box_statusbar = NULL; /* box where the status bar is */
+static JWidget box_tabsbar = NULL; /* box where the tabs bar is */
+static JWidget menubar = NULL; /* the menu bar widget */
+static JWidget statusbar = NULL; /* the status bar widget */
+static JWidget colorbar = NULL; /* the color bar widget */
+static JWidget toolbar = NULL; /* the tool bar widget */
+static JWidget tabsbar = NULL; /* the tabs bar widget */
static JList options; /* list of "Option" structures (options to execute) */
static char *palette_filename = NULL;
+static void tabsbar_select_callback(JWidget tabs, void *data);
+
static int check_args(int argc, char *argv[]);
static void usage(int status);
@@ -186,48 +189,48 @@ void app_loop(void)
if (!top_window)
return;
- box_menu_bar = jwidget_find_name(top_window, "menu_bar");
+ box_menubar = jwidget_find_name(top_window, "menubar");
box_editors = jwidget_find_name(top_window, "editor");
- box_color_bar = jwidget_find_name(top_window, "color_bar");
- box_tool_bar = jwidget_find_name(top_window, "tool_bar");
- box_status_bar = jwidget_find_name(top_window, "status_bar");
- box_tabs_bar = jwidget_find_name(top_window, "tabs_bar");
+ box_colorbar = jwidget_find_name(top_window, "colorbar");
+ box_toolbar = jwidget_find_name(top_window, "toolbar");
+ box_statusbar = jwidget_find_name(top_window, "statusbar");
+ box_tabsbar = jwidget_find_name(top_window, "tabsbar");
- menu_bar = jmenubar_new();
- status_bar = status_bar_new();
- color_bar = color_bar_new(box_color_bar->align);
- tool_bar = tool_bar_new(box_tool_bar->align);
- tabs_bar = tabs_new(sprite_show);
+ menubar = jmenubar_new();
+ statusbar = statusbar_new();
+ colorbar = colorbar_new(box_colorbar->align);
+ toolbar = toolbar_new(box_toolbar->align);
+ tabsbar = tabs_new(tabsbar_select_callback);
view = editor_view_new();
editor = create_new_editor();
/* append the NULL sprite to the tabs */
- tabs_append_tab(tabs_bar, "Nothing", NULL);
+ tabs_append_tab(tabsbar, "Nothing", NULL);
/* configure all widgets to expansives */
- jwidget_expansive(menu_bar, TRUE);
- jwidget_expansive(status_bar, TRUE);
- jwidget_expansive(color_bar, TRUE);
- jwidget_expansive(tool_bar, TRUE);
- jwidget_expansive(tabs_bar, TRUE);
+ jwidget_expansive(menubar, TRUE);
+ jwidget_expansive(statusbar, TRUE);
+ jwidget_expansive(colorbar, TRUE);
+ jwidget_expansive(toolbar, TRUE);
+ jwidget_expansive(tabsbar, TRUE);
jwidget_expansive(view, TRUE);
/* prepare the first editor */
jview_attach(view, editor);
/* setup the menus */
- jmenubar_set_menu(menu_bar, get_root_menu());
+ jmenubar_set_menu(menubar, get_root_menu());
/* start text of status bar */
- app_default_status_bar_message();
+ app_default_statusbar_message();
/* add the widgets in the boxes */
- if (box_menu_bar) jwidget_add_child(box_menu_bar, menu_bar);
+ if (box_menubar) jwidget_add_child(box_menubar, menubar);
if (box_editors) jwidget_add_child(box_editors, view);
- if (box_color_bar) jwidget_add_child(box_color_bar, color_bar);
- if (box_tool_bar) jwidget_add_child(box_tool_bar, tool_bar);
- if (box_status_bar) jwidget_add_child(box_status_bar, status_bar);
- if (box_tabs_bar) jwidget_add_child(box_tabs_bar, tabs_bar);
+ if (box_colorbar) jwidget_add_child(box_colorbar, colorbar);
+ if (box_toolbar) jwidget_add_child(box_toolbar, toolbar);
+ if (box_statusbar) jwidget_add_child(box_statusbar, statusbar);
+ if (box_tabsbar) jwidget_add_child(box_tabsbar, tabsbar);
/* prepare the window */
jwindow_remap(top_window);
@@ -324,7 +327,7 @@ void app_loop(void)
/* remove the root-menu from the menu-bar (because the rootmenu
module should destroy it) */
- jmenubar_set_menu(menu_bar, NULL);
+ jmenubar_set_menu(menubar, NULL);
/* destroy the top-window */
jwidget_free(top_window);
@@ -379,7 +382,7 @@ void app_realloc_sprite_list(void)
/* insert all other sprites */
JI_LIST_FOR_EACH(get_sprite_list(), link) {
sprite = link->data;
- tabs_set_text_for_tab(tabs_bar,
+ tabs_set_text_for_tab(tabsbar,
get_filename(sprite->filename),
sprite);
}
@@ -444,16 +447,22 @@ int app_get_current_image_type(void)
}
JWidget app_get_top_window(void) { return top_window; }
-JWidget app_get_menu_bar(void) { return menu_bar; }
-JWidget app_get_status_bar(void) { return status_bar; }
-JWidget app_get_color_bar(void) { return color_bar; }
-JWidget app_get_tool_bar(void) { return tool_bar; }
-JWidget app_get_tabs_bar(void) { return tabs_bar; }
+JWidget app_get_menubar(void) { return menubar; }
+JWidget app_get_statusbar(void) { return statusbar; }
+JWidget app_get_colorbar(void) { return colorbar; }
+JWidget app_get_toolbar(void) { return toolbar; }
+JWidget app_get_tabsbar(void) { return tabsbar; }
-void app_default_status_bar_message(void)
+void app_default_statusbar_message(void)
{
- status_bar_set_text(app_get_status_bar(), 250,
- "ASE " VERSION ", " COPYRIGHT);
+ statusbar_set_text(app_get_statusbar(), 250,
+ "ASE " VERSION ", " COPYRIGHT);
+}
+
+static void tabsbar_select_callback(JWidget tabs, void *data)
+{
+ /* data can be NULL (the "Nothing" tab) */
+ sprite_show((Sprite *)data);
}
/* looks the inpunt arguments in the command line */
diff --git a/src/core/app.h b/src/core/app.h
index c5f674caa..b99565849 100644
--- a/src/core/app.h
+++ b/src/core/app.h
@@ -33,13 +33,13 @@ bool app_realloc_recent_list(void);
int app_get_current_image_type(void);
JWidget app_get_top_window(void);
-JWidget app_get_menu_bar(void);
-JWidget app_get_status_bar(void);
-JWidget app_get_color_bar(void);
-JWidget app_get_tool_bar(void);
-JWidget app_get_tabs_bar(void);
+JWidget app_get_menubar(void);
+JWidget app_get_statusbar(void);
+JWidget app_get_colorbar(void);
+JWidget app_get_toolbar(void);
+JWidget app_get_tabsbar(void);
-void app_default_status_bar_message(void);
+void app_default_statusbar_message(void);
#endif /* CORE_APP_H */
diff --git a/src/core/cfg.c b/src/core/cfg.c
index b86b86c07..44c02013a 100644
--- a/src/core/cfg.c
+++ b/src/core/cfg.c
@@ -91,6 +91,21 @@ void get_config_rect(const char *section, const char *name, JRect rect)
void set_config_rect(const char *section, const char *name, JRect rect)
{
char buf[128];
- usprintf(buf, "%d %d %d %d", rect->x1, rect->y1, rect->x2, rect->y2);
+ uszprintf(buf, sizeof(buf), "%d %d %d %d",
+ rect->x1, rect->y1, rect->x2, rect->y2);
+ set_config_string(section, name, buf);
+}
+
+color_t get_config_color(const char *section, const char *name, color_t value)
+{
+ char buf[128];
+ color_to_string(value, buf, sizeof(buf));
+ return string_to_color(get_config_string(section, name, buf));
+}
+
+void set_config_color(const char *section, const char *name, color_t value)
+{
+ char buf[128];
+ color_to_string(value, buf, sizeof(buf));
set_config_string(section, name, buf);
}
diff --git a/src/core/cfg.h b/src/core/cfg.h
index 3262233e6..f073eabed 100644
--- a/src/core/cfg.h
+++ b/src/core/cfg.h
@@ -22,6 +22,8 @@
#include
#include "jinete/jbase.h"
+#include "modules/color.h"
+
void ase_config_init(void);
void ase_config_exit(void);
@@ -31,4 +33,7 @@ void set_config_bool(const char *section, const char *name, bool value);
void get_config_rect(const char *section, const char *name, JRect rect);
void set_config_rect(const char *section, const char *name, JRect rect);
+color_t get_config_color(const char *section, const char *name, color_t value);
+void set_config_color(const char *section, const char *name, color_t value);
+
#endif /* CORE_CFG_H */
diff --git a/src/core/file_system.c b/src/core/file_system.c
index 8b6ac6005..19eaac828 100644
--- a/src/core/file_system.c
+++ b/src/core/file_system.c
@@ -96,7 +96,8 @@ struct FileItem
char *displayname;
FileItem *parent;
JList children;
- int last_update;
+ unsigned int version;
+ bool removed;
#ifdef USE_PIDLS
LPITEMIDLIST pidl; /* relative to parent */
LPITEMIDLIST fullpidl; /* relative to the Desktop folder
@@ -111,6 +112,7 @@ struct FileItem
/* the root of the file-system */
static FileItem *rootitem = NULL;
static HashTable *hash_fileitems = NULL;
+static unsigned int current_file_system_version = 0;
/* hash-table for thumbnails */
static HashTable *hash_thumbnail = NULL;
@@ -161,6 +163,8 @@ bool file_system_init(void)
SHGetDesktopFolder(&shl_idesktop);
#endif
+ ++current_file_system_version;
+
hash_fileitems = hash_new(512);
hash_thumbnail = hash_new(512);
get_root_fileitem();
@@ -192,6 +196,17 @@ void file_system_exit(void)
#endif
}
+/**
+ * Marks all FileItems as deprecated to be refresh the next time they
+ * are queried through @ref fileitem_get_children.
+ *
+ * @see fileitem_get_children
+ */
+void file_system_refresh(void)
+{
+ ++current_file_system_version;
+}
+
FileItem *get_root_fileitem(void)
{
FileItem *fileitem;
@@ -348,10 +363,26 @@ JList fileitem_get_children(FileItem *fileitem)
{
assert(fileitem != NULL);
- if (!fileitem->children && IS_FOLDER(fileitem)) {
- fileitem->children = jlist_new();
+ /* is the file-item a folder? */
+ if (IS_FOLDER(fileitem) &&
+ /* if the children list is empty, or the file-system version
+ change (it's like to say: the current fileitem->children list
+ is outdated)... */
+ (!fileitem->children || current_file_system_version > fileitem->version)) {
+ JLink link, next;
+ FileItem *child;
-/* printf("Loading files for %p (%s)\n", fileitem, fileitem->displayname); fflush(stdout); */
+ /* we have to rebuild the childre list */
+ if (!fileitem->children)
+ fileitem->children = jlist_new();
+ else {
+ JI_LIST_FOR_EACH_SAFE(fileitem->children, link, next) {
+ child = (FileItem *)link->data;
+ child->removed = TRUE;
+ }
+ }
+
+ /* printf("Loading files for %p (%s)\n", fileitem, fileitem->displayname); fflush(stdout); */
#ifdef USE_PIDLS
{
IShellFolder *pFolder = NULL;
@@ -393,7 +424,6 @@ JList fileitem_get_children(FileItem *fileitem)
/* generate the FileItems */
for (c=0; cfullpidl,
itempidl[c]);
@@ -442,6 +472,18 @@ JList fileitem_get_children(FileItem *fileitem)
(int)fileitem); /* TODO warning with 64bits */
}
#endif
+
+ /* check old file-items (maybe removed directories or file-items) */
+ JI_LIST_FOR_EACH_SAFE(fileitem->children, link, next) {
+ child = (FileItem *)link->data;
+ if (child->removed) {
+ jlist_delete_link(fileitem->children, link);
+ fileitem_free(child);
+ }
+ }
+
+ /* now this file-item is updated */
+ fileitem->version = current_file_system_version;
}
return fileitem->children;
@@ -504,7 +546,7 @@ static FileItem *fileitem_new(FileItem *parent)
fileitem->displayname = NULL;
fileitem->parent = parent;
fileitem->children = NULL;
- fileitem->last_update = -1;
+ fileitem->version = current_file_system_version;
#ifdef USE_PIDLS
fileitem->pidl = NULL;
fileitem->fullpidl = NULL;
@@ -533,12 +575,8 @@ static void fileitem_free(FileItem *fileitem)
}
#endif
- /* this isn't neccessary (if fileitem_free is called with the
- root-item at the first time)...
-
- if (fileitem->parent)
- jlist_remove(fileitem->parent->children, fileitem);
- */
+ if (fileitem->parent)
+ jlist_remove(fileitem->parent->children, fileitem);
if (fileitem->keyname)
jfree(fileitem->keyname);
@@ -564,6 +602,14 @@ static void fileitem_insert_child_sorted(FileItem *fileitem, FileItem *child)
{
JLink link;
bool inserted = FALSE;
+
+ /* this file-item wasn't removed from the last lookup */
+ child->removed = FALSE;
+
+ /* if the fileitem is already in the list we can go back */
+ if (jlist_find(fileitem->children, child) != fileitem->children->end)
+ return;
+
JI_LIST_FOR_EACH(fileitem->children, link) {
if (fileitem_cmp((FileItem *)link->data, child) > 0) {
jlist_insert_before(fileitem->children, link, child);
diff --git a/src/core/file_system.h b/src/core/file_system.h
index f1640747a..a6258d523 100644
--- a/src/core/file_system.h
+++ b/src/core/file_system.h
@@ -28,6 +28,8 @@ typedef struct FileItem FileItem;
bool file_system_init(void);
void file_system_exit(void);
+void file_system_refresh(void);
+
FileItem *get_root_fileitem(void);
FileItem *get_fileitem_from_path(const char *path);
diff --git a/src/dialogs/colsel.c b/src/dialogs/colsel.c
index 26db19ba9..44f68c762 100644
--- a/src/dialogs/colsel.c
+++ b/src/dialogs/colsel.c
@@ -39,29 +39,29 @@
static JWidget slider_R, slider_G, slider_B, slider_A;
static JWidget slider_H, slider_S, slider_V;
-static JWidget color_viewer;
+static JWidget colorviewer;
static JWidget palette_editor;
static int sliderRGB_change_signal(JWidget widget, int user_data);
static int sliderHSV_change_signal(JWidget widget, int user_data);
static int sliderA_change_signal(JWidget widget, int user_data);
-static int color_viewer_select_signal(JWidget widget, int user_data);
+static int colorviewer_select_signal(JWidget widget, int user_data);
static int palette_editor_change_signal(JWidget widget, int user_data);
static int window_resize_signal(JWidget widget, int user_data);
-char *ji_color_select(int imgtype, const char *color)
+bool ji_color_select(int imgtype, color_t *color)
{
- JWidget window, color_viewer_box, palette_editor_view, button_ok;
- char *selected_color;
+ JWidget window, colorviewer_box, palette_editor_view, button_ok;
char buf[256];
PALETTE palette;
+ bool ret = FALSE;
get_palette(palette);
/* get current palette */
window = load_widget("colsel.jid", "color_selection");
if (!window)
- return NULL;
+ return ret;
/* window title */
sprintf(buf, "%s (%s)", window->text,
@@ -80,18 +80,18 @@ char *ji_color_select(int imgtype, const char *color)
"saturation", &slider_S,
"value", &slider_V,
"button_ok", &button_ok,
- "color_viewer", &color_viewer_box,
+ "colorviewer", &colorviewer_box,
"palette_editor", &palette_editor_view, NULL)) {
jwidget_free(window);
- return NULL;
+ return ret;
}
- color_viewer = color_viewer_new(color, imgtype);
+ colorviewer = colorviewer_new(*color, imgtype);
palette_editor = palette_editor_new(palette, FALSE, 3);
palette_editor_set_columns(palette_editor, 32);
- jwidget_expansive(color_viewer, TRUE);
- jwidget_add_child(color_viewer_box, color_viewer);
+ jwidget_expansive(colorviewer, TRUE);
+ jwidget_add_child(colorviewer_box, colorviewer);
jview_attach(palette_editor_view, palette_editor);
jview_maxsize(palette_editor_view);
@@ -105,26 +105,26 @@ char *ji_color_select(int imgtype, const char *color)
HOOK(slider_H, JI_SIGNAL_SLIDER_CHANGE, sliderHSV_change_signal, 0);
HOOK(slider_S, JI_SIGNAL_SLIDER_CHANGE, sliderHSV_change_signal, 0);
HOOK(slider_V, JI_SIGNAL_SLIDER_CHANGE, sliderHSV_change_signal, 0);
- HOOK(color_viewer, SIGNAL_COLOR_VIEWER_SELECT, color_viewer_select_signal, 0);
+ HOOK(colorviewer, SIGNAL_COLORVIEWER_SELECT, colorviewer_select_signal, 0);
HOOK(palette_editor, SIGNAL_PALETTE_EDITOR_CHANGE, palette_editor_change_signal, 0);
HOOK(window, JI_SIGNAL_WINDOW_RESIZE, window_resize_signal, palette_editor);
/* initial values */
- switch (color_type(color)) {
+ switch (color_type(*color)) {
case COLOR_TYPE_MASK:
- color_viewer_select_signal(NULL, 0);
+ colorviewer_select_signal(NULL, 0);
break;
case COLOR_TYPE_RGB:
case COLOR_TYPE_GRAY:
- jslider_set_value(slider_R, color_get_red(imgtype, color));
- jslider_set_value(slider_G, color_get_green(imgtype, color));
- jslider_set_value(slider_B, color_get_blue(imgtype, color));
- jslider_set_value(slider_A, color_get_alpha(imgtype, color));
+ jslider_set_value(slider_R, color_get_red(imgtype, *color));
+ jslider_set_value(slider_G, color_get_green(imgtype, *color));
+ jslider_set_value(slider_B, color_get_blue(imgtype, *color));
+ jslider_set_value(slider_A, color_get_alpha(imgtype, *color));
sliderRGB_change_signal(NULL, 0);
break;
case COLOR_TYPE_INDEX:
- palette_editor_select_color(palette_editor, color_get_index(imgtype, color));
- palette_editor_change_signal(NULL, color_get_index(imgtype, color));
+ palette_editor_select_color(palette_editor, color_get_index(imgtype, *color));
+ palette_editor_change_signal(NULL, color_get_index(imgtype, *color));
break;
}
@@ -157,12 +157,8 @@ char *ji_color_select(int imgtype, const char *color)
/* check the killer widget */
if (jwindow_get_killer(window) == button_ok) {
/* selected color */
- selected_color = jstrdup(color_viewer_get_color(color_viewer));
- }
- /* cancel or ESC */
- else {
- /* selected color */
- selected_color = NULL;
+ *color = colorviewer_get_color(colorviewer);
+ ret = TRUE;
}
/* save window configuration */
@@ -170,18 +166,18 @@ char *ji_color_select(int imgtype, const char *color)
jwidget_free(window);
- return selected_color;
+ return ret;
}
static int sliderRGB_change_signal(JWidget widget, int user_data)
{
- int imgtype = color_viewer_get_imgtype(color_viewer);
+ int imgtype = colorviewer_get_imgtype(colorviewer);
int r = jslider_get_value(slider_R);
int g = jslider_get_value(slider_G);
int b = jslider_get_value(slider_B);
int a = jslider_get_value(slider_A);
float h, s, v;
- char *color;
+ color_t color;
rgb_to_hsv(r, g, b, &h, &s, &v);
@@ -199,21 +195,19 @@ static int sliderRGB_change_signal(JWidget widget, int user_data)
palette_editor_select_color(palette_editor, -1);
}
- color_viewer_set_color(color_viewer, color);
- jfree(color);
-
+ colorviewer_set_color(colorviewer, color);
return FALSE;
}
static int sliderHSV_change_signal(JWidget widget, int user_data)
{
- int imgtype = color_viewer_get_imgtype(color_viewer);
+ int imgtype = colorviewer_get_imgtype(colorviewer);
int h = jslider_get_value(slider_H);
int s = jslider_get_value(slider_S);
int v = jslider_get_value(slider_V);
int a = jslider_get_value(slider_A);
int r, g, b;
- char *color;
+ color_t color;
hsv_to_rgb(360.0 * h / 255.0, s / 255.0, v / 255.0, &r, &g, &b);
@@ -231,22 +225,20 @@ static int sliderHSV_change_signal(JWidget widget, int user_data)
palette_editor_select_color(palette_editor, -1);
}
- color_viewer_set_color(color_viewer, color);
- jfree(color);
-
+ colorviewer_set_color(colorviewer, color);
return FALSE;
}
static int sliderA_change_signal(JWidget widget, int user_data)
{
- const char *input_color = color_viewer_get_color(color_viewer);
- int imgtype = color_viewer_get_imgtype(color_viewer);
+ color_t input_color = colorviewer_get_color(colorviewer);
+ int imgtype = colorviewer_get_imgtype(colorviewer);
int r = color_get_red(imgtype, input_color);
int g = color_get_green(imgtype, input_color);
int b = color_get_blue(imgtype, input_color);
int a = jslider_get_value(slider_A);
int type = color_type(input_color);
- char *color = NULL;
+ color_t color;
switch (type) {
case COLOR_TYPE_MASK:
@@ -267,18 +259,14 @@ static int sliderA_change_signal(JWidget widget, int user_data)
break;
}
- if (color) {
- color_viewer_set_color(color_viewer, color);
- jfree(color);
- }
-
+ colorviewer_set_color(colorviewer, color);
return FALSE;
}
-static int color_viewer_select_signal(JWidget widget, int user_data)
+static int colorviewer_select_signal(JWidget widget, int user_data)
{
- int imgtype = color_viewer_get_imgtype(color_viewer);
- char *color = color_mask();
+ int imgtype = colorviewer_get_imgtype(colorviewer);
+ color_t color = color_mask();
int r = color_get_red(imgtype, color);
int g = color_get_green(imgtype, color);
int b = color_get_blue(imgtype, color);
@@ -286,7 +274,7 @@ static int color_viewer_select_signal(JWidget widget, int user_data)
rgb_to_hsv(r, g, b, &h, &s, &v);
- color_viewer_set_color(color_viewer, color);
+ colorviewer_set_color(colorviewer, color);
jslider_set_value(slider_R, r);
jslider_set_value(slider_G, g);
@@ -304,15 +292,14 @@ static int color_viewer_select_signal(JWidget widget, int user_data)
palette_editor_select_color(palette_editor, -1);
}
- jfree(color);
return FALSE;
}
static int palette_editor_change_signal(JWidget widget, int user_data)
{
PaletteEditor *paledit = palette_editor_data(palette_editor);
- int imgtype = color_viewer_get_imgtype(color_viewer);
- char *color = color_index(paledit->color[1]);
+ int imgtype = colorviewer_get_imgtype(colorviewer);
+ color_t color = color_index(paledit->color[1]);
int r = color_get_red(imgtype, color);
int g = color_get_green(imgtype, color);
int b = color_get_blue(imgtype, color);
@@ -320,7 +307,7 @@ static int palette_editor_change_signal(JWidget widget, int user_data)
rgb_to_hsv(r, g, b, &h, &s, &v);
- color_viewer_set_color(color_viewer, color);
+ colorviewer_set_color(colorviewer, color);
jslider_set_value(slider_R, r);
jslider_set_value(slider_G, g);
@@ -329,8 +316,6 @@ static int palette_editor_change_signal(JWidget widget, int user_data)
jslider_set_value(slider_H, 255.0 * h / 360.0);
jslider_set_value(slider_V, 255.0 * v);
jslider_set_value(slider_S, 255.0 * s);
-
- jfree(color);
return FALSE;
}
diff --git a/src/dialogs/colsel.h b/src/dialogs/colsel.h
index 3bcab35b2..26e6375e3 100644
--- a/src/dialogs/colsel.h
+++ b/src/dialogs/colsel.h
@@ -19,7 +19,9 @@
#ifndef DIALOGS_COLSEL_H
#define DIALOGS_COLSEL_H
-char *ji_color_select(int imgtype, const char *color);
+#include "modules/color.h"
+
+bool ji_color_select(int imgtype, color_t *color);
#endif /* DIALOGS_COLSEL_H */
diff --git a/src/dialogs/dmapgen.c b/src/dialogs/dmapgen.c
deleted file mode 100644
index da3fdf62e..000000000
--- a/src/dialogs/dmapgen.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/* ASE - Allegro Sprite Editor
- * Copyright (C) 2001-2008 David A. Capello
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "config.h"
-
-#include
-#include
-#include
-#include
-#include
-
-#include "jinete/jinete.h"
-#include "jinete/jintern.h"
-
-#include "console/console.h"
-#include "core/cfg.h"
-#include "core/dirs.h"
-#include "modules/gui.h"
-#include "modules/palette.h"
-#include "modules/sprites.h"
-#include "raster/image.h"
-#include "raster/sprite.h"
-#include "script/import.h"
-#include "util/mapgen.h"
-#include "util/misc.h"
-
-#ifndef M_SQRT2
-#define M_SQRT2 1.41421356237309504880
-#endif
-
-static JWidget entry_width, entry_height, entry_seed, entry_factor;
-static JWidget preview_map, check_preview;
-
-static void regen_map(int forced);
-static void random_seed_command(JWidget widget);
-static void sqrt2_factor_command(JWidget widget);
-static int change_hook(JWidget widget, int user_data);
-
-static JWidget image_viewer_new(Image *image);
-static bool image_viewer_msg_proc(JWidget widget, JMessage msg);
-
-void dialogs_mapgen(void)
-{
- JWidget window, view_map, check_tiled, button_ok;
- Sprite *sprite, *old_sprite = current_sprite;
- PALETTE old_palette;
- RGB *new_palette = NULL;
- double factor;
- char buf[256];
- int w, h, seed;
-
- window = load_widget("mapgen.jid", "mapgen");
- if (!window)
- return;
-
- if (!get_widgets (window,
- "mapview", &view_map,
- "width", &entry_width,
- "height", &entry_height,
- "seed", &entry_seed,
- "fractal_factor", &entry_factor,
- "preview", &check_preview,
- "tiled", &check_tiled,
- "button_ok", &button_ok, NULL)) {
- jwidget_free(window);
- return;
- }
-
- /* get current palette */
- palette_copy(old_palette, current_palette);
-
- /* load terrain palette */
- {
- DIRS *dir, *dirs = filename_in_datadir("palettes/terrain1.col");
- for (dir=dirs; dir; dir=dir->next) {
- new_palette = palette_load(dir->path);
- if (new_palette)
- break;
- }
- dirs_free(dirs);
- }
-
- sprite = sprite_new_with_layer(IMAGE_INDEXED, 256, 256);
- set_current_sprite(sprite);
-
- preview_map = image_viewer_new(GetImage(current_sprite));
-
- /* set palette */
- if (new_palette)
- sprite_set_palette(sprite, new_palette, 0);
- set_current_palette(sprite_get_palette(sprite, 0), FALSE);
- jmanager_refresh_screen();
-
- w = get_config_int("MapGen", "Width", 256);
- sprintf(buf, "%d", MID(1, w, 9999));
- jwidget_set_text(entry_width, buf);
-
- h = get_config_int("MapGen", "Height", 256);
- sprintf(buf, "%d", MID(1, h, 9999));
- jwidget_set_text(entry_height, buf);
-
- seed = get_config_int("MapGen", "Seed", 662355502);
- sprintf(buf, "%d", seed);
- jwidget_set_text(entry_seed, buf);
-
- factor = get_config_float("MapGen", "FractalFactor", M_SQRT2);
- sprintf(buf, "%.16g", factor);
- jwidget_set_text(entry_factor, buf);
-
- if (get_config_bool("MapGen", "Preview", TRUE))
- jwidget_select(check_preview);
-
- jwidget_select(check_tiled);
- jwidget_disable(check_tiled);
-
- HOOK(check_preview, JI_SIGNAL_CHECK_CHANGE, change_hook, 0);
- HOOK(entry_seed, JI_SIGNAL_ENTRY_CHANGE, change_hook, 0);
- HOOK(entry_factor, JI_SIGNAL_ENTRY_CHANGE, change_hook, 0);
-
- jbutton_add_command(jwidget_find_name(window, "random_seed"),
- random_seed_command);
- jbutton_add_command(jwidget_find_name(window, "sqrt2_factor"),
- sqrt2_factor_command);
-
- jview_attach(view_map, preview_map);
-
- /* default position */
- jwindow_remap(window);
- jwindow_center(window);
-
- /* load window configuration */
- load_window_pos(window, "MapGen");
-
- /* open the window */
- regen_map(FALSE);
- jwindow_open_fg(window);
-
- if (jwindow_get_killer(window) == button_ok) {
- /* generate the map */
- regen_map(TRUE);
-
- /* show the sprite */
- sprite_show(sprite);
- }
- else {
- set_current_sprite(old_sprite);
- set_current_palette(old_palette, FALSE);
- jmanager_refresh_screen();
-
- sprite_free(sprite);
- }
-
- /* save window configuration */
- save_window_pos(window, "MapGen");
-
- jwidget_free(window);
-}
-
-static void regen_map(int forced)
-{
- int w, h, seed;
- double factor;
-
- if (forced || jwidget_is_selected(check_preview)) {
- w = strtol(jwidget_get_text(entry_width), NULL, 10);
- h = strtol(jwidget_get_text(entry_height), NULL, 10);
- seed = strtol(jwidget_get_text(entry_seed), NULL, 10);
- factor = strtod(jwidget_get_text(entry_factor), NULL);
-
- if (forced) {
- set_config_int("MapGen", "Width", w);
- set_config_int("MapGen", "Height", h);
- set_config_int("MapGen", "Seed", seed);
- set_config_float("MapGen", "FractalFactor", factor);
- }
-
- /* generate the map */
- mapgen(GetImage(current_sprite), seed, factor);
- jwidget_dirty(preview_map);
- }
-}
-
-static void random_seed_command(JWidget widget)
-{
- char buf[256];
- sprintf(buf, "%d", rand());
- jwidget_set_text(entry_seed, buf);
- regen_map(FALSE);
-}
-
-static void sqrt2_factor_command(JWidget widget)
-{
- char buf[256];
- sprintf(buf, "%.16g", M_SQRT2);
- jwidget_set_text(entry_factor, buf);
- regen_map(FALSE);
-}
-
-static int change_hook(JWidget widget, int user_data)
-{
- regen_map(FALSE);
- return FALSE;
-}
-
-/**********************************************************************/
-/* image viewer (simple preview) */
-
-static JWidget image_viewer_new(Image *image)
-{
- JWidget widget = jwidget_new(JI_WIDGET);
- jwidget_add_hook(widget, JI_WIDGET, image_viewer_msg_proc, NULL);
- widget->user_data[0] = image;
- return widget;
-}
-
-static bool image_viewer_msg_proc(JWidget widget, JMessage msg)
-{
- Image *image = widget->user_data[0];
-
- switch (msg->type) {
-
- case JM_REQSIZE:
- msg->reqsize.w = image->w;
- msg->reqsize.h = image->h;
- return TRUE;
-
- case JM_DRAW: {
- BITMAP *bmp = create_bitmap(image->w, image->h);
- image_to_allegro(image, bmp, 0, 0);
-
- _ji_theme_rectfill_exclude
- (ji_screen,
- widget->rc->x1, widget->rc->y1,
- widget->rc->x2-1, widget->rc->y2-1,
- widget->rc->x1, widget->rc->y1,
- widget->rc->x1+bmp->w-1,
- widget->rc->y1+bmp->h-1, jwidget_get_bg_color(widget));
-
- blit(bmp, ji_screen,
- 0, 0, widget->rc->x1, widget->rc->y1, bmp->w, bmp->h);
- destroy_bitmap(bmp);
- return TRUE;
- }
-
- case JM_BUTTONPRESSED: {
- JWidget view = jwidget_get_view(widget);
- if (view) {
- jwidget_hard_capture_mouse(widget);
- jmouse_set_cursor(JI_CURSOR_MOVE);
- return TRUE;
- }
- break;
- }
-
- case JM_MOTION: {
- JWidget view = jwidget_get_view(widget);
- if (view && jwidget_has_capture(widget)) {
- JRect vp = jview_get_viewport_position(view);
- int scroll_x, scroll_y;
-
- jview_get_scroll(view, &scroll_x, &scroll_y);
- jview_set_scroll(view,
- scroll_x + jmouse_x(1) - jmouse_x(0),
- scroll_y + jmouse_y(1) - jmouse_y(0));
-
- jmouse_control_infinite_scroll(vp);
- jrect_free(vp);
- }
- break;
- }
-
- case JM_BUTTONRELEASED: {
- JWidget view = jwidget_get_view(widget);
- if (view && jwidget_has_capture(widget)) {
- jwidget_release_mouse(widget);
- jmouse_set_cursor(JI_CURSOR_NORMAL);
- return TRUE;
- }
- break;
- }
- }
-
- return FALSE;
-}
diff --git a/src/dialogs/dmapgen.h b/src/dialogs/dmapgen.h
deleted file mode 100644
index 1c5e72729..000000000
--- a/src/dialogs/dmapgen.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ASE - Allegro Sprite Editor
- * Copyright (C) 2001-2008 David A. Capello
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef DIALOGS_DMAPGEN_H
-#define DIALOGS_DMAPGEN_H
-
-void dialogs_mapgen(void);
-
-#endif /* DIALOGS_DMAPGEN_H */
-
diff --git a/src/dialogs/dpaledit.c b/src/dialogs/dpaledit.c
index 3969f3bb1..593977ac0 100644
--- a/src/dialogs/dpaledit.c
+++ b/src/dialogs/dpaledit.c
@@ -41,7 +41,7 @@ static PALETTE *palettes;
static JWidget slider_R, slider_G, slider_B;
static JWidget slider_H, slider_S, slider_V;
-static JWidget color_viewer;
+static JWidget colorviewer;
static JWidget palette_editor;
static JWidget slider_frame;
@@ -61,7 +61,7 @@ static void set_new_palette(RGB *palette);
void dialogs_palette_editor(void)
{
- JWidget window, color_viewer_box, palette_editor_view;
+ JWidget window, colorviewer_box, palette_editor_view;
JWidget slider_columns, button_ok;
JWidget button_select_all;
JWidget button_undo, button_redo;
@@ -99,7 +99,7 @@ void dialogs_palette_editor(void)
"ramp", &button_ramp,
"quantize", &button_quantize,
"button_ok", &button_ok,
- "color_viewer", &color_viewer_box,
+ "colorviewer", &colorviewer_box,
"palette_editor", &palette_editor_view, NULL)) {
jwidget_free(window);
return;
@@ -127,11 +127,11 @@ void dialogs_palette_editor(void)
columns = MID(1, columns, 256);
/* custom widgets */
- color_viewer = color_viewer_new("index{0}", IMAGE_INDEXED);
+ colorviewer = colorviewer_new(color_index(0), IMAGE_INDEXED);
palette_editor = palette_editor_new(palette, TRUE, 6);
- jwidget_expansive(color_viewer, TRUE);
- jwidget_add_child(color_viewer_box, color_viewer);
+ jwidget_expansive(colorviewer, TRUE);
+ jwidget_add_child(colorviewer_box, colorviewer);
jwidget_disable(button_undo);
jwidget_disable(button_redo);
@@ -416,8 +416,8 @@ static int slider_frame_change_signal(JWidget widget, int user_data)
static int palette_editor_change_signal(JWidget widget, int user_data)
{
PaletteEditor *paledit = palette_editor_data(palette_editor);
- int imgtype = color_viewer_get_imgtype(color_viewer);
- char *color = color_index(paledit->color[1]);
+ int imgtype = colorviewer_get_imgtype(colorviewer);
+ color_t color = color_index(paledit->color[1]);
int r = color_get_red(imgtype, color);
int g = color_get_green(imgtype, color);
int b = color_get_blue(imgtype, color);
@@ -425,7 +425,7 @@ static int palette_editor_change_signal(JWidget widget, int user_data)
rgb_to_hsv(r, g, b, &h, &s, &v);
- color_viewer_set_color(color_viewer, color);
+ colorviewer_set_color(colorviewer, color);
jslider_set_value(slider_R, r);
jslider_set_value(slider_G, g);
@@ -433,8 +433,6 @@ static int palette_editor_change_signal(JWidget widget, int user_data)
jslider_set_value(slider_H, 255.0 * h / 360.0);
jslider_set_value(slider_V, 255.0 * v);
jslider_set_value(slider_S, 255.0 * s);
-
- jfree(color);
return FALSE;
}
diff --git a/src/dialogs/drawtext.c b/src/dialogs/drawtext.c
index af820aa5a..c70c3264d 100644
--- a/src/dialogs/drawtext.c
+++ b/src/dialogs/drawtext.c
@@ -82,8 +82,8 @@ void dialogs_draw_text(void)
/* color button */
color_but = color_button_new
- (get_config_string("DrawText", "Color",
- color_bar_get_color(app_get_color_bar(), 0)),
+ (get_config_color("DrawText", "Color",
+ colorbar_get_fg_color(app_get_colorbar())),
current_sprite->imgtype);
jwidget_add_child(color_box, color_but);
@@ -100,12 +100,12 @@ void dialogs_draw_text(void)
jwindow_open_fg(window);
if (jwindow_get_killer(window) == button_ok) {
+ color_t color_with_type = color_button_get_color(color_but);
const char *text = jwidget_get_text(entry_text);
- const char *color_str = color_button_get_color(color_but);
const char *size_str = jwidget_get_text(entry_size);
const char *font_str = get_config_string("DrawText", "Font",
"allegro.pcx");
- int color, rgb_color;
+ int color;
int size;
FONT *f;
@@ -126,11 +126,11 @@ void dialogs_draw_text(void)
ji_font_set_size(f, size);
/* setup color */
- color = get_color_for_image(current_sprite->imgtype, color_str);
- rgb_color = get_color_for_image(IMAGE_RGB, color_str);
+ color = get_color_for_image(current_sprite->imgtype,
+ color_with_type);
/* update configuration */
- set_config_string("DrawText", "Color", color_str);
+ set_config_color("DrawText", "Color", color_with_type);
set_config_string("DrawText", "Text", text);
set_config_int("DrawText", "Size", size);
@@ -222,7 +222,7 @@ static Image *render_text(FONT *f, const char *text, int color)
break;
case IMAGE_GRAYSCALE:
- DO(ase_uint16, _graya(_graya_getk(color), getg32(c)));
+ DO(ase_uint16, _graya(_graya_getv(color), getg32(c)));
break;
case IMAGE_INDEXED:
diff --git a/src/dialogs/filesel.c b/src/dialogs/filesel.c
index 0c9944a0f..d06983548 100644
--- a/src/dialogs/filesel.c
+++ b/src/dialogs/filesel.c
@@ -81,6 +81,8 @@ char *ase_file_selector(const char *message,
char *result = NULL;
char *tok;
+ file_system_refresh();
+
if (!navigation_history)
navigation_history = jlist_new();
diff --git a/src/dialogs/filmedit.c b/src/dialogs/filmedit.c
index 1b1872e11..b55ab7a9f 100644
--- a/src/dialogs/filmedit.c
+++ b/src/dialogs/filmedit.c
@@ -352,7 +352,7 @@ static bool layer_box_msg_proc(JWidget widget, JMessage msg)
return TRUE;
}
- case JM_CHAR: {
+ case JM_KEYPRESSED: {
Command *command = command_get_by_key(msg);
/* close film editor */
@@ -666,9 +666,9 @@ static bool cel_box_msg_proc(JWidget widget, JMessage msg)
x2 = x1+THUMBSIZE-1;
y2 = y1+THUMBSIZE-1;
- _ji_theme_rectedge(bmp, x1-1, y1-1, x2+1, y2+1,
- makecol(128, 128, 128),
- makecol(196, 196, 196));
+ jrectedge(bmp, x1-1, y1-1, x2+1, y2+1,
+ makecol(128, 128, 128),
+ makecol(196, 196, 196));
if (thumbnail)
draw_sprite(bmp, thumbnail, x1, y1);
diff --git a/src/dialogs/maskcol.c b/src/dialogs/maskcol.c
index acefec52e..d0a3fdf1e 100644
--- a/src/dialogs/maskcol.c
+++ b/src/dialogs/maskcol.c
@@ -75,8 +75,8 @@ void dialogs_mask_color(void)
box4 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
label_color = jlabel_new(_("Color:"));
button_color = color_button_new
- (get_config_string("MaskColor", "Color",
- color_bar_get_color(app_get_color_bar(), 0)),
+ (get_config_color("MaskColor", "Color",
+ colorbar_get_fg_color(app_get_colorbar())),
sprite->imgtype);
button_1 = jbutton_new("1");
button_2 = jbutton_new("2");
@@ -103,10 +103,10 @@ void dialogs_mask_color(void)
jwidget_expansive(box2, TRUE);
jwidget_add_child(window, box1);
- jwidget_add_childs(box1, box2, box3, check_preview, box4, NULL);
- jwidget_add_childs(box2, label_color, button_color, button_1, button_2, NULL);
- jwidget_add_childs(box3, label_fuzziness, slider_fuzziness, NULL);
- jwidget_add_childs(box4, button_ok, button_cancel, NULL);
+ jwidget_add_children(box1, box2, box3, check_preview, box4, NULL);
+ jwidget_add_children(box2, label_color, button_color, button_1, button_2, NULL);
+ jwidget_add_children(box3, label_fuzziness, slider_fuzziness, NULL);
+ jwidget_add_children(box4, button_ok, button_cancel, NULL);
/* default position */
jwindow_remap(window);
@@ -133,8 +133,8 @@ void dialogs_mask_color(void)
sprite_set_mask(sprite, mask);
mask_free(mask);
- set_config_string("MaskColor", "Color",
- color_button_get_color(button_color));
+ set_config_color("MaskColor", "Color",
+ color_button_get_color(button_color));
set_config_int("MaskColor", "Fuzziness",
jslider_get_value(slider_fuzziness));
@@ -156,14 +156,14 @@ void dialogs_mask_color(void)
static void button_1_command(JWidget widget)
{
color_button_set_color(button_color,
- color_bar_get_color(app_get_color_bar(), 0));
+ colorbar_get_fg_color(app_get_colorbar()));
mask_preview();
}
static void button_2_command(JWidget widget)
{
color_button_set_color(button_color,
- color_bar_get_color(app_get_color_bar(), 1));
+ colorbar_get_bg_color(app_get_colorbar()));
mask_preview();
}
@@ -188,16 +188,15 @@ static int preview_change_hook(JWidget widget, int user_data)
static Mask *gen_mask(void)
{
int xpos, ypos, color, fuzziness;
- const char *color_text;
Sprite *sprite;
Image *image;
Mask *mask;
sprite = current_sprite;
- image = GetImage2 (sprite, &xpos, &ypos, NULL);
+ image = GetImage2(sprite, &xpos, &ypos, NULL);
- color_text = color_button_get_color(button_color);
- color = get_color_for_image(sprite->imgtype, color_text);
+ color = get_color_for_image(sprite->imgtype,
+ color_button_get_color(button_color));
fuzziness = jslider_get_value(slider_fuzziness);
mask = mask_new();
diff --git a/src/dialogs/minipal.c b/src/dialogs/minipal.c
index eca8c1187..18914ade8 100644
--- a/src/dialogs/minipal.c
+++ b/src/dialogs/minipal.c
@@ -53,20 +53,14 @@ static int paledit_change_signal(JWidget widget, int user_data)
{
if (jmouse_b(0)) {
PaletteEditor *paledit = palette_editor_data(widget);
- JWidget color_bar = (JWidget)user_data;
+ JWidget colorbar = (JWidget)user_data;
if (paledit->color[0] == paledit->color[1]) {
- char *color = color_index(paledit->color[1]);
-
- color_bar_set_color(color_bar,
- jmouse_b(0) == 1 ? 0: 1,
- color, FALSE);
-
- jfree(color);
+ color_t color = color_index(paledit->color[1]);
+ colorbar_set_fg_color(colorbar, color);
}
else {
bool array[256];
- char buf[256];
int c, sel;
palette_editor_get_selected_entries(widget, array);
@@ -74,12 +68,12 @@ static int paledit_change_signal(JWidget widget, int user_data)
if (array[c])
sel++;
- color_bar_set_size(color_bar, sel);
+ colorbar_set_size(colorbar, sel);
for (c=sel=0; c<256; c++) {
if (array[c]) {
- sprintf(buf, "index{%d}", c);
- color_bar_set_color_directly(color_bar, sel++, buf);
+ colorbar_set_color(colorbar, sel++,
+ color_index(c));
}
}
}
diff --git a/src/dialogs/quick.c b/src/dialogs/quick.c
index 0a114dece..a8be9191d 100644
--- a/src/dialogs/quick.c
+++ b/src/dialogs/quick.c
@@ -95,7 +95,7 @@ static void do_quick(int action)
if (action == ACTION_MOVE) {
int enabled = undo_is_enabled(sprite->undo);
undo_disable(sprite->undo);
- ClearMask(color_bar_get_color(app_get_color_bar(), 1));
+ ClearMask(color_mask());
if (enabled)
undo_enable(sprite->undo);
}
diff --git a/src/effect/colcurve.c b/src/effect/colcurve.c
index 36b08710a..bdfa3346a 100644
--- a/src/effect/colcurve.c
+++ b/src/effect/colcurve.c
@@ -317,7 +317,7 @@ void apply_color_curve2 (Effect *effect)
c = *(src_address++);
- k = _graya_getk(c);
+ k = _graya_getv(c);
a = _graya_geta(c);
if (effect->target.k) k = data.cmap[k];
diff --git a/src/effect/convmatr.c b/src/effect/convmatr.c
index c83ee15dc..966c81b3e 100644
--- a/src/effect/convmatr.c
+++ b/src/effect/convmatr.c
@@ -432,7 +432,7 @@ void apply_convolution_matrix2(Effect *effect)
if (_graya_geta(color) == 0)
div -= *mdata;
else {
- k += _graya_getk(color) * (*mdata);
+ k += _graya_getv(color) * (*mdata);
a += _graya_geta(color) * (*mdata);
}
);
@@ -442,7 +442,7 @@ void apply_convolution_matrix2(Effect *effect)
k = MID(0, k, 255);
}
else
- k = _graya_getk(color);
+ k = _graya_getv(color);
if (effect->target.a) {
a = a / matrix->div + matrix->bias;
diff --git a/src/effect/invrtcol.c b/src/effect/invrtcol.c
index 88b764ce1..13c7a7c7a 100644
--- a/src/effect/invrtcol.c
+++ b/src/effect/invrtcol.c
@@ -82,7 +82,7 @@ void apply_invert_color2(Effect *effect)
c = *(src_address++);
- k = _graya_getk(c);
+ k = _graya_getv(c);
a = _graya_geta(c);
if (effect->target.k) k ^= 0xff;
diff --git a/src/effect/median.c b/src/effect/median.c
index 59a13a28c..e06774c64 100644
--- a/src/effect/median.c
+++ b/src/effect/median.c
@@ -152,7 +152,7 @@ void apply_median2(Effect *effect)
GET_MATRIX_DATA
(ase_uint16, data.w, data.h, data.w/2, data.h/2,
color = *src_address;
- data.channel[0][c] = _graya_getk(color);
+ data.channel[0][c] = _graya_getv(color);
data.channel[1][c] = _graya_geta(color);
c++;
);
@@ -165,7 +165,7 @@ void apply_median2(Effect *effect)
if (effect->target.k)
k = data.channel[0][data.ncolors/2];
else
- k = _graya_getk(color);
+ k = _graya_getv(color);
if (effect->target.a)
a = data.channel[1][data.ncolors/2];
diff --git a/src/effect/replcol.c b/src/effect/replcol.c
index 6333b1e1f..04e037fb3 100644
--- a/src/effect/replcol.c
+++ b/src/effect/replcol.c
@@ -90,7 +90,7 @@ void apply_replace_color2(Effect *effect)
src_address = ((ase_uint16 **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((ase_uint16 **)effect->dst->line)[effect->row+effect->y]+effect->x;
- dst_k = _graya_getk(data.from);
+ dst_k = _graya_getv(data.from);
dst_a = _graya_geta(data.from);
for (x=0; xw; x++) {
@@ -107,7 +107,7 @@ void apply_replace_color2(Effect *effect)
c = *(src_address++);
- src_k = _graya_getk(c);
+ src_k = _graya_getv(c);
src_a = _graya_geta(c);
if ((src_k >= dst_k-data.fuzziness) && (src_k <= dst_k+data.fuzziness) &&
diff --git a/src/file/ase_format.c b/src/file/ase_format.c
index e38c9affe..e51e95d1a 100644
--- a/src/file/ase_format.c
+++ b/src/file/ase_format.c
@@ -398,7 +398,7 @@ static void ase_file_prepare_header(FILE *f, ASE_Header *header, Sprite *sprite)
header->bgcolor[3] = _rgba_geta(sprite->bgcolor);
break;
case IMAGE_GRAYSCALE:
- header->bgcolor[0] = _graya_getk(sprite->bgcolor);
+ header->bgcolor[0] = _graya_getv(sprite->bgcolor);
header->bgcolor[1] = _graya_geta(sprite->bgcolor);
break;
case IMAGE_INDEXED:
@@ -864,7 +864,7 @@ static void ase_file_write_cel_chunk(FILE *f, Cel *cel, Layer *layer, Sprite *sp
for (y=0; yh; y++) {
for (x=0; xw; x++) {
c = image->method->getpixel(image, x, y);
- fputc(_graya_getk(c), f);
+ fputc(_graya_getv(c), f);
fputc(_graya_geta(c), f);
}
}
diff --git a/src/file/bmp_format.c b/src/file/bmp_format.c
index 438259733..c7000ef9b 100644
--- a/src/file/bmp_format.c
+++ b/src/file/bmp_format.c
@@ -694,7 +694,7 @@ static bool save_BMP(FileOp *fop)
if (image->imgtype == IMAGE_INDEXED)
fputc(image->method->getpixel(image, j, i), f);
else if (image->imgtype == IMAGE_GRAYSCALE)
- fputc(_graya_getk(image->method->getpixel(image, j, i)), f);
+ fputc(_graya_getv(image->method->getpixel(image, j, i)), f);
}
else {
c = image->method->getpixel(image, j, i);
diff --git a/src/file/jpeg_format.c b/src/file/jpeg_format.c
index 33a1fa54a..7805f9cc4 100644
--- a/src/file/jpeg_format.c
+++ b/src/file/jpeg_format.c
@@ -329,7 +329,7 @@ static bool save_JPEG(FileOp *fop)
src_address = ((ase_uint16 **)image->line)[cinfo.next_scanline+y];
dst_address = ((ase_uint8 **)buffer)[y];
for (x=0; xw; x++)
- *(dst_address++) = _graya_getk(*(src_address++));
+ *(dst_address++) = _graya_getv(*(src_address++));
}
}
jpeg_write_scanlines(&cinfo, buffer, buffer_height);
diff --git a/src/file/pcx_format.c b/src/file/pcx_format.c
index e486e1eb7..821cb21d7 100644
--- a/src/file/pcx_format.c
+++ b/src/file/pcx_format.c
@@ -237,7 +237,7 @@ static bool save_PCX(FileOp *fop)
ch = image->method->getpixel(image, x, y);
else if (image->imgtype == IMAGE_GRAYSCALE) {
c = image->method->getpixel(image, x, y);
- ch = _graya_getk(c);
+ ch = _graya_getv(c);
}
}
else {
diff --git a/src/file/png_format.c b/src/file/png_format.c
index 8d09925e3..7088f5958 100644
--- a/src/file/png_format.c
+++ b/src/file/png_format.c
@@ -441,7 +441,7 @@ static bool save_PNG(FileOp *fop)
for (x=0; xh-1; y>=0; y--) {
for (x=0; xw; x++)
- fputc(_graya_getk(image_getpixel(image, x, y)), f);
+ fputc(_graya_getv(image_getpixel(image, x, y)), f);
fop_progress(fop, (float)(image->h-y) / (float)(image->h));
}
diff --git a/src/jinete/jbase.h b/src/jinete/jbase.h
index 6bf8a0bfc..8ca68d5c1 100644
--- a/src/jinete/jbase.h
+++ b/src/jinete/jbase.h
@@ -87,31 +87,30 @@ struct jtheme;
struct jwidget;
/* alignment */
-#define JI_HORIZONTAL 1
-#define JI_VERTICAL 2
-#define JI_LEFT 4
-#define JI_CENTER 8
-#define JI_RIGHT 16
-#define JI_TOP 32
-#define JI_MIDDLE 64
-#define JI_BOTTOM 128
-#define JI_HOMOGENEOUS 256
-#define JI_WORDWRAP 512
+#define JI_HORIZONTAL 0x0001
+#define JI_VERTICAL 0x0002
+#define JI_LEFT 0x0004
+#define JI_CENTER 0x0008
+#define JI_RIGHT 0x0010
+#define JI_TOP 0x0020
+#define JI_MIDDLE 0x0040
+#define JI_BOTTOM 0x0080
+#define JI_HOMOGENEOUS 0x0100
+#define JI_WORDWRAP 0x0200
/* widget flags */
-/* #define JI_DIRTY 0x000001 /\* need be redraw *\/ */
-#define JI_HIDDEN 0x000002 /* is hidden (not visible, not clickeable) */
-#define JI_SELECTED 0x000004 /* is selected */
-#define JI_DISABLED 0x000008 /* is disabled (not usable) */
-#define JI_HASFOCUS 0x000010 /* has the input focus */
-#define JI_HASMOUSE 0x000020 /* has the mouse */
-#define JI_HASCAPTURE 0x000040 /* captured the mouse */
-#define JI_FOCUSREST 0x000080 /* want the focus (is a rest for focus) */
-#define JI_MAGNETIC 0x000100 /* attract the focus */
-#define JI_EXPANSIVE 0x000200 /* is expansive (want more space) */
-#define JI_DECORATIVE 0x000400 /* to decorate windows */
-#define JI_HARDCAPTURE 0x000800 /* only windows use hard capture */
-#define JI_INITIALIZED 0x001000 /* the widget was already initialized by a theme */
+#define JI_HIDDEN 0x0001 /* is hidden (not visible, not clickeable) */
+#define JI_SELECTED 0x0002 /* is selected */
+#define JI_DISABLED 0x0004 /* is disabled (not usable) */
+#define JI_HASFOCUS 0x0008 /* has the input focus */
+#define JI_HASMOUSE 0x0010 /* has the mouse */
+#define JI_HASCAPTURE 0x0020 /* captured the mouse */
+#define JI_FOCUSREST 0x0040 /* want the focus (is a rest for focus) */
+#define JI_MAGNETIC 0x0080 /* attract the focus */
+#define JI_EXPANSIVE 0x0100 /* is expansive (want more space) */
+#define JI_DECORATIVE 0x0200 /* to decorate windows */
+#define JI_HARDCAPTURE 0x0400 /* only windows use hard capture */
+#define JI_INITIALIZED 0x0800 /* the widget was already initialized by a theme */
/* widget types */
enum {
@@ -124,6 +123,7 @@ enum {
JI_CHECK,
JI_COMBOBOX,
JI_ENTRY,
+ JI_GRID,
JI_IMAGE,
JI_LABEL,
JI_LISTBOX,
@@ -167,7 +167,6 @@ enum {
the last message in the queue */
/* keyboard related messages */
- JM_CHAR, /* a new character in the buffer */
JM_KEYPRESSED, /* when a any key is pressed */
JM_KEYRELEASED, /* when a any key is released */
JM_FOCUSENTER, /* widget gets the focus */
@@ -180,6 +179,7 @@ enum {
JM_MOUSEENTER, /* a widget gets mouse pointer */
JM_MOUSELEAVE, /* a widget losts mouse pointer */
JM_MOTION, /* user moves the mouse on some widget */
+ JM_SETCURSOR, /* a widget needs to setup the mouse cursor */
JM_WHEEL, /* user moves the wheel */
/* XXX drag'n'drop operation? */
@@ -192,7 +192,6 @@ enum {
/* signals */
enum {
/* generic signals */
- JI_SIGNAL_DIRTY,
JI_SIGNAL_ENABLE,
JI_SIGNAL_DISABLE,
JI_SIGNAL_SELECT,
@@ -204,6 +203,7 @@ enum {
JI_SIGNAL_NEW_PARENT,
JI_SIGNAL_GET_TEXT,
JI_SIGNAL_SET_TEXT,
+ JI_SIGNAL_SET_FONT,
JI_SIGNAL_INIT_THEME,
/* special widget signals */
@@ -252,7 +252,7 @@ typedef struct jxmlelem *JXmlElem;
typedef struct jxmltext *JXmlText;
typedef bool (*JMessageFunc) (JWidget widget, JMessage msg);
-typedef void (*JDrawFunc) (JWidget widget);
+typedef void (*JDrawFunc) (JWidget widget, JRect clip);
/* without leak detection */
void *jmalloc (unsigned long n_bytes);
diff --git a/src/jinete/jbox.c b/src/jinete/jbox.c
index 4bf6275ff..f097d8d65 100644
--- a/src/jinete/jbox.c
+++ b/src/jinete/jbox.c
@@ -95,7 +95,7 @@ static void box_request_size(JWidget widget, int *w, int *h)
nvis_children = 0;
JI_LIST_FOR_EACH(widget->children, link) {
child = (JWidget)link->data;
- if (jwidget_is_visible(child))
+ if (!(child->flags & JI_HIDDEN))
nvis_children++;
}
@@ -104,7 +104,7 @@ static void box_request_size(JWidget widget, int *w, int *h)
JI_LIST_FOR_EACH(widget->children, link) {
child = (JWidget)link->data;
- if (jwidget_is_hidden(child))
+ if (child->flags & JI_HIDDEN)
continue;
jwidget_request_size(child, &req_w, &req_h);
@@ -160,33 +160,33 @@ static void box_set_position(JWidget widget, JRect rect)
JI_LIST_FOR_EACH(widget->children, link) { \
child = (JWidget)link->data; \
\
- if (jwidget_is_visible(child)) { \
+ if (!(child->flags & JI_HIDDEN)) { \
if (widget->align & JI_HOMOGENEOUS) { \
if (nvis_children == 1) \
child_width = width; \
else \
child_width = extra; \
\
- nvis_children -= 1; \
+ --nvis_children; \
width -= extra; \
} \
else { \
jwidget_request_size(child, &req_w, &req_h); \
\
- child_width = req_##w;/* + child->padding * 2; */ \
+ child_width = req_##w; \
\
- if (jwidget_is_expansive(child)) { \
+ if (jwidget_is_expansive(child)) { \
if (nexpand_children == 1) \
child_width += width; \
else \
child_width += extra; \
\
- nexpand_children -= 1; \
+ --nexpand_children; \
width -= extra; \
} \
} \
\
- w = MAX(1, child_width/* - child->padding * 2 */); \
+ w = MAX(1, child_width); \
\
if (widget->align & JI_HORIZONTAL) \
jrect_replace(&cpos, x, y, x+w, y+h); \
@@ -194,10 +194,6 @@ static void box_set_position(JWidget widget, JRect rect)
jrect_replace(&cpos, y, x, y+h, x+w); \
\
jwidget_set_rect(child, &cpos); \
- /* x = x + child->padding; */ \
- /* child->w = w; */ \
- /* child->h = h; */ \
- /* jwidget_size(child, w, h); */ \
\
x += child_width + widget->child_spacing; \
} \
@@ -221,7 +217,7 @@ static void box_set_position(JWidget widget, JRect rect)
JI_LIST_FOR_EACH(widget->children, link) {
child = (JWidget)link->data;
- if (jwidget_is_visible(child)) {
+ if (!(child->flags & JI_HIDDEN)) {
nvis_children++;
if (jwidget_is_expansive(child))
nexpand_children++;
diff --git a/src/jinete/jbutton.c b/src/jinete/jbutton.c
index b6c83ca79..331bb9cb8 100644
--- a/src/jinete/jbutton.c
+++ b/src/jinete/jbutton.c
@@ -289,12 +289,45 @@ static bool button_msg_proc(JWidget widget, JMessage msg)
}
break;
- case JM_CHAR:
- if (widget->type != JI_BUTTON) {
- if (jwidget_is_enabled (widget)) {
+ case JM_KEYPRESSED:
+ /* if the button is enabled */
+ if (jwidget_is_enabled(widget)) {
+ /* for JI_BUTTON */
+ if (widget->type == JI_BUTTON) {
+ /* has focus and press enter/space */
+ if (jwidget_has_focus(widget)) {
+ if ((msg->key.scancode == KEY_ENTER) ||
+ (msg->key.scancode == KEY_ENTER_PAD) ||
+ (msg->key.scancode == KEY_SPACE)) {
+ jwidget_select(widget);
+ return TRUE;
+ }
+ }
+ /* the underscored letter with Alt */
+ if ((msg->any.shifts & KB_ALT_FLAG) &&
+ (jwidget_check_underscored(widget, msg->key.scancode))) {
+ jwidget_select(widget);
+ return TRUE;
+ }
+ /* magnetic */
+ else if (jwidget_is_magnetic(widget) &&
+ ((msg->key.scancode == KEY_ENTER) ||
+ (msg->key.scancode == KEY_ENTER_PAD))) {
+ jmanager_set_focus(widget);
+
+ /* dispatch focus movement messages (because the buttons
+ process them) */
+ jmanager_dispatch_messages(ji_get_default_manager());
+
+ jwidget_select(widget);
+ return TRUE;
+ }
+ }
+ /* for JI_CHECK or JI_RADIO */
+ else {
/* if the widget has the focus and the user press space or
if the user press Alt+the underscored letter of the button */
- if ((jwidget_has_focus (widget) &&
+ if ((jwidget_has_focus(widget) &&
(msg->key.scancode == KEY_SPACE)) ||
((msg->any.shifts & KB_ALT_FLAG) &&
(jwidget_check_underscored(widget, msg->key.scancode)))) {
@@ -321,60 +354,12 @@ static bool button_msg_proc(JWidget widget, JMessage msg)
}
break;
- case JM_KEYPRESSED:
- if (widget->type == JI_BUTTON) {
- /* if the button is enabled */
- if (jwidget_is_enabled (widget)) {
- /* has focus and press enter/space */
- if (jwidget_has_focus (widget)) {
- if ((msg->key.scancode == KEY_ENTER) ||
- (msg->key.scancode == KEY_ENTER_PAD) ||
- (msg->key.scancode == KEY_SPACE)) {
- jwidget_select(widget);
- return TRUE;
- }
- }
-/* else { */
- /* the underscored letter with Alt */
- if ((msg->any.shifts & KB_ALT_FLAG) &&
- (jwidget_check_underscored(widget, msg->key.scancode))) {
- jwidget_select(widget);
- return TRUE;
- }
- /* magnetic */
- else if (jwidget_is_magnetic(widget) &&
- ((msg->key.scancode == KEY_ENTER) ||
- (msg->key.scancode == KEY_ENTER_PAD))) {
- jmanager_set_focus(widget);
-
- /* dispatch focus movement messages (because the buttons
- process them) */
- jmanager_dispatch_messages(ji_get_default_manager());
-
- jwidget_select(widget);
- return TRUE;
- }
-/* } */
- }
- }
- break;
-
case JM_KEYRELEASED:
- if (widget->type == JI_BUTTON) {
- /* if the button is enabled */
- if (jwidget_is_enabled(widget)) {
- /* has focus and press enter/space, or if the user just
- pressed the underscored letter */
- if ((jwidget_has_focus(widget) &&
- ((msg->key.scancode == KEY_ENTER) ||
- (msg->key.scancode == KEY_ENTER_PAD) ||
- (msg->key.scancode == KEY_SPACE))) ||
- (jwidget_check_underscored(widget, msg->key.scancode))) {
- /* if it's selected we must emit the signal */
- if (jwidget_is_selected(widget)) {
- button_selected_signal(widget);
- return TRUE;
- }
+ if (jwidget_is_enabled(widget)) {
+ if (widget->type == JI_BUTTON) {
+ if (jwidget_is_selected(widget)) {
+ button_selected_signal(widget);
+ return TRUE;
}
}
}
diff --git a/src/jinete/jcombobox.c b/src/jinete/jcombobox.c
index 6260b9d36..320184503 100644
--- a/src/jinete/jcombobox.c
+++ b/src/jinete/jcombobox.c
@@ -371,7 +371,7 @@ static bool combobox_entry_msg_proc(JWidget widget, JMessage msg)
switch (msg->type) {
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (jwidget_has_focus(widget)) {
if (!jcombobox_is_editable(combo_widget)) {
if (msg->key.scancode == KEY_SPACE ||
@@ -452,7 +452,7 @@ static bool combobox_listbox_msg_proc(JWidget widget, JMessage msg)
/* break; */
/* } */
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (jwidget_has_focus(widget)) {
if (msg->key.scancode == KEY_SPACE ||
msg->key.scancode == KEY_ENTER ||
diff --git a/src/jinete/jdraw.c b/src/jinete/jdraw.c
index d83a98da3..d47b8dd54 100644
--- a/src/jinete/jdraw.c
+++ b/src/jinete/jdraw.c
@@ -47,33 +47,52 @@
ji_font_set_aa_mode(f, fill_bg || \
bitmap_color_depth(ji_screen) == 8 ? bg: -1)
-void jdraw_rect(const JRect r, int color)
+void jrectedge(BITMAP *bmp, int x1, int y1, int x2, int y2,
+ int c1, int c2)
{
- rect(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, color);
+ hline(bmp, x1, y1, x2-1, c1);
+ hline(bmp, x1+1, y2, x2, c2);
+ vline(bmp, x1, y1+1, y2, c1);
+ vline(bmp, x2, y1, y2-1, c2);
}
-void jdraw_rectfill(const JRect r, int color)
+void jrectexclude(BITMAP *bmp, int x1, int y1, int x2, int y2,
+ int ex1, int ey1, int ex2, int ey2, int color)
{
- rectfill(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, color);
+ if ((ex1 > x2) || (ex2 < x1) ||
+ (ey1 > y2) || (ey2 < y1))
+ rectfill(bmp, x1, y1, x2, y2, color);
+ else {
+ int y, my1, my2;
+
+ my1 = MAX(y1, ey1);
+ my2 = MIN(y2, ey2);
+
+ /* top */
+ for (y=y1; y ex2)
+ for (y=my1; y<=my2; y++)
+ hline(bmp, ex2+1, y, x2, color);
+
+ /* bottom */
+ for (y=ey2+1; y<=y2; y++)
+ hline(bmp, x1, y, x2, color);
+ }
}
-void jdraw_rectedge(const JRect r, int c1, int c2)
+void jrectshade(BITMAP *bmp, int x1, int y1, int x2, int y2,
+ int c1, int c2, int align)
{
- vline(ji_screen, r->x1, r->y1, r->y2-1, c1);
- vline(ji_screen, r->x2-1, r->y1, r->y2-1, c2);
-
- hline(ji_screen, r->x1+1, r->y1, r->x2-2, c1);
- hline(ji_screen, r->x1+1, r->y2-1, r->x2-2, c2);
-}
-
-void jdraw_rectshade(const JRect rect, int c1, int c2, int align)
-{
- int c, x1, y1, x2, y2, r[2], g[2], b[2];
-
- x1 = rect->x1;
- y1 = rect->y1;
- x2 = rect->x2-1;
- y2 = rect->y2-1;
+ register int c;
+ int r[2], g[2], b[2];
r[0] = getr(c1);
g[0] = getg(c1);
@@ -85,10 +104,10 @@ void jdraw_rectshade(const JRect rect, int c1, int c2, int align)
if (align & JI_VERTICAL) {
if (y1 == y2)
- hline(ji_screen, x1, y1, x2, c1);
+ hline(bmp, x1, y1, x2, c1);
else
for (c=y1; c<=y2; c++)
- hline(ji_screen,
+ hline(bmp,
x1, c, x2,
makecol((r[0] + (r[1] - r[0]) * (c - y1) / (y2 - y1)),
(g[0] + (g[1] - g[0]) * (c - y1) / (y2 - y1)),
@@ -107,13 +126,35 @@ void jdraw_rectshade(const JRect rect, int c1, int c2, int align)
}
}
+void jdraw_rect(const JRect r, int color)
+{
+ rect(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, color);
+}
+
+void jdraw_rectfill(const JRect r, int color)
+{
+ rectfill(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, color);
+}
+
+void jdraw_rectedge(const JRect r, int c1, int c2)
+{
+ jrectedge(ji_screen, r->x1, r->y1, r->x2-1, r->y2-1, c1, c2);
+}
+
+void jdraw_rectshade(const JRect rect, int c1, int c2, int align)
+{
+ jrectshade(ji_screen,
+ rect->x1, rect->y1,
+ rect->x2-1, rect->y2-1, c1, c2, align);
+}
+
void jdraw_rectexclude(const JRect rc, const JRect exclude, int color)
{
- _ji_theme_rectfill_exclude(ji_screen,
- rc->x1, rc->y1,
- rc->x2-1, rc->y2-1,
- exclude->x1, exclude->y1,
- exclude->x2-1, exclude->y2-1, color);
+ jrectexclude(ji_screen,
+ rc->x1, rc->y1,
+ rc->x2-1, rc->y2-1,
+ exclude->x1, exclude->y1,
+ exclude->x2-1, exclude->y2-1, color);
}
void jdraw_char(FONT *f, int chr, int x, int y, int fg, int bg, bool fill_bg)
diff --git a/src/jinete/jdraw.h b/src/jinete/jdraw.h
index 0ca3cb0a6..0e159c37f 100644
--- a/src/jinete/jdraw.h
+++ b/src/jinete/jdraw.h
@@ -49,6 +49,13 @@ JI_BEGIN_DECLS
struct FONT;
struct BITMAP;
+void jrectedge(struct BITMAP *bmp, int x1, int y1, int x2, int y2,
+ int c1, int c2);
+void jrectexclude(struct BITMAP *bmp, int x1, int y1, int x2, int y2,
+ int ex1, int ey1, int ex2, int ey2, int color);
+void jrectshade(struct BITMAP *bmp, int x1, int y1, int x2, int y2,
+ int c1, int c2, int align);
+
void jdraw_rect(const JRect rect, int color);
void jdraw_rectfill(const JRect rect, int color);
void jdraw_rectedge(const JRect rect, int c1, int c2);
diff --git a/src/jinete/jentry.c b/src/jinete/jentry.c
index c9932b691..92b714e60 100644
--- a/src/jinete/jentry.c
+++ b/src/jinete/jentry.c
@@ -269,7 +269,7 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
entry->recent_focused = FALSE;
break;
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (jwidget_has_focus(widget) && !jentry_is_readonly(widget)) {
char *text = jmalloc(widget->text_size);
int c, selbeg, selend;
@@ -555,7 +555,7 @@ static void entry_request_size(JWidget widget, int *w, int *h)
+ ji_font_char_len(widget->text_font, 'w') * MIN(widget->text_size, 6)
+ 2 + widget->border_width.r;
- *w = MIN(*w, 128);
+ *w = MIN(*w, JI_SCREEN_W/2);
*h =
+ widget->border_width.t
diff --git a/src/jinete/jfilesel.c b/src/jinete/jfilesel.c
index 7a62491fe..7e15b7d5a 100644
--- a/src/jinete/jfilesel.c
+++ b/src/jinete/jfilesel.c
@@ -372,7 +372,7 @@ static bool filesel_msg_proc(JWidget widget, JMessage msg)
}
break;
- case JM_CHAR:
+ case JM_KEYPRESSED:
if ((jwidget_has_focus (widget)) &&
((msg->key.scancode == KEY_ENTER) ||
(msg->key.scancode == KEY_ENTER_PAD))) {
diff --git a/src/jinete/jgrid.c b/src/jinete/jgrid.c
new file mode 100644
index 000000000..43a6aac47
--- /dev/null
+++ b/src/jinete/jgrid.c
@@ -0,0 +1,492 @@
+/* Jinete - a GUI library
+ * Copyright (C) 2003-2008 David A. Capello.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of the Jinete nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "jinete/jlist.h"
+#include "jinete/jmessage.h"
+#include "jinete/jrect.h"
+#include "jinete/jwidget.h"
+
+typedef struct Cell
+{
+ struct Cell *parent;
+ JWidget child;
+ int hspan;
+ int vspan;
+ int align;
+} Cell;
+
+typedef struct Strip
+{
+ int size;
+ int align;
+} Strip;
+
+typedef struct Grid
+{
+ bool same_width_columns;
+ int cols;
+ int rows;
+ Strip *colstrip;
+ Strip *rowstrip;
+ Cell **cells;
+} Grid;
+
+static bool grid_msg_proc(JWidget widget, JMessage msg);
+static void grid_request_size(JWidget widget, int *w, int *h);
+static void grid_set_position(JWidget widget, JRect rect);
+static void grid_calculate_size(JWidget widget);
+static void grid_distribute_size(JWidget widget, JRect rect);
+static bool grid_put_in_a_cell(JWidget widget, JWidget child, int hspan, int vspan, int align);
+static void grid_expand_rows(JWidget widget, int rows);
+
+JWidget jgrid_new(int columns, bool same_width_columns)
+{
+ JWidget widget = jwidget_new(JI_GRID);
+ Grid *grid = jnew(Grid, 1);
+ int col;
+
+ assert(columns > 0);
+
+ grid->same_width_columns = same_width_columns;
+ grid->cols = columns;
+ grid->rows = 0;
+ grid->colstrip = jmalloc(sizeof(Strip) * grid->cols);
+ grid->rowstrip = NULL;
+ grid->cells = NULL;
+
+ for (col=0; colcols; ++col) {
+ grid->colstrip[col].size = 0;
+ grid->colstrip[col].align = 0;
+ }
+
+ jwidget_add_hook(widget, JI_GRID, grid_msg_proc, grid);
+ jwidget_init_theme(widget);
+
+ return widget;
+}
+
+/**
+ * Adds a child widget in the specified grid.
+ *
+ * @param widget The grid widget.
+ * @param child The child widget.
+ * @param hspan
+ * @param vspan
+ * @param align
+ * It's a combination of the following values:
+ *
+ * - JI_HORIZONTAL: The widget'll get excess horizontal space.
+ * - JI_VERTICAL: The widget'll get excess vertical space.
+ *
+ * - JI_LEFT: Sets horizontal alignment to the beginning of cell.
+ * - JI_CENTER: Sets horizontal alignment to the center of cell.
+ * - JI_RIGHT: Sets horizontal alignment to the end of cell.
+ * - None: Uses the whole horizontal space of the cell.
+ *
+ * - JI_TOP: Sets vertical alignment to the beginning of the cell.
+ * - JI_MIDDLE: Sets vertical alignment to the center of the cell.
+ * - JI_BOTTOM: Sets vertical alignment to the end of the cell.
+ * - None: Uses the whole vertical space of the cell.
+ */
+void jgrid_add_child(JWidget widget, JWidget child,
+ int hspan, int vspan, int align)
+{
+ Grid *grid = jwidget_get_data(widget, JI_GRID);
+
+ jwidget_add_child(widget, child);
+
+ if (!grid_put_in_a_cell(widget, child, hspan, vspan, align)) {
+ grid_expand_rows(widget, grid->rows+1);
+ grid_put_in_a_cell(widget, child, hspan, vspan, align);
+ }
+}
+
+static bool grid_msg_proc(JWidget widget, JMessage msg)
+{
+ Grid *grid = jwidget_get_data(widget, JI_GRID);
+
+ switch (msg->type) {
+
+ case JM_DESTROY:
+ if (grid->cells != NULL) {
+ int row;
+ for (row=0; rowrows; ++row)
+ jfree(grid->cells[row]);
+ jfree(grid->cells);
+ }
+ jfree(grid);
+ break;
+
+ case JM_REQSIZE:
+ grid_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
+ return TRUE;
+
+ case JM_SETPOS:
+ grid_set_position(widget, &msg->setpos.rect);
+ return TRUE;
+
+#if 0 /* TODO */
+ case JM_SIGNAL:
+ if (msg->signal.num == JI_SIGNAL_REMOVE_CHILD) {
+ }
+ break;
+#endif
+
+ }
+
+ return FALSE;
+}
+
+static void grid_request_size(JWidget widget, int *w, int *h)
+{
+ Grid *grid = jwidget_get_data(widget, JI_GRID);
+ int i, j;
+
+ grid_calculate_size(widget);
+
+ /* calculate the total */
+
+ *w = 0;
+ *h = 0;
+
+ for (i=j=0; icols; ++i) {
+ if (grid->colstrip[i].size > 0) {
+ *w += grid->colstrip[i].size;
+ if (++j > 1)
+ *w += widget->child_spacing;
+ }
+ }
+
+ for (i=j=0; irows; ++i) {
+ if (grid->rowstrip[i].size > 0) {
+ *h += grid->rowstrip[i].size;
+ if (++j > 1)
+ *h += widget->child_spacing;
+ }
+ }
+
+ *w += widget->border_width.l + widget->border_width.r;
+ *h += widget->border_width.t + widget->border_width.b;
+}
+
+static void grid_set_position(JWidget widget, JRect rect)
+{
+ Grid *grid = jwidget_get_data(widget, JI_GRID);
+ JRect cpos = jrect_new(0, 0, 0, 0);
+ int pos_x, pos_y;
+ int req_w, req_h;
+ int x, y, w, h;
+ int col, row;
+ int i, j;
+ Cell *cell;
+
+ jrect_copy(widget->rc, rect);
+
+ grid_calculate_size(widget);
+ grid_distribute_size(widget, rect);
+
+ pos_y = rect->y1 + widget->border_width.t;
+ for (row=0; rowrows; ++row) {
+ pos_x = rect->x1 + widget->border_width.l;
+
+ cell = grid->cells[row];
+ for (col=0; colcols; ++col, ++cell) {
+ if (cell->child != NULL &&
+ cell->parent == NULL &&
+ !(cell->child->flags & JI_HIDDEN)) {
+ x = pos_x;
+ y = pos_y;
+ w = 0;
+ h = 0;
+
+#define CALCULATE_W(col, hspan, colstrip, w) \
+ for (i=col,j=0; ihspan; ++i) { \
+ if (grid->colstrip[i].size > 0) { \
+ w += grid->colstrip[i].size; \
+ if (++j > 1) \
+ w += widget->child_spacing; \
+ } \
+ }
+
+ CALCULATE_W(col, hspan, colstrip, w);
+ CALCULATE_W(row, vspan, rowstrip, h);
+
+ jwidget_request_size(cell->child, &req_w, &req_h);
+
+ if (cell->align & JI_LEFT) {
+ w = req_w;
+ }
+ else if (cell->align & JI_CENTER) {
+ x += w/2 - req_w/2;
+ w = req_w;
+ }
+ else if (cell->align & JI_RIGHT) {
+ x += w - req_w;
+ w = req_w;
+ }
+
+ if (cell->align & JI_TOP) {
+ h = req_h;
+ }
+ else if (cell->align & JI_MIDDLE) {
+ y += h/2 - req_h/2;
+ h = req_h;
+ }
+ else if (cell->align & JI_BOTTOM) {
+ y += h - req_h;
+ h = req_h;
+ }
+
+ jrect_replace(cpos, x, y, x+w, y+h);
+ jwidget_set_rect(cell->child, cpos);
+ }
+
+ if (grid->colstrip[col].size > 0)
+ pos_x += grid->colstrip[col].size + widget->child_spacing;
+ }
+
+ if (grid->rowstrip[row].size > 0)
+ pos_y += grid->rowstrip[row].size + widget->child_spacing;
+ }
+
+ jrect_free(cpos);
+}
+
+/**
+ * Calculates the size of each row and each column in the grid.
+ */
+static void grid_calculate_size(JWidget widget)
+{
+ Grid *grid = jwidget_get_data(widget, JI_GRID);
+ int row, col, size, align;
+ int req_w, req_h;
+ int max_w;
+ Cell *cell;
+
+ if (grid->rows == 0)
+ return;
+
+ for (row=0; rowrows; ++row) {
+ size = 0;
+ align = 0;
+ for (col=0; colcols; ++col) {
+ cell = grid->cells[row]+col;
+ req_w = req_h = 0;
+
+ if (cell->child != NULL && cell->vspan == 1) {
+ if (!(cell->child->flags & JI_HIDDEN)) {
+ jwidget_request_size(cell->child, &req_w, &req_h);
+ align |= cell->align;
+ }
+
+ col += cell->vspan-1;
+ }
+
+ size = MAX(size, req_h);
+ }
+ grid->rowstrip[row].size = size;
+ grid->rowstrip[row].align = align;
+ }
+
+ for (col=0; colcols; ++col) {
+ size = 0;
+ align = 0;
+ for (row=0; rowrows; ++row) {
+ cell = grid->cells[row]+col;
+ req_w = req_h = 0;
+
+ if (cell->child != NULL && cell->hspan == 1) {
+ if (!(cell->child->flags & JI_HIDDEN)) {
+ jwidget_request_size(cell->child, &req_w, &req_h);
+ align |= cell->align;
+ }
+
+ row += cell->hspan-1;
+ }
+
+ size = MAX(size, req_w);
+ }
+ grid->colstrip[col].size = size;
+ grid->colstrip[col].align = align;
+ }
+
+ /* same width in all columns */
+ if (grid->same_width_columns) {
+ max_w = 0;
+
+ for (col=0; colcols; ++col)
+ max_w = MAX(max_w, grid->colstrip[col].size);
+
+ for (col=0; colcols; ++col)
+ grid->colstrip[col].size = max_w;
+ }
+}
+
+static void grid_distribute_size(JWidget widget, JRect rect)
+{
+ Grid *grid = jwidget_get_data(widget, JI_GRID);
+ int total_req, wantmore_count;
+ int i, j;
+
+ if (grid->rows == 0)
+ return;
+
+#define DISTRIBUTE_SIZE(cols, colstrip, JI_HORIZONTAL, l, r, jrect_w) \
+ total_req = 0; \
+ wantmore_count = 0; \
+ for (i=j=0; icols; ++i) { \
+ if (grid->colstrip[i].size > 0) { \
+ total_req += grid->colstrip[i].size; \
+ if (++j > 1) \
+ total_req += widget->child_spacing; \
+ } \
+ \
+ if (grid->colstrip[i].align & JI_HORIZONTAL || \
+ grid->same_width_columns) { \
+ ++wantmore_count; \
+ } \
+ } \
+ total_req += widget->border_width.l + widget->border_width.r; \
+ \
+ if (wantmore_count > 0) { \
+ int extra_total = jrect_w(rect) - total_req; \
+ if (extra_total > 0) { \
+ int extra_foreach = extra_total / wantmore_count; \
+ \
+ for (i=0; icols; ++i) { \
+ if (grid->colstrip[i].align & JI_HORIZONTAL || \
+ grid->same_width_columns) { \
+ assert(wantmore_count > 0); \
+ assert(extra_total > 0); \
+ \
+ grid->colstrip[i].size += extra_foreach; \
+ extra_total -= extra_foreach; \
+ \
+ if (--wantmore_count == 0) { \
+ grid->colstrip[i].size += extra_total; \
+ extra_total = 0; \
+ } \
+ } \
+ } \
+ assert(wantmore_count == 0); \
+ assert(extra_total == 0); \
+ } \
+ }
+
+ DISTRIBUTE_SIZE(cols, colstrip, JI_HORIZONTAL, l, r, jrect_w);
+ DISTRIBUTE_SIZE(rows, rowstrip, JI_VERTICAL, t, b, jrect_h);
+}
+
+static bool grid_put_in_a_cell(JWidget widget, JWidget child, int hspan, int vspan, int align)
+{
+ Grid *grid = jwidget_get_data(widget, JI_GRID);
+ int col, row, colbeg, colend, rowend;
+ Cell *cell, *parentcell;
+
+ for (row=0; rowrows; ++row) {
+ cell = grid->cells[row];
+ for (col=0; colcols; ++col, ++cell) {
+ if (cell->child == NULL) {
+ cell->child = child;
+ cell->hspan = hspan;
+ cell->vspan = vspan;
+ cell->align = align;
+
+ parentcell = cell;
+ colbeg = col;
+ colend = MIN(col+hspan, grid->cols);
+ rowend = row+vspan;
+
+ grid_expand_rows(widget, row+vspan);
+
+ for (++col, ++cell; colparent == NULL);
+ assert(cell->child == NULL);
+
+ cell->parent = parentcell;
+ cell->child = child;
+ }
+
+ for (++row; rowcells[grid->cols*row + col];
+ for (col=colbeg; colparent == NULL);
+ assert(cell->child == NULL);
+
+ cell->parent = parentcell;
+ cell->child = child;
+ }
+ }
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ * Expands the grid's rows to reach the specified quantity of rows in
+ * the parameter.
+ */
+static void grid_expand_rows(JWidget widget, int rows)
+{
+ Grid *grid = jwidget_get_data(widget, JI_GRID);
+ Cell *cell;
+ int row;
+
+ if (grid->rows < rows) {
+ grid->cells = jrealloc(grid->cells, sizeof(Cell *) * rows);
+ grid->rowstrip = jrealloc(grid->rowstrip, sizeof(Strip) * rows);
+
+ for (row=grid->rows; rowcells[row] = jmalloc(sizeof(Cell) * grid->cols);
+ grid->rowstrip[row].size = 0;
+ grid->rowstrip[row].align = 0;
+
+ for (cell=grid->cells[row];
+ cellcells[row]+grid->cols; ++cell) {
+ cell->parent = NULL;
+ cell->child = NULL;
+ cell->hspan = 0;
+ cell->vspan = 0;
+ }
+ }
+
+ grid->rows = rows;
+ }
+}
diff --git a/src/jinete/jgrid.h b/src/jinete/jgrid.h
new file mode 100644
index 000000000..7d14a91eb
--- /dev/null
+++ b/src/jinete/jgrid.h
@@ -0,0 +1,46 @@
+/* Jinete - a GUI library
+ * Copyright (C) 2003-2008 David A. Capello.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of the Jinete nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JINETE_GRID_H
+#define JINETE_GRID_H
+
+#include "jinete/jbase.h"
+
+JI_BEGIN_DECLS
+
+JWidget jgrid_new(int columns, bool same_width_columns);
+
+void jgrid_add_child(JWidget grid, JWidget child,
+ int hspan, int vspan, int align);
+
+JI_END_DECLS
+
+#endif /* JINETE_BOX_H */
diff --git a/src/jinete/jinete.h b/src/jinete/jinete.h
index 834d96535..2f98a346e 100644
--- a/src/jinete/jinete.h
+++ b/src/jinete/jinete.h
@@ -41,6 +41,7 @@
#include "jinete/jcombobox.h"
#include "jinete/jdraw.h"
#include "jinete/jentry.h"
+#include "jinete/jgrid.h"
#include "jinete/jfile.h"
#include "jinete/jfilesel.h"
#include "jinete/jfont.h"
diff --git a/src/jinete/jintern.c b/src/jinete/jintern.c
index 9fe92642b..7d0c0ba94 100644
--- a/src/jinete/jintern.c
+++ b/src/jinete/jintern.c
@@ -103,7 +103,8 @@ void _ji_free_all_widgets(void)
if (nwidgets) {
for (c=0; cborder_width.l;
- t = widgets[c]->border_width.t;
- r = widgets[c]->border_width.r;
- b = widgets[c]->border_width.b;
-
+ if (_ji_is_valid_widget(widgets[c])) {
jwidget_set_font(widgets[c], f);
jwidget_init_theme(widgets[c]);
-
- widgets[c]->border_width.l = l;
- widgets[c]->border_width.t = t;
- widgets[c]->border_width.r = r;
- widgets[c]->border_width.b = b;
}
for (c=0; ctype == JI_WINDOW)
jwindow_remap(widgets[c]);
}
jmanager_refresh_screen();
}
-
-
-
diff --git a/src/jinete/jintern.h b/src/jinete/jintern.h
index faff7eeae..440ee8842 100644
--- a/src/jinete/jintern.h
+++ b/src/jinete/jintern.h
@@ -91,13 +91,6 @@ void _ji_theme_exit(void);
void _ji_theme_draw_sprite_color(struct BITMAP *bmp, struct BITMAP *sprite,
int x, int y, int color);
-void _ji_theme_rectedge(struct BITMAP *bmp,
- int x1, int y1, int x2, int y2, int c1, int c2);
-
-void _ji_theme_rectfill_exclude(struct BITMAP *bmp,
- int x1, int y1, int x2, int y2,
- int ex1, int ey1, int ex2, int ey2, int color);
-
void _ji_theme_textbox_draw(struct BITMAP *bmp, JWidget textbox,
int *w, int *h, int bg, int fg);
diff --git a/src/jinete/jlistbox.c b/src/jinete/jlistbox.c
index a7caa7afa..22056f50a 100644
--- a/src/jinete/jlistbox.c
+++ b/src/jinete/jlistbox.c
@@ -247,7 +247,7 @@ static bool listbox_msg_proc(JWidget widget, JMessage msg)
break;
}
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (jwidget_has_focus(widget) && !jlist_empty(widget->children)) {
int select = jlistbox_get_selected_index(widget);
JWidget view = jwidget_get_view(widget);
diff --git a/src/jinete/jmanager.c b/src/jinete/jmanager.c
index 784359c75..20ca11107 100644
--- a/src/jinete/jmanager.c
+++ b/src/jinete/jmanager.c
@@ -106,20 +106,23 @@ static bool first_time_poll; /* TRUE when we don't enter in poll yet */
static char old_readed_key[KEY_MAX]; /* keyboard status of previous
poll */
+static unsigned key_repeated[KEY_MAX];
+
/* manager widget */
static bool manager_msg_proc(JWidget widget, JMessage msg);
static void manager_request_size(JWidget widget, int *w, int *h);
static void manager_set_position(JWidget widget, JRect rect);
-static void dispatch_messages(JWidget widget);
+static void manager_pump_queue(JWidget widget);
static void manager_redraw_region(JWidget widget, JRegion region);
/* auxiliary */
+static void generate_setcursor_message(void);
static void remove_msgs_for(JWidget widget, JMessage msg);
static void generate_proc_windows_list(void);
static void generate_proc_windows_list2(JWidget manager);
static int some_parent_is_focusrest(JWidget widget);
static JWidget find_magnetic_widget(JWidget widget);
-static JMessage new_mouse_msg(int type);
+static JMessage new_mouse_msg(int type, JWidget destination);
static void broadcast_key_msg(JWidget manager, JMessage msg);
static Filter *filter_new(int message, JWidget widget);
static void filter_free(Filter *filter);
@@ -179,8 +182,10 @@ JWidget jmanager_new(void)
double_click_ticks = 0;
/* reset keyboard */
- for (c=0; cflags & JI_HARDCAPTURE)
+ destination = capture_widget;
+ else
+ destination = mouse_widget;
/* send the mouse movement message */
- if (capture_widget)
- jmessage_broadcast_to_parents(msg, capture_widget);
- else if (mouse_widget)
- jmessage_broadcast_to_parents(msg, mouse_widget);
-
- jmanager_enqueue_message(msg);
+ if (destination) {
+ msg = new_mouse_msg(JM_MOTION, destination);
+ jmanager_enqueue_message(msg);
+ }
+ generate_setcursor_message();
}
}
/* mouse wheel */
if (jmouse_z(0) != jmouse_z(1)) {
- msg = new_mouse_msg(JM_WHEEL);
-
- /* send the mouse wheel message */
- if (capture_widget)
- jmessage_broadcast_to_parents(msg, capture_widget);
- else if (mouse_widget)
- jmessage_broadcast_to_parents(msg, mouse_widget);
-
- jmanager_enqueue_message(msg);
+ if (capture_widget || mouse_widget) {
+ msg = new_mouse_msg(JM_WHEEL,
+ capture_widget ? capture_widget:
+ mouse_widget);
+ jmanager_enqueue_message(msg);
+ }
}
/* mouse clicks */
if ((jmouse_b(0) != jmouse_b(1)) &&
((!jmouse_b(0)) || (!jmouse_b(1)))) {
- int current_ticks = ji_clock;
+ if (capture_widget || mouse_widget) {
+ int current_ticks = ji_clock;
- /* press and release button messages */
- msg = new_mouse_msg((!jmouse_b(1))? JM_BUTTONPRESSED:
- JM_BUTTONRELEASED);
+ msg = new_mouse_msg(!jmouse_b(1) ? JM_BUTTONPRESSED:
+ JM_BUTTONRELEASED,
+ capture_widget ? capture_widget:
+ mouse_widget);
- /**********************************************************************/
- /* Double Click */
- if (msg->type == JM_BUTTONPRESSED) {
- if (double_click_level != DOUBLE_CLICK_NONE) {
- /* time out, back to NONE */
- if (current_ticks - double_click_ticks > DOUBLE_CLICK_TIMEOUT_MSECS) {
- double_click_level = DOUBLE_CLICK_NONE;
- }
- else if (double_click_buttons == msg->mouse.flags) {
- if (double_click_level == DOUBLE_CLICK_UP) {
- msg->type = JM_DOUBLECLICK;
+ /**********************************************************************/
+ /* Double Click */
+ if (msg->type == JM_BUTTONPRESSED) {
+ if (double_click_level != DOUBLE_CLICK_NONE) {
+ /* time out, back to NONE */
+ if (current_ticks - double_click_ticks > DOUBLE_CLICK_TIMEOUT_MSECS) {
+ double_click_level = DOUBLE_CLICK_NONE;
}
+ else if (double_click_buttons == msg->mouse.flags) {
+ if (double_click_level == DOUBLE_CLICK_UP) {
+ msg->type = JM_DOUBLECLICK;
+ }
+ else {
+ double_click_level = DOUBLE_CLICK_NONE;
+ }
+ }
+ /* press other button, back to NONE */
else {
double_click_level = DOUBLE_CLICK_NONE;
}
}
- /* press other button, back to NONE */
- else {
- double_click_level = DOUBLE_CLICK_NONE;
- }
- }
- /* this could be the beginning of the state */
- if (double_click_level == DOUBLE_CLICK_NONE) {
- double_click_level = DOUBLE_CLICK_DOWN;
- double_click_buttons = msg->mouse.flags;
- double_click_ticks = current_ticks;
- }
- }
- else if (msg->type == JM_BUTTONRELEASED) {
- if (double_click_level != DOUBLE_CLICK_NONE) {
- /* time out, back to NONE */
- if (current_ticks - double_click_ticks > DOUBLE_CLICK_TIMEOUT_MSECS) {
- double_click_level = DOUBLE_CLICK_NONE;
+ /* this could be the beginning of the state */
+ if (double_click_level == DOUBLE_CLICK_NONE) {
+ double_click_level = DOUBLE_CLICK_DOWN;
+ double_click_buttons = msg->mouse.flags;
+ double_click_ticks = current_ticks;
}
- else if (double_click_buttons == msg->mouse.flags) {
- if (double_click_level == DOUBLE_CLICK_DOWN) {
- double_click_level = DOUBLE_CLICK_UP;
- double_click_ticks = current_ticks;
+ }
+ else if (msg->type == JM_BUTTONRELEASED) {
+ if (double_click_level != DOUBLE_CLICK_NONE) {
+ /* time out, back to NONE */
+ if (current_ticks - double_click_ticks > DOUBLE_CLICK_TIMEOUT_MSECS) {
+ double_click_level = DOUBLE_CLICK_NONE;
+ }
+ else if (double_click_buttons == msg->mouse.flags) {
+ if (double_click_level == DOUBLE_CLICK_DOWN) {
+ double_click_level = DOUBLE_CLICK_UP;
+ double_click_ticks = current_ticks;
+ }
+ }
+ /* press other button, back to NONE */
+ else {
+ double_click_level = DOUBLE_CLICK_NONE;
}
}
- /* press other button, back to NONE */
- else {
- double_click_level = DOUBLE_CLICK_NONE;
- }
}
- }
- /* add receivers of the message */
-
- if (capture_widget)
- jmessage_broadcast_to_parents(msg, capture_widget);
- else if (mouse_widget) {
/* Z-Order:
Send the window to top (only when you click in a window
that aren't the desktop) */
- if (msg->type == JM_BUTTONPRESSED) {
+ if (!capture_widget && msg->type == JM_BUTTONPRESSED) {
JWidget window = jwidget_get_window(mouse_widget);
JWidget win_manager = window ? jwidget_get_manager(window): NULL;
@@ -480,10 +484,8 @@ bool jmanager_generate_messages(JWidget manager)
jmanager_set_focus(mouse_widget);
}
- jmessage_broadcast_to_parents(msg, mouse_widget);
+ jmanager_enqueue_message(msg);
}
-
- jmanager_enqueue_message(msg);
}
/* generate JM_CHAR/JM_KEYPRESSED messages */
@@ -491,37 +493,41 @@ bool jmanager_generate_messages(JWidget manager)
int readkey_value = readkey();
/* char message first */
- msg = jmessage_new_key_related(JM_CHAR, readkey_value);
- broadcast_key_msg(manager, msg);
+ msg = jmessage_new_key_related(JM_KEYPRESSED, readkey_value);
- /* key-pressed message is dependent from char message (if char
- message isn't used, we send the key-pressed message) */
c = readkey_value >> 8;
- if (old_readed_key[c] != key[c] && !old_readed_key[c]) {
- JMessage sub_msg = jmessage_new_key_related(JM_KEYPRESSED,
- readkey_value);
- old_readed_key[c] = key[c];
-
- /* same address */
- jlist_free(sub_msg->any.widgets);
- sub_msg->any.widgets = jlist_copy(msg->any.widgets);
-
- jmessage_set_sub_msg(msg, sub_msg);
- jmessage_free(sub_msg);
- }
+ old_readed_key[c] = key[c];
+ msg->key.repeat = key_repeated[c]++;
+ broadcast_key_msg(manager, msg);
jmanager_enqueue_message(msg);
}
- /* generate JM_KEYRELEASED messages */
for (c=0; c= KEY_MODIFIERS) {
+ /* press/release key interface */
+ msg = jmessage_new_key_related(JM_KEYPRESSED,
+ (c << 8) | scancode_to_ascii(c));
+ old_readed_key[c] = key[c];
+ msg->key.repeat = key_repeated[c]++;
+
+ broadcast_key_msg(manager, msg);
+ jmanager_enqueue_message(msg);
+ }
}
}
@@ -564,13 +570,14 @@ bool jmanager_generate_messages(JWidget manager)
void jmanager_dispatch_messages(JWidget manager)
{
JMessage msg;
+
+ assert(manager != NULL);
/* add the "Queue Processing" message for the manager */
- msg = new_mouse_msg(JM_QUEUEPROCESSING);
- jmessage_add_dest(msg, manager);
+ msg = new_mouse_msg(JM_QUEUEPROCESSING, manager);
jmanager_enqueue_message(msg);
- dispatch_messages(manager);
+ manager_pump_queue(manager);
}
/**
@@ -828,6 +835,7 @@ void jmanager_set_mouse(JWidget widget)
}
jmanager_enqueue_message(msg);
+ generate_setcursor_message();
}
jlist_free(widget_parents);
@@ -959,7 +967,7 @@ void _jmanager_open_window(JWidget manager, JWidget window)
/* broadcast the open message */
msg = jmessage_new(JM_OPEN);
- jmessage_broadcast_to_children(msg, window);
+ jmessage_add_dest(msg, window);
jmanager_enqueue_message(msg);
/* update the new windows list to show */
@@ -1011,7 +1019,7 @@ void _jmanager_close_window(JWidget manager, JWidget window, bool redraw_backgro
/* close message */
msg = jmessage_new(JM_CLOSE);
- jmessage_broadcast_to_children(msg, window);
+ jmessage_add_dest(msg, window);
jmanager_enqueue_message(msg);
/* update manager list stuff */
@@ -1063,24 +1071,35 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
jdraw_rectfill(&msg->draw.rect, widget->theme->desktop_color);
return TRUE;
- case JM_CHAR:
-#if 0 /* TODO do this */
- /* close desktop? */
- if (msg->key.scancode == KEY_ESC) {
- JWidget window;
- JLink link;
+ case JM_KEYPRESSED:
+ case JM_KEYRELEASED: {
+ JLink link, link2;
- JI_LIST_FOR_EACH(widget->children, link) {
- window = link->data;
- if (jwindow_is_desktop(window)) {
- jwindow_close(window, widget);
+ msg->key.propagate_to_children = TRUE;
+ msg->key.propagate_to_parent = FALSE;
+
+ /* continue sending the message to the children of all windows
+ (until a desktop or foreground window) */
+ JI_LIST_FOR_EACH(widget->children, link) {
+ JWidget w = (JWidget)link->data;
+
+ /* send to the window */
+ JI_LIST_FOR_EACH(w->children, link2)
+ if (jwidget_send_message(link2->data, msg))
return TRUE;
- }
- }
+
+ if (jwindow_is_foreground(w) ||
+ jwindow_is_desktop(w))
+ break;
}
-#endif
+
/* check the focus movement */
- return move_focus(widget, msg);
+ if (msg->type == JM_KEYPRESSED)
+ move_focus(widget, msg);
+
+ return TRUE;
+ }
+
}
return FALSE;
@@ -1134,7 +1153,7 @@ static void manager_set_position(JWidget widget, JRect rect)
jrect_free(old_pos);
}
-static void dispatch_messages(JWidget widget_manager)
+static void manager_pump_queue(JWidget widget_manager)
{
JMessage msg, first_msg;
JLink link, link2, next;
@@ -1169,100 +1188,89 @@ static void dispatch_messages(JWidget widget_manager)
first_msg = msg;
done = FALSE;
- do {
- JI_LIST_FOR_EACH(msg->any.widgets, link2) {
- widget = link2->data;
+ JI_LIST_FOR_EACH(msg->any.widgets, link2) {
+ widget = link2->data;
#ifdef REPORT_EVENTS
- {
- static char *msg_name[] = {
- "Open",
- "Close",
- "Destroy",
- "Draw",
- "Signal",
- "Timer",
- "ReqSize",
- "SetPos",
- "WinMove",
- "DrawRgn",
- "DeferredFree",
- "DirtyChildren",
- "QueueProcessing",
- "Char",
- "KeyPressed",
- "KeyReleased",
- "FocusEnter",
- "FocusLeave",
- "ButtonPressed",
- "ButtonReleased",
- "DoubleClick",
- "MouseEnter",
- "MouseLeave",
- "Motion",
- "Wheel",
- };
- const char *string =
- (msg->type >= JM_OPEN &&
- msg->type <= JM_WHEEL) ? msg_name[msg->type]:
- "Unknown";
+ {
+ static char *msg_name[] = {
+ "Open",
+ "Close",
+ "Destroy",
+ "Draw",
+ "Signal",
+ "Timer",
+ "ReqSize",
+ "SetPos",
+ "WinMove",
+ "DrawRgn",
+ "DeferredFree",
+ "DirtyChildren",
+ "QueueProcessing",
+ "KeyPressed",
+ "KeyReleased",
+ "FocusEnter",
+ "FocusLeave",
+ "ButtonPressed",
+ "ButtonReleased",
+ "DoubleClick",
+ "MouseEnter",
+ "MouseLeave",
+ "Motion",
+ "SetCursor",
+ "Wheel",
+ };
+ const char *string =
+ (msg->type >= JM_OPEN &&
+ msg->type <= JM_WHEEL) ? msg_name[msg->type]:
+ "Unknown";
- printf("Event: %s (%d)\n", string, widget->id);
- fflush(stdout);
- }
+ printf("Event: %s (%d)\n", string, widget->id);
+ fflush(stdout);
+ }
#endif
- /* draw message? */
- if (msg->type == JM_DRAW) {
- /* hidden? */
- if (widget->flags & JI_HIDDEN)
- continue;
+ /* draw message? */
+ if (msg->type == JM_DRAW) {
+ /* hidden? */
+ if (widget->flags & JI_HIDDEN)
+ continue;
- jmouse_hide();
- acquire_bitmap(ji_screen);
+ jmouse_hide();
+ acquire_bitmap(ji_screen);
- /* set clip */
- set_clip(ji_screen,
- msg->draw.rect.x1, msg->draw.rect.y1,
- msg->draw.rect.x2-1, msg->draw.rect.y2-1);
-#ifdef REPORT_EVENTS
- printf("set_clip(%d, %d, %d, %d)\n",
+ /* set clip */
+ set_clip(ji_screen,
msg->draw.rect.x1, msg->draw.rect.y1,
msg->draw.rect.x2-1, msg->draw.rect.y2-1);
- fflush(stdout);
+#ifdef REPORT_EVENTS
+ printf("set_clip(%d, %d, %d, %d)\n",
+ msg->draw.rect.x1, msg->draw.rect.y1,
+ msg->draw.rect.x2-1, msg->draw.rect.y2-1);
+ fflush(stdout);
#endif
-/* rectfill(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, makecol(255, 0, 0)); */
-/* vsync(); vsync(); vsync(); vsync(); */
- }
-
- /* call message handler */
- done = jwidget_send_message(widget, msg);
-
- /* restore clip */
- if (msg->type == JM_DRAW) {
- set_clip(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
-
- /* dirty rectangles */
- if (ji_dirty_region)
- ji_add_dirty_rect(&msg->draw.rect);
-
- release_bitmap(ji_screen);
- jmouse_show();
- }
-
- if (done)
- break;
+ /* rectfill(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, makecol(255, 0, 0)); */
+ /* vsync(); vsync(); vsync(); vsync(); */
}
- /* done? */
- if (done)
- /* don't go to sub-msg */
- msg = NULL;
- else
- /* use sub-msg */
- msg = msg->any.sub_msg;
+ /* call message handler */
+ done = jwidget_send_message(widget, msg);
- } while (msg);
+ /* restore clip */
+ if (msg->type == JM_DRAW) {
+ set_clip(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
+
+ /* dirty rectangles */
+ if (ji_dirty_region)
+ ji_add_dirty_rect(&msg->draw.rect);
+
+ release_bitmap(ji_screen);
+ jmouse_show();
+ }
+
+ if (done)
+ break;
+ }
/* remove the message from the msg_queue */
next = link->next;
@@ -1319,6 +1327,25 @@ static void manager_redraw_region(JWidget widget, JRegion region)
Internal routines
**********************************************************************/
+static void generate_setcursor_message(void)
+{
+ JWidget destination;
+ JMessage msg;
+
+ if (capture_widget &&
+ capture_widget->flags & JI_HARDCAPTURE)
+ destination = capture_widget;
+ else
+ destination = mouse_widget;
+
+ if (destination) {
+ msg = new_mouse_msg(JM_SETCURSOR, destination);
+ jmanager_enqueue_message(msg);
+ }
+ else
+ jmouse_set_cursor(JI_CURSOR_NORMAL);
+}
+
static void remove_msgs_for(JWidget widget, JMessage msg)
{
JLink link, next;
@@ -1327,9 +1354,6 @@ static void remove_msgs_for(JWidget widget, JMessage msg)
if (link->data == widget)
jlist_delete_link(msg->any.widgets, link);
}
-
- if (msg->any.sub_msg)
- remove_msgs_for(widget, msg->any.sub_msg);
}
static void generate_proc_windows_list(void)
@@ -1384,9 +1408,11 @@ static JWidget find_magnetic_widget(JWidget widget)
return NULL;
}
-static JMessage new_mouse_msg(int type)
+static JMessage new_mouse_msg(int type, JWidget widget)
{
JMessage msg = jmessage_new(type);
+ if (!msg)
+ return NULL;
msg->mouse.x = jmouse_x(0);
msg->mouse.y = jmouse_y(0);
@@ -1397,34 +1423,24 @@ static JMessage new_mouse_msg(int type)
msg->mouse.right = msg->mouse.flags & 2 ? TRUE: FALSE;
msg->mouse.middle = msg->mouse.flags & 4 ? TRUE: FALSE;
+ assert(widget != NULL);
+ jmessage_add_dest(msg, widget);
+
return msg;
}
static void broadcast_key_msg(JWidget manager, JMessage msg)
{
- JWidget window;
- JLink link;
-
/* send the message to the widget with capture */
- if (capture_widget)
- jmessage_broadcast_to_parents(msg, capture_widget);
+ if (capture_widget) {
+ jmessage_add_dest(msg, capture_widget);
+ }
+ /* send the msg to the focused widget */
+ else if (focus_widget) {
+ jmessage_add_dest(msg, focus_widget);
+ }
+ /* finally, send the message to the manager, it'll know what to do */
else {
- /* send the msg to the focused widget */
- if (focus_widget)
- jmessage_broadcast_to_parents(msg, focus_widget);
-
- /* send to more closest desktop (if the window didn't in foreground) */
- JI_LIST_FOR_EACH(manager->children, link) {
- window = (JWidget)link->data;
-
- jmessage_broadcast_to_children(msg, window);
-
- if (jwindow_is_foreground(window) ||
- jwindow_is_desktop(window))
- break;
- }
-
- /* finally, send the message to the manager, it'll know what to do */
jmessage_add_dest(msg, manager);
}
}
diff --git a/src/jinete/jmem.c b/src/jinete/jmem.c
index bfaaab2f7..834904474 100644
--- a/src/jinete/jmem.c
+++ b/src/jinete/jmem.c
@@ -29,6 +29,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include
#include
#include
#include
@@ -45,52 +46,31 @@
void *jmalloc(unsigned long n_bytes)
{
- if (n_bytes) {
- void *mem;
-
- mem = malloc(n_bytes);
- if (mem)
- return mem;
- }
-
- return NULL;
+ assert(n_bytes != 0);
+ return malloc(n_bytes);
}
void *jmalloc0(unsigned long n_bytes)
{
- if (n_bytes) {
- void *mem;
-
- mem = calloc(1, n_bytes);
- if (mem)
- return mem;
- }
-
- return NULL;
+ assert(n_bytes != 0);
+ return calloc(1, n_bytes);
}
void *jrealloc(void *mem, unsigned long n_bytes)
{
- if (n_bytes) {
- void *newmem = realloc(mem, n_bytes);
- if (newmem)
- return newmem;
- }
-
- if (mem)
- jfree(mem);
-
- return NULL;
+ assert(n_bytes != 0);
+ return realloc(mem, n_bytes);
}
void jfree(void *mem)
{
- if (mem)
- free(mem);
+ assert(mem != NULL);
+ free(mem);
}
char *jstrdup(const char *string)
{
+ assert(string != NULL);
return ustrdup(string);
}
@@ -122,7 +102,7 @@ void jmemleak_exit()
FILE *f = fopen("_ase_memlog.txt", "wt");
slot_t *it;
- if (f) {
+ if (f != NULL) {
/* memory leaks */
for (it=headslot; it!=NULL; it=it->next) {
fprintf(f,
@@ -143,6 +123,9 @@ static void addslot(void *ptr, unsigned long size)
{
slot_t *p = malloc(sizeof(slot_t));
+ assert(ptr != NULL);
+ assert(size != 0);
+
p->backtrace[0] = __builtin_return_address(4); /* a GCC extension */
p->backtrace[1] = __builtin_return_address(3);
p->backtrace[2] = __builtin_return_address(2);
@@ -160,6 +143,8 @@ static void delslot(void *ptr)
{
slot_t *it, *prev = NULL;
+ assert(ptr != NULL);
+
jmutex_lock(mutex);
for (it=headslot; it!=NULL; prev=it, it=it->next) {
@@ -179,63 +164,69 @@ static void delslot(void *ptr)
void *jmalloc(unsigned long n_bytes)
{
- if (n_bytes) {
- void *mem;
+ void *mem;
- mem = malloc(n_bytes);
- if (mem) {
- addslot(mem, n_bytes);
- return mem;
- }
+ assert(n_bytes != 0);
+
+ mem = malloc(n_bytes);
+ if (mem != NULL) {
+ addslot(mem, n_bytes);
+ return mem;
}
-
- return NULL;
+ else
+ return NULL;
}
void *jmalloc0(unsigned long n_bytes)
{
- if (n_bytes) {
- void *mem;
+ void *mem;
- mem = calloc(1, n_bytes);
- if (mem) {
- addslot(mem, n_bytes);
- return mem;
- }
+ assert(n_bytes != 0);
+
+ mem = calloc(1, n_bytes);
+ if (mem != NULL) {
+ addslot(mem, n_bytes);
+ return mem;
}
-
- return NULL;
+ else
+ return NULL;
}
void *jrealloc(void *mem, unsigned long n_bytes)
{
- if (n_bytes) {
- void *newmem = realloc(mem, n_bytes);
- if (newmem) {
- if (mem) delslot(mem);
- addslot(newmem, n_bytes);
- return newmem;
- }
+ void *newmem;
+
+ assert(n_bytes != 0);
+
+ newmem = realloc(mem, n_bytes);
+ if (newmem != NULL) {
+ if (mem != NULL)
+ delslot(mem);
+
+ addslot(newmem, n_bytes);
+ return newmem;
}
-
- if (mem)
- jfree(mem);
-
- return NULL;
+ else
+ return NULL;
}
void jfree(void *mem)
{
+ assert(mem != NULL);
delslot(mem);
- if (mem)
- free(mem);
+ free(mem);
}
char *jstrdup(const char *string)
{
- void *mem = ustrdup(string);
- if (mem)
+ void *mem;
+
+ assert(string != NULL);
+
+ mem = ustrdup(string);
+ if (mem != NULL)
addslot(mem, strlen(mem));
+
return mem;
}
diff --git a/src/jinete/jmenu.c b/src/jinete/jmenu.c
index eabe66855..c1aefa140 100644
--- a/src/jinete/jmenu.c
+++ b/src/jinete/jmenu.c
@@ -570,7 +570,7 @@ static bool menubox_msg_proc(JWidget widget, JMessage msg)
}
break;
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (menu) {
JWidget selected;
diff --git a/src/jinete/jmessage.c b/src/jinete/jmessage.c
index 4eb964521..bc1cabb94 100644
--- a/src/jinete/jmessage.c
+++ b/src/jinete/jmessage.c
@@ -76,6 +76,10 @@ JMessage jmessage_new_key_related(int type, int readkey_value)
msg->key.scancode = (readkey_value >> 8) & 0xff;
msg->key.ascii = readkey_value & 0xff;
+ msg->key.repeat = 0;
+ msg->key.propagate_to_children = FALSE;
+ msg->key.propagate_to_parent = TRUE;
+
#if 0
printf("%i: %i %i [%c]\n", type, msg->key.scancode,
msg->key.ascii, msg->key.ascii);
@@ -96,8 +100,6 @@ JMessage jmessage_new_copy(const JMessage msg)
memcpy(copy, msg, sizeof(union jmessage));
copy->any.widgets = jlist_copy(msg->any.widgets);
- copy->any.sub_msg = msg->any.sub_msg ?
- jmessage_new_copy(msg->any.sub_msg): NULL;
copy->any.used = FALSE;
return copy;
@@ -107,9 +109,6 @@ void jmessage_free(JMessage msg)
{
assert(msg != NULL);
- if (msg->any.sub_msg)
- jmessage_free(msg->any.sub_msg);
-
jlist_free(msg->any.widgets);
jfree(msg);
}
@@ -153,13 +152,3 @@ void jmessage_broadcast_to_parents(JMessage msg, JWidget widget)
jmessage_broadcast_to_parents(msg, jwidget_get_parent(widget));
}
}
-
-void jmessage_set_sub_msg(JMessage msg, JMessage sub_msg)
-{
- assert(msg != NULL);
-
- if (msg->any.sub_msg)
- jmessage_free(msg->any.sub_msg);
-
- msg->any.sub_msg = sub_msg ? jmessage_new_copy(sub_msg): NULL;
-}
diff --git a/src/jinete/jmessage.h b/src/jinete/jmessage.h
index b0b620281..1ad0c96b9 100644
--- a/src/jinete/jmessage.h
+++ b/src/jinete/jmessage.h
@@ -51,7 +51,6 @@ struct jmessage_any
{
int type; /* type of message */
JList widgets; /* destination widgets */
- JMessage sub_msg; /* sub-message if this msg isn't used */
bool used : 1; /* was used */
int shifts; /* key shifts pressed when message was created */
};
@@ -67,6 +66,9 @@ struct jmessage_key
struct jmessage_any any;
unsigned scancode : 8; /* Allegro scancode */
unsigned ascii : 8; /* ASCII code */
+ unsigned repeat; /* repeat=0 means the first time the key is pressed */
+ bool propagate_to_children : 1;
+ bool propagate_to_parent : 1;
};
struct jmessage_draw
@@ -154,11 +156,6 @@ void jmessage_add_pre_dest(JMessage msg, JWidget widget);
void jmessage_broadcast_to_children(JMessage msg, JWidget widget);
void jmessage_broadcast_to_parents(JMessage msg, JWidget widget);
-void jmessage_set_sub_msg(JMessage msg, JMessage sub_msg);
-
-/* TODO */
-/* void jmessage_set_marshal(JMessage msg, JMarshal marshal); */
-
JI_END_DECLS
#endif /* JINETE_MSG_H */
diff --git a/src/jinete/jpanel.c b/src/jinete/jpanel.c
index 15f9b9b2f..653f50a01 100644
--- a/src/jinete/jpanel.c
+++ b/src/jinete/jpanel.c
@@ -133,7 +133,7 @@ static bool panel_msg_proc(JWidget widget, JMessage msg)
if (!click_bar)
break;
- jwidget_capture_mouse(widget);
+ jwidget_hard_capture_mouse(widget);
/* Continue with motion message... */
}
else
@@ -144,16 +144,10 @@ static bool panel_msg_proc(JWidget widget, JMessage msg)
Panel *panel = jwidget_get_data(widget, JI_PANEL);
if (widget->align & JI_HORIZONTAL) {
- if (jmouse_get_cursor() != JI_CURSOR_SIZE_L)
- jmouse_set_cursor(JI_CURSOR_SIZE_L);
-
panel->pos =
100.0 * (msg->mouse.x-widget->rc->x1) / jrect_w(widget->rc);
}
else {
- if (jmouse_get_cursor() != JI_CURSOR_SIZE_T)
- jmouse_set_cursor(JI_CURSOR_SIZE_T);
-
panel->pos =
100.0 * (msg->mouse.y-widget->rc->y1) / jrect_h(widget->rc);
}
@@ -164,8 +158,17 @@ static bool panel_msg_proc(JWidget widget, JMessage msg)
jwidget_dirty(widget);
return TRUE;
}
- /* handle mouse cursor */
- else if (jwidget_is_enabled(widget)) {
+ break;
+
+ case JM_BUTTONRELEASED:
+ if (jwidget_has_capture(widget)) {
+ jwidget_release_mouse(widget);
+ return TRUE;
+ }
+ break;
+
+ case JM_SETCURSOR:
+ if (jwidget_is_enabled(widget)) {
JWidget c1, c2;
JLink link;
int x1, y1, x2, y2;
@@ -198,37 +201,17 @@ static bool panel_msg_proc(JWidget widget, JMessage msg)
}
if (change_cursor) {
- if (widget->align & JI_HORIZONTAL) {
- if (jmouse_get_cursor() != JI_CURSOR_SIZE_L)
- jmouse_set_cursor(JI_CURSOR_SIZE_L);
- }
- else {
- if (jmouse_get_cursor() != JI_CURSOR_SIZE_T)
- jmouse_set_cursor(JI_CURSOR_SIZE_T);
- }
+ if (widget->align & JI_HORIZONTAL)
+ jmouse_set_cursor(JI_CURSOR_SIZE_L);
+ else
+ jmouse_set_cursor(JI_CURSOR_SIZE_T);
return TRUE;
}
- else {
- if (jmouse_get_cursor() != JI_CURSOR_NORMAL)
- jmouse_set_cursor(JI_CURSOR_NORMAL);
- }
+ else
+ return FALSE;
}
break;
- case JM_BUTTONRELEASED:
- if (jwidget_has_capture(widget)) {
- jwidget_release_mouse(widget);
- jmouse_set_cursor(JI_CURSOR_NORMAL);
- return TRUE;
- }
- break;
-
-/* case JM_MOUSEENTER: */
-/* case JM_MOUSELEAVE: */
- /* TODO theme stuff */
-/* if (jwidget_is_enabled(widget)) */
-/* jwidget_dirty(widget); */
-/* break; */
}
return FALSE;
@@ -256,7 +239,7 @@ static void panel_request_size(JWidget widget, int *w, int *h)
nvis_children = 0;
JI_LIST_FOR_EACH(widget->children, link) {
child = (JWidget)link->data;
- if (jwidget_is_visible(child))
+ if (!(child->flags & JI_HIDDEN))
nvis_children++;
}
@@ -265,7 +248,7 @@ static void panel_request_size(JWidget widget, int *w, int *h)
JI_LIST_FOR_EACH(widget->children, link) {
child = (JWidget)link->data;
- if (jwidget_is_hidden(child))
+ if (child->flags & JI_HIDDEN)
continue;
jwidget_request_size(child, &req_w, &req_h);
diff --git a/src/jinete/jslider.c b/src/jinete/jslider.c
index b5eca4e72..0a4458321 100644
--- a/src/jinete/jslider.c
+++ b/src/jinete/jslider.c
@@ -46,8 +46,13 @@ typedef struct Slider
int value;
} Slider;
+static int slider_press_x;
+static int slider_press_value;
+static int slider_press_left;
+
static bool slider_msg_proc(JWidget widget, JMessage msg);
static void slider_request_size(JWidget widget, int *w, int *h);
+static void slider_setcursor(JWidget widget);
JWidget jslider_new(int min, int max, int value)
{
@@ -107,9 +112,6 @@ void jtheme_slider_info(JWidget widget, int *min, int *max, int *value)
static bool slider_msg_proc(JWidget widget, JMessage msg)
{
- static int slider_press_x;
- static int slider_press_value;
- static int slider_press_left;
Slider *slider = jwidget_get_data(widget, JI_SLIDER);
switch (msg->type) {
@@ -133,16 +135,13 @@ static bool slider_msg_proc(JWidget widget, JMessage msg)
return TRUE;
jwidget_select(widget);
- jwidget_capture_mouse(widget);
+ jwidget_hard_capture_mouse(widget);
slider_press_x = msg->mouse.x;
slider_press_value = slider->value;
slider_press_left = msg->mouse.left;
-
- if (slider_press_left)
- jmouse_set_cursor(JI_CURSOR_HAND);
- else
- jmouse_set_cursor(JI_CURSOR_MOVE);
+
+ slider_setcursor(widget);
/* continue to JM_MOTION */
@@ -175,9 +174,20 @@ static bool slider_msg_proc(JWidget widget, JMessage msg)
jwidget_emit_signal(widget, JI_SIGNAL_SLIDER_CHANGE);
}
+ /* for left click */
+ if (slider_press_left) {
+ int x = jmouse_x(0);
+
+ if (x < widget->rc->x1)
+ x = widget->rc->x1;
+ else if (x > widget->rc->x2)
+ x = widget->rc->x2;
+
+ if (x != jmouse_x(0))
+ jmouse_set_position(x, jmouse_y(0));
+ }
/* for right click */
- if ((!slider_press_left) &&
- (jmouse_control_infinite_scroll(rect))) {
+ else if (jmouse_control_infinite_scroll(rect)) {
slider_press_x = jmouse_x(0);
slider_press_value = slider->value;
}
@@ -191,8 +201,7 @@ static bool slider_msg_proc(JWidget widget, JMessage msg)
if (jwidget_has_capture(widget)) {
jwidget_deselect(widget);
jwidget_release_mouse(widget);
-
- jmouse_set_cursor(JI_CURSOR_NORMAL);
+ slider_setcursor(widget);
}
break;
@@ -214,7 +223,7 @@ static bool slider_msg_proc(JWidget widget, JMessage msg)
jwidget_dirty(widget);
break;
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (jwidget_has_focus (widget)) {
int min = slider->min;
int max = slider->max;
@@ -253,6 +262,10 @@ static bool slider_msg_proc(JWidget widget, JMessage msg)
return TRUE;
}
break;
+
+ case JM_SETCURSOR:
+ slider_setcursor(widget);
+ return TRUE;
}
return FALSE;
@@ -276,3 +289,15 @@ static void slider_request_size(JWidget widget, int *w, int *h)
*w += widget->border_width.l + widget->border_width.r;
*h += widget->border_width.t + widget->border_width.b;
}
+
+static void slider_setcursor(JWidget widget)
+{
+ if (jwidget_has_capture(widget)) {
+ if (slider_press_left)
+ jmouse_set_cursor(JI_CURSOR_NORMAL);
+ else
+ jmouse_set_cursor(JI_CURSOR_SIZE_L);
+ }
+ else
+ jmouse_set_cursor(JI_CURSOR_NORMAL);
+}
diff --git a/src/jinete/jsystem.c b/src/jinete/jsystem.c
index f6d483680..f842a349e 100644
--- a/src/jinete/jsystem.c
+++ b/src/jinete/jsystem.c
@@ -241,31 +241,35 @@ int jmouse_get_cursor(void)
int jmouse_set_cursor(int type)
{
- JTheme theme = ji_get_theme();
- int old = m_cursor;
- m_cursor = type;
-
- if (m_cursor == JI_CURSOR_NULL) {
- show_mouse(NULL);
- set_cursor(NULL, 0, 0);
- }
+ if (m_cursor == type)
+ return type;
else {
- show_mouse(NULL);
+ JTheme theme = ji_get_theme();
+ int old = m_cursor;
+ m_cursor = type;
- if (theme->set_cursor) {
- BITMAP *sprite;
- int x = 0;
- int y = 0;
+ if (m_cursor == JI_CURSOR_NULL) {
+ show_mouse(NULL);
+ set_cursor(NULL, 0, 0);
+ }
+ else {
+ show_mouse(NULL);
- sprite = (*theme->set_cursor)(type, &x, &y);
- set_cursor(sprite, x, y);
+ if (theme->set_cursor) {
+ BITMAP *sprite;
+ int x = 0;
+ int y = 0;
+
+ sprite = (*theme->set_cursor)(type, &x, &y);
+ set_cursor(sprite, x, y);
+ }
+
+ if (ji_screen == screen)
+ show_mouse(ji_screen);
}
- if (ji_screen == screen)
- show_mouse(ji_screen);
+ return old;
}
-
- return old;
}
/**
diff --git a/src/jinete/jsystem.h b/src/jinete/jsystem.h
index 4ce0837d9..bf0467918 100644
--- a/src/jinete/jsystem.h
+++ b/src/jinete/jsystem.h
@@ -83,6 +83,7 @@ enum {
JI_CURSOR_SIZE_BL,
JI_CURSOR_SIZE_B,
JI_CURSOR_SIZE_BR,
+ JI_CURSOR_EYEDROPPER,
JI_CURSORS
};
diff --git a/src/jinete/jtextbox.c b/src/jinete/jtextbox.c
index 0ddc991b8..bc1ae5138 100644
--- a/src/jinete/jtextbox.c
+++ b/src/jinete/jtextbox.c
@@ -75,7 +75,7 @@ static bool textbox_msg_proc(JWidget widget, JMessage msg)
}
break;
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (jwidget_has_focus(widget)) {
JWidget view = jwidget_get_view(widget);
if (view) {
diff --git a/src/jinete/jtheme.c b/src/jinete/jtheme.c
index 9a134ea08..2bf0083a8 100644
--- a/src/jinete/jtheme.c
+++ b/src/jinete/jtheme.c
@@ -32,6 +32,7 @@
#include
#include
+#include "jinete/jdraw.h"
#include "jinete/jfont.h"
#include "jinete/jmanager.h"
#include "jinete/jrect.h"
@@ -252,49 +253,6 @@ void _ji_theme_draw_sprite_color(BITMAP *bmp, BITMAP *sprite,
putpixel(bmp, x+u, y+v, color);
}
-void _ji_theme_rectedge(BITMAP *bmp,
- int x1, int y1, int x2, int y2, int c1, int c2)
-{
- vline(bmp, x1, y1, y2, c1);
- vline(bmp, x2, y1, y2, c2);
-
- hline(bmp, x1+1, y1, x2-1, c1);
- hline(bmp, x1+1, y2, x2-1, c2);
-}
-
-void _ji_theme_rectfill_exclude(BITMAP *bmp,
- int x1, int y1, int x2, int y2,
- int ex1, int ey1, int ex2, int ey2, int color)
-{
- if ((ex1 > x2) || (ex2 < x1) ||
- (ey1 > y2) || (ey2 < y1))
- rectfill(bmp, x1, y1, x2, y2, color);
- else {
- int y, my1, my2;
-
- my1 = MAX(y1, ey1);
- my2 = MIN(y2, ey2);
-
- /* top */
- for (y=y1; y ex2)
- for (y=my1; y<=my2; y++)
- hline(bmp, ex2+1, y, x2, color);
-
- /* bottom */
- for (y=ey2+1; y<=y2; y++)
- hline(bmp, x1, y, x2, color);
- }
-}
-
void _ji_theme_textbox_draw(BITMAP *bmp, JWidget widget,
int *w, int *h, int bg, int fg)
{
@@ -425,10 +383,9 @@ void _ji_theme_textbox_draw(BITMAP *bmp, JWidget widget,
draw_text(bmp, font, beg, xout, y, fg, bg, TRUE);
- _ji_theme_rectfill_exclude
- (bmp,
- x1, y, x2, y+textheight-1,
- xout, y, xout+len-1, y+textheight-1, bg);
+ jrectexclude(bmp,
+ x1, y, x2, y+textheight-1,
+ xout, y, xout+len-1, y+textheight-1, bg);
}
/* width */
diff --git a/src/jinete/jtooltips.c b/src/jinete/jtooltips.c
index b0b2222d4..d20e1e0de 100644
--- a/src/jinete/jtooltips.c
+++ b/src/jinete/jtooltips.c
@@ -16,8 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "config.h"
-
+#include
#include
#include "jinete/jinete.h"
@@ -30,11 +29,20 @@ typedef struct TipData
int timer_id;
} TipData;
+typedef struct TipWindow
+{
+ bool close_on_buttonpressed;
+ JRegion hot_region;
+ bool filtering;
+} TipWindow;
+
static int tip_type(void);
static bool tip_hook(JWidget widget, JMessage msg);
-static JWidget tip_window_new(const char *text);
-static bool tip_window_hook(JWidget widget, JMessage msg);
+static JWidget tipwindow_new(const char *text, bool close_on_buttonpressed);
+static int tipwindow_type(void);
+static TipWindow *tipwindow_data(JWidget widget);
+static bool tipwindow_msg_proc(JWidget widget, JMessage msg);
void jwidget_add_tooltip_text(JWidget widget, const char *text)
{
@@ -48,6 +56,35 @@ void jwidget_add_tooltip_text(JWidget widget, const char *text)
jwidget_add_hook(widget, tip_type(), tip_hook, tip);
}
+/**
+ * Creates a window to show a tool-tip.
+ */
+JWidget jtooltip_window_new(const char *text)
+{
+ JWidget window = tipwindow_new(text, FALSE);
+
+ return window;
+}
+
+void jtooltip_window_set_hotregion(JWidget widget, JRegion region)
+{
+ TipWindow *tipwindow = tipwindow_data(widget);
+
+ assert(region != NULL);
+
+ if (tipwindow->hot_region != NULL)
+ jfree(tipwindow->hot_region);
+
+ if (!tipwindow->filtering) {
+ tipwindow->filtering = TRUE;
+ jmanager_add_msg_filter(JM_MOTION, widget);
+ }
+ tipwindow->hot_region = region;
+}
+
+/********************************************************************/
+/* hook for widgets that want a tool-tip */
+
static int tip_type(void)
{
static int type = 0;
@@ -78,7 +115,6 @@ static bool tip_hook(JWidget widget, JMessage msg)
jmanager_start_timer(tip->timer_id);
break;
- case JM_CHAR:
case JM_KEYPRESSED:
case JM_BUTTONPRESSED:
case JM_MOUSELEAVE:
@@ -95,7 +131,7 @@ static bool tip_hook(JWidget widget, JMessage msg)
case JM_TIMER:
if (msg->timer.timer_id == tip->timer_id) {
if (!tip->window) {
- JWidget window = tip_window_new(tip->text);
+ JWidget window = tipwindow_new(tip->text, TRUE);
int x = tip->widget->rc->x1;
int y = tip->widget->rc->y2;
int w = jrect_w(window->rc);
@@ -117,68 +153,156 @@ static bool tip_hook(JWidget widget, JMessage msg)
return FALSE;
}
-static JWidget tip_window_new(const char *text)
+/********************************************************************/
+/* TipWindow */
+
+static JWidget tipwindow_new(const char *text, bool close_on_buttonpressed)
{
JWidget window = jwindow_new(text);
JLink link, next;
+ TipWindow *tipwindow = jnew(TipWindow, 1);
+
+ tipwindow->close_on_buttonpressed = close_on_buttonpressed;
+ tipwindow->hot_region = NULL;
+ tipwindow->filtering = FALSE;
jwindow_sizeable(window, FALSE);
jwindow_moveable(window, FALSE);
jwindow_wantfocus(window, FALSE);
-/* jwidget_set_align(window, JI_CENTER | JI_MIDDLE); */
jwidget_set_align(window, JI_LEFT | JI_TOP);
/* remove decorative widgets */
- JI_LIST_FOR_EACH_SAFE(window->children, link, next) {
+ JI_LIST_FOR_EACH_SAFE(window->children, link, next)
jwidget_free(link->data);
- }
- jwidget_add_hook(window, JI_WIDGET, tip_window_hook, NULL);
+ jwidget_add_hook(window, tipwindow_type(),
+ tipwindow_msg_proc, tipwindow);
jwidget_init_theme(window);
+ jwidget_set_bg_color(window, makecol(255, 255, 200));
return window;
}
-static bool tip_window_hook(JWidget widget, JMessage msg)
+static int tipwindow_type(void)
{
+ static int type = 0;
+ if (!type)
+ type = ji_register_widget_type();
+ return type;
+}
+
+static TipWindow *tipwindow_data(JWidget widget)
+{
+ return (TipWindow *)jwidget_get_data(widget,
+ tipwindow_type());
+}
+
+static bool tipwindow_msg_proc(JWidget widget, JMessage msg)
+{
+ TipWindow *tipwindow = tipwindow_data(widget);
+
switch (msg->type) {
- case JM_REQSIZE:
- _ji_theme_textbox_draw(NULL, widget,
- &msg->reqsize.w,
- &msg->reqsize.h, 0, 0);
+ case JM_CLOSE:
+ if (tipwindow->filtering) {
+ tipwindow->filtering = FALSE;
+ jmanager_remove_msg_filter(JM_MOTION, widget);
+ }
+ break;
-/* msg->reqsize.w += widget->border_width.l + widget->border_width.r; */
-/* msg->reqsize.h += widget->border_width.t + widget->border_width.b; */
+ case JM_DESTROY:
+ if (tipwindow->hot_region != NULL) {
+ jregion_free(tipwindow->hot_region);
+ }
+ jfree(tipwindow);
+ break;
+
+ case JM_REQSIZE: {
+ int w = 0, h = 0;
+
+ _ji_theme_textbox_draw(NULL, widget, &w, &h, 0, 0);
+
+ msg->reqsize.w = w;
+ msg->reqsize.h = widget->border_width.t + widget->border_width.b;
+
+ if (!jlist_empty(widget->children)) {
+ int max_w, max_h;
+ int req_w, req_h;
+ JWidget child;
+ JLink link;
+
+ max_w = max_h = 0;
+ JI_LIST_FOR_EACH(widget->children, link) {
+ child = (JWidget)link->data;
+
+ jwidget_request_size(child, &req_w, &req_h);
+
+ max_w = MAX(max_w, req_w);
+ max_h = MAX(max_h, req_h);
+ }
+
+ msg->reqsize.w = MAX(msg->reqsize.w,
+ widget->border_width.l + max_w + widget->border_width.r);
+ msg->reqsize.h += max_h;
+ }
return TRUE;
+ }
case JM_SIGNAL:
if (msg->signal.num == JI_SIGNAL_INIT_THEME) {
+ int w = 0, h = 0;
+
widget->border_width.l = 3;
widget->border_width.t = 3;
widget->border_width.r = 3;
widget->border_width.b = 3;
+
+ _ji_theme_textbox_draw(NULL, widget, &w, &h, 0, 0);
+
+ widget->border_width.t = h-3;
return TRUE;
}
break;
case JM_MOUSELEAVE:
+ if (tipwindow->hot_region == NULL)
+ jwindow_close(widget, NULL);
+ break;
+
case JM_BUTTONPRESSED:
- jwindow_close(widget, NULL);
+ if (tipwindow->close_on_buttonpressed)
+ jwindow_close(widget, NULL);
+ break;
+
+ case JM_MOTION:
+ if (tipwindow->hot_region != NULL &&
+ jmanager_get_capture() == NULL) {
+ struct jrect box;
+
+ /* if the mouse is outside the hot-region we have to close the window */
+ if (!jregion_point_in(tipwindow->hot_region,
+ msg->mouse.x, msg->mouse.y, &box)) {
+ jwindow_close(widget, NULL);
+ }
+ }
break;
case JM_DRAW: {
JRect pos = jwidget_get_rect(widget);
+ int oldt;
jdraw_rect(pos, makecol(0, 0, 0));
jrect_shrink(pos, 1);
- jdraw_rectfill(pos, makecol(255, 255, 140));
+ jdraw_rectfill(pos, widget->bg_color);
+ oldt = widget->border_width.t;
+ widget->border_width.t = 3;
_ji_theme_textbox_draw(ji_screen, widget, NULL, NULL,
- makecol(255, 255, 140),
- makecol(0, 0, 0));
+ widget->bg_color,
+ ji_color_foreground());
+ widget->border_width.t = oldt;
return TRUE;
}
diff --git a/src/jinete/jtooltips.h b/src/jinete/jtooltips.h
index 813e86f2a..19b7d4a8d 100644
--- a/src/jinete/jtooltips.h
+++ b/src/jinete/jtooltips.h
@@ -38,6 +38,9 @@ JI_BEGIN_DECLS
void jwidget_add_tooltip_text(JWidget widget, const char *text);
+JWidget jtooltip_window_new(const char *text);
+void jtooltip_window_set_hotregion(JWidget window, JRegion region);
+
JI_END_DECLS
#endif /* JINETE_VIEW_H */
diff --git a/src/jinete/jview.c b/src/jinete/jview.c
index 84e187b98..302286c42 100644
--- a/src/jinete/jview.c
+++ b/src/jinete/jview.c
@@ -555,7 +555,7 @@ static bool scrollbar_msg_proc(JWidget widget, JMessage msg)
}
case JM_MOTION:
- if (jwidget_has_capture (widget)) {
+ if (jwidget_has_capture(widget)) {
View *view = jwidget_get_data(widget->parent, JI_VIEW);
int pos, len, bar_size, viewport_size;
int old_pos;
diff --git a/src/jinete/jwidget.c b/src/jinete/jwidget.c
index 85faeed0f..9124e2095 100644
--- a/src/jinete/jwidget.c
+++ b/src/jinete/jwidget.c
@@ -310,6 +310,16 @@ void jwidget_set_text(JWidget widget, const char *text)
{
assert_valid_widget(widget);
+ jwidget_set_text_soft(widget, text);
+
+ jwidget_emit_signal(widget, JI_SIGNAL_SET_TEXT);
+ jwidget_dirty(widget);
+}
+
+void jwidget_set_text_soft(JWidget widget, const char *text)
+{
+ assert_valid_widget(widget);
+
if (text) {
/* more space needed */
if (!widget->text || widget->text_size < strlen (text)+1) {
@@ -323,9 +333,6 @@ void jwidget_set_text(JWidget widget, const char *text)
if (widget->text_font)
widget->text_size_pix = ji_font_text_len(widget->text_font,
widget->text);
-
- jwidget_emit_signal(widget, JI_SIGNAL_SET_TEXT);
- jwidget_dirty(widget);
}
/* NULL text */
else if (widget->text) {
@@ -356,6 +363,7 @@ void jwidget_set_font(JWidget widget, FONT *font)
else
widget->text_size_pix = 0;
+ jwidget_emit_signal(widget, JI_SIGNAL_SET_FONT);
jwidget_dirty(widget);
}
@@ -436,25 +444,7 @@ bool jwidget_is_focusrest(JWidget widget)
void jwidget_dirty(JWidget widget)
{
assert_valid_widget(widget);
-
-#if 0
- /* is visible? */
- if (jwidget_is_visible (widget)) {
- JMessage msg;
-
- /* dirty it */
- widget->flags |= JI_DIRTY;
-
- /* dirty children */
- msg = jmessage_new(JM_DIRTYCHILDREN);
- jwidget_send_message(widget, msg);
- jmessage_free(msg);
-
- jwidget_emit_signal(widget, JI_SIGNAL_DIRTY);
- }
-#else
jwidget_invalidate(widget);
-#endif
}
void jwidget_show(JWidget widget)
@@ -626,7 +616,7 @@ void jwidget_add_child(JWidget widget, JWidget child)
jwidget_emit_signal(widget, JI_SIGNAL_ADD_CHILD);
}
-void jwidget_add_childs(JWidget widget, ...)
+void jwidget_add_children(JWidget widget, ...)
{
JWidget child;
va_list ap;
@@ -635,7 +625,7 @@ void jwidget_add_childs(JWidget widget, ...)
va_start(ap, widget);
- while ((child = va_arg(ap, JWidget)))
+ while ((child=va_arg(ap, JWidget)) != NULL)
jwidget_add_child(widget, child);
va_end(ap);
@@ -791,6 +781,12 @@ void jwidget_request_size(JWidget widget, int *w, int *h)
jmessage_free(msg);
}
+void jwidget_relayout(JWidget widget)
+{
+ jwidget_set_rect(widget, widget->rc);
+ jwidget_dirty(widget);
+}
+
/* gets the position of the widget */
JRect jwidget_get_rect(JWidget widget)
{
@@ -827,8 +823,8 @@ JRegion jwidget_get_region(JWidget widget)
/* gets the region to be able to draw in */
JRegion jwidget_get_drawable_region(JWidget widget, int flags)
{
+ JWidget window, manager, view, child;
JRegion region, reg1, reg2, reg3;
- JWidget window, manager, view;
JList windows_list;
JLink link;
JRect cpos;
@@ -862,29 +858,32 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags)
}
}
- /* cut the areas where are children */
+ /* clip the areas where are children */
if (!(flags & JI_GDR_USECHILDAREA) && !jlist_empty(widget->children)) {
cpos = jwidget_get_child_rect(widget);
reg1 = jregion_new(NULL, 0);
reg2 = jregion_new(cpos, 1);
JI_LIST_FOR_EACH(widget->children, link) {
- reg3 = jwidget_get_region(link->data);
- if (((JWidget)link->data)->flags & JI_DECORATIVE) {
- jregion_reset(reg1, widget->rc);
- jregion_intersect(reg1, reg1, reg3);
+ child = link->data;
+ if (jwidget_is_visible(child)) {
+ reg3 = jwidget_get_region(child);
+ if (child->flags & JI_DECORATIVE) {
+ jregion_reset(reg1, widget->rc);
+ jregion_intersect(reg1, reg1, reg3);
+ }
+ else {
+ jregion_intersect(reg1, reg2, reg3);
+ }
+ jregion_subtract(region, region, reg1);
+ jregion_free(reg3);
}
- else {
- jregion_intersect(reg1, reg2, reg3);
- }
- jregion_subtract(region, region, reg1);
- jregion_free(reg3);
}
jregion_free(reg1);
jregion_free(reg2);
jrect_free(cpos);
}
- /* cut the parent area */
+ /* intersect with the parent area */
if (!(widget->flags & JI_DECORATIVE)) {
JWidget parent = widget->parent;
@@ -1411,7 +1410,11 @@ void jwidget_close_window(JWidget widget)
/**
* Captures the mouse to send the future JM_BUTTONRELEASED messsage to
- * the specified widget.
+ * the specified widget. There are messages like JM_MOTION and
+ * JM_SETCURSOR that are sent normally to the widget with the mouse
+ * (and not with the "soft" capture).
+ *
+ * @see jwidget_hard_capture_mouse
*/
void jwidget_capture_mouse(JWidget widget)
{
@@ -1427,7 +1430,9 @@ void jwidget_capture_mouse(JWidget widget)
/**
* Captures the mouse to send all the future mouse messsages to the
- * specified widget.
+ * specified widget (included the JM_MOTION and JM_SETCURSOR).
+ *
+ * @see jwidget_capture_mouse
*/
void jwidget_hard_capture_mouse(JWidget widget)
{
@@ -1514,13 +1519,25 @@ bool jwidget_check_underscored(JWidget widget, int scancode)
static bool widget_msg_proc(JWidget widget, JMessage msg)
{
+ assert(msg != NULL);
assert_valid_widget(widget);
switch (msg->type) {
+ case JM_OPEN:
+ case JM_CLOSE:
+ case JM_WINMOVE: {
+ JLink link;
+
+ /* broadcast the message to the children */
+ JI_LIST_FOR_EACH(widget->children, link)
+ jwidget_send_message(link->data, msg);
+ break;
+ }
+
case JM_DRAW:
if (widget->draw_method) {
- (*widget->draw_method) (widget);
+ (*widget->draw_method)(widget, &msg->draw.rect);
return TRUE;
}
break;
@@ -1605,6 +1622,43 @@ static bool widget_msg_proc(JWidget widget, JMessage msg)
return TRUE;
}
+
+ case JM_KEYPRESSED:
+ case JM_KEYRELEASED:
+ if (msg->key.propagate_to_children) {
+ JLink link;
+
+ /* broadcast the message to the children */
+ JI_LIST_FOR_EACH(widget->children, link)
+ jwidget_send_message(link->data, msg);
+ }
+
+ /* propagate the message to the parent */
+ if (msg->key.propagate_to_parent && widget->parent != NULL)
+ return jwidget_send_message(widget->parent, msg);
+ else
+ break;
+
+ case JM_BUTTONPRESSED:
+ case JM_BUTTONRELEASED:
+ case JM_DOUBLECLICK:
+ case JM_MOTION:
+ case JM_WHEEL:
+ /* propagate the message to the parent */
+ if (widget->parent != NULL)
+ return jwidget_send_message(widget->parent, msg);
+ else
+ break;
+
+ case JM_SETCURSOR:
+ /* propagate the message to the parent */
+ if (widget->parent != NULL)
+ return jwidget_send_message(widget->parent, msg);
+ else {
+ jmouse_set_cursor(JI_CURSOR_NORMAL);
+ return TRUE;
+ }
+
}
return FALSE;
diff --git a/src/jinete/jwidget.h b/src/jinete/jwidget.h
index 6e3f7ff4e..32e2f35d1 100644
--- a/src/jinete/jwidget.h
+++ b/src/jinete/jwidget.h
@@ -123,6 +123,7 @@ struct FONT *jwidget_get_font(JWidget widget);
void jwidget_set_name(JWidget widget, const char *name);
void jwidget_set_text(JWidget widget, const char *text);
+void jwidget_set_text_soft(JWidget widget, const char *text);
void jwidget_set_align(JWidget widget, int align);
void jwidget_set_font(JWidget widget, struct FONT *font);
@@ -164,7 +165,7 @@ bool jwidget_has_capture(JWidget widget);
/* children handle */
void jwidget_add_child(JWidget widget, JWidget child);
-void jwidget_add_childs(JWidget widget, ...);
+void jwidget_add_children(JWidget widget, ...);
void jwidget_remove_child(JWidget widget, JWidget child);
void jwidget_replace_child(JWidget widget, JWidget old_child,
JWidget new_child);
@@ -182,6 +183,7 @@ bool jwidget_has_child(JWidget widget, JWidget child);
/* position and geometry */
void jwidget_request_size(JWidget widget, int *w, int *h);
+void jwidget_relayout(JWidget widget);
JRect jwidget_get_rect(JWidget widget);
JRect jwidget_get_child_rect(JWidget widget);
JRegion jwidget_get_region(JWidget widget);
diff --git a/src/jinete/jwindow.c b/src/jinete/jwindow.c
index cdbebda33..1014b9f01 100644
--- a/src/jinete/jwindow.c
+++ b/src/jinete/jwindow.c
@@ -67,7 +67,7 @@ static bool window_msg_proc(JWidget widget, JMessage msg);
static void window_request_size(JWidget widget, int *w, int *h);
static void window_set_position(JWidget widget, JRect rect);
-static int setup_cursor(JWidget widget, int x, int y);
+static int get_action(JWidget widget, int x, int y);
static void limit_size(JWidget widget, int *w, int *h);
static void move_window(JWidget widget, JRect rect, bool use_blit);
static void displace_widgets(JWidget widget, int x, int y);
@@ -332,8 +332,7 @@ static bool window_msg_proc(JWidget widget, JMessage msg)
press_x = msg->mouse.x;
press_y = msg->mouse.y;
- window_action = setup_cursor(widget, press_x, press_y);
-
+ window_action = get_action(widget, press_x, press_y);
if (window_action != WINDOW_NONE) {
jwidget_hard_capture_mouse(widget);
return TRUE;
@@ -357,23 +356,12 @@ static bool window_msg_proc(JWidget widget, JMessage msg)
}
break;
- case JM_MOUSELEAVE:
- setup_cursor(widget, msg->mouse.x, msg->mouse.y);
- break;
-
case JM_MOTION:
if (!window->is_moveable)
break;
- /* without capture */
- if (!jwidget_has_capture(widget)) {
- if (!jmanager_get_capture())
- return setup_cursor(widget, msg->mouse.x, msg->mouse.y) != WINDOW_NONE;
- else
- break;
- }
- /* with capture */
- else {
+ /* does it have the mouse captured? */
+ if (jwidget_has_capture(widget)) {
/* reposition/resize */
if (window_action == WINDOW_MOVE) {
int x = click_pos->x1 + (msg->mouse.x - press_x);
@@ -435,6 +423,42 @@ static bool window_msg_proc(JWidget widget, JMessage msg)
/* } */
/* } */
break;
+
+ case JM_SETCURSOR:
+ if (window->is_moveable) {
+ int action = get_action(widget,
+ msg->mouse.x,
+ msg->mouse.y);
+ int cursor = JI_CURSOR_NORMAL;
+
+ if (action == WINDOW_MOVE)
+ cursor = MOTION_CURSOR;
+ else if (action & WINDOW_RESIZE_LEFT) {
+ if (action & WINDOW_RESIZE_TOP)
+ cursor = JI_CURSOR_SIZE_TL;
+ else if (action & WINDOW_RESIZE_BOTTOM)
+ cursor = JI_CURSOR_SIZE_BL;
+ else
+ cursor = JI_CURSOR_SIZE_L;
+ }
+ else if (action & WINDOW_RESIZE_RIGHT) {
+ if (action & WINDOW_RESIZE_TOP)
+ cursor = JI_CURSOR_SIZE_TR;
+ else if (action & WINDOW_RESIZE_BOTTOM)
+ cursor = JI_CURSOR_SIZE_BR;
+ else
+ cursor = JI_CURSOR_SIZE_R;
+ }
+ else if (action & WINDOW_RESIZE_TOP)
+ cursor = JI_CURSOR_SIZE_T;
+ else if (action & WINDOW_RESIZE_BOTTOM)
+ cursor = JI_CURSOR_SIZE_B;
+
+ jmouse_set_cursor(cursor);
+ return TRUE;
+ }
+ break;
+
}
return FALSE;
@@ -500,18 +524,16 @@ static void window_set_position(JWidget widget, JRect rect)
jrect_free(cpos);
}
-static int setup_cursor(JWidget widget, int x, int y)
+static int get_action(JWidget widget, int x, int y)
{
Window *window = jwidget_get_data(widget, JI_WINDOW);
int action = WINDOW_NONE;
- int cursor;
JRect pos;
JRect cpos;
if (!window->is_moveable)
return action;
- cursor = JI_CURSOR_NORMAL;
pos = jwidget_get_rect(widget);
cpos = jwidget_get_child_rect(widget);
@@ -523,7 +545,6 @@ static int setup_cursor(JWidget widget, int x, int y)
(y < cpos->y1))
|| (key_shifts & KB_ALT_FLAG))) {
action = WINDOW_MOVE;
- cursor = MOTION_CURSOR;
}
/* resize */
else if (window->is_sizeable) {
@@ -532,12 +553,7 @@ static int setup_cursor(JWidget widget, int x, int y)
action |= WINDOW_RESIZE_LEFT;
/* top */
if ((y >= pos->y1) && (y < cpos->y1)) {
-#if 1
action |= WINDOW_RESIZE_TOP;
-#else
- action = WINDOW_MOVE;
- cursor = MOTION_CURSOR;
-#endif
}
/* bottom */
else if ((y > cpos->y2-1) && (y <= pos->y2-1))
@@ -545,7 +561,6 @@ static int setup_cursor(JWidget widget, int x, int y)
}
/* top *****************************************/
else if ((y >= pos->y1) && (y < cpos->y1)) {
-#if 1
action |= WINDOW_RESIZE_TOP;
/* left */
if ((x >= pos->x1) && (x < cpos->x1))
@@ -553,22 +568,13 @@ static int setup_cursor(JWidget widget, int x, int y)
/* right */
else if ((x > cpos->x2-1) && (x <= pos->x2-1))
action |= WINDOW_RESIZE_RIGHT;
-#else
- action = WINDOW_MOVE;
- cursor = MOTION_CURSOR;
-#endif
}
/* right *****************************************/
else if ((x > cpos->x2-1) && (x <= pos->x2-1)) {
action |= WINDOW_RESIZE_RIGHT;
/* top */
if ((y >= pos->y1) && (y < cpos->y1)) {
-#if 1
action |= WINDOW_RESIZE_TOP;
-#else
- action = WINDOW_MOVE;
- cursor = MOTION_CURSOR;
-#endif
}
/* bottom */
else if ((y > cpos->y2-1) && (y <= pos->y2-1))
@@ -584,33 +590,8 @@ static int setup_cursor(JWidget widget, int x, int y)
else if ((x > cpos->x2-1) && (x <= pos->x2-1))
action |= WINDOW_RESIZE_RIGHT;
}
-
- /* cursor */
- if (action & WINDOW_RESIZE_LEFT) {
- if (action & WINDOW_RESIZE_TOP)
- cursor = JI_CURSOR_SIZE_TL;
- else if (action & WINDOW_RESIZE_BOTTOM)
- cursor = JI_CURSOR_SIZE_BL;
- else
- cursor = JI_CURSOR_SIZE_L;
- }
- else if (action & WINDOW_RESIZE_RIGHT) {
- if (action & WINDOW_RESIZE_TOP)
- cursor = JI_CURSOR_SIZE_TR;
- else if (action & WINDOW_RESIZE_BOTTOM)
- cursor = JI_CURSOR_SIZE_BR;
- else
- cursor = JI_CURSOR_SIZE_R;
- }
- else if (action & WINDOW_RESIZE_TOP)
- cursor = JI_CURSOR_SIZE_T;
- else if (action & WINDOW_RESIZE_BOTTOM)
- cursor = JI_CURSOR_SIZE_B;
}
- if (jmouse_get_cursor() != cursor)
- jmouse_set_cursor(cursor);
-
jrect_free(pos);
jrect_free(cpos);
@@ -632,7 +613,7 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
{
#define FLAGS JI_GDR_CUTTOPWINDOWS | JI_GDR_USECHILDAREA
- JRegion old_reg;
+ JWidget manager = jwidget_get_manager(widget);
JRegion old_drawable_region;
JRegion new_drawable_region;
JRegion manager_refresh_region;
@@ -641,51 +622,70 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
JRect man_pos;
JMessage msg;
- jmanager_dispatch_messages(ji_get_default_manager());
+ jmanager_dispatch_messages(manager);
+ /* get the window's current position */
old_pos = jrect_new_copy(widget->rc);
- man_pos = jwidget_get_rect(jwidget_get_manager(widget));
-
+
+ /* get the manager's current position */
+ man_pos = jwidget_get_rect(manager);
+
+ /* sent a JM_WINMOVE message to the window */
msg = jmessage_new(JM_WINMOVE);
- jmessage_broadcast_to_children(msg, widget);
+ jmessage_add_dest(msg, widget);
jmanager_enqueue_message(msg);
- old_reg = jwidget_get_region(widget);
+ /* get the region & the drawable region of the window */
old_drawable_region = jwidget_get_drawable_region(widget, FLAGS);
+ /* if the size of the window changes... */
if (jrect_w(old_pos) != jrect_w(rect) ||
jrect_h(old_pos) != jrect_h(rect)) {
+ /* we have to change the whole positions sending JM_SETPOS
+ messages... */
window_set_position(widget, rect);
}
else {
+ /* we can just displace all the widgets
+ by a delta (new_position - old_position)... */
displace_widgets(widget,
rect->x1 - old_pos->x1,
rect->y1 - old_pos->y1);
}
+ /* get the new drawable region of the window (it's new because we
+ moved the window to "rect") */
new_drawable_region = jwidget_get_drawable_region(widget, FLAGS);
+ /* create a new region to refresh the manager later */
manager_refresh_region = jregion_new(NULL, 0);
+
+ /* create a new region to refresh the window later */
window_refresh_region = jregion_new(NULL, 0);
+
+ /* first of all, we have to refresh the manager in the old window's
+ drawable region... */
jregion_copy(manager_refresh_region, old_drawable_region);
- /* redraw new position */
-/* if (!use_blit || !jwindow_is_toplevel (widget)) */
+ /* ...but we have to substract the new window's drawable region (and
+ that is all for the manager's refresh region) */
+ jregion_subtract(manager_refresh_region, manager_refresh_region,
+ new_drawable_region);
+
+ /* now we have to setup the window's refresh region... */
+
+ /* if "use_blit" isn't activated, we have to redraw the whole window
+ (sending JM_DRAW messages) in the new drawable region */
if (!use_blit) {
jregion_copy(window_refresh_region, new_drawable_region);
}
- /* try to blit new position from old position (to redraw the less
- possible) */
+ /* if "use_blit" is activated, we can move the old drawable to the
+ new position (to redraw as little as possible) */
else {
JRegion reg1 = jregion_new(NULL, 0);
- JRegion reg2 = jregion_new(widget->rc, 1);
JRegion moveable_region = jregion_new(NULL, 0);
- /* substract new window region */
- jregion_subtract(manager_refresh_region, manager_refresh_region,
- new_drawable_region);
-
- /* add a region to draw areas that were outside the screen */
+ /* add a region to draw areas which were outside of the screen */
jregion_copy(reg1, new_drawable_region);
jregion_translate(reg1,
old_pos->x1 - widget->rc->x1,
@@ -694,8 +694,8 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
jregion_subtract(reg1, reg1, moveable_region);
jregion_translate(reg1,
- widget->rc->x1 - old_pos->x1,
- widget->rc->y1 - old_pos->y1);
+ widget->rc->x1 - old_pos->x1,
+ widget->rc->y1 - old_pos->y1);
jregion_union(window_refresh_region, window_refresh_region, reg1);
/* move the window's graphics */
@@ -710,15 +710,12 @@ static void move_window(JWidget widget, JRect rect, bool use_blit)
jmouse_show();
jregion_free(reg1);
- jregion_free(reg2);
jregion_free(moveable_region);
}
- jwidget_redraw_region(jwidget_get_manager(widget),
- manager_refresh_region);
+ jwidget_redraw_region(manager, manager_refresh_region);
jwidget_redraw_region(widget, window_refresh_region);
- jregion_free(old_reg);
jregion_free(old_drawable_region);
jregion_free(new_drawable_region);
jregion_free(manager_refresh_region);
diff --git a/src/jinete/themes/jstandard_theme.c b/src/jinete/themes/jstandard_theme.c
index 1fdab3a65..12f340252 100644
--- a/src/jinete/themes/jstandard_theme.c
+++ b/src/jinete/themes/jstandard_theme.c
@@ -53,8 +53,8 @@
/* "icons_data" indexes */
enum {
FIRST_CURSOR = 0,
- LAST_CURSOR = 12,
- ICON_CHECK_EDGE = 13,
+ LAST_CURSOR = 13,
+ ICON_CHECK_EDGE = 14,
ICON_CHECK_MARK,
ICON_CLOSE,
ICON_MENU_MARK,
@@ -81,6 +81,7 @@ static struct {
{ FALSE, default_theme_csizebl },
{ FALSE, default_theme_csizeb },
{ FALSE, default_theme_csizebr },
+ { FALSE, default_theme_ceyedropper },
{ FALSE, default_theme_ichecke },
{ FALSE, default_theme_icheckm },
{ FALSE, default_theme_iclose },
@@ -104,24 +105,25 @@ static int theme_color_face(void);
static int theme_color_hotface(void);
static int theme_color_selected(void);
static int theme_color_background(void);
-static void theme_draw_box(JWidget widget);
-static void theme_draw_button(JWidget widget);
-static void theme_draw_check(JWidget widget);
-static void theme_draw_entry(JWidget widget);
-static void theme_draw_label(JWidget widget);
-static void theme_draw_listbox(JWidget widget);
-static void theme_draw_listitem(JWidget widget);
-static void theme_draw_menu(JWidget widget);
-static void theme_draw_menuitem(JWidget widget);
-static void theme_draw_panel(JWidget widget);
-static void theme_draw_radio(JWidget widget);
-static void theme_draw_separator(JWidget widget);
-static void theme_draw_slider(JWidget widget);
-static void theme_draw_textbox(JWidget widget);
-static void theme_draw_view(JWidget widget);
-static void theme_draw_view_scrollbar(JWidget widget);
-static void theme_draw_view_viewport(JWidget widget);
-static void theme_draw_window(JWidget widget);
+static void theme_draw_box(JWidget widget, JRect clip);
+static void theme_draw_button(JWidget widget, JRect clip);
+static void theme_draw_check(JWidget widget, JRect clip);
+static void theme_draw_entry(JWidget widget, JRect clip);
+static void theme_draw_grid(JWidget widget, JRect clip);
+static void theme_draw_label(JWidget widget, JRect clip);
+static void theme_draw_listbox(JWidget widget, JRect clip);
+static void theme_draw_listitem(JWidget widget, JRect clip);
+static void theme_draw_menu(JWidget widget, JRect clip);
+static void theme_draw_menuitem(JWidget widget, JRect clip);
+static void theme_draw_panel(JWidget widget, JRect clip);
+static void theme_draw_radio(JWidget widget, JRect clip);
+static void theme_draw_separator(JWidget widget, JRect clip);
+static void theme_draw_slider(JWidget widget, JRect clip);
+static void theme_draw_textbox(JWidget widget, JRect clip);
+static void theme_draw_view(JWidget widget, JRect clip);
+static void theme_draw_view_scrollbar(JWidget widget, JRect clip);
+static void theme_draw_view_viewport(JWidget widget, JRect clip);
+static void theme_draw_window(JWidget widget, JRect clip);
static int get_bg_color(JWidget widget);
static void draw_textstring(const char *t, int fg_color, int bg_color,
@@ -168,6 +170,7 @@ JTheme jtheme_new_standard(void)
jtheme_set_method(theme, JI_BUTTON, theme_draw_button);
jtheme_set_method(theme, JI_CHECK, theme_draw_check);
jtheme_set_method(theme, JI_ENTRY, theme_draw_entry);
+ jtheme_set_method(theme, JI_GRID, theme_draw_grid);
jtheme_set_method(theme, JI_LABEL, theme_draw_label);
jtheme_set_method(theme, JI_LISTBOX, theme_draw_listbox);
jtheme_set_method(theme, JI_LISTITEM, theme_draw_listitem);
@@ -270,6 +273,10 @@ static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y)
*focus_x = 8;
*focus_y = 8;
break;
+ case JI_CURSOR_EYEDROPPER:
+ *focus_x = 0;
+ *focus_y = 15;
+ break;
}
}
@@ -291,14 +298,14 @@ static void theme_init_widget(JWidget widget)
widget->border_width.b = B;
if ((widget->flags & JI_INITIALIZED) &&
- (widget->type != JI_WINDOW))
+ (widget->type != JI_WINDOW) &&
+ (widget->type != JI_SEPARATOR))
return;
switch (widget->draw_type) {
case JI_BOX:
BORDER(0);
-/* widget->child_spacing = 2; */
widget->child_spacing = 4;
break;
@@ -309,7 +316,6 @@ static void theme_init_widget(JWidget widget)
case JI_CHECK:
BORDER(2);
-/* widget->child_spacing = 2; */
widget->child_spacing = 4;
break;
@@ -317,6 +323,11 @@ static void theme_init_widget(JWidget widget)
BORDER(3);
break;
+ case JI_GRID:
+ BORDER(0);
+ widget->child_spacing = 4;
+ break;
+
case JI_LABEL:
BORDER(1);
break;
@@ -408,7 +419,7 @@ static void theme_init_widget(JWidget widget)
break;
case JI_WINDOW:
- if (!jwindow_is_desktop (widget)) {
+ if (!jwindow_is_desktop(widget)) {
if (widget->text) {
BORDER4(6, 4+jwidget_get_text_height(widget)+6, 6, 6);
#if 1 /* add close button */
@@ -491,12 +502,12 @@ static int theme_color_background(void)
return COLOR_BACKGROUND;
}
-static void theme_draw_box(JWidget widget)
+static void theme_draw_box(JWidget widget, JRect clip)
{
- jdraw_rectfill(widget->rc, BGCOLOR);
+ jdraw_rectfill(clip, BGCOLOR);
}
-static void theme_draw_button(JWidget widget)
+static void theme_draw_button(JWidget widget, JRect clip)
{
BITMAP *icon_bmp = ji_generic_button_get_icon(widget);
int icon_align = ji_generic_button_get_icon_align(widget);
@@ -609,7 +620,7 @@ static void theme_draw_button(JWidget widget)
}
}
-static void theme_draw_check(JWidget widget)
+static void theme_draw_check(JWidget widget, JRect clip)
{
struct jrect box, text, icon;
int bg;
@@ -639,7 +650,12 @@ static void theme_draw_check(JWidget widget)
draw_icons(icon.x1, icon.y1, widget, ICON_CHECK_EDGE);
}
-static void theme_draw_entry(JWidget widget)
+static void theme_draw_grid(JWidget widget, JRect clip)
+{
+ jdraw_rectfill(clip, BGCOLOR);
+}
+
+static void theme_draw_entry(JWidget widget, JRect clip)
{
bool password = jentry_is_password(widget);
int scroll, cursor, state, selbeg, selend;
@@ -659,8 +675,8 @@ static void theme_draw_entry(JWidget widget)
bg = COLOR_BACKGROUND;
/* 1st border */
- _ji_theme_rectedge(ji_screen, x1, y1, x2, y2,
- COLOR_DISABLED, COLOR_BACKGROUND);
+ jrectedge(ji_screen, x1, y1, x2, y2,
+ COLOR_DISABLED, COLOR_BACKGROUND);
/* 2nd border */
x1++, y1++, x2--, y2--;
@@ -722,7 +738,7 @@ static void theme_draw_entry(JWidget widget)
draw_entry_cursor(widget, x, y);
}
-static void theme_draw_label(JWidget widget)
+static void theme_draw_label(JWidget widget, JRect clip)
{
int bg = BGCOLOR;
@@ -731,7 +747,7 @@ static void theme_draw_label(JWidget widget)
draw_textstring(NULL, -1, bg, FALSE, widget, widget->rc, 0);
}
-static void theme_draw_listbox(JWidget widget)
+static void theme_draw_listbox(JWidget widget, JRect clip)
{
int bg;
@@ -743,7 +759,7 @@ static void theme_draw_listbox(JWidget widget)
jdraw_rectfill(widget->rc, COLOR_BACKGROUND);
}
-static void theme_draw_listitem(JWidget widget)
+static void theme_draw_listitem(JWidget widget, JRect clip)
{
int fg, bg;
int x, y;
@@ -769,7 +785,7 @@ static void theme_draw_listitem(JWidget widget)
jdraw_text(widget->text_font, widget->text, x, y, fg, bg, TRUE);
/* background */
- _ji_theme_rectfill_exclude
+ jrectexclude
(ji_screen,
widget->rc->x1, widget->rc->y1,
widget->rc->x2-1, widget->rc->y2-1,
@@ -783,12 +799,12 @@ static void theme_draw_listitem(JWidget widget)
}
}
-static void theme_draw_menu(JWidget widget)
+static void theme_draw_menu(JWidget widget, JRect clip)
{
jdraw_rectfill(widget->rc, BGCOLOR);
}
-static void theme_draw_menuitem(JWidget widget)
+static void theme_draw_menuitem(JWidget widget, JRect clip)
{
int c, bg, fg, bar;
int x1, y1, x2, y2;
@@ -900,7 +916,7 @@ static void theme_draw_menuitem(JWidget widget)
}
}
-static void theme_draw_panel(JWidget widget)
+static void theme_draw_panel(JWidget widget, JRect clip)
{
JWidget c1, c2;
JLink link;
@@ -956,7 +972,7 @@ static void theme_draw_panel(JWidget widget)
}
}
-static void theme_draw_radio(JWidget widget)
+static void theme_draw_radio(JWidget widget, JRect clip)
{
struct jrect box, text, icon;
int bg = BGCOLOR;
@@ -985,7 +1001,7 @@ static void theme_draw_radio(JWidget widget)
draw_icons(icon.x1, icon.y1, widget, ICON_RADIO_EDGE);
}
-static void theme_draw_separator(JWidget widget)
+static void theme_draw_separator(JWidget widget, JRect clip)
{
int x1, y1, x2, y2;
@@ -1055,7 +1071,7 @@ static int my_add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2)
}
#endif
-static void theme_draw_slider(JWidget widget)
+static void theme_draw_slider(JWidget widget, JRect clip)
{
int x, x1, y1, x2, y2, bg, c1, c2;
int min, max, value;
@@ -1077,8 +1093,8 @@ static void theme_draw_slider(JWidget widget)
bg = COLOR_FACE;
/* 1st border */
- _ji_theme_rectedge(ji_screen, x1, y1, x2, y2,
- COLOR_DISABLED, COLOR_BACKGROUND);
+ jrectedge(ji_screen, x1, y1, x2, y2,
+ COLOR_DISABLED, COLOR_BACKGROUND);
/* 2nd border */
x1++, y1++, x2--, y2--;
@@ -1098,7 +1114,7 @@ static void theme_draw_slider(JWidget widget)
}
x1++, y1++, x2--, y2--;
- _ji_theme_rectedge(ji_screen, x1, y1, x2, y2, c1, c2);
+ jrectedge(ji_screen, x1, y1, x2, y2, c1, c2);
/* progress bar */
x1++, y1++, x2--, y2--;
@@ -1159,14 +1175,14 @@ static void theme_draw_slider(JWidget widget)
}
}
-static void theme_draw_textbox(JWidget widget)
+static void theme_draw_textbox(JWidget widget, JRect clip)
{
_ji_theme_textbox_draw(ji_screen, widget, NULL, NULL,
widget->theme->textbox_bg_color,
widget->theme->textbox_fg_color);
}
-static void theme_draw_view(JWidget widget)
+static void theme_draw_view(JWidget widget, JRect clip)
{
JRect pos = jwidget_get_rect(widget);
@@ -1194,7 +1210,7 @@ static void theme_draw_view(JWidget widget)
jrect_free(pos);
}
-static void theme_draw_view_scrollbar(JWidget widget)
+static void theme_draw_view_scrollbar(JWidget widget, JRect clip)
{
int x1, y1, x2, y2;
int u1, v1, u2, v2;
@@ -1229,17 +1245,17 @@ static void theme_draw_view_scrollbar(JWidget widget)
}
/* background */
- _ji_theme_rectfill_exclude(ji_screen,
- x1, y1, x2, y2,
- u1, v1, u2, v2, BGCOLOR);
+ jrectexclude(ji_screen,
+ x1, y1, x2, y2,
+ u1, v1, u2, v2, BGCOLOR);
/* 1st border */
if (jwidget_is_selected(widget))
- _ji_theme_rectedge(ji_screen, u1, v1, u2, v2,
- COLOR_DISABLED, COLOR_BACKGROUND);
+ jrectedge(ji_screen, u1, v1, u2, v2,
+ COLOR_DISABLED, COLOR_BACKGROUND);
else
- _ji_theme_rectedge(ji_screen, u1, v1, u2, v2,
- COLOR_BACKGROUND, COLOR_DISABLED);
+ jrectedge(ji_screen, u1, v1, u2, v2,
+ COLOR_BACKGROUND, COLOR_DISABLED);
/* bar-block background */
u1++, v1++, u2--, v2--;
@@ -1249,12 +1265,12 @@ static void theme_draw_view_scrollbar(JWidget widget)
rectfill(ji_screen, u1, v1, u2, v2, BGCOLOR);
}
-static void theme_draw_view_viewport(JWidget widget)
+static void theme_draw_view_viewport(JWidget widget, JRect clip)
{
jdraw_rectfill(widget->rc, BGCOLOR);
}
-static void theme_draw_window(JWidget widget)
+static void theme_draw_window(JWidget widget, JRect clip)
{
JRect pos = jwidget_get_rect(widget);
JRect cpos = jwidget_get_child_rect(widget);
diff --git a/src/jinete/themes/jstandard_theme_icons.h b/src/jinete/themes/jstandard_theme_icons.h
index 04f3ca0fe..d9ef389d0 100644
--- a/src/jinete/themes/jstandard_theme_icons.h
+++ b/src/jinete/themes/jstandard_theme_icons.h
@@ -1,5 +1,25 @@
/* Generated by pcx2data */
+static unsigned char default_theme_ceyedropper[258] = {
+ 16, 16,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 1, 3, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 3, 3, 3, 1, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 3, 3, 3, 1, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
static unsigned char default_theme_cforbidden[258] = {
16, 16,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -296,16 +316,12 @@ static unsigned char default_theme_iclose[66] = {
0, 0, 0, 0, 0, 0, 0, 0
};
-static unsigned char default_theme_icombobox[66] = {
- 8, 8,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 0,
- 0, 1, 1, 1, 1, 1, 0, 0,
- 0, 0, 1, 1, 1, 0, 0, 0,
- 0, 0, 0, 1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
+static unsigned char default_theme_icombobox[30] = {
+ 7, 4,
+ 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 0,
+ 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0
};
static unsigned char default_theme_imenum[66] = {
diff --git a/src/jinete/themes/stand/ceyedropper.pcx b/src/jinete/themes/stand/ceyedropper.pcx
new file mode 100644
index 000000000..0331e761b
Binary files /dev/null and b/src/jinete/themes/stand/ceyedropper.pcx differ
diff --git a/src/modules/color.c b/src/modules/color.c
index 91582de81..54218b6b3 100644
--- a/src/modules/color.c
+++ b/src/modules/color.c
@@ -18,6 +18,7 @@
#include "config.h"
+#include
#include
#include "jinete/jbase.h"
@@ -31,12 +32,31 @@
#include "raster/image.h"
#include "widgets/colbar.h"
-static struct {
- int type;
- int data;
-} color_struct;
+/* #define GET_COLOR_TYPE(color) (((color) >> 32) & 0xff) */
+/* #define GET_COLOR_DATA(color) ((color) & 0xffffffff) */
+
+/* #define GET_COLOR_RGB(color) ((color) & 0xffffffff) /\* RGBA *\/ */
+/* #define GET_COLOR_GRAY(color) ((color) & 0xffff) /\* KA *\/ */
+/* #define GET_COLOR_INDEX(color) ((color) & 0xff) /\* I *\/ */
+
+/* #define MAKE_COLOR(type,data) ((color_t)((((color_t)(type)&0xff) << 32) | \ */
+/* (((data)&0xffffffff)))) */
+
+#define _hsva_geth _rgba_getr
+#define _hsva_gets _rgba_getg
+#define _hsva_getv _rgba_getb
+#define _hsva_geta _rgba_geta
+#define _hsva _rgba
+
+
+#define GET_COLOR_TYPE(color) ((ase_uint32)((color).coltype))
+#define GET_COLOR_DATA(color) ((ase_uint32)((color).imgcolor))
+
+#define GET_COLOR_RGB(color) (GET_COLOR_DATA(color) & 0xffffffff)
+#define GET_COLOR_HSV(color) (GET_COLOR_DATA(color) & 0xffffffff)
+#define GET_COLOR_GRAY(color) (GET_COLOR_DATA(color) & 0xffff)
+#define GET_COLOR_INDEX(color) (GET_COLOR_DATA(color) & 0xff)
-static void fill_color_struct(const char *color);
static int get_mask_for_bitmap(int depth);
int init_module_color(void)
@@ -48,165 +68,445 @@ void exit_module_color(void)
{
}
-int color_type(const char *color)
+char *color_to_string(color_t color, char *buf, int size)
{
- fill_color_struct(color);
- return color_struct.type;
-}
+ int data;
-char *color_mask(void)
-{
- return jstrdup("mask");
-}
+ switch (GET_COLOR_TYPE(color)) {
-char *color_rgb(int r, int g, int b, int a)
-{
- char buf[256];
- usprintf(buf, "rgb{%d,%d,%d", r, g, b);
- if (a == 255)
- ustrcat(buf, "}");
- else
- usprintf(buf+ustrlen(buf), ",%d}", a);
- return jstrdup(buf);
-}
+ case COLOR_TYPE_MASK:
+ uszprintf(buf, size, "mask");
+ break;
-char *color_gray(int g, int a)
-{
- char buf[256];
- usprintf(buf, "gray{%d", g);
- if (a == 255)
- ustrcat(buf, "}");
- else
- usprintf(buf+ustrlen(buf), ",%d}", a);
- return jstrdup(buf);
-}
+ case COLOR_TYPE_RGB:
+ data = GET_COLOR_RGB(color);
+ uszprintf(buf, size, "rgb{%d,%d,%d,%d}",
+ _rgba_getr(data),
+ _rgba_getg(data),
+ _rgba_getb(data),
+ _rgba_geta(data));
+ break;
-char *color_index(int index)
-{
- char buf[256];
- usprintf(buf, "index{%d}", index);
- return jstrdup(buf);
-}
+ case COLOR_TYPE_HSV:
+ data = GET_COLOR_HSV(color);
+ uszprintf(buf, size, "hsv{%d,%d,%d,%d}",
+ _hsva_geth(data),
+ _hsva_gets(data),
+ _hsva_getv(data),
+ _hsva_geta(data));
+ break;
-int color_get_black(int imgtype, const char *color)
-{
- fill_color_struct(color);
+ case COLOR_TYPE_GRAY:
+ data = GET_COLOR_GRAY(color);
+ uszprintf(buf, size, "gray{%d,%d}",
+ _graya_getv(data),
+ _graya_geta(data));
+ break;
+
+ case COLOR_TYPE_INDEX:
+ data = GET_COLOR_INDEX(color);
+ uszprintf(buf, size, "index{%d}",
+ data);
+ break;
- if (color_struct.type == COLOR_TYPE_MASK)
- return 0;
- else if (color_struct.type == COLOR_TYPE_RGB) {
- PRINTF("Getting `black' from a rgb color\n");
}
- else if (color_struct.type == COLOR_TYPE_GRAY)
- return _graya_getk(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_INDEX) {
- PRINTF("Getting `black' from a index color\n");
+ return buf;
+}
+
+color_t string_to_color(const char *_str)
+{
+ char *str = jstrdup(_str);
+ color_t color = color_mask();
+ char *tok;
+
+ if (ustrcmp(str, "mask") != 0) {
+ if (ustrncmp(str, "rgb{", 4) == 0) {
+ int c=0, table[4] = { 0, 0, 0, 255 };
+
+ for (tok=ustrtok(str+4, ","); tok;
+ tok=ustrtok(NULL, ",")) {
+ if (c < 4)
+ table[c++] = ustrtol(tok, NULL, 10);
+ }
+
+ color = color_rgb(table[0], table[1], table[2], table[3]);
+ }
+ else if (ustrncmp(str, "hsv{", 4) == 0) {
+ int c=0, table[4] = { 0, 0, 0, 255 };
+
+ for (tok=ustrtok(str+4, ","); tok;
+ tok=ustrtok(NULL, ",")) {
+ if (c < 4)
+ table[c++] = ustrtol(tok, NULL, 10);
+ }
+
+ color = color_hsv(table[0], table[1], table[2], table[3]);
+ }
+ else if (ustrncmp(str, "gray{", 5) == 0) {
+ int c=0, table[2] = { 0, 255 };
+
+ for (tok=ustrtok(str+5, ","); tok;
+ tok=ustrtok(NULL, ",")) {
+ if (c < 2)
+ table[c++] = ustrtol(tok, NULL, 10);
+ }
+
+ color = color_gray(table[0], table[1]);
+ }
+ else if (ustrncmp(str, "index{", 6) == 0) {
+ color = color_index(ustrtol(str+6, NULL, 10));
+ }
}
- return -1;
+ jfree(str);
+ return color;
}
-int color_get_red(int imgtype, const char *color)
+int color_type(color_t color)
{
- fill_color_struct(color);
-
- if (color_struct.type == COLOR_TYPE_MASK)
- return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].r]: 0;
- else if (color_struct.type == COLOR_TYPE_RGB)
- return _rgba_getr(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_GRAY)
- return _graya_getk(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_INDEX)
- return _rgb_scale_6[current_palette[color_struct.data & 0xff].r];
-
- return -1;
+ return GET_COLOR_TYPE(color);
}
-int color_get_green(int imgtype, const char *color)
+color_t color_mask(void)
{
- fill_color_struct(color);
-
- if (color_struct.type == COLOR_TYPE_MASK)
- return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].g]: 0;
- else if (color_struct.type == COLOR_TYPE_RGB)
- return _rgba_getg(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_GRAY)
- return _graya_getk(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_INDEX)
- return _rgb_scale_6[current_palette[color_struct.data & 0xff].g];
-
- return -1;
+ color_t c = { COLOR_TYPE_MASK, 0 };
+ return c;
}
-int color_get_blue(int imgtype, const char *color)
+color_t color_rgb(int r, int g, int b, int a)
{
- fill_color_struct(color);
-
- if (color_struct.type == COLOR_TYPE_MASK)
- return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].b]: 0;
- else if (color_struct.type == COLOR_TYPE_RGB)
- return _rgba_getb(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_GRAY)
- return _graya_getk(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_INDEX)
- return _rgb_scale_6[current_palette[color_struct.data & 0xff].b];
-
- return -1;
+ color_t c = { COLOR_TYPE_RGB,
+ _rgba(r & 0xff,
+ g & 0xff,
+ b & 0xff,
+ a & 0xff) };
+ return c;
}
-int color_get_index(int imgtype, const char *color)
+color_t color_hsv(int h, int s, int v, int a)
{
- fill_color_struct(color);
+ color_t c = { COLOR_TYPE_HSV,
+ _hsva(h & 0xff,
+ s & 0xff,
+ v & 0xff,
+ a & 0xff) };
+ return c;
+}
+
+color_t color_gray(int g, int a)
+{
+ color_t c = { COLOR_TYPE_GRAY,
+ _graya(g & 0xff,
+ a & 0xff) };
+ return c;
+}
+
+color_t color_index(int index)
+{
+ color_t c = { COLOR_TYPE_INDEX,
+ index & 0xff };
+ return c;
+}
+
+int color_get_red(int imgtype, color_t color)
+{
+ switch (GET_COLOR_TYPE(color)) {
+
+ case COLOR_TYPE_MASK:
+ return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].r]: 0;
+
+ case COLOR_TYPE_RGB:
+ return _rgba_getr(GET_COLOR_RGB(color));
+
+ case COLOR_TYPE_HSV: {
+ int c = GET_COLOR_HSV(color);
+ int h = _hsva_geth(c);
+ int s = _hsva_gets(c);
+ int v = _hsva_getv(c);
+ hsv_to_rgb_int(&h, &s, &v);
+ return h;
+ }
+
+ case COLOR_TYPE_GRAY:
+ return _graya_getv(GET_COLOR_GRAY(color));
+
+ case COLOR_TYPE_INDEX:
+ return _rgb_scale_6[current_palette[GET_COLOR_INDEX(color)].r];
- if (color_struct.type == COLOR_TYPE_MASK)
- return 0;
- else if (color_struct.type == COLOR_TYPE_RGB) {
- PRINTF("Getting `index' from a rgb color\n");
}
- else if (color_struct.type == COLOR_TYPE_GRAY)
- return _graya_getk(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_INDEX)
- return color_struct.data & 0xff;
+ assert(FALSE);
return -1;
}
-int color_get_alpha(int imgtype, const char *color)
+int color_get_green(int imgtype, color_t color)
{
- fill_color_struct(color);
+ switch (GET_COLOR_TYPE(color)) {
- if (color_struct.type == COLOR_TYPE_MASK)
- return imgtype == IMAGE_INDEXED ? 255: 0;
- else if (color_struct.type == COLOR_TYPE_RGB)
- return _rgba_geta(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_GRAY)
- return _graya_geta(color_struct.data);
- else if (color_struct.type == COLOR_TYPE_INDEX)
- return 255;
+ case COLOR_TYPE_MASK:
+ return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].g]: 0;
+ case COLOR_TYPE_RGB:
+ return _rgba_getg(GET_COLOR_RGB(color));
+
+ case COLOR_TYPE_HSV: {
+ int c = GET_COLOR_HSV(color);
+ int h = _hsva_geth(c);
+ int s = _hsva_gets(c);
+ int v = _hsva_getv(c);
+ hsv_to_rgb_int(&h, &s, &v);
+ return s;
+ }
+
+ case COLOR_TYPE_GRAY:
+ return _graya_getv(GET_COLOR_GRAY(color));
+
+ case COLOR_TYPE_INDEX:
+ return _rgb_scale_6[current_palette[GET_COLOR_INDEX(color)].g];
+
+ }
+
+ assert(FALSE);
+ return -1;
+}
+
+int color_get_blue(int imgtype, color_t color)
+{
+ switch (GET_COLOR_TYPE(color)) {
+
+ case COLOR_TYPE_MASK:
+ return imgtype == IMAGE_INDEXED ? _rgb_scale_6[current_palette[0].b]: 0;
+
+ case COLOR_TYPE_RGB:
+ return _rgba_getb(GET_COLOR_RGB(color));
+
+ case COLOR_TYPE_HSV: {
+ int c = GET_COLOR_HSV(color);
+ int h = _hsva_geth(c);
+ int s = _hsva_gets(c);
+ int v = _hsva_getv(c);
+ hsv_to_rgb_int(&h, &s, &v);
+ return v;
+ }
+
+ case COLOR_TYPE_GRAY:
+ return _graya_getv(GET_COLOR_GRAY(color));
+
+ case COLOR_TYPE_INDEX:
+ return _rgb_scale_6[current_palette[GET_COLOR_INDEX(color)].b];
+
+ }
+
+ assert(FALSE);
+ return -1;
+}
+
+int color_get_hue(int imgtype, color_t color)
+{
+ switch (GET_COLOR_TYPE(color)) {
+
+ case COLOR_TYPE_MASK:
+ PRINTF("Getting 'hue' from MASK color\n");
+ break;
+
+ case COLOR_TYPE_RGB: {
+ int c = GET_COLOR_RGB(color);
+ int r = _rgba_getr(c);
+ int g = _rgba_getg(c);
+ int b = _rgba_getb(c);
+ rgb_to_hsv_int(&r, &g, &b);
+ return r;
+ }
+
+ case COLOR_TYPE_HSV:
+ return _hsva_geth(GET_COLOR_HSV(color));
+
+ case COLOR_TYPE_GRAY:
+ return 0;
+
+ case COLOR_TYPE_INDEX: {
+ int c = GET_COLOR_INDEX(color);
+ int r = _rgb_scale_6[current_palette[c].r];
+ int g = _rgb_scale_6[current_palette[c].g];
+ int b = _rgb_scale_6[current_palette[c].b];
+ rgb_to_hsv_int(&r, &g, &b);
+ return r;
+ }
+
+ }
+
+ assert(FALSE);
+ return -1;
+}
+
+int color_get_saturation(int imgtype, color_t color)
+{
+ switch (GET_COLOR_TYPE(color)) {
+
+ case COLOR_TYPE_MASK:
+ return 0;
+
+ case COLOR_TYPE_RGB: {
+ int c = GET_COLOR_RGB(color);
+ int r = _rgba_getr(c);
+ int g = _rgba_getg(c);
+ int b = _rgba_getb(c);
+ rgb_to_hsv_int(&r, &g, &b);
+ return g;
+ }
+
+ case COLOR_TYPE_HSV:
+ return _hsva_gets(GET_COLOR_HSV(color));
+
+ case COLOR_TYPE_GRAY:
+ return 0;
+
+ case COLOR_TYPE_INDEX: {
+ int c = GET_COLOR_INDEX(color);
+ int r = _rgb_scale_6[current_palette[c].r];
+ int g = _rgb_scale_6[current_palette[c].g];
+ int b = _rgb_scale_6[current_palette[c].b];
+ rgb_to_hsv_int(&r, &g, &b);
+ return g;
+ }
+
+ }
+
+ assert(FALSE);
+ return -1;
+}
+
+int color_get_value(int imgtype, color_t color)
+{
+ switch (GET_COLOR_TYPE(color)) {
+
+ case COLOR_TYPE_MASK:
+ return 0;
+
+ case COLOR_TYPE_RGB: {
+ int c = GET_COLOR_RGB(color);
+ int r = _rgba_getr(c);
+ int g = _rgba_getg(c);
+ int b = _rgba_getb(c);
+ rgb_to_hsv_int(&r, &g, &b);
+ return b;
+ }
+
+ case COLOR_TYPE_HSV:
+ return _hsva_getv(GET_COLOR_HSV(color));
+
+ case COLOR_TYPE_GRAY:
+ return _graya_getv(GET_COLOR_GRAY(color));
+
+ case COLOR_TYPE_INDEX: {
+ int c = GET_COLOR_INDEX(color);
+ int r = _rgb_scale_6[current_palette[c].r];
+ int g = _rgb_scale_6[current_palette[c].g];
+ int b = _rgb_scale_6[current_palette[c].b];
+ rgb_to_hsv_int(&r, &g, &b);
+ return b;
+ }
+
+ }
+
+ assert(FALSE);
+ return -1;
+}
+
+int color_get_index(int imgtype, color_t color)
+{
+ switch (GET_COLOR_TYPE(color)) {
+
+ case COLOR_TYPE_MASK:
+ return 0;
+
+ case COLOR_TYPE_RGB:
+ PRINTF("Getting `index' from a RGB color\n");
+ assert(FALSE);
+ break;
+
+ case COLOR_TYPE_HSV:
+ PRINTF("Getting `index' from a HSV color\n");
+ assert(FALSE);
+ break;
+
+ case COLOR_TYPE_GRAY:
+ return _graya_getv(GET_COLOR_GRAY(color));
+
+ case COLOR_TYPE_INDEX:
+ return GET_COLOR_INDEX(color);
+
+ }
+
+ assert(FALSE);
+ return -1;
+}
+
+int color_get_alpha(int imgtype, color_t color)
+{
+ switch (GET_COLOR_TYPE(color)) {
+
+ case COLOR_TYPE_MASK:
+ return imgtype == IMAGE_INDEXED ? 255: 0;
+
+ case COLOR_TYPE_RGB:
+ return _rgba_geta(GET_COLOR_RGB(color));
+
+ case COLOR_TYPE_HSV:
+ return _hsva_geta(GET_COLOR_HSV(color));
+
+ case COLOR_TYPE_GRAY:
+ return _graya_geta(GET_COLOR_RGB(color));
+
+ case COLOR_TYPE_INDEX:
+ return 255;
+
+ }
+
+ assert(FALSE);
return -1;
}
/* set the alpha channel in the color */
-void color_set_alpha(char **color, int alpha)
+void color_set_alpha(color_t *color, int alpha)
{
- fill_color_struct(*color);
+ int data;
+
+ switch (GET_COLOR_TYPE(*color)) {
+
+ case COLOR_TYPE_MASK:
+ assert(FALSE);
+ break;
+
+ case COLOR_TYPE_RGB:
+ data = GET_COLOR_RGB(*color);
+ *color = color_rgb(_rgba_getr(data),
+ _rgba_getg(data),
+ _rgba_getb(data), alpha);
+ break;
+
+ case COLOR_TYPE_HSV:
+ data = GET_COLOR_HSV(*color);
+ *color = color_hsv(_hsva_geth(data),
+ _hsva_gets(data),
+ _hsva_getv(data), alpha);
+ break;
+
+ case COLOR_TYPE_GRAY:
+ data = GET_COLOR_GRAY(*color);
+ *color = color_gray(_rgba_getg(data), alpha);
+ break;
+
+ case COLOR_TYPE_INDEX:
+ assert(FALSE);
+ break;
- if (color_struct.type == COLOR_TYPE_RGB) {
- jfree(*color);
- *color = color_rgb(_rgba_getr(color_struct.data),
- _rgba_getg(color_struct.data),
- _rgba_getb(color_struct.data), alpha);
- }
- else if (color_struct.type == COLOR_TYPE_GRAY) {
- jfree(*color);
- *color = color_gray(_rgba_getg(color_struct.data), alpha);
}
}
-char *color_from_image(int imgtype, int c)
+color_t color_from_image(int imgtype, int c)
{
- char *color = NULL;
+ color_t color = color_mask();
switch (imgtype) {
@@ -221,7 +521,7 @@ char *color_from_image(int imgtype, int c)
case IMAGE_GRAYSCALE:
if (_graya_geta(c) > 0) {
- color = color_gray(_graya_getk(c),
+ color = color_gray(_graya_getv(c),
_graya_geta(c));
}
break;
@@ -232,7 +532,7 @@ char *color_from_image(int imgtype, int c)
break;
}
- return (color) ? color: color_mask();
+ return color;
}
int blackandwhite(int r, int g, int b)
@@ -247,39 +547,56 @@ int blackandwhite_neg(int r, int g, int b)
makecol(255, 255, 255): makecol(0, 0, 0);
}
-int get_color_for_allegro(int depth, const char *color)
+int get_color_for_allegro(int depth, color_t color)
{
- int c;
+ int data;
+ int c = -1;
+
+ switch (GET_COLOR_TYPE(color)) {
- fill_color_struct(color);
+ case COLOR_TYPE_MASK:
+ c = get_mask_for_bitmap(depth);
+ break;
- if (color_struct.type == COLOR_TYPE_MASK) {
- c = get_mask_for_bitmap(depth);
- }
- else if (color_struct.type == COLOR_TYPE_RGB) {
- c = makeacol_depth(depth,
- _rgba_getr(color_struct.data),
- _rgba_getg(color_struct.data),
- _rgba_getb(color_struct.data),
- _rgba_geta(color_struct.data));
- }
- else if (color_struct.type == COLOR_TYPE_GRAY) {
- c = _graya_getk(color_struct.data);
-
- if (depth != 8)
- c = makeacol_depth(depth, c, c, c, _graya_geta(color_struct.data));
- }
- else if (color_struct.type == COLOR_TYPE_INDEX) {
- c = color_struct.data & 0xff;
-
- if (depth != 8)
+ case COLOR_TYPE_RGB:
+ data = GET_COLOR_RGB(color);
c = makeacol_depth(depth,
- _rgb_scale_6[current_palette[c].r],
- _rgb_scale_6[current_palette[c].g],
- _rgb_scale_6[current_palette[c].b], 255);
+ _rgba_getr(data),
+ _rgba_getg(data),
+ _rgba_getb(data),
+ _rgba_geta(data));
+ break;
+
+ case COLOR_TYPE_HSV: {
+ int h, s, v;
+
+ data = GET_COLOR_HSV(color);
+ h = _hsva_geth(data);
+ s = _hsva_gets(data);
+ v = _hsva_getv(data);
+ hsv_to_rgb_int(&h, &s, &v);
+
+ c = makeacol_depth(depth, h, s, v, _hsva_geta(data));
+ break;
+ }
+
+ case COLOR_TYPE_GRAY:
+ data = GET_COLOR_GRAY(color);
+ c = _graya_getv(data);
+ if (depth != 8)
+ c = makeacol_depth(depth, c, c, c, _graya_geta(data));
+ break;
+
+ case COLOR_TYPE_INDEX:
+ c = GET_COLOR_INDEX(color);
+ if (depth != 8)
+ c = makeacol_depth(depth,
+ _rgb_scale_6[current_palette[c].r],
+ _rgb_scale_6[current_palette[c].g],
+ _rgb_scale_6[current_palette[c].b], 255);
+ break;
+
}
- else
- c = -1;
if (depth == 8 && c >= 0 && c < 256)
c = _index_cmap[c];
@@ -287,79 +604,125 @@ int get_color_for_allegro(int depth, const char *color)
return c;
}
-int get_color_for_image(int imgtype, const char *color)
+int get_color_for_image(int imgtype, color_t color)
{
int c = -1;
+ int data;
- fill_color_struct(color);
+ switch (GET_COLOR_TYPE(color)) {
- switch (imgtype) {
-
- case IMAGE_RGB:
- if (color_struct.type == COLOR_TYPE_MASK) {
- c = _rgba(0, 0, 0, 0);
- }
- else if (color_struct.type == COLOR_TYPE_RGB) {
- c = color_struct.data;
- }
- else if (color_struct.type == COLOR_TYPE_GRAY) {
- c = _graya_getk(color_struct.data);
- c = _rgba(c, c, c, _graya_geta(color_struct.data));
- }
- else if (color_struct.type == COLOR_TYPE_INDEX) {
- c = color_struct.data & 0xff;
- c = _rgba(_rgb_scale_6[current_palette[c].r],
- _rgb_scale_6[current_palette[c].g],
- _rgb_scale_6[current_palette[c].b], 255);
+ case COLOR_TYPE_MASK:
+ switch (imgtype) {
+ case IMAGE_RGB:
+ c = _rgba(0, 0, 0, 0);
+ break;
+ case IMAGE_GRAYSCALE:
+ c = _graya(0, 0);
+ break;
+ case IMAGE_INDEXED:
+ c = 0;
+ break;
}
break;
- case IMAGE_GRAYSCALE:
- if (color_struct.type == COLOR_TYPE_MASK) {
- c = _graya(0, 0);
- }
- else if (color_struct.type == COLOR_TYPE_RGB) {
- int r = _rgba_getr(color_struct.data);
- int g = _rgba_getg(color_struct.data);
- int b = _rgba_getb(color_struct.data);
+ case COLOR_TYPE_RGB:
+ data = GET_COLOR_RGB(color);
+ switch (imgtype) {
+ case IMAGE_RGB:
+ c = data;
+ break;
+ case IMAGE_GRAYSCALE: {
+ int r = _rgba_getr(data);
+ int g = _rgba_getg(data);
+ int b = _rgba_getb(data);
- rgb_to_hsv_int(&r, &g, &b);
+ rgb_to_hsv_int(&r, &g, &b);
- c = _graya(b, _rgba_geta(color_struct.data));
- }
- else if (color_struct.type == COLOR_TYPE_GRAY) {
- c = _graya(_graya_getk(color_struct.data),
- _graya_geta(color_struct.data));
- }
- else if (color_struct.type == COLOR_TYPE_INDEX) {
- c = _graya(color_struct.data & 0xff, 255);
+ c = _graya(b, _rgba_geta(data));
+ break;
+ }
+ case IMAGE_INDEXED:
+ c = orig_rgb_map->data
+ [_rgba_getr(data) >> 3]
+ [_rgba_getg(data) >> 3]
+ [_rgba_getb(data) >> 3];
+ break;
}
break;
- case IMAGE_INDEXED:
- if (color_struct.type == COLOR_TYPE_MASK) {
- c = 0;
- }
- else if (color_struct.type == COLOR_TYPE_RGB) {
- c = orig_rgb_map->data
- [_rgba_getr(color_struct.data) >> 3]
- [_rgba_getg(color_struct.data) >> 3]
- [_rgba_getb(color_struct.data) >> 3];
- }
- else if (color_struct.type == COLOR_TYPE_GRAY) {
- c = _graya_getk(color_struct.data);
- c = orig_rgb_map->data[c>>3][c>>3][c>>3];
- }
- else if (color_struct.type == COLOR_TYPE_INDEX) {
- c = color_struct.data & 0xff;
+
+ case COLOR_TYPE_HSV: {
+ int h, s, v;
+
+ data = GET_COLOR_HSV(color);
+
+ switch (imgtype) {
+ case IMAGE_RGB:
+ h = _hsva_geth(data);
+ s = _hsva_gets(data);
+ v = _hsva_getv(data);
+ hsv_to_rgb_int(&h, &s, &v);
+
+ c = _rgba(h, s, v, _hsva_geta(data));
+ break;
+ case IMAGE_GRAYSCALE: {
+ c = _graya(_hsva_getv(data),
+ _hsva_geta(data));
+ break;
+ }
+ case IMAGE_INDEXED:
+ h = _hsva_geth(data);
+ s = _hsva_gets(data);
+ v = _hsva_getv(data);
+ hsv_to_rgb_int(&h, &s, &v);
+
+ c = orig_rgb_map->data[h >> 3][s >> 3][v >> 3];
+ break;
}
break;
+ }
+
+ case COLOR_TYPE_GRAY:
+ data = GET_COLOR_GRAY(color);
+ switch (imgtype) {
+ case IMAGE_RGB:
+ c = _graya_getv(data);
+ c = _rgba(c, c, c, _graya_geta(data));
+ break;
+ case IMAGE_GRAYSCALE:
+ c = data;
+ break;
+ case IMAGE_INDEXED:
+ c = _graya_getv(data);
+ c = orig_rgb_map->data[c>>3][c>>3][c>>3];
+ break;
+ }
+ break;
+
+ case COLOR_TYPE_INDEX:
+ data = GET_COLOR_INDEX(color);
+ switch (imgtype) {
+ case IMAGE_RGB:
+ c = data;
+ c = _rgba(_rgb_scale_6[current_palette[c].r],
+ _rgb_scale_6[current_palette[c].g],
+ _rgb_scale_6[current_palette[c].b], 255);
+ break;
+ case IMAGE_GRAYSCALE:
+ c = _graya(data & 0xff, 255);
+ break;
+ case IMAGE_INDEXED:
+ c = data & 0xff;
+ break;
+ }
+ break;
+
}
return c;
}
-char *image_getpixel_color(Image *image, int x, int y)
+color_t image_getpixel_color(Image *image, int x, int y)
{
if ((x >= 0) && (y >= 0) && (x < image->w) && (y < image->h))
return color_from_image(image->imgtype, image_getpixel(image, x, y));
@@ -367,102 +730,145 @@ char *image_getpixel_color(Image *image, int x, int y)
return color_mask();
}
-void color_to_formalstring(int imgtype, const char *color, char *buf,
- int size, int long_format)
+void color_to_formalstring(int imgtype, color_t color,
+ char *buf, int size, bool long_format)
{
- fill_color_struct(color);
+ int data;
/* long format */
if (long_format) {
- if (color_struct.type == COLOR_TYPE_MASK) {
- uszprintf(buf, size, _("Mask"));
- }
- else if (color_struct.type == COLOR_TYPE_RGB) {
- if (imgtype == IMAGE_GRAYSCALE) {
- uszprintf(buf, size, "%s %d %s %d",
- _("Gray"),
- _graya_getk(get_color_for_image(imgtype, color)),
- _("Alpha"),
- _rgba_geta(color_struct.data));
- }
- else {
- uszprintf(buf, size, "%s %d %d %d",
- _("RGB"),
- _rgba_getr(color_struct.data),
- _rgba_getg(color_struct.data),
- _rgba_getb(color_struct.data));
-
- if (imgtype == IMAGE_INDEXED)
- uszprintf(buf+ustrlen(buf), size, " %s %d",
- _("Index"), get_color_for_image(imgtype, color));
- else if (imgtype == IMAGE_RGB)
- uszprintf(buf+ustrlen(buf), size, " %s %d",
- _("Alpha"), _rgba_geta(color_struct.data));
- }
- }
- else if (color_struct.type == COLOR_TYPE_GRAY) {
- uszprintf(buf, size, "%s %d",
- _("Gray"), _graya_getk(color_struct.data));
+ switch (GET_COLOR_TYPE(color)) {
- if ((imgtype == IMAGE_RGB) ||
- (imgtype == IMAGE_GRAYSCALE)) {
- uszprintf(buf+ustrlen(buf), size, " %s %d",
- _("Alpha"), _graya_geta(color_struct.data));
- }
- }
- else if (color_struct.type == COLOR_TYPE_INDEX) {
- uszprintf(buf, size, "%s %d(RGB %d %d %d)",
- _("Index"),
- color_struct.data & 0xff,
- _rgb_scale_6[current_palette[color_struct.data & 0xff].r],
- _rgb_scale_6[current_palette[color_struct.data & 0xff].g],
- _rgb_scale_6[current_palette[color_struct.data & 0xff].b]);
- }
- else {
- uszprintf(buf, size, _("Unknown"));
+ case COLOR_TYPE_MASK:
+ uszprintf(buf, size, _("Mask"));
+ break;
+
+ case COLOR_TYPE_RGB:
+ data = GET_COLOR_RGB(color);
+ if (imgtype == IMAGE_GRAYSCALE) {
+ uszprintf(buf, size, "%s %d %s %d",
+ _("Gray"),
+ _graya_getv(get_color_for_image(imgtype, color)),
+ _("Alpha"),
+ _rgba_geta(data));
+ }
+ else {
+ uszprintf(buf, size, "%s %d %d %d",
+ _("RGB"),
+ _rgba_getr(data),
+ _rgba_getg(data),
+ _rgba_getb(data));
+
+ if (imgtype == IMAGE_INDEXED)
+ uszprintf(buf+ustrlen(buf), size, " %s %d",
+ _("Index"), get_color_for_image(imgtype, color));
+ else if (imgtype == IMAGE_RGB)
+ uszprintf(buf+ustrlen(buf), size, " %s %d",
+ _("Alpha"), _rgba_geta(data));
+ }
+ break;
+
+ case COLOR_TYPE_HSV:
+ data = GET_COLOR_HSV(color);
+ if (imgtype == IMAGE_GRAYSCALE) {
+ uszprintf(buf, size, "%s %d %s %d",
+ _("Gray"), _hsva_getv(data),
+ _("Alpha"), _hsva_geta(data));
+ }
+ else {
+ uszprintf(buf, size, "%s %d %d %d",
+ _("HSV"),
+ _hsva_geth(data),
+ _hsva_gets(data),
+ _hsva_getv(data));
+
+ if (imgtype == IMAGE_INDEXED)
+ uszprintf(buf+ustrlen(buf), size, " %s %d",
+ _("Index"), get_color_for_image(imgtype, color));
+ else if (imgtype == IMAGE_RGB)
+ uszprintf(buf+ustrlen(buf), size, " %s %d",
+ _("Alpha"), _hsva_geta(data));
+ }
+ break;
+
+ case COLOR_TYPE_GRAY:
+ data = GET_COLOR_GRAY(color);
+ uszprintf(buf, size, "%s %d",
+ _("Gray"), _graya_getv(data));
+
+ if ((imgtype == IMAGE_RGB) ||
+ (imgtype == IMAGE_GRAYSCALE)) {
+ uszprintf(buf+ustrlen(buf), size, " %s %d",
+ _("Alpha"), _graya_geta(data));
+ }
+ break;
+
+ case COLOR_TYPE_INDEX:
+ data = GET_COLOR_INDEX(color);
+ uszprintf(buf, size, "%s %d(RGB %d %d %d)",
+ _("Index"),
+ data & 0xff,
+ _rgb_scale_6[current_palette[data & 0xff].r],
+ _rgb_scale_6[current_palette[data & 0xff].g],
+ _rgb_scale_6[current_palette[data & 0xff].b]);
+ break;
+
+ default:
+ assert(FALSE);
+ break;
}
}
/* short format */
else {
- if (color_struct.type == COLOR_TYPE_MASK) {
- uszprintf(buf, size, "MASK");
- }
- else if (color_struct.type == COLOR_TYPE_RGB) {
- if (imgtype == IMAGE_GRAYSCALE) {
- uszprintf(buf, size, "KA %02x(%d)",
- _graya_getk(get_color_for_image(imgtype, color)),
- _graya_getk(get_color_for_image(imgtype, color)));
- }
- else {
- uszprintf(buf, size, "RGB %02x%02x%02x",
- _rgba_getr(color_struct.data),
- _rgba_getg(color_struct.data),
- _rgba_getb(color_struct.data));
+ switch (GET_COLOR_TYPE(color)) {
- if (imgtype == IMAGE_INDEXED)
- uszprintf(buf+ustrlen(buf), size, "(%d)",
- get_color_for_image(imgtype, color));
- }
- }
- else if (color_struct.type == COLOR_TYPE_GRAY) {
- uszprintf(buf, size, "I %02x (%d)",
- _graya_getk(color_struct.data),
- _graya_getk(color_struct.data));
- }
- else if (color_struct.type == COLOR_TYPE_INDEX) {
- uszprintf(buf, size, "I %02x (%d)",
- color_struct.data & 0xff,
- color_struct.data & 0xff);
- }
- else {
- uszprintf(buf, size, "?");
+ case COLOR_TYPE_MASK:
+ uszprintf(buf, size, "MASK");
+ break;
+
+ case COLOR_TYPE_RGB:
+ data = GET_COLOR_RGB(color);
+ if (imgtype == IMAGE_GRAYSCALE) {
+ uszprintf(buf, size, "KA %02x(%d)",
+ _graya_getv(get_color_for_image(imgtype, color)),
+ _graya_getv(get_color_for_image(imgtype, color)));
+ }
+ else {
+ uszprintf(buf, size, "RGB %02x%02x%02x",
+ _rgba_getr(data),
+ _rgba_getg(data),
+ _rgba_getb(data));
+
+ if (imgtype == IMAGE_INDEXED)
+ uszprintf(buf+ustrlen(buf), size, "(%d)",
+ get_color_for_image(imgtype, color));
+ }
+ break;
+
+ case COLOR_TYPE_GRAY:
+ data = GET_COLOR_GRAY(color);
+ uszprintf(buf, size, "I %02x (%d)",
+ _graya_getv(data),
+ _graya_getv(data));
+ break;
+
+ case COLOR_TYPE_INDEX:
+ data = GET_COLOR_INDEX(color);
+ uszprintf(buf, size, "I %02x (%d)", data, data);
+ break;
+
+ default:
+ assert(FALSE);
+ break;
}
}
}
void draw_color(BITMAP *bmp, int x1, int y1, int x2, int y2,
- int imgtype, const char *color)
+ int imgtype, color_t color)
{
+ int type = GET_COLOR_TYPE(color);
+ int data;
int w = x2 - x1 + 1;
int h = y2 - y1 + 1;
BITMAP *graph;
@@ -471,12 +877,11 @@ void draw_color(BITMAP *bmp, int x1, int y1, int x2, int y2,
grid = MIN(w, h) / 2;
grid += MIN(w, h) - grid*2;
- fill_color_struct(color);
-
- if (color_struct.type == COLOR_TYPE_INDEX) {
+ if (type == COLOR_TYPE_INDEX) {
+ data = GET_COLOR_INDEX(color);
rectfill(bmp, x1, y1, x2, y2,
/* get_color_for_allegro(bitmap_color_depth(bmp), color)); */
- palette_color[_index_cmap[color_struct.data & 0xff]]);
+ palette_color[_index_cmap[data]]);
return;
}
@@ -498,12 +903,11 @@ void draw_color(BITMAP *bmp, int x1, int y1, int x2, int y2,
set_trans_blender(0, 0, 0, color_get_alpha(imgtype, color));
{
int rgb_bitmap_color = get_color_for_image(imgtype, color);
- char *color2 = color_rgb(_rgba_getr(rgb_bitmap_color),
- _rgba_getg(rgb_bitmap_color),
- _rgba_getb(rgb_bitmap_color),
- _rgba_geta(rgb_bitmap_color));
+ color_t color2 = color_rgb(_rgba_getr(rgb_bitmap_color),
+ _rgba_getg(rgb_bitmap_color),
+ _rgba_getb(rgb_bitmap_color),
+ _rgba_geta(rgb_bitmap_color));
rectfill(graph, 0, 0, w-1, h-1, get_color_for_allegro(32, color2));
- jfree(color2);
}
drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
@@ -525,10 +929,9 @@ void draw_color(BITMAP *bmp, int x1, int y1, int x2, int y2,
set_trans_blender(0, 0, 0, color_get_alpha(imgtype, color));
{
int gray_bitmap_color = get_color_for_image(imgtype, color);
- char *color2 = color_gray(_graya_getk(gray_bitmap_color),
- _graya_geta(gray_bitmap_color));
+ color_t color2 = color_gray(_graya_getv(gray_bitmap_color),
+ _graya_geta(gray_bitmap_color));
rectfill(graph, 0, 0, w-1, h-1, get_color_for_allegro(32, color2));
- jfree(color2);
}
drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
@@ -541,51 +944,6 @@ void draw_color(BITMAP *bmp, int x1, int y1, int x2, int y2,
}
}
-static void fill_color_struct(const char *color)
-{
- char *buf, *tok;
-
- color_struct.type = COLOR_TYPE_MASK;
- color_struct.data = 0;
-
- buf = color ? jstrdup(color): NULL;
- if (!buf)
- return;
-
- if (ustrcmp (buf, "mask") != 0) {
- if (ustrncmp (buf, "rgb{", 4) == 0) {
- int c=0, table[4] = { 0, 0, 0, 255 };
-
- for (tok=ustrtok(buf+4, ","); tok;
- tok=ustrtok(NULL, ",")) {
- if (c < 4)
- table[c++] = ustrtol(tok, NULL, 10);
- }
-
- color_struct.type = COLOR_TYPE_RGB;
- color_struct.data = _rgba(table[0], table[1], table[2], table[3]);
- }
- else if (ustrncmp (buf, "gray{", 5) == 0) {
- int c=0, table[2] = { 0, 255 };
-
- for (tok=ustrtok(buf+5, ","); tok;
- tok=ustrtok(NULL, ",")) {
- if (c < 2)
- table[c++] = ustrtol(tok, NULL, 10);
- }
-
- color_struct.type = COLOR_TYPE_GRAY;
- color_struct.data = _graya(table[0], table[1]);
- }
- else if (ustrncmp (buf, "index{", 6) == 0) {
- color_struct.type = COLOR_TYPE_INDEX;
- color_struct.data = ustrtol(buf+6, NULL, 10);
- }
- }
-
- jfree(buf);
-}
-
/* returns the same values of bitmap_mask_color() (this function *must*
returns the same values) */
static int get_mask_for_bitmap(int depth)
diff --git a/src/modules/color.h b/src/modules/color.h
index c90879156..aa01a5093 100644
--- a/src/modules/color.h
+++ b/src/modules/color.h
@@ -25,37 +25,52 @@ struct Image;
enum {
COLOR_TYPE_MASK,
COLOR_TYPE_RGB,
+ COLOR_TYPE_HSV,
COLOR_TYPE_GRAY,
COLOR_TYPE_INDEX,
};
+typedef struct color_t
+{
+ ase_uint32 coltype;
+ ase_uint32 imgcolor;
+} color_t;
+
+/* typedef uint64_t color_t; */
+
int init_module_color(void);
void exit_module_color(void);
-int color_type(const char *color);
-char *color_mask(void);
-char *color_rgb(int r, int g, int b, int a);
-char *color_gray(int g, int a);
-char *color_index(int index);
-int color_get_black(int imgtype, const char *color);
-int color_get_red(int imgtype, const char *color);
-int color_get_green(int imgtype, const char *color);
-int color_get_blue(int imgtype, const char *color);
-int color_get_index(int imgtype, const char *color);
-int color_get_alpha(int imgtype, const char *color);
-void color_set_alpha(char **color, int alpha);
-char *color_from_image(int imgtype, int c);
+char *color_to_string(color_t color, char *buf, int size);
+color_t string_to_color(const char *str);
+
+int color_type(color_t color);
+color_t color_mask(void);
+color_t color_rgb(int r, int g, int b, int a);
+color_t color_hsv(int h, int s, int v, int a);
+color_t color_gray(int g, int a);
+color_t color_index(int index);
+int color_get_red(int imgtype, color_t color);
+int color_get_green(int imgtype, color_t color);
+int color_get_blue(int imgtype, color_t color);
+int color_get_hue(int imgtype, color_t color);
+int color_get_saturation(int imgtype, color_t color);
+int color_get_value(int imgtype, color_t color);
+int color_get_index(int imgtype, color_t color);
+int color_get_alpha(int imgtype, color_t color);
+void color_set_alpha(color_t *color, int alpha);
+color_t color_from_image(int imgtype, int c);
int blackandwhite(int r, int g, int b);
int blackandwhite_neg(int r, int g, int b);
-int get_color_for_allegro(int depth, const char *color);
-int get_color_for_image(int imgtype, const char *color);
-char *image_getpixel_color(struct Image *image, int x, int y);
-void color_to_formalstring(int imgtype, const char *color, char *buf,
- int size, int long_format);
+int get_color_for_allegro(int depth, color_t color);
+int get_color_for_image(int imgtype, color_t color);
+color_t image_getpixel_color(struct Image *image, int x, int y);
+void color_to_formalstring(int imgtype, color_t color, char *buf,
+ int size, bool long_format);
void draw_color(struct BITMAP *bmp, int x1, int y1, int x2, int y2,
- int imgtype, const char *color);
+ int imgtype, color_t color);
#endif /* MODULES_COLOR_H */
diff --git a/src/modules/gfx.c b/src/modules/gfx.c
index 7e9678efc..20c3e5ac3 100644
--- a/src/modules/gfx.c
+++ b/src/modules/gfx.c
@@ -28,6 +28,7 @@
#include "core/cfg.h"
#include "core/dirs.h"
#include "modules/gfx.h"
+#include "modules/gui.h"
#include "modules/palette.h"
#include "modules/tools.h"
#include "widgets/editor.h"
@@ -39,6 +40,7 @@ static BITMAP *gfx_bmps[GFX_BITMAP_COUNT];
static void convert_data_to_bitmap(DATA *data, BITMAP **bmp)
{
+ int guiscale = GUISCALE;
const char *p;
int x, y;
int black = makecol(0, 0, 0);
@@ -46,18 +48,20 @@ static void convert_data_to_bitmap(DATA *data, BITMAP **bmp)
int white = makecol(255, 255, 255);
int mask;
- *bmp = create_bitmap(data->w, data->h);
+ *bmp = create_bitmap(data->w * guiscale,
+ data->h * guiscale);
mask = bitmap_mask_color(*bmp);
p = data->line;
- for (y=0; yh; y++)
- for (x=0; xw; x++) {
- putpixel(*bmp, x, y,
+ for (y=0; y<(*bmp)->h; y+=guiscale) {
+ for (x=0; x<(*bmp)->w; x+=guiscale) {
+ rectfill(*bmp, x, y, x+guiscale-1, y+guiscale-1,
(*p == '#') ? black:
(*p == '%') ? gray:
(*p == '.') ? white: mask);
p++;
}
+ }
}
static void gen_gfx(void)
@@ -516,44 +520,6 @@ void rectgrid(BITMAP *bmp, int x1, int y1, int x2, int y2, int w, int h)
}
}
-void rectfill_exclude(BITMAP *bmp, int x1, int y1, int x2, int y2, int ex1, int ey1, int ex2, int ey2, int color)
-{
- _ji_theme_rectfill_exclude(bmp, x1, y1, x2, y2,
- ex1, ey1, ex2, ey2, color);
-}
-
-void rectshade(BITMAP *bmp, int x1, int y1, int x2, int y2, int top, int bottom)
-{
- int x, y, r[3], g[3], b[3];
-
- r[0] = getr(top);
- g[0] = getg(top);
- b[0] = getb(top);
-
- r[2] = getr(bottom);
- g[2] = getg(bottom);
- b[2] = getb(bottom);
-
- if ((x2-x1+1) > (y2-y1+1)/2) {
- for (y=y1; y<=y2; y++) {
- r[1] = r[0] + (r[2] - r[0]) * (y - y1) / (y2 - y1);
- g[1] = g[0] + (g[2] - g[0]) * (y - y1) / (y2 - y1);
- b[1] = b[0] + (b[2] - b[0]) * (y - y1) / (y2 - y1);
-
- hline(bmp, x1, y, x2, makecol(r[1], g[1], b[1]));
- }
- }
- else {
- for (x=x1; x<=x2; x++) {
- r[1] = r[0] + (r[2] - r[0]) * (x - x1) / (x2 - x1);
- g[1] = g[0] + (g[2] - g[0]) * (x - x1) / (x2 - x1);
- b[1] = b[0] + (b[2] - b[0]) * (x - x1) / (x2 - x1);
-
- vline(bmp, x, y1, y2, makecol(r[1], g[1], b[1]));
- }
- }
-}
-
void draw_emptyset_symbol(JRect rc, int color)
{
int cx, cy, x1, y1, x2, y2, size;
@@ -568,7 +534,7 @@ void draw_emptyset_symbol(JRect rc, int color)
x2 = x1+size-1;
y2 = y1+size-1;
- circle(ji_screen, cx, cy, size/2, color);
+ circle(ji_screen, cx, cy, size*4/10, color);
line(ji_screen, x1, y2, x2, y1, color);
}
diff --git a/src/modules/gfx.h b/src/modules/gfx.h
index 6404d7e65..77462cf2f 100644
--- a/src/modules/gfx.h
+++ b/src/modules/gfx.h
@@ -112,8 +112,6 @@ void rectdiscard(void *data);
void bevel_box(struct BITMAP *bmp, int x1, int y1, int x2, int y2, int c1, int c2, int bevel);
void rectdotted(struct BITMAP *bmp, int x1, int y1, int x2, int y2, int fg, int bg);
void rectgrid(struct BITMAP *bmp, int x1, int y1, int x2, int y2, int w, int h);
-void rectfill_exclude(struct BITMAP *bmp, int x1, int y1, int x2, int y2, int ex1, int ey1, int ex2, int ey2, int color);
-void rectshade(struct BITMAP *bmp, int x1, int y1, int x2, int y2, int top, int bottom);
void draw_emptyset_symbol(JRect rc, int color);
diff --git a/src/modules/gui.c b/src/modules/gui.c
index 717d8db09..10d02736c 100644
--- a/src/modules/gui.c
+++ b/src/modules/gui.c
@@ -425,7 +425,7 @@ void update_screen_for_sprite(Sprite *sprite)
}
}
- status_bar_set_text(app_get_status_bar(), -1, "");
+ statusbar_set_text(app_get_statusbar(), -1, "");
}
void gui_run(void)
@@ -495,6 +495,8 @@ void gui_setup_screen(void)
ji_screen_created = FALSE;
}
+ reload_default_font();
+
/* set the configuration */
save_gui_config();
}
@@ -502,8 +504,9 @@ void gui_setup_screen(void)
void reload_default_font(void)
{
JTheme theme = ji_get_theme();
- const char *default_font;
+ const char *user_font;
DIRS *dirs, *dir;
+ char buf[512];
/* no font for now */
@@ -515,25 +518,19 @@ void reload_default_font(void)
/* directories */
dirs = dirs_new();
- default_font = get_config_string("Options", "DefaultFont", "");
- if ((default_font) && (*default_font))
- dirs_add_path(dirs, default_font);
+ user_font = get_config_string("Options", "UserFont", "");
+ if ((user_font) && (*user_font))
+ dirs_add_path(dirs, user_font);
- /* big font */
-/* if (JI_SCREEN_W > 400) */
-/* dirs_cat_dirs(dirs, filename_in_datadir("fonts/default2.pcx")); */
-/* /\* tiny font *\/ */
-/* else */
- dirs_cat_dirs(dirs, filename_in_datadir("fonts/default.pcx"));
+ usprintf(buf, "fonts/ase%d.pcx", GUISCALE);
+ dirs_cat_dirs(dirs, filename_in_datadir(buf));
/* try to load the font */
for (dir=dirs; dir; dir=dir->next) {
theme->default_font = ji_font_load(dir->path);
if (theme->default_font) {
- if (ji_font_is_scalable (theme->default_font)) {
- ji_font_set_size(theme->default_font,
- (JI_SCREEN_W > 320) ? 14: 8);
- }
+ if (ji_font_is_scalable(theme->default_font))
+ ji_font_set_size(theme->default_font, 8*GUISCALE);
break;
}
}
@@ -852,7 +849,7 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
}
break;
- case JM_CHAR: {
+ case JM_KEYPRESSED: {
Command *command = command_get_by_key(msg);
if (!command)
break;
diff --git a/src/modules/gui.h b/src/modules/gui.h
index 457c95a3e..3886cf6bf 100644
--- a/src/modules/gui.h
+++ b/src/modules/gui.h
@@ -24,6 +24,8 @@
#define HOOK(widget, signal, signal_handler, user_data) \
hook_signal((widget), (signal), (signal_handler), (int)(user_data))
+#define GUISCALE (JI_SCREEN_W > 512 ? 2: 1)
+
struct Sprite;
struct Monitor;
diff --git a/src/modules/rootmenu.c b/src/modules/rootmenu.c
index 77048c4dc..9a02e7f06 100644
--- a/src/modules/rootmenu.c
+++ b/src/modules/rootmenu.c
@@ -93,8 +93,8 @@ static int load_root_menu(void)
DIRS *dirs, *dir;
JXml xml;
- if (app_get_menu_bar())
- jmenubar_set_menu(app_get_menu_bar(), NULL);
+ if (app_get_menubar())
+ jmenubar_set_menu(app_get_menubar(), NULL);
/* destroy `root-menu' if it exists */
if (root_menu) {
@@ -202,8 +202,8 @@ static int load_root_menu(void)
}
/* sets the "menu" of the "menu-bar" to the new "root-menu" */
- if (app_get_menu_bar()) {
- jmenubar_set_menu(app_get_menu_bar(), root_menu);
+ if (app_get_menubar()) {
+ jmenubar_set_menu(app_get_menubar(), root_menu);
jwindow_remap(app_get_top_window());
jwidget_dirty(app_get_top_window());
}
diff --git a/src/modules/sprites.c b/src/modules/sprites.c
index 426741c08..9aa81e147 100644
--- a/src/modules/sprites.c
+++ b/src/modules/sprites.c
@@ -127,7 +127,7 @@ void sprite_mount(Sprite *sprite)
if (is_interactive()) {
/* add the tab for this sprite */
- tabs_append_tab(app_get_tabs_bar(),
+ tabs_append_tab(app_get_tabsbar(),
get_filename(sprite->filename), sprite);
/* rebuild the menu list of sprites */
@@ -147,7 +147,7 @@ void sprite_unmount(Sprite *sprite)
if (is_interactive()) {
/* remove this sprite from tabs */
- tabs_remove_tab(app_get_tabs_bar(), sprite);
+ tabs_remove_tab(app_get_tabsbar(), sprite);
/* rebuild the menu list of sprites */
app_realloc_sprite_list();
@@ -166,10 +166,9 @@ void sprite_unmount(Sprite *sprite)
void set_current_sprite(Sprite *sprite)
{
current_sprite = sprite;
- update_global_script_variables();
/* select the sprite in the tabs */
- tabs_select_tab(app_get_tabs_bar(), sprite);
+ tabs_select_tab(app_get_tabsbar(), sprite);
}
void send_sprite_to_top(Sprite *sprite)
diff --git a/src/modules/tools.c b/src/modules/tools.c
index 967d2b278..4d3585677 100644
--- a/src/modules/tools.c
+++ b/src/modules/tools.c
@@ -69,7 +69,7 @@ static bool view_grid;
static JRect grid;
static bool onionskin;
-static char *cursor_color = NULL;
+static color_t cursor_color;
static int _cursor_color;
static int _cursor_mask;
@@ -78,15 +78,13 @@ static int tool_color;
static void update_cursor_color(void)
{
- if (cursor_color) {
- if (ji_screen)
- _cursor_color = get_color_for_allegro(bitmap_color_depth(ji_screen),
- cursor_color);
- else
- _cursor_color = 0;
+ if (ji_screen)
+ _cursor_color = get_color_for_allegro(bitmap_color_depth(ji_screen),
+ cursor_color);
+ else
+ _cursor_color = 0;
- _cursor_mask = (ustrcmp(cursor_color, "mask") == 0);
- }
+ _cursor_mask = (color_type(cursor_color) == COLOR_TYPE_MASK);
}
int init_module_tools(void)
@@ -109,7 +107,7 @@ int init_module_tools(void)
brush_set_angle(brush, MID(0, angle, 360));
/* cursor color */
- set_cursor_color(get_config_string("Tools", "CursorColor", "mask"));
+ set_cursor_color(get_config_color("Tools", "CursorColor", color_mask()));
/* tools configuration */
glass_dirty = get_config_int("Tools", "GlassDirty", 128);
@@ -137,7 +135,7 @@ int init_module_tools(void)
void exit_module_tools(void)
{
- set_config_string("Tools", "CursorColor", cursor_color);
+ set_config_color("Tools", "CursorColor", cursor_color);
set_config_int("Tools", "GlassDirty", glass_dirty);
set_config_int("Tools", "SprayWidth", spray_width);
set_config_int("Tools", "AirSpeed", air_speed);
@@ -155,7 +153,6 @@ void exit_module_tools(void)
jrect_free(grid);
brush_free(brush);
- jfree(cursor_color);
unhook_palette_changes(update_cursor_color);
}
@@ -175,14 +172,14 @@ void select_tool(Tool *tool)
current_tool = tool;
/* update status-bar */
- if (app_get_status_bar() &&
- jwidget_is_visible(app_get_status_bar()))
- status_bar_set_text(app_get_status_bar(), 500, "%s: %s",
+ if (app_get_statusbar() &&
+ jwidget_is_visible(app_get_statusbar()))
+ statusbar_set_text(app_get_statusbar(), 500, "%s: %s",
_("Tool"), current_tool->translated_name);
/* update tool-bar */
- if (app_get_tool_bar())
- tool_bar_update(app_get_tool_bar());
+ if (app_get_toolbar())
+ toolbar_update(app_get_toolbar());
}
void select_tool_by_name(const char *tool_name)
@@ -257,18 +254,14 @@ bool is_cursor_mask(void)
return _cursor_mask;
}
-const char *get_cursor_color(void)
+color_t get_cursor_color(void)
{
return cursor_color;
}
-void set_cursor_color(const char *color)
+void set_cursor_color(color_t color)
{
- if (cursor_color)
- jfree(cursor_color);
-
- cursor_color = jstrdup(color);
-
+ cursor_color = color;
update_cursor_color();
}
@@ -605,7 +598,6 @@ Tool *ase_tools_list[] =
/* TOOL CONTROL */
/***********************************************************/
-/* static void apply_grid(int *x, int *y); */
static void fourchain_line(int x1, int y1, int x2, int y2, void *data);
static void my_image_hline4_opaque(int x1, int y, int x2, void *data);
@@ -639,10 +631,10 @@ static void marker_scroll_callback(int before_change)
}
/* controls any tool to draw in the current sprite */
-void control_tool(JWidget widget, Tool *tool, const char *_color)
+void control_tool(JWidget widget, Tool *tool, color_t _color)
{
Editor *editor = editor_data(widget);
- JWidget status_bar = app_get_status_bar();
+ JWidget statusbar = app_get_statusbar();
Dirty *dirty = NULL;
int x1, y1, x2, y2;
int old_x1, old_y1, old_x2, old_y2;
@@ -749,8 +741,8 @@ void control_tool(JWidget widget, Tool *tool, const char *_color)
/* grid */
if (use_grid) {
- apply_grid(&x1, &y1);
- apply_grid(&x2, &y2);
+ apply_grid(&x1, &y1, TRUE);
+ apply_grid(&x2, &y2, TRUE);
}
/* square aspect */
@@ -801,8 +793,8 @@ void control_tool(JWidget widget, Tool *tool, const char *_color)
/* grid */
if (use_grid && (tool != &ase_tool_floodfill)) {
- apply_grid(&x1, &y1);
- apply_grid(&x2, &y2);
+ apply_grid(&x1, &y1, TRUE);
+ apply_grid(&x2, &y2, TRUE);
}
x1 += offset_x;
@@ -818,7 +810,7 @@ void control_tool(JWidget widget, Tool *tool, const char *_color)
/* grid */
if (use_grid)
- apply_grid(&pts[c*2], &pts[c*2+1]);
+ apply_grid(&pts[c*2], &pts[c*2+1], TRUE);
pts[c*2 ] += offset_x;
pts[c*2+1] += offset_y;
@@ -1039,7 +1031,7 @@ void control_tool(JWidget widget, Tool *tool, const char *_color)
editor_draw_cursor(widget, jmouse_x(0), jmouse_y(0));
/* update the state-bar */
- if (jwidget_is_visible(status_bar)) {
+ if (jwidget_is_visible(statusbar)) {
if (tool->flags & TOOL_UPDATE_BOX) {
char mode[256] = "";
@@ -1058,17 +1050,17 @@ void control_tool(JWidget widget, Tool *tool, const char *_color)
}
}
- status_bar_set_text(status_bar, 0,
+ statusbar_set_text(statusbar, 0,
"%s %3d %3d %s %3d %3d (%s %3d %3d) %s",
_start, x1, y1,
_end, x2, y2,
_size, ABS(x2-x1)+1, ABS(y2-y1)+1, mode);
}
else {
- status_bar_set_text(status_bar, 0, "%s %3d %3d", _pos, x1, y1);
+ statusbar_set_text(statusbar, 0, "%s %3d %3d", _pos, x1, y1);
}
- jwidget_flush_redraw(status_bar);
+ jwidget_flush_redraw(statusbar);
jmanager_dispatch_messages(ji_get_default_manager());
}
@@ -1172,7 +1164,7 @@ void control_tool(JWidget widget, Tool *tool, const char *_color)
}
/* draws the "tool" traces with the given points */
-void do_tool_points(Sprite *sprite, Tool *tool, const char *_color,
+void do_tool_points(Sprite *sprite, Tool *tool, color_t _color,
int npoints, int *x, int *y)
{
int x1=0, y1=0, x2=0, y2=0;
@@ -1280,17 +1272,22 @@ void do_tool_points(Sprite *sprite, Tool *tool, const char *_color,
dirty_free(dirty);
}
-void apply_grid(int *x, int *y)
+void apply_grid(int *x, int *y, bool flexible)
{
div_t d, dx, dy;
int w = jrect_w(grid);
int h = jrect_h(grid);
+ flexible = flexible ? 1: 0;
+
dx = div(grid->x1, w);
dy = div(grid->y1, h);
- d = div((*x)-dx.rem, w); *x = dx.rem + d.quot*w + ((d.rem > w/2)? w-1: 0);
- d = div((*y)-dy.rem, h); *y = dy.rem + d.quot*h + ((d.rem > h/2)? h-1: 0);
+ d = div((*x)-dx.rem, w);
+ *x = dx.rem + d.quot*w + ((d.rem > w/2)? w-flexible: 0);
+
+ d = div((*y)-dy.rem, h);
+ *y = dy.rem + d.quot*h + ((d.rem > h/2)? h-flexible: 0);
}
static void fourchain_line(int x1, int y1, int x2, int y2, void *data)
@@ -1353,7 +1350,7 @@ static void my_image_hline2_glass(int x1, int y, int x2, void *data)
{
register ase_uint16 *address = ((ase_uint16 **)tool_image->line)[y]+x1;
register int x = x2 - x1 + 1;
- int c = _graya(_graya_getk(tool_color), glass_dirty);
+ int c = _graya(_graya_getv(tool_color), glass_dirty);
int o = _graya_geta(tool_color);
while (x--) {
diff --git a/src/modules/tools.h b/src/modules/tools.h
index 5353db935..70aa597bc 100644
--- a/src/modules/tools.h
+++ b/src/modules/tools.h
@@ -22,6 +22,8 @@
#include "jinete/jbase.h"
#include "jinete/jrect.h"
+#include "modules/color.h"
+
struct _GList;
struct Brush;
struct Dirty;
@@ -108,17 +110,17 @@ void set_onionskin(bool status);
int get_raw_cursor_color(void);
bool is_cursor_mask(void);
-const char *get_cursor_color(void);
-void set_cursor_color(const char *color);
+color_t get_cursor_color(void);
+void set_cursor_color(color_t color);
int get_thickness_for_cursor(void);
-void control_tool(JWidget editor, Tool *tool, const char *color);
+void control_tool(JWidget editor, Tool *tool, color_t color);
-void do_tool_points(struct Sprite *sprite, Tool *tool, const char *color,
+void do_tool_points(struct Sprite *sprite, Tool *tool, color_t color,
int npoints, int *x, int *y);
-void apply_grid(int *x, int *y);
+void apply_grid(int *x, int *y, bool flexible);
#endif /* MODULES_TOOLS_H */
diff --git a/src/modules/tools2.c b/src/modules/tools2.c
index e7355ddd5..a1f543575 100644
--- a/src/modules/tools2.c
+++ b/src/modules/tools2.c
@@ -115,7 +115,7 @@ void SetDrawMode(const char *string)
rectangle, ellipse
uses the current FG color
*/
-void ToolTrace(const char *string, const char *color)
+void ToolTrace(const char *string, const char *_color)
{
Sprite *sprite = current_sprite;
@@ -127,6 +127,7 @@ void ToolTrace(const char *string, const char *color)
int npoints = 0;
int *x = NULL;
int *y = NULL;
+ color_t color = string_to_color(_color);
for (tok=strtok(copy, " "), count=0; tok;
tok=strtok(NULL, " "), count++) {
@@ -242,7 +243,7 @@ void ResetConfig(void)
set_brush_size(1);
set_brush_angle(0);
set_brush_mode(DRAWMODE_OPAQUE);
- set_cursor_color("mask");
+ set_cursor_color(color_mask());
set_glass_dirty(128);
set_spray_width(16);
set_air_speed(75);
diff --git a/src/raster/blend.c b/src/raster/blend.c
index 4d203845c..aa342c1c3 100644
--- a/src/raster/blend.c
+++ b/src/raster/blend.c
@@ -358,10 +358,10 @@ int _graya_blend_##mode (int back, int front, int opacity) \
int F_g, F_a; \
int D_g, D_a; \
\
- B_g = _graya_getk(back); \
+ B_g = _graya_getv(back); \
B_a = _graya_geta(back); \
\
- F_g = _graya_getk(front); \
+ F_g = _graya_getv(front); \
F_a = _graya_geta(front); \
F_a = INT_MULT(F_a, opacity, t);
@@ -392,7 +392,7 @@ int _graya_blend_FORPATH(int back, int front, int opacity)
int F_k, F_a;
T_VAR
- F_k = _graya_getk(front);
+ F_k = _graya_getv(front);
F_a = _graya_geta(front);
F_a = INT_MULT(F_a, opacity, t);
diff --git a/src/raster/image.c b/src/raster/image.c
index 29a6642ea..d37de4fe1 100644
--- a/src/raster/image.c
+++ b/src/raster/image.c
@@ -342,9 +342,9 @@ void image_convert(Image *dst, const Image *src)
for (x=0; xmethod->getpixel(src, x, y);
dst->method->putpixel(dst, x, y,
- _rgba(_graya_getk(c),
- _graya_getk(c),
- _graya_getk(c),
+ _rgba(_graya_getv(c),
+ _graya_getv(c),
+ _graya_getv(c),
_graya_geta(c)));
}
}
@@ -355,13 +355,13 @@ void image_convert(Image *dst, const Image *src)
for (y=0; ymethod->getpixel(src, x, y);
- if (!_graya_geta (c))
+ if (!_graya_geta(c))
dst->method->putpixel(dst, x, y, 0);
else
dst->method->putpixel(dst, x, y,
- makecol8(_graya_getk(c),
- _graya_getk(c),
- _graya_getk(c)));
+ makecol8(_graya_getv(c),
+ _graya_getv(c),
+ _graya_getv(c)));
}
}
break;
diff --git a/src/raster/image.h b/src/raster/image.h
index 97a8bd938..3175f56d9 100644
--- a/src/raster/image.h
+++ b/src/raster/image.h
@@ -37,12 +37,12 @@
((b) << _rgba_b_shift) | \
((a) << _rgba_a_shift))
-#define _graya_k_shift 0
+#define _graya_v_shift 0
#define _graya_a_shift 8
-#define _graya_getk(c) (((c) >> _graya_k_shift) & 0xff)
+#define _graya_getv(c) (((c) >> _graya_v_shift) & 0xff)
#define _graya_geta(c) (((c) >> _graya_a_shift) & 0xff)
-#define _graya(k,a) \
- (((k) << _graya_k_shift) | \
+#define _graya(v,a) \
+ (((v) << _graya_v_shift) | \
((a) << _graya_a_shift))
#define _image_bitmap_next_bit(d, a) \
diff --git a/src/raster/imgrgb.c b/src/raster/imgrgb.c
index 0760c2833..8e9d35b9b 100644
--- a/src/raster/imgrgb.c
+++ b/src/raster/imgrgb.c
@@ -28,7 +28,7 @@ static int rgb_regenerate_lines(Image *image)
int y;
if (LINES(image))
- jfree (LINES(image));
+ jfree(LINES(image));
image->line = jmalloc(sizeof(ase_uint32 *) * image->h);
if (!LINES(image))
diff --git a/src/raster/layer.c b/src/raster/layer.c
index 827264bf2..28caae426 100644
--- a/src/raster/layer.c
+++ b/src/raster/layer.c
@@ -18,6 +18,7 @@
#include "config.h"
+#include
#include
#include "jinete/jlist.h"
@@ -28,6 +29,7 @@
#include "raster/layer.h"
#include "raster/sprite.h"
#include "raster/stock.h"
+#include "raster/undo.h"
static bool has_cels(Layer *layer, int frame);
@@ -83,7 +85,8 @@ Layer *layer_new_copy(const Layer *layer)
switch (layer->gfxobj.type) {
case GFXOBJ_LAYER_IMAGE: {
- Cel *cel_copy;
+ Cel *cel_copy, *cel;
+ Image *image_copy, *image;
JLink link;
layer_copy = layer_new(layer->sprite);
@@ -94,11 +97,31 @@ Layer *layer_new_copy(const Layer *layer)
/* copy cels */
JI_LIST_FOR_EACH(layer->cels, link) {
- cel_copy = cel_new_copy(link->data);
+ cel = (Cel *)link->data;
+ cel_copy = cel_new_copy(cel);
if (!cel_copy) {
layer_free(layer_copy);
return NULL;
}
+
+ assert((cel->image >= 0) &&
+ (cel->image < layer->sprite->stock->nimage));
+
+ image = layer->sprite->stock->image[cel->image];
+ assert(image != NULL);
+
+ image_copy = image_new_copy(image);
+
+ if (layer->sprite != NULL &&
+ undo_is_enabled(layer->sprite->undo)) {
+ undo_add_image(layer->sprite->undo,
+ layer->sprite->stock,
+ image_copy);
+ }
+
+ cel_copy->image = stock_add_image(layer->sprite->stock,
+ image_copy);
+
layer_add_cel(layer_copy, cel_copy);
}
break;
@@ -316,19 +339,17 @@ void layer_render(Layer *layer, Image *image, int x, int y, int frame)
Image *src_image;
if (cel) {
- if ((cel->image >= 0) &&
- (cel->image < layer->sprite->stock->nimage))
- src_image = layer->sprite->stock->image[cel->image];
- else
- src_image = NULL;
+ assert((cel->image >= 0) &&
+ (cel->image < layer->sprite->stock->nimage));
- if (src_image) {
- image_merge(image, src_image,
- cel->x + x,
- cel->y + y,
- MID (0, cel->opacity, 255),
- layer->blend_mode);
- }
+ src_image = layer->sprite->stock->image[cel->image];
+ assert(src_image != NULL);
+
+ image_merge(image, src_image,
+ cel->x + x,
+ cel->y + y,
+ MID (0, cel->opacity, 255),
+ layer->blend_mode);
}
break;
}
diff --git a/src/raster/mask.c b/src/raster/mask.c
index f39ca2764..afc4f6f79 100644
--- a/src/raster/mask.c
+++ b/src/raster/mask.c
@@ -271,7 +271,7 @@ void mask_by_color(Mask *mask, const Image *src, int color, int fuzziness)
int u, v, c;
div_t d;
- dst_k = _graya_getk(color);
+ dst_k = _graya_getv(color);
dst_a = _graya_geta(color);
for (v=0; vh; v++) {
@@ -283,8 +283,8 @@ void mask_by_color(Mask *mask, const Image *src, int color, int fuzziness)
for (u=0; uw; u++) {
c = *(src_address++);
- src_k = _graya_getk (c);
- src_a = _graya_geta (c);
+ src_k = _graya_getv(c);
+ src_a = _graya_geta(c);
if (!((src_k >= dst_k-fuzziness) && (src_k <= dst_k+fuzziness) &&
(src_a >= dst_a-fuzziness) && (src_a <= dst_a+fuzziness)))
diff --git a/src/raster/quant.c b/src/raster/quant.c
index 999d9e33e..5a39756b6 100644
--- a/src/raster/quant.c
+++ b/src/raster/quant.c
@@ -96,8 +96,8 @@ Image *image_set_imgtype(Image *image, int imgtype,
rgb_address = (ase_uint32 *)new_image->dat;
for (i=0; idat;
for (i=0; iframe);
- sprite_set_speed(sprite, 42);
+ sprite_set_speed(sprite, 100);
/* multiple access */
sprite->locked = FALSE;
@@ -550,7 +550,7 @@ void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
switch (imgtype) {
/* Grayscale -> RGB */
case IMAGE_RGB:
- g = _graya_getk(c);
+ g = _graya_getv(c);
c = _rgba(g, g, g, _graya_geta(c));
break;
/* Grayscale -> Indexed */
@@ -558,7 +558,7 @@ void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
if (_graya_geta(c) == 0)
c = 0;
else
- c = _graya_getk(c);
+ c = _graya_getv(c);
break;
}
break;
@@ -754,6 +754,32 @@ int sprite_layer2index(const Sprite *sprite, const Layer *layer)
return layer2index(sprite->set, layer, &index_count);
}
+/**
+ * Gets a pixel from the sprite in the specified position. If in the
+ * specified coordinates there're background this routine will return
+ * the 0 color (the mask-color).
+ */
+int sprite_getpixel(Sprite *sprite, int x, int y)
+{
+ Image *image;
+ int color = 0;
+
+ if ((x >= 0) && (y >= 0) && (x < sprite->w) && (y < sprite->h)) {
+ int old_bgcolor = sprite->bgcolor;
+ sprite->bgcolor = 0;
+
+ image = image_new(sprite->imgtype, 1, 1);
+ image_clear(image, 0);
+ sprite_render(sprite, image, -x, -y);
+ color = image_getpixel(image, 0, 0);
+ image_free(image);
+
+ sprite->bgcolor = old_bgcolor;
+ }
+
+ return color;
+}
+
static Layer *index2layer(Layer *layer, int index, int *index_count)
{
if (index == *index_count)
diff --git a/src/raster/sprite.h b/src/raster/sprite.h
index 5e725d178..247027bb1 100644
--- a/src/raster/sprite.h
+++ b/src/raster/sprite.h
@@ -115,4 +115,6 @@ void sprite_generate_mask_boundaries(Sprite *sprite);
struct Layer *sprite_index2layer(Sprite *sprite, int index);
int sprite_layer2index(const Sprite *sprite, const struct Layer *layer);
+int sprite_getpixel(Sprite *sprite, int x, int y);
+
#endif /* RASTER_SPRITE_H */
diff --git a/src/script/bindings.c b/src/script/bindings.c
index 78ad1d666..7c3acfc16 100644
--- a/src/script/bindings.c
+++ b/src/script/bindings.c
@@ -151,29 +151,6 @@ void unregister_lua_object_metatable(void)
lua_unref(get_lua_state(), metatable);
}
-/**
- * Update global variables in the Lua state.
- */
-void update_global_script_variables(void)
-{
- lua_State *L = get_lua_state();
-
- lua_pushstring(L, VERSION);
- lua_setglobal(L, "VERSION");
-
- push_userdata(L, Type_Sprite, current_sprite);
- lua_setglobal(L, "current_sprite");
-
- push_userdata(L, Type_JWidget, current_editor);
- lua_setglobal(L, "current_editor");
-
- lua_pushnumber(L, ji_screen ? JI_SCREEN_W: 0);
- lua_setglobal(L, "SCREEN_W");
-
- lua_pushnumber(L, ji_screen ? JI_SCREEN_H: 0);
- lua_setglobal(L, "SCREEN_H");
-}
-
static void push_userdata(lua_State *L, int type, void *ptr)
{
if (!ptr)
diff --git a/src/script/bindings.h b/src/script/bindings.h
index 58766940e..9c6039942 100644
--- a/src/script/bindings.h
+++ b/src/script/bindings.h
@@ -24,6 +24,4 @@
void register_lua_object_metatable(void);
void unregister_lua_object_metatable(void);
-void update_global_script_variables(void);
-
#endif /* SCRIPT_BINDINGS_H */
diff --git a/src/script/script.c b/src/script/script.c
index a5a1c1256..34f9b5f31 100644
--- a/src/script/script.c
+++ b/src/script/script.c
@@ -221,9 +221,6 @@ static void prepare(void)
/* open console */
console_open();
- /* update variables */
- update_global_script_variables();
-
/* make a copy of the list of sprites to known which sprites where
created with the script */
sprites_of_users = jlist_copy(all_sprites);
diff --git a/src/test/jinete/00hello.c b/src/test/jinete/00hello.c
index 6597c7da9..dec266be9 100644
--- a/src/test/jinete/00hello.c
+++ b/src/test/jinete/00hello.c
@@ -1,7 +1,32 @@
-/* jinete - a GUI library
- * Copyright (C) 2003-2008 by David A. Capello
+/* Jinete - a GUI library
+ * Copyright (C) 2003-2008 David A. Capello.
+ * All rights reserved.
*
- * Jinete is gift-ware.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of the Jinete nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include
diff --git a/src/test/jinete/01simple.c b/src/test/jinete/01simple.c
index 5f2d59b84..3a48d92c1 100644
--- a/src/test/jinete/01simple.c
+++ b/src/test/jinete/01simple.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/02label.c b/src/test/jinete/02label.c
index e050367b5..5a86081b6 100644
--- a/src/test/jinete/02label.c
+++ b/src/test/jinete/02label.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/03slider.c b/src/test/jinete/03slider.c
index fd75d682c..96252da82 100644
--- a/src/test/jinete/03slider.c
+++ b/src/test/jinete/03slider.c
@@ -76,9 +76,9 @@ int main(int argc, char *argv[])
jwidget_expansive(slider5, TRUE);
jwidget_add_child(window, box);
- jwidget_add_childs(box,
- slider1, slider2, slider3,
- slider4, slider5, button1, NULL);
+ jwidget_add_children(box,
+ slider1, slider2, slider3,
+ slider4, slider5, button1, NULL);
jwindow_open_bg(window);
diff --git a/src/test/jinete/04alert.c b/src/test/jinete/04alert.c
index ef49ed940..f0823aa82 100644
--- a/src/test/jinete/04alert.c
+++ b/src/test/jinete/04alert.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/05fsel.c b/src/test/jinete/05fsel.c
index 05195d83b..4997fa648 100644
--- a/src/test/jinete/05fsel.c
+++ b/src/test/jinete/05fsel.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, 2008, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/06entry.c b/src/test/jinete/06entry.c
index dcda540a9..b857e0c3e 100644
--- a/src/test/jinete/06entry.c
+++ b/src/test/jinete/06entry.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/07panel.c b/src/test/jinete/07panel.c
index 13a6311e2..82fbcdb24 100644
--- a/src/test/jinete/07panel.c
+++ b/src/test/jinete/07panel.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,13 +58,13 @@ int main (int argc, char *argv[])
view2 = jview_new();
button = jbutton_new("&Close");
- jwidget_expansive (view1, TRUE);
- jwidget_expansive (view2, TRUE);
- jwidget_expansive (box2, TRUE);
+ jwidget_expansive(view1, TRUE);
+ jwidget_expansive(view2, TRUE);
+ jwidget_expansive(box2, TRUE);
- jwidget_add_child (window, box1);
- jwidget_add_childs (box1, box2, button, 0);
- jwidget_add_childs (box2, view1, view2, 0);
+ jwidget_add_child(window, box1);
+ jwidget_add_children(box1, box2, button, NULL);
+ jwidget_add_children(box2, view1, view2, NULL);
jwindow_open_bg (window);
diff --git a/src/test/jinete/08txtbox.c b/src/test/jinete/08txtbox.c
index fa33d6e8b..a0b07c8de 100644
--- a/src/test/jinete/08txtbox.c
+++ b/src/test/jinete/08txtbox.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, 2008 David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/09lists.c b/src/test/jinete/09lists.c
index b5246496f..41c7125fb 100644
--- a/src/test/jinete/09lists.c
+++ b/src/test/jinete/09lists.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/10chcks.c b/src/test/jinete/10chcks.c
index 9a4f6848c..8c0b6d43a 100644
--- a/src/test/jinete/10chcks.c
+++ b/src/test/jinete/10chcks.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/11file.c b/src/test/jinete/11file.c
index d4a4b7a9a..32362546a 100644
--- a/src/test/jinete/11file.c
+++ b/src/test/jinete/11file.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/12qckmnu.c b/src/test/jinete/12qckmnu.c
index ef883a8fd..4e57238b6 100644
--- a/src/test/jinete/12qckmnu.c
+++ b/src/test/jinete/12qckmnu.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/13menu.c b/src/test/jinete/13menu.c
index eb97f4b85..2f0ba2916 100644
--- a/src/test/jinete/13menu.c
+++ b/src/test/jinete/13menu.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/14win.c b/src/test/jinete/14win.c
index 909be56f0..137daccc1 100644
--- a/src/test/jinete/14win.c
+++ b/src/test/jinete/14win.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,7 @@
int main (int argc, char *argv[])
{
JWidget manager, desktop, box, view, sub_manager, button, window;
+ JWidget subwindows[256];
char buf[256];
int c;
@@ -64,9 +65,9 @@ int main (int argc, char *argv[])
jview_attach(view, sub_manager);
jwidget_expansive(view, TRUE);
- jwidget_add_child (desktop, box);
- jwidget_add_child (box, view);
- jwidget_add_child (box, button);
+ jwidget_add_child(desktop, box);
+ jwidget_add_child(box, view);
+ jwidget_add_child(box, button);
jwindow_open_bg(desktop);
@@ -77,8 +78,7 @@ int main (int argc, char *argv[])
window = jwindow_new(buf);
button = jbutton_new("&Close");
- jwidget_add_child (window, button);
- jwidget_autodestroy(window, TRUE);
+ jwidget_add_child(window, button);
jwindow_remap(window);
jwindow_position
@@ -87,10 +87,16 @@ int main (int argc, char *argv[])
sub_manager->rc->y1 + (rand () % (jrect_h(sub_manager->rc) - jrect_h(window->rc))));
_jmanager_open_window(sub_manager, window);
+ subwindows[c] = window;
}
- jmanager_run (manager);
- jmanager_free (manager);
+ jmanager_run(manager);
+
+ for (c=0; c<128; c++)
+ jwidget_free(subwindows[c]);
+ jwidget_free(desktop);
+
+ jmanager_free(manager);
return 0;
}
diff --git a/src/test/jinete/15colbut.c b/src/test/jinete/15colbut.c
index 17cecb952..7a6780d8e 100644
--- a/src/test/jinete/15colbut.c
+++ b/src/test/jinete/15colbut.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/16theme.c b/src/test/jinete/16theme.c
index e63aa9b5c..8c2a91836 100644
--- a/src/test/jinete/16theme.c
+++ b/src/test/jinete/16theme.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,8 +33,8 @@
#include "jinete/jinete.h"
-void set_my_palette (void);
-JTheme my_theme_new (void);
+void set_my_palette(void);
+JTheme my_theme_new(void);
int main (int argc, char *argv[])
{
@@ -43,84 +43,72 @@ int main (int argc, char *argv[])
JTheme my_theme;
/* Allegro stuff */
- allegro_init ();
+ allegro_init();
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
allegro_message("%s\n", allegro_error);
return 1;
}
}
- install_timer ();
- install_keyboard ();
- install_mouse ();
+ install_timer();
+ install_keyboard();
+ install_mouse();
- set_my_palette ();
+ set_my_palette();
/* Jinete initialization */
- manager = jmanager_new ();
+ manager = jmanager_new();
/* change to custom theme */
- my_theme = my_theme_new ();
- ji_set_theme (my_theme);
+ my_theme = my_theme_new();
+ ji_set_theme(my_theme);
- window1 = jwindow_new ("Window1");
- window2 = jwindow_new ("Window2");
- box2 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
- button1 = jbutton_new ("Button1");
- button2a = jbutton_new ("Button2a");
- button2b = jbutton_new ("Button2b");
+ window1 = jwindow_new("Window1");
+ window2 = jwindow_new("Window2");
+ box2 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
+ button1 = jbutton_new("Button1");
+ button2a = jbutton_new("Button2a");
+ button2b = jbutton_new("Button2b");
/* change to default theme */
- ji_set_standard_theme ();
+ ji_set_standard_theme();
- window3 = jwindow_new ("Window3");
- box3 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
- button3a = jbutton_new ("Button3a");
- button3b = jbutton_new ("Button3b");
+ window3 = jwindow_new("Window3");
+ box3 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
+ button3a = jbutton_new("Button3a");
+ button3b = jbutton_new("Button3b");
/* setup widgets */
- jwidget_disable (button2b);
- jwidget_disable (button3b);
+ jwidget_disable(button2b);
+ jwidget_disable(button3b);
- jwidget_add_child (window1, button1);
- jwidget_add_child (window2, box2);
- jwidget_add_child (box2, button2a);
- jwidget_add_child (box2, button2b);
- jwidget_add_child (window3, box3);
- jwidget_add_child (box3, button3a);
- jwidget_add_child (box3, button3b);
+ jwidget_add_child(window1, button1);
+ jwidget_add_child(window2, box2);
+ jwidget_add_child(box2, button2a);
+ jwidget_add_child(box2, button2b);
+ jwidget_add_child(window3, box3);
+ jwidget_add_child(box3, button3a);
+ jwidget_add_child(box3, button3b);
- jwindow_open (window1);
- jwindow_open (window2);
- jwindow_open (window3);
+ jwindow_open(window1);
+ jwindow_open(window2);
+ jwindow_open(window3);
- jmanager_run (manager);
+ jmanager_run(manager);
/* back to the custom theme */
- ji_set_theme (my_theme);
+ ji_set_theme(my_theme);
- jalert ("Warning<init_widget = theme_init_widget;
theme->get_window_mask = theme_get_window_mask;
- jtheme_set_method (theme, JI_BOX, theme_draw_box);
- jtheme_set_method (theme, JI_BUTTON, theme_draw_button);
- jtheme_set_method (theme, JI_LABEL, theme_draw_label);
- jtheme_set_method (theme, JI_WINDOW, theme_draw_window);
+ jtheme_set_method(theme, JI_BOX, theme_draw_box);
+ jtheme_set_method(theme, JI_BUTTON, theme_draw_button);
+ jtheme_set_method(theme, JI_LABEL, theme_draw_label);
+ jtheme_set_method(theme, JI_WINDOW, theme_draw_window);
return theme;
}
-static void theme_regen (void)
+static void theme_regen(void)
{
- ji_get_theme ()->desktop_color = makecol (64, 100, 128);
+ ji_get_theme()->desktop_color = makecol(64, 100, 128);
}
-static void theme_set_cursor (int type)
+static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y)
{
- set_mouse_sprite (NULL); /* use default Allegro cursor */
+ return NULL;
}
-static void theme_init_widget (JWidget widget)
+static void theme_init_widget(JWidget widget)
{
#define BORDER(n) \
widget->border_width.l = n; \
@@ -210,26 +198,26 @@ static void theme_init_widget (JWidget widget)
switch (widget->draw_type) {
case JI_BOX:
- BORDER (8);
+ BORDER(8);
widget->child_spacing = 8;
break;
case JI_BUTTON:
- BORDER (6);
+ BORDER(6);
widget->child_spacing = 0;
break;
case JI_WINDOW:
- BORDER4 (8, 12+jwidget_get_text_height (widget)+12, 8, 8);
+ BORDER4(8, 12+jwidget_get_text_height(widget)+12, 8, 8);
widget->child_spacing = 1;
break;
}
}
-static JRegion theme_get_window_mask (JWidget widget)
+static JRegion theme_get_window_mask(JWidget widget)
{
- JRegion reg1 = jregion_new (NULL, 0);
- JRegion reg2 = jregion_new (NULL, 0);
+ JRegion reg1 = jregion_new(NULL, 0);
+ JRegion reg2 = jregion_new(NULL, 0);
int table[6] = { 6, 4, 3, 2, 1, 1 };
JRect rect = jrect_new (0, 0, 0, 0);
JRect pos = jwidget_get_rect (widget);
@@ -237,122 +225,125 @@ static JRegion theme_get_window_mask (JWidget widget)
int c;
for (c=0; c<6; c++) {
- jrect_replace (rect,
- pos->x1+table[c], pos->y1+c,
- pos->x2-table[c], pos->y1+c+1);
- jregion_reset (reg2, rect);
- jregion_append (reg1, reg2);
+ jrect_replace(rect,
+ pos->x1+table[c], pos->y1+c,
+ pos->x2-table[c], pos->y1+c+1);
+ jregion_reset(reg2, rect);
+ jregion_append(reg1, reg2);
- jrect_replace (rect,
- pos->x1+table[c], pos->y2-c-1,
- pos->x2-table[c], pos->y2-c);
- jregion_reset (reg2, rect);
- jregion_append (reg1, reg2);
+ jrect_replace(rect,
+ pos->x1+table[c], pos->y2-c-1,
+ pos->x2-table[c], pos->y2-c);
+ jregion_reset(reg2, rect);
+ jregion_append(reg1, reg2);
}
- jrect_replace (rect, pos->x1, pos->y1+c, pos->x2, pos->y2-c);
- jregion_reset (reg2, rect);
- jregion_append (reg1, reg2);
+ jrect_replace(rect, pos->x1, pos->y1+c, pos->x2, pos->y2-c);
+ jregion_reset(reg2, rect);
+ jregion_append(reg1, reg2);
- jrect_free (pos);
- jrect_free (rect);
- jregion_free (reg2);
+ jrect_free(pos);
+ jrect_free(rect);
+ jregion_free(reg2);
- jregion_validate (reg1, &overlap);
+ jregion_validate(reg1, &overlap);
return reg1;
}
-static void theme_draw_box (JWidget widget)
+static void theme_draw_box(JWidget widget, JRect clip)
{
- JWidget window = jwidget_get_window (widget);
+ JWidget window = jwidget_get_window(widget);
if (window) {
- JRect pos = jwidget_get_child_rect (window);
- jdraw_rectshade (pos, makecol (128, 128, 128), makecol (196, 196, 196),
- JI_VERTICAL);
- jrect_free (pos);
+ JRect pos = jwidget_get_child_rect(window);
+ jdraw_rectshade(pos,
+ makecol(128, 128, 128),
+ makecol(196, 196, 196),
+ JI_VERTICAL);
+ jrect_free(pos);
}
}
-static void theme_draw_button (JWidget widget)
+static void theme_draw_button(JWidget widget, JRect clip)
{
- JRect pos = jwidget_get_rect (widget);
+ JRect pos = jwidget_get_rect(widget);
int c1, c2, fg, bg;
- if (jwidget_is_disabled (widget)) {
- if (jwidget_is_selected (widget)) {
- bg = makecol (64, 64, 64);
- fg = makecol (128, 128, 128);
- c1 = makecol (0, 0, 0);
- c2 = makecol (255, 255, 255);
+ if (jwidget_is_disabled(widget)) {
+ if (jwidget_is_selected(widget)) {
+ bg = makecol(64, 64, 64);
+ fg = makecol(128, 128, 128);
+ c1 = makecol(0, 0, 0);
+ c2 = makecol(255, 255, 255);
}
else {
- bg = makecol (128, 128, 128);
- fg = makecol (64, 64, 64);
- c1 = makecol (255, 255, 255);
- c2 = makecol (0, 0, 0);
+ bg = makecol(128, 128, 128);
+ fg = makecol(64, 64, 64);
+ c1 = makecol(255, 255, 255);
+ c2 = makecol(0, 0, 0);
}
}
else {
- if (jwidget_is_selected (widget)) {
- bg = makecol (255, 255, 255);
- fg = makecol (128, 128, 128);
- c1 = makecol (0, 0, 0);
- c2 = makecol (255, 255, 255);
+ if (jwidget_is_selected(widget)) {
+ bg = makecol(255, 255, 255);
+ fg = makecol(128, 128, 128);
+ c1 = makecol(0, 0, 0);
+ c2 = makecol(255, 255, 255);
}
else {
- bg = makecol (128, 128, 128);
- fg = makecol (255, 255, 255);
- c1 = makecol (255, 255, 255);
- c2 = makecol (0, 0, 0);
+ bg = makecol(128, 128, 128);
+ fg = makecol(255, 255, 255);
+ c1 = makecol(255, 255, 255);
+ c2 = makecol(0, 0, 0);
}
}
- jdraw_rectedge (pos, c1, c2);
+ jdraw_rectedge(pos, c1, c2);
- jrect_shrink (pos, 1);
- jdraw_rectedge (pos, makecol (128, 128, 128), makecol (64, 64, 64));
+ jrect_shrink(pos, 1);
+ jdraw_rectedge(pos, makecol (128, 128, 128), makecol (64, 64, 64));
- jrect_shrink (pos, 1);
- jdraw_rectshade (pos, fg, bg, JI_VERTICAL);
+ jrect_shrink(pos, 1);
+ jdraw_rectshade(pos, fg, bg, JI_VERTICAL);
- if (jwidget_get_text (widget)) {
+ if (jwidget_get_text(widget)) {
struct jrect text;
- int s = jwidget_is_selected (widget) ? 1: 0;
+ int s = jwidget_is_selected(widget) ? 1: 0;
- jwidget_get_texticon_info (widget, NULL, &text, NULL, 0, 0, 0);
+ jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0);
- jdraw_text (widget->text_font, widget->text,
- text.x1+s+1, text.y1+s+1, makecol (0, 0, 0), bg, FALSE);
- jdraw_text (widget->text_font, widget->text,
- text.x1+s, text.y1+s, fg, bg, FALSE);
+ jdraw_text(widget->text_font, widget->text,
+ text.x1+s+1, text.y1+s+1, makecol (0, 0, 0), bg, FALSE);
+ jdraw_text(widget->text_font, widget->text,
+ text.x1+s, text.y1+s, fg, bg, FALSE);
}
- jrect_free (pos);
+ jrect_free(pos);
}
-static void theme_draw_label (JWidget widget)
+static void theme_draw_label(JWidget widget, JRect clip)
{
/* draw background as Box */
- theme_draw_box (widget);
+ theme_draw_box(widget, clip);
- jdraw_widget_text (widget, makecol (0, 0, 0), makecol (196, 196, 196), FALSE);
+ jdraw_widget_text(widget, makecol(0, 0, 0), makecol(196, 196, 196), FALSE);
}
-static void theme_draw_window (JWidget widget)
+static void theme_draw_window(JWidget widget, JRect clip)
{
JRect pos;
- pos = jwidget_get_rect (widget);
- jdraw_rectfill (pos, makecol (196, 196, 0));
- jrect_shrink (pos, 8);
+ pos = jwidget_get_rect(widget);
+ jdraw_rectfill(pos, makecol(196, 196, 0));
+ jrect_shrink(pos, 8);
/* title bar */
- pos->y2 = pos->y1+4+jwidget_get_text_height (widget)+4;
- jdraw_rectshade (pos, makecol (0, 0, 0), makecol (128, 128, 128), JI_VERTICAL);
+ pos->y2 = pos->y1+4+jwidget_get_text_height(widget)+4;
+ jdraw_rectshade(pos, makecol(0, 0, 0), makecol(128, 128, 128), JI_VERTICAL);
pos->x1 += 1;
- jdraw_text (widget->text_font, widget->text, pos->x1, pos->y1+4,
- makecol (255, 255, 255), makecol (196, 196, 0), FALSE);
+ jdraw_text(widget->text_font, widget->text, pos->x1, pos->y1+4,
+ makecol(255, 255, 255),
+ makecol(196, 196, 0), FALSE);
- jrect_free (pos);
+ jrect_free(pos);
}
diff --git a/src/test/jinete/17theme.c b/src/test/jinete/17theme.c
index 9dca29314..2ec425c0a 100644
--- a/src/test/jinete/17theme.c
+++ b/src/test/jinete/17theme.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -171,11 +171,11 @@ static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y);
static void theme_init_widget(JWidget widget);
static JRegion theme_get_window_mask(JWidget widget);
-static void theme_draw_box(JWidget widget);
-static void theme_draw_button(JWidget widget);
-static void theme_draw_entry(JWidget widget);
-static void theme_draw_label(JWidget widget);
-static void theme_draw_window(JWidget widget);
+static void theme_draw_box(JWidget widget, JRect clip);
+static void theme_draw_button(JWidget widget, JRect clip);
+static void theme_draw_entry(JWidget widget, JRect clip);
+static void theme_draw_label(JWidget widget, JRect clip);
+static void theme_draw_window(JWidget widget, JRect clip);
static void draw_rect(JRect rect, int color, bool invert);
static void draw_edge(JRect rect, int color, bool invert);
@@ -291,7 +291,7 @@ static JRegion theme_get_window_mask(JWidget widget)
return reg1;
}
-static void theme_draw_box(JWidget widget)
+static void theme_draw_box(JWidget widget, JRect clip)
{
JWidget window = jwidget_get_window(widget);
if (window) {
@@ -303,7 +303,7 @@ static void theme_draw_box(JWidget widget)
}
}
-static void theme_draw_button(JWidget widget)
+static void theme_draw_button(JWidget widget, JRect clip)
{
JRect pos = jwidget_get_rect(widget);
int fg, bg;
@@ -351,7 +351,7 @@ static void theme_draw_button(JWidget widget)
jrect_free(pos);
}
-static void theme_draw_entry(JWidget widget)
+static void theme_draw_entry(JWidget widget, JRect clip)
{
int scroll, cursor, state, selbeg, selend;
bool password = jentry_is_password(widget);
@@ -429,10 +429,10 @@ static void theme_draw_entry(JWidget widget)
jrect_free(pos);
}
-static void theme_draw_label(JWidget widget)
+static void theme_draw_label(JWidget widget, JRect clip)
{
/* draw background as Box */
- theme_draw_box(widget);
+ theme_draw_box(widget, clip);
if (widget->text) {
struct jrect text;
@@ -446,7 +446,7 @@ static void theme_draw_label(JWidget widget)
}
}
-static void theme_draw_window(JWidget widget)
+static void theme_draw_window(JWidget widget, JRect clip)
{
JRect pos;
int c;
diff --git a/src/test/jinete/19game.c b/src/test/jinete/19game.c
index 4bcbf1959..5c12e6f07 100644
--- a/src/test/jinete/19game.c
+++ b/src/test/jinete/19game.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, 2008, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -111,8 +111,8 @@ void init_gui(void)
jwidget_expansive(entry, TRUE);
jwidget_add_child(window, box1);
- jwidget_add_childs(box1, box2, check, button, NULL);
- jwidget_add_childs(box2, label, entry, NULL);
+ jwidget_add_children(box1, box2, check, button, NULL);
+ jwidget_add_children(box2, label, entry, NULL);
jwindow_open(window);
}
@@ -159,7 +159,6 @@ static bool my_manager_hook(JWidget widget, JMessage msg)
{
switch (msg->type) {
- case JM_CHAR:
case JM_KEYPRESSED:
/* don't use UP & DOWN keys for focus movement */
if (msg->key.scancode == KEY_UP || msg->key.scancode == KEY_DOWN) {
diff --git a/src/test/jinete/20combo.c b/src/test/jinete/20combo.c
index adf1671ab..b19d42d41 100644
--- a/src/test/jinete/20combo.c
+++ b/src/test/jinete/20combo.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,56 +41,56 @@ int main (int argc, char *argv[])
int c;
/* Allegro stuff */
- allegro_init ();
+ allegro_init();
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
allegro_message("%s\n", allegro_error);
return 1;
}
}
- install_timer ();
- install_keyboard ();
- install_mouse ();
+ install_timer();
+ install_keyboard();
+ install_mouse();
/* Jinete initialization */
- manager = jmanager_new ();
- ji_set_standard_theme ();
+ manager = jmanager_new();
+ ji_set_standard_theme();
/* create main window */
- window = jwindow_new ("Combo-boxes");
- box1 = jbox_new (JI_VERTICAL);
- box2 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
- label1 = jlabel_new ("Non-editable");
- label2 = jlabel_new ("Editable");
- combobox1 = jcombobox_new ();
- combobox2 = jcombobox_new ();
- button_ok = jbutton_new ("&OK");
- button_cancel = jbutton_new ("&Cancel");
+ window = jwindow_new("Combo-boxes");
+ box1 = jbox_new(JI_VERTICAL);
+ box2 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
+ label1 = jlabel_new("Non-editable");
+ label2 = jlabel_new("Editable");
+ combobox1 = jcombobox_new();
+ combobox2 = jcombobox_new();
+ button_ok = jbutton_new("&OK");
+ button_cancel = jbutton_new("&Cancel");
- jwidget_expansive (label1, TRUE);
- jwidget_expansive (label2, TRUE);
+ jwidget_expansive(label1, TRUE);
+ jwidget_expansive(label2, TRUE);
for (c=0; c<16; c++) {
usprintf(buf, "Option %d", c);
- jcombobox_add_string(combobox1, buf);
+ jcombobox_add_string(combobox1, buf, NULL);
}
- jcombobox_add_string (combobox2, "First");
- jcombobox_add_string (combobox2, "Second");
- jcombobox_add_string (combobox2, "Third");
- jcombobox_add_string (combobox2, "Fourth");
- jcombobox_add_string (combobox2, "Fifth");
- jcombobox_add_string (combobox2, "Sixth");
- jcombobox_editable (combobox2, TRUE);
+ jcombobox_add_string(combobox2, "First", NULL);
+ jcombobox_add_string(combobox2, "Second", NULL);
+ jcombobox_add_string(combobox2, "Third", NULL);
+ jcombobox_add_string(combobox2, "Fourth", NULL);
+ jcombobox_add_string(combobox2, "Fifth", NULL);
+ jcombobox_add_string(combobox2, "Sixth", NULL);
+ jcombobox_editable(combobox2, TRUE);
- jwidget_add_child (window, box1);
- jwidget_add_childs (box1, label1, combobox1, label2, combobox2, box2, 0);
- jwidget_add_childs (box2, button_ok, button_cancel, 0);
+ jwidget_add_child(window, box1);
+ jwidget_add_children(box1, label1, combobox1, label2, combobox2, box2, 0);
+ jwidget_add_children(box2, button_ok, button_cancel, 0);
- jwindow_open_bg (window);
+ jwindow_open_bg(window);
- jmanager_run (manager);
- jmanager_free (manager);
+ jmanager_run(manager);
+ jmanager_free(manager);
return 0;
}
diff --git a/src/test/jinete/21manage.c b/src/test/jinete/21manage.c
index e8748b2e7..21796d3fe 100644
--- a/src/test/jinete/21manage.c
+++ b/src/test/jinete/21manage.c
@@ -1,5 +1,5 @@
/* Jinete - a GUI library
- * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello
+ * Copyright (C) 2003-2008 David A. Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/jinete/22xml.c b/src/test/jinete/22xml.c
index fb06377e7..7ce1fd654 100644
--- a/src/test/jinete/22xml.c
+++ b/src/test/jinete/22xml.c
@@ -1,7 +1,32 @@
-/* jinete - a GUI library
- * Copyright (C) 2003-2008 by David A. Capello.
+/* Jinete - a GUI library
+ * Copyright (C) 2003-2008 David A. Capello.
+ * All rights reserved.
*
- * Jinete is gift-ware.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of the Jinete nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include
diff --git a/src/test/jinete/23grid.c b/src/test/jinete/23grid.c
new file mode 100644
index 000000000..6492a3805
--- /dev/null
+++ b/src/test/jinete/23grid.c
@@ -0,0 +1,89 @@
+/* Jinete - a GUI library
+ * Copyright (C) 2003-2008 David A. Capello.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of the Jinete nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include
+
+#include "jinete/jinete.h"
+
+int main(int argc, char *argv[])
+{
+ JWidget manager, window;
+
+ allegro_init();
+ if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) {
+ if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) < 0) {
+ allegro_message("%s\n", allegro_error);
+ return 1;
+ }
+ }
+ install_timer();
+ install_keyboard();
+ install_mouse();
+
+ manager = jmanager_new();
+ ji_set_standard_theme();
+
+ window = jwindow_new("GRID");
+ {
+ JWidget grid, label1, label2, label3, entry1, entry2, entry3;
+ JWidget grid2, button1, button2;
+ grid = jgrid_new(2, FALSE);
+ grid2 = jgrid_new(2, TRUE);
+ label1 = jlabel_new("A:");
+ label2 = jlabel_new("BB:");
+ label3 = jlabel_new("CCC:");
+ entry1 = jentry_new(8, "");
+ entry2 = jentry_new(256, "%d+%d=%d", 4, 5, 4+5);
+ entry3 = jentry_new(8, "");
+ button1 = jbutton_new("&OK");
+ button2 = jbutton_new("&Cancel");
+
+ jgrid_add_child(grid, label1, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, entry1, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, label2, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, entry2, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, label3, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, entry3, 1, 1, JI_HORIZONTAL);
+
+ jgrid_add_child(grid2, button1, 1, 1, JI_RIGHT | JI_HORIZONTAL);
+ jgrid_add_child(grid2, button2, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, grid2, 2, 1, 0);
+ jwidget_add_child(window, grid);
+ }
+
+ jwindow_open_bg(window);
+
+ jmanager_run(manager);
+ jmanager_free(manager);
+ return 0;
+}
+
+END_OF_MAIN();
diff --git a/src/test/raster/00dirty.c b/src/test/raster/00dirty.c
index d9538dc2a..120a9bb80 100644
--- a/src/test/raster/00dirty.c
+++ b/src/test/raster/00dirty.c
@@ -112,13 +112,13 @@ int main (int argc, char *argv[])
if (redraw) {
redraw = FALSE;
- jmouse_hide();
+ scare_mouse();
clear(bmp);
image_to_allegro(image, bmp, 0, 0);
text_mode(0);
textout(bmp, font, "R:restore image", 0, 0, 15);
stretch_blit(bmp, screen, 0, 0, bmp->w, bmp->h, 0, 0, SCREEN_W, SCREEN_H);
- jmouse_show();
+ unscare_mouse();
}
} while (!key[KEY_ESC]);
diff --git a/src/test/raster/01mask.c b/src/test/raster/01mask.c
index a948f7b5f..d662b5bca 100644
--- a/src/test/raster/01mask.c
+++ b/src/test/raster/01mask.c
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
xend = mouse_x;
yend = mouse_y;
- jmouse_hide();
+ scare_mouse();
if (xold >= 0) {
xor_mode (TRUE);
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
rect (screen, xbeg, ybeg, xold = xend, yold = yend, 0xff);
xor_mode (FALSE);
- jmouse_show ();
+ unscare_mouse();
}
}
@@ -136,9 +136,9 @@ int main(int argc, char *argv[])
}
}
- jmouse_hide();
+ scare_mouse();
blit(bmp, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
- jmouse_show();
+ unscare_mouse();
destroy_bitmap(bmp);
}
diff --git a/src/test/test_jlist.c b/src/test/test_jlist.c
new file mode 100644
index 000000000..41667357e
--- /dev/null
+++ b/src/test/test_jlist.c
@@ -0,0 +1,122 @@
+/* ASE - Allegro Sprite Editor
+ * Copyright (C) 2001-2008 David A. Capello
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "test/test.h"
+
+#include
+
+#include "jinete/jlist.h"
+
+static void test_append_clear(void)
+{
+ JList q;
+
+ q = jlist_new();
+ assert(q != NULL);
+ assert(jlist_length(q) == 0);
+
+ jlist_append(q, (void *)10);
+ assert(jlist_length(q) == 1);
+
+ jlist_append(q, (void *)20);
+ jlist_append(q, (void *)30);
+ assert(jlist_length(q) == 3);
+ assert(jlist_nth_data(q, 0) == (void *)10);
+ assert(jlist_nth_data(q, 1) == (void *)20);
+ assert(jlist_nth_data(q, 2) == (void *)30);
+
+ jlist_clear(q);
+ assert(jlist_length(q) == 0);
+
+ jlist_free(q);
+}
+
+static void test_prepend(void)
+{
+ JList q;
+
+ q = jlist_new();
+ jlist_prepend(q, (void *)30);
+ jlist_prepend(q, (void *)20);
+ jlist_prepend(q, (void *)10);
+
+ assert(jlist_length(q) == 3);
+ assert(jlist_nth_data(q, 0) == (void *)10);
+ assert(jlist_nth_data(q, 1) == (void *)20);
+ assert(jlist_nth_data(q, 2) == (void *)30);
+
+ jlist_free(q);
+}
+
+static void test_insert(void)
+{
+}
+
+static void test_insert_before(void)
+{
+}
+
+static void test_remove(void)
+{
+}
+
+static void test_remove_all(void)
+{
+}
+
+static void test_remove_link(void)
+{
+}
+
+static void test_delete_link(void)
+{
+}
+
+static void test_copy(void)
+{
+}
+
+static void test_nth_link(void)
+{
+}
+
+static void test_find(void)
+{
+}
+
+int main(int argc, char *argv[])
+{
+ allegro_init();
+
+ test_append_clear();
+ test_prepend();
+ test_insert();
+ test_insert_before();
+ test_remove();
+ test_remove_all();
+ test_remove_link();
+ test_delete_link();
+ test_copy();
+ test_nth_link();
+ test_find();
+
+ allegro_exit();
+ return 0;
+}
+
+END_OF_MAIN();
diff --git a/src/util/clipbrd.c b/src/util/clipbrd.c
index c2ac74577..7d55bbc86 100644
--- a/src/util/clipbrd.c
+++ b/src/util/clipbrd.c
@@ -138,7 +138,7 @@ void cut_to_clipboard(void)
if (!low_copy())
console_printf("Can't copying an image portion from the current layer\n");
else {
- ClearMask(color_bar_get_color(app_get_color_bar(), 1));
+ ClearMask(color_mask());
update_screen_for_sprite(current_sprite);
}
}
@@ -572,7 +572,7 @@ static bool interactive_transform(JWidget widget,
if (get_use_grid() && angle == 0) {
int ox = x1;
int oy = y1;
- apply_grid(&x1, &y1);
+ apply_grid(&x1, &y1, FALSE);
x2 += x1 - ox;
y2 += y1 - oy;
}
@@ -819,8 +819,8 @@ static void update_status_bar(JWidget editor, Image *image,
screen_to_editor(editor, x1, y1, &u1, &v1);
screen_to_editor(editor, x2, y2, &u2, &v2);
- status_bar_set_text
- (app_get_status_bar(), 0,
+ statusbar_set_text
+ (app_get_statusbar(), 0,
"Pos: %3d %3d Size: %3d %3d Orig: %3d %3d (%.02f%% %.02f%%) Angle: %3d",
u1, v1, u2-u1, v2-v1,
image->w, image->h,
@@ -828,6 +828,6 @@ static void update_status_bar(JWidget editor, Image *image,
(double)(v2-v1)*100/image->h,
iangle);
- jwidget_flush_redraw(app_get_status_bar());
+ jwidget_flush_redraw(app_get_statusbar());
jmanager_dispatch_messages(ji_get_default_manager());
}
diff --git a/src/util/mapgen.c b/src/util/mapgen.c
deleted file mode 100644
index 319f6810b..000000000
--- a/src/util/mapgen.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/* ASE - Allegro Sprite Editor
- * Copyright (C) 2001-2008 David A. Capello
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Original source code from mapgen 1.1, Copyright by Johan Halmén and
- Anders "Trezker" Andersson
-
- http://edu.loviisa.fi/~lg/jh/mapgen/
- http://www.angelfire.com/art/dumlesoft/Projects.html
- */
-
-#include "config.h"
-
-#include
-
-#include "core/app.h"
-#include "raster/image.h"
-#include "widgets/statebar.h"
-
-static int Minus (int j, int i, int size);
-static int Plus (int j, int i, int size);
-static float FRandom (float amount);
-
-void mapgen (Image *image, int seed, float fractal_factor)
-{
- Progress *progress = NULL;
- float **map;
- float amount = 128;
- float min, max;
- int i, j, k;
- int size = 256;
-
- srand (seed);
-
- /**********************************************************************/
- /* create the map */
-
- map = malloc (sizeof(float *) * size);
- for (i = 0; i < size; i++)
- map[i] = malloc(sizeof(float) * size);
-
- /* Do the corners */
- map[0][0] = 0; /* map[0][0] = FRandom(amount); */
- map[size-1][0] = map[0][0];
- map[size-1][size-1] = map[0][0];
- map[0][size-1] = map[0][0];
- amount /= fractal_factor;
-
- if (app_get_status_bar())
- progress = progress_new(app_get_status_bar());
-
- for (i=128; i>0; i/=2) {
- /* This is the square phase */
- for (j=i; j map[i][j]) min = map[i][j];
- if (max < map[i][j]) max = map[i][j];
- }
-
- for (i=0; i 255)
- k = 255;
- image_putpixel(image, i, j, k);
- }
-
- for (i=0; i= 0)
- return r;
- else
- return r + size;
-}
-
-/* Me too */
-static int Plus (int j, int i, int size)
-{
- int r = j + i;
- if (r < size)
- return r;
- else
- return r - size;
-}
-
-static float FRandom (float amount)
-{
- return amount * (((float)rand()) / RAND_MAX - 0.5);
-}
-
diff --git a/src/util/misc.c b/src/util/misc.c
index cc5dc7f7e..3c1422769 100644
--- a/src/util/misc.c
+++ b/src/util/misc.c
@@ -123,7 +123,7 @@ void LoadPalette(const char *filename)
}
/* clears the mask region in the current sprite with the BG color */
-void ClearMask(const char *str_color)
+void ClearMask(color_t _color)
{
Sprite *sprite = current_sprite;
int x, y, u, v, putx, puty;
@@ -135,7 +135,7 @@ void ClearMask(const char *str_color)
if (sprite) {
image = GetImage2(sprite, &x, &y, NULL);
if (image) {
- color = get_color_for_image(sprite->imgtype, str_color);
+ color = get_color_for_image(sprite->imgtype, _color);
if (mask_is_empty(sprite->mask)) {
if (undo_is_enabled(sprite->undo))
@@ -294,8 +294,8 @@ int interactive_move_layer(int mode, int use_undo, int (*callback)(void))
jwidget_dirty(editor);
/* update status bar */
- status_bar_set_text
- (app_get_status_bar(), 0,
+ statusbar_set_text
+ (app_get_statusbar(), 0,
"Pos %3d %3d Offset %3d %3d",
(int)cel->x,
(int)cel->y,
diff --git a/src/util/misc.h b/src/util/misc.h
index 9a8e0ba9e..eee54e4c8 100644
--- a/src/util/misc.h
+++ b/src/util/misc.h
@@ -19,6 +19,7 @@
#ifndef UTIL_MISC_H
#define UTIL_MISC_H
+#include "modules/color.h"
#include "widgets/editor.h" /* for movement modes */
struct Frame;
@@ -32,7 +33,7 @@ struct Image *GetImage2(struct Sprite *sprite, int *x, int *y, int *opacity);
void LoadPalette(const char *filename);
-void ClearMask(const char *color);
+void ClearMask(color_t color);
struct Layer *NewLayerFromMask(struct Sprite *src, struct Sprite *dst);
struct Image *GetLayerImage(struct Layer *layer, int *x, int *y, int frame);
diff --git a/src/util/render.c b/src/util/render.c
index 6f2025c3b..d49da02ea 100644
--- a/src/util/render.c
+++ b/src/util/render.c
@@ -16,6 +16,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/* TODO modificable option: scalable-tiles */
+/* #define SCALABLE_TILES */
+
#include "config.h"
#include "jinete/jlist.h"
@@ -120,9 +123,7 @@ Image *render_sprite(Sprite *sprite,
break;
}
-/* TODO modificable option: scalable-tiles */
-#define ASE_SCALABLE_TILES
-#ifdef ASE_SCALABLE_TILES
+#ifdef SCALABLE_TILES
u = (-source_x / (16<
+#include
#include
+#include
-#include "jinete/jintern.h"
-#include "jinete/jmessage.h"
-#include "jinete/jrect.h"
-#include "jinete/jsystem.h"
-#include "jinete/jwidget.h"
+#include "jinete/jinete.h"
#include "core/app.h"
#include "core/cfg.h"
#include "dialogs/colsel.h"
#include "dialogs/minipal.h"
#include "modules/color.h"
+#include "modules/gfx.h"
#include "modules/gui.h"
#include "modules/palette.h"
#include "modules/sprites.h"
#include "raster/image.h"
#include "raster/sprite.h"
#include "widgets/colbar.h"
+#include "widgets/colsel2.h"
#include "widgets/statebar.h"
-static bool color_bar_msg_proc(JWidget widget, JMessage msg);
+#define COLORBAR_MAX_COLORS 256
-static void update_status_bar(ColorBar *color_bar, int color, int msecs);
-static void get_info(JWidget widget, int *beg, int *end);
+typedef enum {
+ HOTCOLOR_NONE = -4,
+ HOTCOLOR_FGCOLOR = -3,
+ HOTCOLOR_BGCOLOR = -2,
+ HOTCOLOR_BGSPRITE = -1,
+ HOTCOLOR_GRADIENT = 0,
+} hotcolor_t;
-JWidget color_bar_new(int align)
+typedef struct ColorBar
{
- JWidget widget = jwidget_new(color_bar_type());
- ColorBar *color_bar = jnew0(ColorBar, 1);
+ JWidget widget;
+ int ncolor;
+ color_t color[COLORBAR_MAX_COLORS];
+ color_t fgcolor;
+ color_t bgcolor;
+ hotcolor_t hot;
+ hotcolor_t hot_editing;
+ JWidget tooltip_window;
+} ColorBar;
- color_bar->widget = widget;
- color_bar->ncolor = 16;
- color_bar->select[0] = -1;
- color_bar->select[1] = -1;
+static ColorBar *colorbar_data(JWidget colorbar);
- jwidget_add_hook(widget, color_bar_type(),
- color_bar_msg_proc, color_bar);
+static bool colorbar_msg_proc(JWidget widget, JMessage msg);
+static color_t colorbar_get_hot_color(JWidget widget);
+static void colorbar_open_tooltip(JWidget widget, int x, int y1, int y2,
+ JRect bounds, color_t color, hotcolor_t hot);
+static void colorbar_close_tooltip(JWidget widget);
+
+static int tooltip_window_color_changed(JWidget widget, int user_data);
+
+static void update_status_bar(color_t color, int msecs);
+static void get_info(JWidget widget, int *beg, int *end);
+static void draw_colorbox(BITMAP *bmp,
+ int x1, int y1, int x2, int y2,
+ int b0, int b1, int b2, int b3,
+ int imgtype, color_t color,
+ bool hot);
+
+JWidget colorbar_new(int align)
+{
+ JWidget widget = jwidget_new(colorbar_type());
+ ColorBar *colorbar = jnew0(ColorBar, 1);
+
+ colorbar->widget = widget;
+ colorbar->ncolor = 16;
+ colorbar->fgcolor = color_mask();
+ colorbar->bgcolor = color_mask();
+ colorbar->hot = HOTCOLOR_NONE;
+ colorbar->hot_editing = HOTCOLOR_NONE;
+ colorbar->tooltip_window = NULL;
+
+ jwidget_add_hook(widget, colorbar_type(), colorbar_msg_proc, colorbar);
jwidget_focusrest(widget, TRUE);
jwidget_set_align(widget, align);
@@ -69,7 +105,7 @@ JWidget color_bar_new(int align)
return widget;
}
-int color_bar_type(void)
+int colorbar_type(void)
{
static int type = 0;
if (!type)
@@ -77,102 +113,90 @@ int color_bar_type(void)
return type;
}
-ColorBar *color_bar_data(JWidget widget)
+void colorbar_set_size(JWidget widget, int size)
{
- return jwidget_get_data(widget, color_bar_type());
-}
+ ColorBar *colorbar = colorbar_data(widget);
-void color_bar_set_size(JWidget widget, int size)
-{
- ColorBar *color_bar = color_bar_data(widget);
-
- color_bar->ncolor = MID(1, size, COLOR_BAR_COLORS);
+ colorbar->ncolor = MID(1, size, COLORBAR_MAX_COLORS);
jwidget_dirty(widget);
}
-const char *color_bar_get_color(JWidget widget, int num)
+color_t colorbar_get_fg_color(JWidget widget)
{
- ColorBar *color_bar = color_bar_data(widget);
+ ColorBar *colorbar = colorbar_data(widget);
- return color_bar->color[color_bar->select[num]];
+ return colorbar->fgcolor;
}
-void color_bar_set_color(JWidget widget, int num, const char *color, bool find)
+color_t colorbar_get_bg_color(JWidget widget)
{
- ColorBar *color_bar = color_bar_data(widget);
- int other = num == 1 ? 0: 1;
+ ColorBar *colorbar = colorbar_data(widget);
- /* find if the color is in other place */
+ return colorbar->bgcolor;
+}
- if (find) {
- int c, beg, end;
+void colorbar_set_fg_color(JWidget widget, color_t color)
+{
+ ColorBar *colorbar = colorbar_data(widget);
- get_info(widget, &beg, &end);
-
- for (c=beg; c<=end; c++) {
- if (c != color_bar->select[other] &&
- ustrcmp(color_bar->color[c], color) == 0) {
- /* change the selection to the color found */
- color_bar->select[num] = c;
-
- jwidget_dirty(widget);
- update_status_bar(color_bar, color_bar->select[num], 100);
- return;
- }
- }
- }
-
- /* if the color doesn't exist in the color-bar, change the selected */
- if (color_bar->color[color_bar->select[num]])
- jfree(color_bar->color[color_bar->select[num]]);
-
- color_bar->color[color_bar->select[num]] = jstrdup(color);
+ colorbar->fgcolor = color;
jwidget_dirty(widget);
- update_status_bar(color_bar, color_bar->select[num], 100);
+ update_status_bar(colorbar->fgcolor, 100);
}
-void color_bar_set_color_directly(JWidget widget, int index, const char *color)
+void colorbar_set_bg_color(JWidget widget, color_t color)
{
- ColorBar *color_bar = color_bar_data(widget);
+ ColorBar *colorbar = colorbar_data(widget);
- if (color_bar->color[index])
- jfree(color_bar->color[index]);
+ colorbar->bgcolor = color;
- color_bar->color[index] = jstrdup(color);
+ jwidget_dirty(widget);
+ update_status_bar(colorbar->bgcolor, 100);
+}
+
+void colorbar_set_color(JWidget widget, int index, color_t color)
+{
+ ColorBar *colorbar = colorbar_data(widget);
+
+ assert(index >= 0 && index < COLORBAR_MAX_COLORS);
+
+ colorbar->color[index] = color;
jwidget_dirty(widget);
}
-static bool color_bar_msg_proc (JWidget widget, JMessage msg)
+static ColorBar *colorbar_data(JWidget widget)
{
- ColorBar *color_bar = color_bar_data(widget);
+ return jwidget_get_data(widget, colorbar_type());
+}
+
+static bool colorbar_msg_proc(JWidget widget, JMessage msg)
+{
+ ColorBar *colorbar = colorbar_data(widget);
switch (msg->type) {
case JM_OPEN: {
- int ncolor = get_config_int ("ColorBar", "NColors", color_bar->ncolor);
- char buf[256], def[256];
+ int ncolor = get_config_int("ColorBar", "NColors", colorbar->ncolor);
+ char buf[256];
int c, beg, end;
- color_bar->ncolor = MID(1, ncolor, COLOR_BAR_COLORS);
+ colorbar->ncolor = MID(1, ncolor, COLORBAR_MAX_COLORS);
- get_info (widget, &beg, &end);
+ get_info(widget, &beg, &end);
/* fill color-bar with saved colors in the configuration file */
- for (c=0; ccolor[c] = jstrdup(get_config_string("ColorBar",
- buf, def));
+ colorbar->color[c] = get_config_color("ColorBar",
+ buf, color_index(c));
}
/* get selected colors */
- color_bar->select[0] = get_config_int("ColorBar", "FG", 15);
- color_bar->select[1] = get_config_int("ColorBar", "BG", 0);
- color_bar->select[0] = MID(beg, color_bar->select[0], end);
- color_bar->select[1] = MID(beg, color_bar->select[1], end);
+ colorbar->fgcolor = get_config_color("ColorBar", "FG", color_index(15));
+ colorbar->bgcolor = get_config_color("ColorBar", "BG", color_index(0));
break;
}
@@ -180,124 +204,131 @@ static bool color_bar_msg_proc (JWidget widget, JMessage msg)
char buf[256];
int c;
- set_config_int("ColorBar", "NColors", color_bar->ncolor);
- set_config_int("ColorBar", "FG", color_bar->select[0]);
- set_config_int("ColorBar", "BG", color_bar->select[1]);
+ if (colorbar->tooltip_window != NULL)
+ jwidget_free(colorbar->tooltip_window);
- for (c=0; cncolor; c++) {
+ set_config_int("ColorBar", "NColors", colorbar->ncolor);
+ set_config_color("ColorBar", "FG", colorbar->fgcolor);
+ set_config_color("ColorBar", "BG", colorbar->bgcolor);
+
+ for (c=0; cncolor; c++) {
usprintf(buf, "Color%03d", c);
- set_config_string("ColorBar", buf, color_bar->color[c]);
- jfree(color_bar->color[c]);
+ set_config_color("ColorBar", buf, colorbar->color[c]);
}
- for (; ccolor[c]);
- jfree(color_bar);
+ jfree(colorbar);
break;
}
case JM_REQSIZE:
- msg->reqsize.w = msg->reqsize.h = 16;
+ msg->reqsize.w = msg->reqsize.h = 24;
return TRUE;
case JM_DRAW: {
+ BITMAP *doublebuffer = create_bitmap(jrect_w(&msg->draw.rect),
+ jrect_h(&msg->draw.rect));
int imgtype = app_get_current_image_type();
- int x1, y1, x2, y2;
- int c, beg, end;
+ int x1, y1, x2, y2, v1, v2;
+ int c, h, beg, end;
get_info(widget, &beg, &end);
- x1 = widget->rc->x1;
- y1 = widget->rc->y1;
- x2 = widget->rc->x2-1;
- y2 = widget->rc->y2-1;
+ x1 = widget->rc->x1 - msg->draw.rect.x1;
+ y1 = widget->rc->y1 - msg->draw.rect.y1;
+ x2 = x1 + jrect_w(widget->rc) - 1;
+ y2 = y1 + jrect_h(widget->rc) - 1;
- _ji_theme_rectedge(ji_screen, x1, y1, x2, y2,
- makecol(128, 128, 128), makecol(255, 255, 255));
+ rectfill(doublebuffer, x1, y1, x2, y2, ji_color_face());
+ ++x1, ++y1, --x2, --y2;
- x1++, y1++, x2--, y2--;
- rect(ji_screen, x1, y1, x2, y2, makecol(192, 192, 192));
+ h = (y2-y1+1-(4+16+4+16+16+4));
- x1++, y1++, x2--, y2--;
+ /* draw gradient */
+ for (c=beg; c<=end; c++) {
+ v1 = y1 + h*(c-beg )/(end-beg+1);
+ v2 = y1 + h*(c-beg+1)/(end-beg+1) - 1;
- if (widget->align & JI_HORIZONTAL) {
- int r, g, b;
- int u1, u2;
+ draw_colorbox(doublebuffer, x1, v1, x2, v2,
+ c == beg, c == beg,
+ c == end, c == end, imgtype, colorbar->color[c],
+ (c == colorbar->hot));
- for (c=beg; c<=end; c++) {
- u1 = x1 + (x2-x1+1)*(c-beg )/(end-beg+1);
- u2 = x1 + (x2-x1+1)*(c-beg+1)/(end-beg+1) - 1;
+ /* a selected color */
+#if 0
+ if ((c == colorbar->select[0]) || (c == colorbar->select[1])) {
+ color_t new_color;
+ int color;
- draw_color(ji_screen, u1, y1, u2, y2, imgtype, color_bar->color[c]);
+ new_color = color_from_image(imgtype,
+ get_color_for_image(imgtype,
+ colorbar->color[c]));
- /* a selected color */
- if ((c == color_bar->select[0]) || (c == color_bar->select[1])) {
- char *new_color;
- int color;
+ r = color_get_red(imgtype, new_color);
+ g = color_get_green(imgtype, new_color);
+ b = color_get_blue(imgtype, new_color);
- new_color = color_from_image
- (imgtype, get_color_for_image(imgtype, color_bar->color[c]));
+ jfree(new_color);
- r = color_get_red(imgtype, new_color);
- g = color_get_green(imgtype, new_color);
- b = color_get_blue(imgtype, new_color);
+ color = blackandwhite_neg(r, g, b);
- jfree(new_color);
+ if (c == colorbar->select[0])
+ rectfill(ji_screen, x1, v1, x1+1, v2, color);
- color = blackandwhite_neg(r, g, b);
-
- if (c == color_bar->select[0])
- rectfill(ji_screen, u1, y1, u2, y1+1, color);
-
- if (c == color_bar->select[1])
- rectfill(ji_screen, u1, y2-1, u2, y2, color);
- }
+ if (c == colorbar->select[1])
+ rectfill(ji_screen, x2-1, v1, x2, v2, color);
}
+#endif
}
- else {
- int r, g, b;
- int v1, v2;
- for (c=beg; c<=end; c++) {
- v1 = y1 + (y2-y1+1)*(c-beg )/(end-beg+1);
- v2 = y1 + (y2-y1+1)*(c-beg+1)/(end-beg+1) - 1;
+ /* draw tool foreground color */
+ v1 = y2-4-16-4-16-16;
+ v2 = y2-4-16-4-16;
+ draw_colorbox(doublebuffer, x1, v1, x2, v2, 1, 1, 0, 0,
+ imgtype, colorbar->fgcolor,
+ (colorbar->hot == HOTCOLOR_FGCOLOR));
- draw_color(ji_screen, x1, v1, x2, v2, imgtype, color_bar->color[c]);
+ /* draw tool background color */
+ v1 = y2-4-16-4-16+1;
+ v2 = y2-4-16-4;
+ draw_colorbox(doublebuffer, x1, v1, x2, v2, 0, 0, 1, 1,
+ imgtype, colorbar->bgcolor,
+ (colorbar->hot == HOTCOLOR_BGCOLOR));
- /* a selected color */
- if ((c == color_bar->select[0]) || (c == color_bar->select[1])) {
- char *new_color;
- int color;
-
- new_color = color_from_image
- (imgtype, get_color_for_image(imgtype, color_bar->color[c]));
-
- r = color_get_red(imgtype, new_color);
- g = color_get_green(imgtype, new_color);
- b = color_get_blue(imgtype, new_color);
-
- jfree(new_color);
-
- color = blackandwhite_neg(r, g, b);
-
- if (c == color_bar->select[0])
- rectfill(ji_screen, x1, v1, x1+1, v2, color);
-
- if (c == color_bar->select[1])
- rectfill(ji_screen, x2-1, v1, x2, v2, color);
- }
- }
+ /* draw sprite background color */
+ v1 = y2-4-16;
+ v2 = y2-4;
+ {
+ color_t c =
+ current_sprite != NULL ? color_from_image(imgtype,
+ current_sprite->bgcolor):
+ color_mask();
+ draw_colorbox(doublebuffer, x1, v1, x2, v2, 1, 1, 1, 1,
+ imgtype, c,
+ (colorbar->hot == HOTCOLOR_BGSPRITE));
}
+
+ blit(doublebuffer, ji_screen, 0, 0,
+ msg->draw.rect.x1,
+ msg->draw.rect.y1,
+ doublebuffer->w,
+ doublebuffer->h);
+ destroy_bitmap(doublebuffer);
return TRUE;
}
case JM_BUTTONPRESSED:
- jwidget_hard_capture_mouse(widget);
+ jwidget_capture_mouse(widget);
+ case JM_MOUSEENTER:
case JM_MOTION: {
- int x1, y1, x2, y2;
- int c, beg, end;
+ int x1, y1, x2, y2, v1, v2;
+ int c, h, beg, end;
+ int old_hot = colorbar->hot;
+ int hot_v1 = 0;
+ int hot_v2 = 0;
+ colorbar->hot = HOTCOLOR_NONE;
+
get_info(widget, &beg, &end);
x1 = widget->rc->x1;
@@ -305,122 +336,391 @@ static bool color_bar_msg_proc (JWidget widget, JMessage msg)
x2 = widget->rc->x2-1;
y2 = widget->rc->y2-1;
- x1++, y1++, x2--, y2--;
- x1++, y1++, x2--, y2--;
+ ++x1, ++y1, --x2, --y2;
- if (widget->align & JI_HORIZONTAL) {
- int u1, u2;
+ h = (y2-y1+1-(4+16+4+16+16+4));
- for (c=beg; c<=end; c++) {
- u1 = x1 + (x2-x1+1)*(c-beg )/(end-beg+1);
- u2 = x1 + (x2-x1+1)*(c-beg+1)/(end-beg+1) - 1;
+ for (c=beg; c<=end; c++) {
+ v1 = y1 + h*(c-beg )/(end-beg+1);
+ v2 = y1 + h*(c-beg+1)/(end-beg+1) - 1;
- if ((msg->mouse.x >= u1) && (msg->mouse.x <= u2)) {
- /* change the color */
- if ((jwidget_has_capture(widget)) ||
- (msg->type == JM_BUTTONPRESSED)) {
- if (msg->mouse.left) {
- color_bar->select[0] = c;
- jwidget_dirty(widget);
- }
- else if (msg->mouse.right) {
- color_bar->select[1] = c;
- jwidget_dirty(widget);
- }
- }
-
- /* change the text of the status bar */
- update_status_bar(color_bar, c, 0);
+ if ((msg->mouse.y >= v1) && (msg->mouse.y <= v2)) {
+ if (colorbar->hot != c) {
+ colorbar->hot = c;
+ hot_v1 = v1;
+ hot_v2 = v2;
break;
}
}
}
- else {
- int v1, v2;
- for (c=beg; c<=end; c++) {
- v1 = y1 + (y2-y1+1)*(c-beg )/(end-beg+1);
- v2 = y1 + (y2-y1+1)*(c-beg+1)/(end-beg+1) - 1;
+ /* in tool foreground color */
+ v1 = y2-4-16-4-16-16;
+ v2 = y2-4-16-4-16;
+ if ((msg->mouse.y >= v1) && (msg->mouse.y <= v2)) {
+ colorbar->hot = HOTCOLOR_FGCOLOR;
+ hot_v1 = v1;
+ hot_v2 = v2;
+ }
- if ((msg->mouse.y >= v1) && (msg->mouse.y <= v2)) {
- /* change the color */
- if ((jwidget_has_capture(widget)) ||
- (msg->type == JM_BUTTONPRESSED)) {
- int num = -1;
+ /* in tool background color */
+ v1 = y2-4-16-4-16+1;
+ v2 = y2-4-16-4;
+ if ((msg->mouse.y >= v1) && (msg->mouse.y <= v2)) {
+ colorbar->hot = HOTCOLOR_BGCOLOR;
+ hot_v1 = v1;
+ hot_v2 = v2;
+ }
- if (msg->mouse.left) {
- color_bar->select[num = 0] = c;
- jwidget_dirty(widget);
- }
- else if (msg->mouse.right) {
- color_bar->select[num = 1] = c;
- jwidget_dirty(widget);
- }
+ /* in sprite background color */
+ v1 = y2-4-16;
+ v2 = y2-4;
+ if ((msg->mouse.y >= v1) && (msg->mouse.y <= v2)) {
+ colorbar->hot = HOTCOLOR_BGSPRITE;
+ hot_v1 = v1;
+ hot_v2 = v2;
+ }
- /* show a minipal? */
- if (msg->type == JM_BUTTONPRESSED &&
- msg->any.shifts & KB_CTRL_FLAG && num >= 0) {
- ji_minipal_new(widget, x2, v1);
- }
- }
+ /* redraw 'hot' color */
+ if (colorbar->hot != old_hot) {
+ jwidget_dirty(widget);
- /* change the text of the status bar */
- update_status_bar(color_bar, c, 0);
- break;
- }
+ /* close the old tooltip window to edit the 'old_hot' color slot */
+ colorbar_close_tooltip(widget);
+
+ if (colorbar->hot != HOTCOLOR_NONE) {
+ color_t color = colorbar_get_hot_color(widget);
+ JRect bounds = jwidget_get_rect(widget);
+
+ update_status_bar(color, 0);
+
+ /* open the tooltip window to edit the hot color */
+ bounds->y1 = hot_v1;
+ bounds->y2 = hot_v2;
+
+ colorbar_open_tooltip(widget, bounds->x2+1, hot_v1, hot_v2,
+ bounds, color, colorbar->hot);
+
+ jrect_free(bounds);
}
}
- break;
- }
- case JM_BUTTONRELEASED:
- jwidget_release_mouse(widget);
- break;
+ /* if the widget has the capture, we should replace the
+ selected-color with the hot-color */
+ if (jwidget_has_capture(widget) &&
+ colorbar->hot != HOTCOLOR_NONE) {
+ color_t color = colorbar_get_hot_color(widget);
- case JM_DOUBLECLICK: {
- int num = (msg->mouse.left) ? 0: 1;
- const char *src;
- char *dst;
+ if (msg->mouse.left) {
+ colorbar_set_fg_color(widget, color);
+ }
+ if (msg->mouse.right) {
+ colorbar_set_bg_color(widget, color);
+ }
+/* else if (msg->mouse.right) { */
+/* /\* TODO *\/ */
+/* /\* colorbar->select[num = 1] = c; *\/ */
+/* /\* jwidget_dirty(widget); *\/ */
+/* } */
- while (jmouse_b(0))
- jmouse_poll();
+/* /\* show a minipal? *\/ */
+/* if (msg->type == JM_BUTTONPRESSED && */
+/* msg->any.shifts & KB_CTRL_FLAG && num >= 0) { */
+/* ji_minipal_new(widget, x2, v1); */
+/* } */
- /* get the color from the table */
- src = color_bar_get_color(widget, num);
-
- /* change this color with the color-select dialog */
- dst = ji_color_select(app_get_current_image_type(), src);
-
- /* set the color of the table */
- if (dst) {
- color_bar_set_color(widget, num, dst, FALSE);
- jfree(dst);
+ return TRUE;
}
+
return TRUE;
}
+
+ case JM_MOUSELEAVE:
+ if (colorbar->hot != HOTCOLOR_NONE) {
+ colorbar->hot = HOTCOLOR_NONE;
+ jwidget_dirty(widget);
+ }
+ break;
+
+ case JM_BUTTONRELEASED:
+ if (jwidget_has_capture(widget))
+ jwidget_release_mouse(widget);
+ break;
+
+ case JM_DOUBLECLICK:
+ if (colorbar->hot != HOTCOLOR_NONE) {
+ int hot = colorbar->hot;
+ color_t color = colorbar_get_hot_color(widget);
+
+ while (jmouse_b(0))
+ jmouse_poll();
+
+ /* change this color with the color-select dialog */
+ if (ji_color_select(app_get_current_image_type(), &color)) {
+ switch (hot) {
+ case HOTCOLOR_FGCOLOR:
+ colorbar->fgcolor = color;
+ break;
+ case HOTCOLOR_BGCOLOR:
+ colorbar->bgcolor = color;
+ break;
+ case HOTCOLOR_BGSPRITE:
+ /* TODO setup sprite background color */
+ break;
+ default:
+ assert(hot >= 0 && hot < colorbar->ncolor);
+ colorbar->color[hot] = color;
+ break;
+ }
+ jwidget_dirty(widget);
+ }
+ return TRUE;
+ }
+ break;
+
+ case JM_SETCURSOR:
+ if (colorbar->hot != HOTCOLOR_FGCOLOR &&
+ colorbar->hot != HOTCOLOR_NONE) {
+ jmouse_set_cursor(JI_CURSOR_EYEDROPPER);
+ return TRUE;
+ }
+ break;
}
return FALSE;
}
-static void update_status_bar(ColorBar *color_bar, int color, int msecs)
+static color_t colorbar_get_hot_color(JWidget widget)
{
- char buf[128];
+ ColorBar *colorbar = colorbar_data(widget);
- color_to_formalstring(app_get_current_image_type(),
- color_bar->color[color], buf, sizeof(buf), TRUE);
+ switch (colorbar->hot) {
+ case HOTCOLOR_NONE: return color_mask();
+ case HOTCOLOR_FGCOLOR: return colorbar->fgcolor;
+ case HOTCOLOR_BGCOLOR: return colorbar->bgcolor;
+ case HOTCOLOR_BGSPRITE: {
+ int imgtype = app_get_current_image_type();
+ return
+ current_sprite != NULL ? color_from_image(imgtype,
+ current_sprite->bgcolor):
+ color_mask();
+ }
+ default:
+ assert(colorbar->hot >= 0 &&
+ colorbar->hot < colorbar->ncolor);
+ return colorbar->color[colorbar->hot];
+ }
+}
- status_bar_set_text(app_get_status_bar(), msecs, "%s %s", _("Color"), buf);
+static void colorbar_open_tooltip(JWidget widget, int x, int y1, int y2,
+ JRect bounds,
+ color_t color, hotcolor_t hot)
+{
+ ColorBar *colorbar = colorbar_data(widget);
+ JWidget window;
+ char buf[256];
+
+ if (colorbar->tooltip_window == NULL) {
+ window = colorselector_new();
+ HOOK(window, SIGNAL_COLORSELECTOR_COLOR_CHANGED,
+ tooltip_window_color_changed, widget);
+
+ colorbar->tooltip_window = window;
+ }
+ else
+ window = colorbar->tooltip_window;
+
+ switch (colorbar->hot) {
+ case HOTCOLOR_NONE:
+ assert(FALSE);
+ break;
+ case HOTCOLOR_FGCOLOR:
+ ustrcpy(buf, _("Primary Tool Color"));
+ break;
+ case HOTCOLOR_BGCOLOR:
+ ustrcpy(buf, _("Secondary Tool Color (to fill shapes)"));
+ break;
+ case HOTCOLOR_BGSPRITE:
+ ustrcpy(buf, _("Sprite Background Color"));
+ break;
+ default:
+ usprintf(buf, _("Gradient Entry %d"), colorbar->hot);
+ break;
+ }
+ jwidget_set_text(window, buf);
+
+ colorselector_set_color(window, color);
+ colorbar->hot_editing = hot;
+
+ jwindow_open(window);
+
+ x = MID(0, x, JI_SCREEN_W-jrect_w(window->rc));
+ jwindow_position(window,
+ x, MID(0, y1, JI_SCREEN_H-jrect_h(window->rc)));
+
+ jmanager_dispatch_messages(jwidget_get_manager(window));
+ jwidget_relayout(window);
+
+ {
+ JRect rc = jrect_new(window->rc->x1,
+ window->rc->y1-8,
+ window->rc->x2+16,
+ window->rc->y2+8);
+ JRect rc2 = jrect_new(widget->rc->x1, y1, x, y2+1);
+ JRegion rgn = jregion_new(rc, 1);
+ JRegion rgn2 = jregion_new(rc2, 1);
+
+ jregion_union(rgn, rgn, rgn2);
+
+ jregion_free(rgn2);
+ jrect_free(rc2);
+ jrect_free(rc);
+
+ jtooltip_window_set_hotregion(window, rgn);
+ }
+}
+
+static void colorbar_close_tooltip(JWidget widget)
+{
+ ColorBar *colorbar = colorbar_data(widget);
+
+ if (colorbar->tooltip_window != NULL)
+ jwindow_close(colorbar->tooltip_window, NULL);
+}
+
+static int tooltip_window_color_changed(JWidget widget, int user_data)
+{
+ JWidget colorbar_widget = (JWidget)user_data;
+ ColorBar *colorbar = colorbar_data(colorbar_widget);
+ color_t color = colorselector_get_color(widget);
+
+ switch (colorbar->hot_editing) {
+ case HOTCOLOR_NONE:
+ assert(FALSE);
+ break;
+ case HOTCOLOR_FGCOLOR:
+ colorbar->fgcolor = color;
+ break;
+ case HOTCOLOR_BGCOLOR:
+ colorbar->bgcolor = color;
+ break;
+ case HOTCOLOR_BGSPRITE: {
+/* int imgtype = app_get_current_image_type(); */
+/* return */
+/* current_sprite != NULL ? color_from_image(imgtype, */
+/* current_sprite->bgcolor): */
+/* color_mask(); */
+ /* TODO */
+ break;
+ }
+ default:
+ assert(colorbar->hot_editing >= 0 &&
+ colorbar->hot_editing < colorbar->ncolor);
+ colorbar->color[colorbar->hot_editing] = color;
+
+ if (colorbar->hot_editing == 0 ||
+ colorbar->hot_editing == colorbar->ncolor-1) {
+ int imgtype = app_get_current_image_type();
+ color_t c1 = colorbar->color[0];
+ color_t c2 = colorbar->color[colorbar->ncolor-1];
+ int r1 = color_get_red(imgtype, c1);
+ int g1 = color_get_green(imgtype, c1);
+ int b1 = color_get_blue(imgtype, c1);
+ int a1 = color_get_alpha(imgtype, c1);
+ int r2 = color_get_red(imgtype, c2);
+ int g2 = color_get_green(imgtype, c2);
+ int b2 = color_get_blue(imgtype, c2);
+ int a2 = color_get_alpha(imgtype, c2);
+ int c, r, g, b, a;
+
+ for (c=1; cncolor-1; ++c) {
+ r = r1 + (r2-r1) * c / colorbar->ncolor;
+ g = g1 + (g2-g1) * c / colorbar->ncolor;
+ b = b1 + (b2-b1) * c / colorbar->ncolor;
+ a = a1 + (a2-a1) * c / colorbar->ncolor;
+ colorbar->color[c] = color_rgb(r, g, b, a);
+ }
+ }
+ }
+
+ jwidget_dirty(colorbar_widget);
+ return 0;
+}
+
+static void update_status_bar(color_t color, int msecs)
+{
+ statusbar_show_color(app_get_statusbar(),
+ msecs,
+ app_get_current_image_type(),
+ color);
}
static void get_info(JWidget widget, int *_beg, int *_end)
{
- ColorBar *color_bar = color_bar_data(widget);
+ ColorBar *colorbar = colorbar_data(widget);
int beg, end;
beg = 0;
- end = color_bar->ncolor-1;
+ end = colorbar->ncolor-1;
if (_beg) *_beg = beg;
if (_end) *_end = end;
}
+
+static void draw_colorbox(BITMAP *bmp,
+ int x1, int y1, int x2, int y2,
+ int b0, int b1, int b2, int b3,
+ int imgtype, color_t color,
+ bool hot)
+{
+ int face = ji_color_face();
+ int fore = ji_color_foreground();
+
+ draw_color(bmp, x1, y1, x2, y2, imgtype, color);
+
+ hline(bmp, x1, y1, x2, fore);
+ if (b2 && b3)
+ hline(bmp, x1, y2, x2, fore);
+ vline(bmp, x1, y1, y2, fore);
+ vline(bmp, x2, y1, y2, fore);
+
+ if (!hot) {
+ int r = color_get_red(imgtype, color);
+ int g = color_get_green(imgtype, color);
+ int b = color_get_blue(imgtype, color);
+ int c = makecol(MIN(255, r+64),
+ MIN(255, g+64),
+ MIN(255, b+64));
+ rect(bmp, x1+1, y1+1, x2-1, y2-((b2 && b3)?1:0), c);
+ }
+ else {
+ rect(bmp, x1+1, y1+1, x2-1, y2-((b2 && b3)?1:0), fore);
+ bevel_box(bmp,
+ x1+1, y1+1, x2-1, y2-((b2 && b3)?1:0),
+ ji_color_facelight(), ji_color_faceshadow(), 1);
+ }
+
+ if (b0) {
+ hline(bmp, x1, y1, x1+1, face);
+ putpixel(bmp, x1, y1+1, face);
+ putpixel(bmp, x1+1, y1+1, fore);
+ }
+
+ if (b1) {
+ hline(bmp, x2-1, y1, x2, face);
+ putpixel(bmp, x2, y1+1, face);
+ putpixel(bmp, x2-1, y1+1, fore);
+ }
+
+ if (b2) {
+ putpixel(bmp, x1, y2-1, face);
+ hline(bmp, x1, y2, x1+1, face);
+ putpixel(bmp, x1+1, y2-1, fore);
+ }
+
+ if (b3) {
+ putpixel(bmp, x2, y2-1, face);
+ hline(bmp, x2-1, y2, x2, face);
+ putpixel(bmp, x2-1, y2-1, fore);
+ }
+}
diff --git a/src/widgets/colbar.h b/src/widgets/colbar.h
index f79370be1..d76cd5b0d 100644
--- a/src/widgets/colbar.h
+++ b/src/widgets/colbar.h
@@ -21,25 +21,19 @@
#include "jinete/jbase.h"
-#define COLOR_BAR_COLORS 256
+#include "modules/color.h"
-typedef struct ColorBar
-{
- JWidget widget;
- int ncolor;
- char *color[COLOR_BAR_COLORS];
- int select[2];
-} ColorBar;
+JWidget colorbar_new(int align);
+int colorbar_type(void);
-JWidget color_bar_new (int align);
-int color_bar_type (void);
+void colorbar_set_size(JWidget colorbar, int size);
-ColorBar *color_bar_data (JWidget color_bar);
+color_t colorbar_get_fg_color(JWidget colorbar);
+color_t colorbar_get_bg_color(JWidget colorbar);
-void color_bar_set_size (JWidget color_bar, int size);
+void colorbar_set_fg_color(JWidget colorbar, color_t color);
+void colorbar_set_bg_color(JWidget colorbar, color_t color);
-const char *color_bar_get_color (JWidget color_bar, int num);
-void color_bar_set_color (JWidget color_bar, int num, const char *color, bool find);
-void color_bar_set_color_directly (JWidget color_bar, int index, const char *color);
+void colorbar_set_color(JWidget colorbar, int index, color_t color);
#endif /* WIDGETS_COLBAR_H */
diff --git a/src/widgets/colbut.c b/src/widgets/colbut.c
index 961e51f1a..5fde68f2a 100644
--- a/src/widgets/colbut.c
+++ b/src/widgets/colbut.c
@@ -36,63 +36,78 @@
typedef struct ColorButton
{
+ color_t color;
int imgtype;
} ColorButton;
-static bool color_button_msg_proc (JWidget widget, JMessage msg);
-static void color_button_draw (JWidget widget);
+static ColorButton *color_button_data(JWidget widget);
+static bool color_button_msg_proc(JWidget widget, JMessage msg);
+static void color_button_draw(JWidget widget);
-JWidget color_button_new (const char *color, int imgtype)
+JWidget color_button_new(color_t color, int imgtype)
{
- JWidget widget = jbutton_new (color);
- ColorButton *color_button = jnew (ColorButton, 1);
+ JWidget widget = jbutton_new("");
+ ColorButton *color_button = jnew(ColorButton, 1);
- /* widget->type = color_button_type (); */
+ color_button->color = color;
color_button->imgtype = imgtype;
- jwidget_add_hook (widget, color_button_type (),
- color_button_msg_proc, color_button);
- jwidget_focusrest (widget, TRUE);
+ jwidget_add_hook(widget, color_button_type(),
+ color_button_msg_proc, color_button);
+ jwidget_focusrest(widget, TRUE);
return widget;
}
-int color_button_type (void)
+int color_button_type(void)
{
static int type = 0;
if (!type)
- type = ji_register_widget_type ();
+ type = ji_register_widget_type();
return type;
}
-int color_button_get_imgtype (JWidget widget)
+int color_button_get_imgtype(JWidget widget)
{
- return ((ColorButton *)jwidget_get_data (widget,
- color_button_type ()))->imgtype;
+ ColorButton *color_button = color_button_data(widget);
+
+ return color_button->imgtype;
}
-const char *color_button_get_color (JWidget widget)
+color_t color_button_get_color(JWidget widget)
{
- return jwidget_get_text (widget);
+ ColorButton *color_button = color_button_data(widget);
+
+ return color_button->color;
}
-void color_button_set_color (JWidget widget, const char *color)
+void color_button_set_color(JWidget widget, color_t color)
{
- jwidget_set_text (widget, color);
+ ColorButton *color_button = color_button_data(widget);
+
+ color_button->color = color;
+ jwidget_dirty(widget);
}
-static bool color_button_msg_proc (JWidget widget, JMessage msg)
+static ColorButton *color_button_data(JWidget widget)
{
+ return jwidget_get_data(widget, color_button_type());
+}
+
+static bool color_button_msg_proc(JWidget widget, JMessage msg)
+{
+ ColorButton *color_button = color_button_data(widget);
+
switch (msg->type) {
case JM_DESTROY:
- jfree (jwidget_get_data (widget, color_button_type ()));
+ jfree(color_button);
break;
case JM_REQSIZE: {
struct jrect box;
- jwidget_get_texticon_info (widget, &box, NULL, NULL, 0, 0, 0);
+ jwidget_get_texticon_info(widget, &box, NULL, NULL, 0, 0, 0);
box.x2 = box.x1+64;
@@ -102,18 +117,16 @@ static bool color_button_msg_proc (JWidget widget, JMessage msg)
}
case JM_DRAW:
- color_button_draw (widget);
+ color_button_draw(widget);
return TRUE;
case JM_SIGNAL:
if (msg->signal.num == JI_SIGNAL_BUTTON_SELECT) {
- char *new_color = ji_color_select (color_button_get_imgtype (widget),
- color_button_get_color (widget));
- if (new_color) {
- color_button_set_color (widget, new_color);
- jfree (new_color);
+ color_t color = color_button->color;
- jwidget_emit_signal (widget, SIGNAL_COLOR_BUTTON_CHANGE);
+ if (ji_color_select(color_button->imgtype, &color)) {
+ color_button_set_color(widget, color);
+ jwidget_emit_signal(widget, SIGNAL_COLOR_BUTTON_CHANGE);
}
return TRUE;
}
@@ -123,13 +136,12 @@ static bool color_button_msg_proc (JWidget widget, JMessage msg)
return FALSE;
}
-static void color_button_draw (JWidget widget)
+static void color_button_draw(JWidget widget)
{
- int imgtype = color_button_get_imgtype(widget);
+ ColorButton *color_button = color_button_data(widget);
struct jrect box, text, icon;
int x1, y1, x2, y2;
int bg, c1, c2;
- char *old_text;
char buf[256];
jwidget_get_texticon_info(widget, &box, &text, &icon, 0, 0, 0);
@@ -177,18 +189,19 @@ static void color_button_draw (JWidget widget)
/* background */
x1++, y1++, x2--, y2--;
- draw_color(ji_screen, x1, y1, x2, y2, imgtype, widget->text);
+ draw_color(ji_screen, x1, y1, x2, y2,
+ color_button->imgtype,
+ color_button->color);
/* draw text */
- color_to_formalstring(imgtype, widget->text, buf, sizeof(buf), FALSE);
-
- old_text = widget->text;
- widget->text = buf;
+ color_to_formalstring(color_button->imgtype,
+ color_button->color, buf, sizeof(buf), FALSE);
+ jwidget_set_text_soft(widget, buf);
jwidget_get_texticon_info(widget, &box, &text, &icon, 0, 0, 0);
rectfill(ji_screen, text.x1, text.y1, text.x2-1, text.y2-1, makecol(0, 0, 0));
jdraw_text(widget->text_font, widget->text, text.x1, text.y1,
- makecol(255, 255, 255), makecol(0, 0, 0), FALSE);
- widget->text = old_text;
+ makecol(255, 255, 255),
+ makecol(0, 0, 0), FALSE);
}
diff --git a/src/widgets/colbut.h b/src/widgets/colbut.h
index 0bf1b17ce..9c9e5af43 100644
--- a/src/widgets/colbut.h
+++ b/src/widgets/colbut.h
@@ -19,15 +19,17 @@
#ifndef WIDGETS_COLBUT_H
#define WIDGETS_COLBUT_H
+#include "modules/color.h"
+
/* TODO use some JI_SIGNAL_USER */
#define SIGNAL_COLOR_BUTTON_CHANGE 0x10001
-JWidget color_button_new (const char *color, int imgtype);
-int color_button_type (void);
+JWidget color_button_new(color_t color, int imgtype);
+int color_button_type(void);
-int color_button_get_imgtype (JWidget color_button);
+int color_button_get_imgtype(JWidget color_button);
-const char *color_button_get_color (JWidget color_button);
-void color_button_set_color (JWidget color_button, const char *color);
+color_t color_button_get_color(JWidget color_button);
+void color_button_set_color(JWidget color_button, color_t color);
#endif /* WIDGETS_COLBUT_H */
diff --git a/src/widgets/colsel2.c b/src/widgets/colsel2.c
new file mode 100644
index 000000000..0b9999c24
--- /dev/null
+++ b/src/widgets/colsel2.c
@@ -0,0 +1,370 @@
+/* ASE - Allegro Sprite Editor
+ * Copyright (C) 2001-2008 David A. Capello
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+
+#include
+#include
+
+#include "jinete/jinete.h"
+
+#include "core/app.h"
+#include "modules/gui.h"
+#include "modules/palette.h"
+#include "widgets/colsel2.h"
+#include "widgets/paledit.h"
+#include "widgets/tabs.h"
+
+enum {
+ MODEL_RGB,
+ MODEL_HSV,
+ MODEL_GRAY,
+ MODEL_MASK
+};
+
+typedef struct Model
+{
+ const char *text;
+ int model;
+ int color_type;
+ JWidget (*create)(JWidget colsel);
+} Model;
+
+typedef struct ColorSelector
+{
+ color_t color;
+} ColorSelector;
+
+static JWidget create_rgb_container(JWidget colsel);
+static JWidget create_hsv_container(JWidget colsel);
+static JWidget create_gray_container(JWidget colsel);
+static JWidget create_mask_container(JWidget colsel);
+
+static int colorselector_type(void);
+static ColorSelector *colorselector_data(JWidget widget);
+static bool colorselector_msg_proc(JWidget widget, JMessage msg);
+static void select_tab_callback(JWidget tabs, void *data);
+
+static int slider_change_signal(JWidget widget, int user_data);
+
+static Model models[] = {
+ { "RGB", MODEL_RGB, COLOR_TYPE_RGB, create_rgb_container },
+ { "HSV", MODEL_HSV, COLOR_TYPE_RGB, create_hsv_container },
+ { "Gray", MODEL_GRAY, COLOR_TYPE_GRAY, create_gray_container },
+ { "Mask", MODEL_MASK, COLOR_TYPE_MASK, create_mask_container },
+ { NULL, 0, 0, NULL }
+};
+
+JWidget colorselector_new(void)
+{
+ int guiscale = GUISCALE;
+ JWidget window = jtooltip_window_new("");
+ JWidget vbox = jbox_new(JI_VERTICAL);
+ JWidget grid = jgrid_new(5, FALSE);
+ JWidget tabs = tabs_new(select_tab_callback);
+ JWidget pal = palette_editor_new(current_palette, FALSE, 4);
+ JWidget child;
+ ColorSelector *colorselector = jnew(ColorSelector, 1);
+ Model *m;
+
+ jwidget_set_bg_color(tabs, window->bg_color);
+ vbox->child_spacing = 0;
+
+ grid->border_width.t = 3;
+ jwidget_set_min_size(grid, 200*guiscale, 0);
+
+ jwidget_set_name(tabs, "tabs");
+
+ for (m=models; m->text!=NULL; ++m) {
+ tabs_append_tab(tabs, _(m->text), (void *)m);
+
+ child = (*m->create)(window);
+ jwidget_set_name(child, m->text);
+ jgrid_add_child(grid, child, 1, 1, JI_HORIZONTAL | JI_TOP);
+ }
+
+ jgrid_add_child(grid, pal, 1, 1, JI_RIGHT | JI_TOP);
+ jwidget_expansive(grid, TRUE);
+
+ jwidget_add_child(vbox, tabs);
+ jwidget_add_child(vbox, grid);
+ jwidget_add_child(window, vbox);
+
+ jwidget_add_hook(window,
+ colorselector_type(),
+ colorselector_msg_proc, colorselector);
+
+ return window;
+}
+
+void colorselector_set_color(JWidget widget, color_t color)
+{
+ ColorSelector *colorselector = colorselector_data(widget);
+ JWidget tabs = jwidget_find_name(widget, "tabs");
+ int imgtype = app_get_current_image_type();
+ Model *m = NULL;
+ JWidget rgb_rslider = jwidget_find_name(widget, "rgb_r");
+ JWidget rgb_gslider = jwidget_find_name(widget, "rgb_g");
+ JWidget rgb_bslider = jwidget_find_name(widget, "rgb_b");
+ JWidget rgb_aslider = jwidget_find_name(widget, "rgb_a");
+ JWidget hsv_hslider = jwidget_find_name(widget, "hsv_h");
+ JWidget hsv_sslider = jwidget_find_name(widget, "hsv_s");
+ JWidget hsv_vslider = jwidget_find_name(widget, "hsv_v");
+ JWidget hsv_aslider = jwidget_find_name(widget, "hsv_a");
+ JWidget gray_vslider = jwidget_find_name(widget, "gray_v");
+ JWidget gray_aslider = jwidget_find_name(widget, "gray_a");
+
+ colorselector->color = color;
+
+ jslider_set_value(rgb_rslider, color_get_red(imgtype, color));
+ jslider_set_value(rgb_gslider, color_get_green(imgtype, color));
+ jslider_set_value(rgb_bslider, color_get_blue(imgtype, color));
+ jslider_set_value(rgb_aslider, color_get_alpha(imgtype, color));
+ jslider_set_value(hsv_hslider, color_get_hue(imgtype, color));
+ jslider_set_value(hsv_sslider, color_get_saturation(imgtype, color));
+ jslider_set_value(hsv_vslider, color_get_value(imgtype, color));
+ jslider_set_value(hsv_aslider, color_get_alpha(imgtype, color));
+ jslider_set_value(gray_vslider, color_get_value(imgtype, color));
+ jslider_set_value(gray_aslider, color_get_alpha(imgtype, color));
+
+ switch (color_type(color)) {
+ case COLOR_TYPE_MASK:
+ m = models+MODEL_MASK;
+ break;
+ case COLOR_TYPE_RGB:
+ case COLOR_TYPE_INDEX:
+ m = models+MODEL_RGB;
+ break;
+ case COLOR_TYPE_HSV:
+ m = models+MODEL_HSV;
+ break;
+ case COLOR_TYPE_GRAY:
+ m = models+MODEL_GRAY;
+ break;
+ default:
+ assert(FALSE);
+ }
+
+ tabs_select_tab(tabs, m);
+ select_tab_callback(tabs, m);
+}
+
+color_t colorselector_get_color(JWidget widget)
+{
+ ColorSelector *colorselector = colorselector_data(widget);
+
+ return colorselector->color;
+}
+
+static JWidget create_rgb_container(JWidget colsel)
+{
+ JWidget grid = jgrid_new(2, FALSE);
+ JWidget rlabel = jlabel_new("R");
+ JWidget glabel = jlabel_new("G");
+ JWidget blabel = jlabel_new("B");
+ JWidget alabel = jlabel_new("A");
+ JWidget rslider = jslider_new(0, 255, 0);
+ JWidget gslider = jslider_new(0, 255, 0);
+ JWidget bslider = jslider_new(0, 255, 0);
+ JWidget aslider = jslider_new(0, 255, 0);
+ jgrid_add_child(grid, rlabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, rslider, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, glabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, gslider, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, blabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, bslider, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, alabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, aslider, 1, 1, JI_HORIZONTAL);
+
+ jwidget_set_name(rslider, "rgb_r");
+ jwidget_set_name(gslider, "rgb_g");
+ jwidget_set_name(bslider, "rgb_b");
+ jwidget_set_name(aslider, "rgb_a");
+
+ HOOK(rslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+ HOOK(gslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+ HOOK(bslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+ HOOK(aslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+
+ return grid;
+}
+
+static JWidget create_hsv_container(JWidget colsel)
+{
+ JWidget grid = jgrid_new(2, FALSE);
+ JWidget hlabel = jlabel_new("H");
+ JWidget slabel = jlabel_new("S");
+ JWidget vlabel = jlabel_new("V");
+ JWidget alabel = jlabel_new("A");
+ JWidget hslider = jslider_new(0, 255, 0);
+ JWidget sslider = jslider_new(0, 255, 0);
+ JWidget vslider = jslider_new(0, 255, 0);
+ JWidget aslider = jslider_new(0, 255, 0);
+ jgrid_add_child(grid, hlabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, hslider, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, slabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, sslider, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, vlabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, vslider, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, alabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, aslider, 1, 1, JI_HORIZONTAL);
+
+ jwidget_set_name(hslider, "hsv_h");
+ jwidget_set_name(sslider, "hsv_s");
+ jwidget_set_name(vslider, "hsv_v");
+ jwidget_set_name(aslider, "hsv_a");
+
+ HOOK(hslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+ HOOK(sslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+ HOOK(vslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+ HOOK(aslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+
+ return grid;
+}
+
+static JWidget create_gray_container(JWidget colsel)
+{
+ JWidget grid = jgrid_new(2, FALSE);
+ JWidget klabel = jlabel_new("V");
+ JWidget alabel = jlabel_new("A");
+ JWidget vslider = jslider_new(0, 255, 0);
+ JWidget aslider = jslider_new(0, 255, 0);
+ jgrid_add_child(grid, klabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, vslider, 1, 1, JI_HORIZONTAL);
+ jgrid_add_child(grid, alabel, 1, 1, JI_RIGHT);
+ jgrid_add_child(grid, aslider, 1, 1, JI_HORIZONTAL);
+
+ jwidget_set_name(vslider, "gray_v");
+ jwidget_set_name(aslider, "gray_a");
+
+ HOOK(vslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+ HOOK(aslider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+
+ return grid;
+}
+
+static JWidget create_mask_container(JWidget colsel)
+{
+ return jlabel_new("M");
+}
+
+static int colorselector_type(void)
+{
+ static int type = 0;
+ if (!type)
+ type = ji_register_widget_type();
+ return type;
+}
+
+static ColorSelector *colorselector_data(JWidget widget)
+{
+ return (ColorSelector *)jwidget_get_data(widget,
+ colorselector_type());
+}
+
+static bool colorselector_msg_proc(JWidget widget, JMessage msg)
+{
+ ColorSelector *colorselector = colorselector_data(widget);
+
+ switch (msg->type) {
+
+ case JM_DESTROY:
+ jfree(colorselector);
+ break;
+
+ }
+
+ return FALSE;
+}
+
+static void select_tab_callback(JWidget tabs, void *data)
+{
+ JWidget window = jwidget_get_window(tabs);
+ JWidget child;
+ Model *selected_model = (Model *)data;
+ Model *m;
+
+ for (m=models; m->text!=NULL; ++m) {
+ child = jwidget_find_name(window, m->text);
+
+ if (m == selected_model)
+ jwidget_show(child);
+ else
+ jwidget_hide(child);
+ }
+
+ jwidget_relayout(window);
+}
+
+static int slider_change_signal(JWidget widget, int user_data)
+{
+ ColorSelector *colorselector;
+ color_t color;
+ JWidget tabs;
+ Model *m;
+
+ widget = jwidget_get_window(widget);
+ tabs = jwidget_find_name(widget, "tabs");
+ colorselector = colorselector_data(widget);
+ m = tabs_get_selected_tab(tabs);
+ color = colorselector->color;
+
+ switch (m->model) {
+ case MODEL_RGB:
+ {
+ JWidget rslider = jwidget_find_name(widget, "rgb_r");
+ JWidget gslider = jwidget_find_name(widget, "rgb_g");
+ JWidget bslider = jwidget_find_name(widget, "rgb_b");
+ JWidget aslider = jwidget_find_name(widget, "rgb_a");
+ int r = jslider_get_value(rslider);
+ int g = jslider_get_value(gslider);
+ int b = jslider_get_value(bslider);
+ int a = jslider_get_value(aslider);
+ color = color_rgb(r, g, b, a);
+ }
+ break;
+ case MODEL_HSV:
+ {
+ JWidget hslider = jwidget_find_name(widget, "hsv_h");
+ JWidget sslider = jwidget_find_name(widget, "hsv_s");
+ JWidget vslider = jwidget_find_name(widget, "hsv_v");
+ JWidget aslider = jwidget_find_name(widget, "hsv_a");
+ int h = jslider_get_value(hslider);
+ int s = jslider_get_value(sslider);
+ int v = jslider_get_value(vslider);
+ int a = jslider_get_value(aslider);
+ color = color_hsv(h, s, v, a);
+ }
+ break;
+ case MODEL_GRAY:
+ {
+ JWidget vslider = jwidget_find_name(widget, "gray_v");
+ JWidget aslider = jwidget_find_name(widget, "gray_a");
+ int v = jslider_get_value(vslider);
+ int a = jslider_get_value(aslider);
+ color = color_gray(v, a);
+ }
+ break;
+ }
+
+ colorselector_set_color(widget, color);
+
+ jwidget_emit_signal(widget, SIGNAL_COLORSELECTOR_COLOR_CHANGED);
+ return 0;
+}
+
diff --git a/src/util/mapgen.h b/src/widgets/colsel2.h
similarity index 68%
rename from src/util/mapgen.h
rename to src/widgets/colsel2.h
index bf9354fdf..72170492b 100644
--- a/src/util/mapgen.h
+++ b/src/widgets/colsel2.h
@@ -16,12 +16,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef UTIL_MAPGEN_H
-#define UTIL_MAPGEN_H
+#ifndef WIDGETS_COLSEL2_H
+#define WIDGETS_COLSEL2_H
-struct Image;
+#include "jinete/jbase.h"
-void mapgen (struct Image *image, int seed, float fractal_factor);
+#include "modules/color.h"
-#endif /* UTIL_MAPGEN_H */
+/* TODO use some JI_SIGNAL_USER */
+#define SIGNAL_COLORSELECTOR_COLOR_CHANGED 0x10009
+JWidget colorselector_new(void);
+
+void colorselector_set_color(JWidget colsel, color_t color);
+color_t colorselector_get_color(JWidget colsel);
+
+#endif /* WIDGETS_COLSEL2_H */
diff --git a/src/widgets/colview.c b/src/widgets/colview.c
index 0bf02a5cd..774819815 100644
--- a/src/widgets/colview.c
+++ b/src/widgets/colview.c
@@ -22,6 +22,7 @@
#include
#include "jinete/jdraw.h"
+#include "jinete/jfont.h"
#include "jinete/jmessage.h"
#include "jinete/jrect.h"
#include "jinete/jsystem.h"
@@ -33,65 +34,79 @@
typedef struct ColorViewer
{
+ color_t color;
int imgtype;
} ColorViewer;
-static bool color_viewer_msg_proc (JWidget widget, JMessage msg);
+static ColorViewer *colorviewer_data(JWidget widget);
+static bool colorviewer_msg_proc(JWidget widget, JMessage msg);
-JWidget color_viewer_new (const char *color, int imgtype)
+JWidget colorviewer_new(color_t color, int imgtype)
{
- JWidget widget = jwidget_new (color_viewer_type ());
- ColorViewer *color_viewer = jnew (ColorViewer, 1);
+ JWidget widget = jwidget_new(colorviewer_type());
+ ColorViewer *colorviewer = jnew(ColorViewer, 1);
- color_viewer->imgtype = imgtype;
+ colorviewer->color = color;
+ colorviewer->imgtype = imgtype;
- jwidget_add_hook (widget, color_viewer_type (),
- color_viewer_msg_proc, color_viewer);
- jwidget_focusrest (widget, TRUE);
- jwidget_set_text (widget, color);
- jwidget_set_border (widget, 2, 2, 2, 2);
- jwidget_set_align (widget, JI_CENTER | JI_MIDDLE);
+ jwidget_add_hook(widget, colorviewer_type(),
+ colorviewer_msg_proc, colorviewer);
+ jwidget_focusrest(widget, TRUE);
+ jwidget_set_border(widget, 2, 2, 2, 2);
+ jwidget_set_align(widget, JI_CENTER | JI_MIDDLE);
return widget;
}
-int color_viewer_type (void)
+int colorviewer_type(void)
{
static int type = 0;
if (!type)
- type = ji_register_widget_type ();
+ type = ji_register_widget_type();
return type;
}
-int color_viewer_get_imgtype (JWidget widget)
+int colorviewer_get_imgtype(JWidget widget)
{
- return ((ColorViewer *)jwidget_get_data (widget,
- color_viewer_type ()))->imgtype;
+ ColorViewer *colorviewer = colorviewer_data(widget);
+
+ return colorviewer->imgtype;
}
-const char *color_viewer_get_color (JWidget widget)
+color_t colorviewer_get_color(JWidget widget)
{
- return jwidget_get_text (widget);
+ ColorViewer *colorviewer = colorviewer_data(widget);
+
+ return colorviewer->color;
}
-void color_viewer_set_color (JWidget widget, const char *color)
+void colorviewer_set_color(JWidget widget, color_t color)
{
- jwidget_set_text (widget, color);
+ ColorViewer *colorviewer = colorviewer_data(widget);
+
+ colorviewer->color = color;
+ jwidget_dirty(widget);
}
-static bool color_viewer_msg_proc (JWidget widget, JMessage msg)
+static ColorViewer *colorviewer_data(JWidget widget)
{
- int imgtype = (int)widget->user_data[0];
+ return (ColorViewer *)jwidget_get_data(widget,
+ colorviewer_type());
+}
+
+static bool colorviewer_msg_proc(JWidget widget, JMessage msg)
+{
+ ColorViewer *colorviewer = colorviewer_data(widget);
switch (msg->type) {
case JM_DESTROY:
- jfree (jwidget_get_data (widget, color_viewer_type ()));
+ jfree(colorviewer);
break;
case JM_REQSIZE: {
- msg->reqsize.w = jwidget_get_text_length (widget);
- msg->reqsize.h = jwidget_get_text_height (widget);
+ msg->reqsize.w = ji_font_text_len(widget->text_font, "255,255,255,255");
+ msg->reqsize.h = jwidget_get_text_height(widget);
msg->reqsize.w += widget->border_width.l + widget->border_width.r;
msg->reqsize.h += widget->border_width.t + widget->border_width.b;
@@ -100,43 +115,43 @@ static bool color_viewer_msg_proc (JWidget widget, JMessage msg)
case JM_DRAW: {
struct jrect box, text, icon;
- JRect rect = jwidget_get_rect (widget);
- char *old_text;
+ JRect rect = jwidget_get_rect(widget);
char buf[256];
- jdraw_rectedge (rect, makecol (128, 128, 128),
- makecol (255, 255, 255));
+ jdraw_rectedge(rect,
+ makecol(128, 128, 128),
+ makecol(255, 255, 255));
- jrect_shrink (rect, 1);
- jdraw_rect (rect,
- jwidget_has_focus (widget) ? makecol (0, 0, 0):
- makecol (192, 192, 192));
+ jrect_shrink(rect, 1);
+ jdraw_rect(rect,
+ jwidget_has_focus(widget) ? makecol(0, 0, 0):
+ makecol(192, 192, 192));
/* draw color background */
- jrect_shrink (rect, 1);
- draw_color (ji_screen, rect->x1, rect->y1, rect->x2-1, rect->y2-1,
- imgtype, widget->text);
+ jrect_shrink(rect, 1);
+ draw_color(ji_screen, rect->x1, rect->y1, rect->x2-1, rect->y2-1,
+ colorviewer->imgtype,
+ colorviewer->color);
/* draw text */
- color_to_formalstring (imgtype, widget->text, buf, sizeof (buf), FALSE);
+ color_to_formalstring(colorviewer->imgtype,
+ colorviewer->color, buf, sizeof(buf), FALSE);
- old_text = widget->text;
- widget->text = buf;
+ jwidget_set_text_soft(widget, buf);
+ jwidget_get_texticon_info(widget, &box, &text, &icon, 0, 0, 0);
- jwidget_get_texticon_info (widget, &box, &text, &icon, 0, 0, 0);
+ jdraw_rectfill(&text, makecol(0, 0, 0));
+ jdraw_text(widget->text_font, widget->text, text.x1, text.y1,
+ makecol(255, 255, 255), makecol(0, 0, 0), FALSE);
- jdraw_rectfill (&text, makecol (0, 0, 0));
- jdraw_text (widget->text_font, widget->text, text.x1, text.y1,
- makecol (255, 255, 255), makecol (0, 0, 0), FALSE);
- widget->text = old_text;
-
- jrect_free (rect);
+ jrect_free(rect);
return TRUE;
}
case JM_BUTTONPRESSED:
- jwidget_emit_signal (widget, SIGNAL_COLOR_VIEWER_SELECT);
+ jwidget_emit_signal(widget, SIGNAL_COLORVIEWER_SELECT);
return TRUE;
+
}
return FALSE;
diff --git a/src/widgets/colview.h b/src/widgets/colview.h
index d44596758..6c6eb2ed3 100644
--- a/src/widgets/colview.h
+++ b/src/widgets/colview.h
@@ -21,15 +21,17 @@
#include "jinete/jbase.h"
+#include "modules/color.h"
+
/* TODO use some JI_SIGNAL_USER */
-#define SIGNAL_COLOR_VIEWER_SELECT 0x10002
+#define SIGNAL_COLORVIEWER_SELECT 0x10002
-JWidget color_viewer_new (const char *color, int imgtype);
-int color_viewer_type (void);
+JWidget colorviewer_new(color_t color, int imgtype);
+int colorviewer_type(void);
-int color_viewer_get_imgtype (JWidget color_viewer_id);
+int colorviewer_get_imgtype(JWidget colorviewer);
-const char *color_viewer_get_color (JWidget color_viewer);
-void color_viewer_set_color (JWidget color_viewer, const char *color);
+color_t colorviewer_get_color(JWidget colorviewer);
+void colorviewer_set_color(JWidget colorviewer, color_t color);
#endif /* WIDGETS_COLVIEW_H */
diff --git a/src/widgets/curvedit.c b/src/widgets/curvedit.c
index 096a44b6b..8612852ef 100644
--- a/src/widgets/curvedit.c
+++ b/src/widgets/curvedit.c
@@ -164,7 +164,7 @@ static bool curve_editor_msg_proc(JWidget widget, JMessage msg)
return TRUE;
}
- case JM_CHAR: {
+ case JM_KEYPRESSED: {
switch (msg->key.scancode) {
case KEY_INSERT: {
diff --git a/src/widgets/editor.h b/src/widgets/editor.h
index 7bc7c7a04..5b6e26312 100644
--- a/src/widgets/editor.h
+++ b/src/widgets/editor.h
@@ -42,9 +42,8 @@ typedef struct Editor
int cursor_editor_x; /* position in the editor (model) */
int cursor_editor_y;
int old_cursor_thick;
-
- /* for the mouse */
- unsigned lagged_mouseenter : 1;
+ bool cursor_candraw : 1;
+ bool cursor_eyedropper : 1;
/* offset for the sprite */
int offset_x;
@@ -98,7 +97,7 @@ void editor_to_screen(JWidget editor, int xin, int yin, int *xout, int *yout);
void show_drawing_cursor(JWidget editor);
void hide_drawing_cursor(JWidget editor);
-void editor_update_status_bar_for_standby(JWidget editor);
+void editor_update_statusbar_for_standby(JWidget editor);
void editor_refresh_region(JWidget editor);
@@ -114,7 +113,6 @@ bool editor_cursor_is_subpixel(JWidget editor);
int editor_keys_toset_zoom(JWidget editor, int scancode);
int editor_keys_toset_brushsize(JWidget editor, int scancode);
-int editor_keys_toget_pixels(JWidget editor, int scancode);
/**********************************************************************/
/* src/gui/editor/click.c */
diff --git a/src/widgets/editor/editor.c b/src/widgets/editor/editor.c
index 6afcb611d..83b0ea96a 100644
--- a/src/widgets/editor/editor.c
+++ b/src/widgets/editor/editor.c
@@ -26,6 +26,7 @@
#include "jinete/jinete.h"
+#include "commands/commands.h"
#include "core/app.h"
#include "core/cfg.h"
#include "modules/color.h"
@@ -68,9 +69,10 @@ enum {
static int use_dither = FALSE;
-static bool editor_view_msg_proc (JWidget widget, JMessage msg);
-static bool editor_msg_proc (JWidget widget, JMessage msg);
-static void editor_request_size (JWidget widget, int *w, int *h);
+static bool editor_view_msg_proc(JWidget widget, JMessage msg);
+static bool editor_msg_proc(JWidget widget, JMessage msg);
+static void editor_request_size(JWidget widget, int *w, int *h);
+static void editor_setcursor(JWidget widget, int x, int y);
JWidget editor_view_new(void)
{
@@ -94,6 +96,8 @@ JWidget editor_new(void)
editor->cursor_thick = 0;
editor->old_cursor_thick = 0;
+ editor->cursor_candraw = FALSE;
+ editor->cursor_eyedropper = FALSE;
jwidget_add_hook(widget, editor_type(), editor_msg_proc, editor);
jwidget_focusrest(widget, TRUE);
@@ -276,15 +280,15 @@ void editor_update(JWidget widget)
*/
void editor_draw_sprite(JWidget widget, int x1, int y1, int x2, int y2)
{
- Editor *editor = editor_data (widget);
- JWidget view = jwidget_get_view (widget);
- JRect vp = jview_get_viewport_position (view);
+ Editor *editor = editor_data(widget);
+ JWidget view = jwidget_get_view(widget);
+ JRect vp = jview_get_viewport_position(view);
int source_x, source_y, dest_x, dest_y, width, height;
int scroll_x, scroll_y;
/* get scroll */
- jview_get_scroll (view, &scroll_x, &scroll_y);
+ jview_get_scroll(view, &scroll_x, &scroll_y);
/* output information */
@@ -804,22 +808,10 @@ void show_drawing_cursor(JWidget widget)
assert(editor->sprite != NULL);
- if (!sprite_is_locked(editor->sprite) &&
- editor->sprite->layer != NULL &&
- layer_is_image(editor->sprite->layer) &&
- layer_is_readable(editor->sprite->layer) &&
- layer_is_writable(editor->sprite->layer) &&
- layer_get_cel(editor->sprite->layer, editor->sprite->frame) != NULL) {
- jmouse_set_cursor(JI_CURSOR_NULL);
-
- if (!editor->cursor_thick) {
- jmouse_hide();
- editor_draw_cursor(widget, jmouse_x(0), jmouse_y(0));
- jmouse_show();
- }
- }
- else {
- jmouse_set_cursor(JI_CURSOR_FORBIDDEN);
+ if (!editor->cursor_thick && editor->cursor_candraw) {
+ jmouse_hide();
+ editor_draw_cursor(widget, jmouse_x(0), jmouse_y(0));
+ jmouse_show();
}
}
@@ -832,28 +824,43 @@ void hide_drawing_cursor(JWidget widget)
editor_clean_cursor(widget);
jmouse_show();
}
-
- jmouse_set_cursor(JI_CURSOR_NORMAL);
}
-void editor_update_status_bar_for_standby(JWidget widget)
+void editor_update_statusbar_for_standby(JWidget widget)
{
Editor *editor = editor_data(widget);
+ char buf[256];
int x, y;
screen_to_editor(widget, jmouse_x(0), jmouse_y(0), &x, &y);
- status_bar_set_text(app_get_status_bar(), 0,
- "%s %3d %3d (%s %3d %3d) [%s %d]",
- _("Pos"), x, y,
- _("Size"),
- ((editor->sprite->mask->bitmap)?
- editor->sprite->mask->w:
- editor->sprite->w),
- ((editor->sprite->mask->bitmap)?
- editor->sprite->mask->h:
- editor->sprite->h),
- _("Frame"), editor->sprite->frame+1);
+ if (editor->cursor_eyedropper) {
+ color_t color = color_from_image(editor->sprite->imgtype,
+ sprite_getpixel(editor->sprite, x, y));
+
+ usprintf(buf, "%s ", _("Color"));
+ color_to_formalstring(editor->sprite->imgtype,
+ color,
+ buf+ustrlen(buf),
+ sizeof(buf)-ustrlen(buf), TRUE);
+ }
+ else {
+ ustrcpy(buf, empty_string);
+ }
+
+ statusbar_set_text
+ (app_get_statusbar(), 0,
+ "%s %3d %3d (%s %3d %3d) [%s %d] %s",
+ _("Pos"), x, y,
+ _("Size"),
+ ((editor->sprite->mask->bitmap)?
+ editor->sprite->mask->w:
+ editor->sprite->w),
+ ((editor->sprite->mask->bitmap)?
+ editor->sprite->mask->h:
+ editor->sprite->h),
+ _("Frame"), editor->sprite->frame+1,
+ buf);
}
void editor_refresh_region(JWidget widget)
@@ -1002,10 +1009,10 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
x2 = x1 + (editor->sprite->w << editor->zoom) - 1;
y2 = y1 + (editor->sprite->h << editor->zoom) - 1;
- rectfill_exclude(ji_screen,
- widget->rc->x1, widget->rc->y1,
- widget->rc->x2-1, widget->rc->y2-1,
- x1, y1, x2, y2, makecol(128, 128, 128));
+ jrectexclude(ji_screen,
+ widget->rc->x1, widget->rc->y1,
+ widget->rc->x2-1, widget->rc->y2-1,
+ x1, y1, x2, y2, makecol(128, 128, 128));
/* draw the sprite in the editor */
editor_draw_sprite(widget, 0, 0,
@@ -1065,23 +1072,27 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
break;
case JM_MOUSEENTER:
- if (editor->state == EDIT_MOVING_SCROLL)
- break;
+ /* when the mouse enter to the editor, we can calculate the
+ 'cursor_candraw' field to avoid a heavy if-condition in the
+ 'editor_setcursor' routine */
+ editor->cursor_candraw =
+ (editor->sprite != NULL &&
+ !sprite_is_locked(editor->sprite) &&
+ editor->sprite->layer != NULL &&
+ layer_is_image(editor->sprite->layer) &&
+ layer_is_readable(editor->sprite->layer) &&
+ layer_is_writable(editor->sprite->layer) &&
+ layer_get_cel(editor->sprite->layer,
+ editor->sprite->frame) != NULL);
- if (editor->sprite) {
- show_drawing_cursor(widget);
- }
- else {
- hide_drawing_cursor(widget);
- app_default_status_bar_message();
- }
+ if (msg->any.shifts & KB_ALT_FLAG)
+ editor->cursor_eyedropper = TRUE;
break;
case JM_MOUSELEAVE:
- if (editor->state == EDIT_MOVING_SCROLL)
- break;
-
hide_drawing_cursor(widget);
+ if (editor->cursor_eyedropper)
+ editor->cursor_eyedropper = FALSE;
break;
case JM_BUTTONPRESSED: {
@@ -1096,8 +1107,7 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
(msg->mouse.middle && has_only_shifts(msg, 0))) {
editor->state = EDIT_MOVING_SCROLL;
- hide_drawing_cursor(widget);
- jmouse_set_cursor(JI_CURSOR_MOVE);
+ editor_setcursor(widget, msg->mouse.x, msg->mouse.y);
}
/* move frames position */
else if (msg->mouse.left && has_only_shifts(msg, KB_CTRL_FLAG)) {
@@ -1112,13 +1122,20 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
return TRUE;
}
}
+ /* call the eyedropper command */
+ else if (editor->cursor_eyedropper) {
+ Command *command = command_get_by_name(CMD_EYEDROPPER_TOOL);
+ if (command_is_enabled(command, NULL))
+ command_execute(command, NULL);
+ return TRUE;
+ }
/* draw */
else if (current_tool) {
editor->state = EDIT_DRAWING;
}
/* set capture */
- jwidget_capture_mouse(widget);
+ jwidget_hard_capture_mouse(widget);
}
case JM_MOTION: {
@@ -1141,10 +1158,12 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
}
/* draw */
else if (editor->state == EDIT_DRAWING) {
- JWidget color_bar = app_get_color_bar();
- const char *color;
-
- color = color_bar_get_color(color_bar, msg->mouse.left ? 0: 1);
+ JWidget colorbar = app_get_colorbar();
+ color_t color = msg->mouse.left ?
+ /* color with left button */
+ colorbar_get_fg_color(colorbar):
+ /* color with right button */
+ color_mask();
/* call the tool-control routine */
control_tool(widget, current_tool, color);
@@ -1157,6 +1176,8 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
if (editor->cursor_thick) {
int x, y;
+ /* jmouse_set_cursor(JI_CURSOR_NULL); */
+
x = msg->mouse.x;
y = msg->mouse.y;
@@ -1172,14 +1193,15 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
/* status bar text */
if (editor->state == EDIT_STANDBY) {
- editor_update_status_bar_for_standby(widget);
+ editor_update_statusbar_for_standby(widget);
}
else if (editor->state == EDIT_MOVING_SCROLL) {
int x, y;
screen_to_editor(widget, jmouse_x(0), jmouse_y(0), &x, &y);
- status_bar_set_text(app_get_status_bar(), 0,
- "Pos %3d %3d (Size %3d %3d)", x, y,
- editor->sprite->w, editor->sprite->h);
+ statusbar_set_text
+ (app_get_statusbar(), 0,
+ "Pos %3d %3d (Size %3d %3d)", x, y,
+ editor->sprite->w, editor->sprite->h);
}
return TRUE;
}
@@ -1188,27 +1210,37 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
if (!editor->sprite)
break;
- if (editor->state == EDIT_MOVING_SCROLL) {
- jmanager_free_mouse();
-
- /* change mouse cursor */
- jmouse_set_cursor(JI_CURSOR_NORMAL);
- }
-
editor->state = EDIT_STANDBY;
- jwidget_release_mouse(widget);
+ editor_setcursor(widget, msg->mouse.x, msg->mouse.y);
- show_drawing_cursor(widget);
+ jwidget_release_mouse(widget);
return TRUE;
- case JM_CHAR:
- if (!editor_keys_toset_zoom(widget, msg->key.scancode) &&
- !editor_keys_toset_brushsize(widget, msg->key.scancode) &&
- !editor_keys_toget_pixels(widget, msg->key.scancode))
- return FALSE;
- else
+ case JM_KEYPRESSED:
+ if (editor_keys_toset_zoom(widget, msg->key.scancode) ||
+ editor_keys_toset_brushsize(widget, msg->key.scancode))
return TRUE;
+ /* eye-dropper is activated with ALT key */
+ if (msg->key.scancode == KEY_ALT &&
+ jwidget_has_mouse(widget)) {
+ editor->cursor_eyedropper = TRUE;
+ editor_setcursor(widget, jmouse_x(0), jmouse_y(0));
+ return TRUE;
+ }
+ break;
+
+ case JM_KEYRELEASED:
+ if (editor->cursor_eyedropper) {
+ /* eye-dropper is deactivated with ALT key */
+ if (msg->key.scancode == KEY_ALT) {
+ editor->cursor_eyedropper = FALSE;
+ editor_setcursor(widget, jmouse_x(0), jmouse_y(0));
+ return TRUE;
+ }
+ }
+ break;
+
case JM_WHEEL:
if (editor->state == EDIT_STANDBY) {
/* there are and sprite in the editor, there is the mouse inside*/
@@ -1286,16 +1318,19 @@ static bool editor_msg_proc(JWidget widget, JMessage msg)
}
}
break;
-
+
+ case JM_SETCURSOR:
+ editor_setcursor(widget, msg->mouse.x, msg->mouse.y);
+ return TRUE;
+
}
return FALSE;
}
-/**********************************************************************/
-/* request size for the editor viewport */
-/**********************************************************************/
-
+/**
+ * Returns size for the editor viewport
+ */
static void editor_request_size(JWidget widget, int *w, int *h)
{
Editor *editor = editor_data(widget);
@@ -1317,3 +1352,45 @@ static void editor_request_size(JWidget widget, int *w, int *h)
*h = 4;
}
}
+
+static void editor_setcursor(JWidget widget, int x, int y)
+{
+ Editor *editor = editor_data(widget);
+
+ switch (editor->state) {
+
+ case EDIT_MOVING_SCROLL:
+ hide_drawing_cursor(widget);
+ jmouse_set_cursor(JI_CURSOR_MOVE);
+ break;
+
+ case EDIT_DRAWING:
+ jmouse_set_cursor(JI_CURSOR_NULL);
+ show_drawing_cursor(widget);
+ break;
+
+ case EDIT_STANDBY:
+ if (editor->sprite) {
+ if (editor->cursor_candraw) {
+ if (editor->cursor_eyedropper) {
+ hide_drawing_cursor(widget);
+ jmouse_set_cursor(JI_CURSOR_EYEDROPPER);
+ }
+ else {
+ jmouse_set_cursor(JI_CURSOR_NULL);
+ show_drawing_cursor(widget);
+ }
+ }
+ else {
+ hide_drawing_cursor(widget);
+ jmouse_set_cursor(JI_CURSOR_FORBIDDEN);
+ }
+ }
+ else {
+ hide_drawing_cursor(widget);
+ jmouse_set_cursor(JI_CURSOR_NORMAL);
+ }
+ break;
+
+ }
+}
diff --git a/src/widgets/editor/keys.c b/src/widgets/editor/keys.c
index fd7235297..1bf3f3355 100644
--- a/src/widgets/editor/keys.c
+++ b/src/widgets/editor/keys.c
@@ -34,8 +34,6 @@
#include "widgets/colbar.h"
#include "widgets/editor.h"
-static int getpixel_sprite(Sprite *sprite, int x, int y);
-
int editor_keys_toset_zoom(JWidget widget, int scancode)
{
Editor *editor = editor_data (widget);
@@ -115,60 +113,3 @@ int editor_keys_toset_brushsize(JWidget widget, int scancode)
return FALSE;
}
-
-int editor_keys_toget_pixels(JWidget widget, int scancode)
-{
- Editor *editor = editor_data (widget);
-
- if ((editor->sprite) &&
- (jwidget_has_mouse (widget)) &&
- !(key_shifts & (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG))) {
- /* TODO make these keys configurable */
- /* get a color from the sprite */
- if ((scancode == KEY_9) || (scancode == KEY_0)) {
- char *color = NULL;
- int x, y;
-
- /* pixel position to get */
- screen_to_editor(widget, jmouse_x(0), jmouse_y(0), &x, &y);
-
- /* get the color from the image */
- color = color_from_image(editor->sprite->imgtype,
- getpixel_sprite(editor->sprite, x, y));
-
- /* set the color of the color-bar */
- color_bar_set_color(app_get_color_bar(),
- scancode == KEY_9 ? 0: 1, color, TRUE);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/**
- * Gets a pixel from the sprite in the specified position. If in the
- * specified coordinates there're background this routine will return
- * the 0 color (the mask-color).
- */
-static int getpixel_sprite(Sprite *sprite, int x, int y)
-{
- Image *image;
- int color = 0;
-
- if ((x >= 0) && (y >= 0) && (x < sprite->w) && (y < sprite->h)) {
- int old_bgcolor = sprite->bgcolor;
- sprite->bgcolor = 0;
-
- image = image_new(sprite->imgtype, 1, 1);
- image_clear(image, 0);
- sprite_render(sprite, image, -x, -y);
- color = image_getpixel(image, 0, 0);
- image_free(image);
-
- sprite->bgcolor = old_bgcolor;
- }
-
- return color;
-}
diff --git a/src/widgets/fileview.c b/src/widgets/fileview.c
index 87580e11b..a0be9246b 100644
--- a/src/widgets/fileview.c
+++ b/src/widgets/fileview.c
@@ -41,6 +41,7 @@
#include "widgets/statebar.h"
#define MAX_THUMBNAIL_SIZE 128
+#define ISEARCH_KEYPRESS_INTERVAL_MSECS 500
typedef struct FileView
{
@@ -51,6 +52,10 @@ typedef struct FileView
FileItem *selected;
const char *exts;
+ /* incremental-search */
+ char isearch[256];
+ int isearch_clock;
+
/* thumbnail generation process */
FileItem *item_to_generate_thumbnail;
int timer_id;
@@ -106,6 +111,9 @@ JWidget fileview_new(FileItem *start_folder, const char *exts)
fileview->selected = NULL;
fileview->exts = exts;
+ ustrcpy(fileview->isearch, empty_string);
+ fileview->isearch_clock = 0;
+
fileview->item_to_generate_thumbnail = NULL;
fileview->timer_id = jmanager_add_timer(widget, 200);
fileview->monitors = jlist_new();
@@ -279,16 +287,16 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
fgcolor, bgcolor, TRUE);
/* background for the icon */
- rectfill_exclude(ji_screen,
- /* rectangle to fill */
- widget->rc->x1, y,
- x+icon_w+2-1, y+2+th+2-1,
- /* exclude where is the icon located */
- x, y+2,
- x+icon_w-1,
- y+2+icon_h-1,
- /* fill with the background color */
- bgcolor);
+ jrectexclude(ji_screen,
+ /* rectangle to fill */
+ widget->rc->x1, y,
+ x+icon_w+2-1, y+2+th+2-1,
+ /* exclude where is the icon located */
+ x, y+2,
+ x+icon_w-1,
+ y+2+icon_h-1,
+ /* fill with the background color */
+ bgcolor);
x += icon_w+2;
}
@@ -306,17 +314,17 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
fgcolor, bgcolor, TRUE);
/* background for the item name */
- rectfill_exclude(ji_screen,
- /* rectangle to fill */
- x, y,
- widget->rc->x2-1, y+2+th+2-1,
- /* exclude where is the text located */
- x, y+2,
- x+ji_font_text_len(widget->text_font,
- fileitem_get_displayname(fi))-1,
- y+2+ji_font_get_size(widget->text_font)-1,
- /* fill with the background color */
- bgcolor);
+ jrectexclude(ji_screen,
+ /* rectangle to fill */
+ x, y,
+ widget->rc->x2-1, y+2+th+2-1,
+ /* exclude where is the text located */
+ x, y+2,
+ x+ji_font_text_len(widget->text_font,
+ fileitem_get_displayname(fi))-1,
+ y+2+ji_font_get_size(widget->text_font)-1,
+ /* fill with the background color */
+ bgcolor);
/* thumbnail position */
if (fi == fileview->selected) {
@@ -356,7 +364,7 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
}
case JM_BUTTONPRESSED:
- jwidget_capture_mouse(widget);
+ jwidget_hard_capture_mouse(widget);
case JM_MOTION:
if (jwidget_has_capture(widget)) {
@@ -399,7 +407,7 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
}
break;
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (jwidget_has_focus(widget)) {
int select = fileview_get_selected_index(widget);
JWidget view = jwidget_get_view(widget);
@@ -463,7 +471,37 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
fileview_goup(widget);
return TRUE;
default:
- return FALSE;
+ if (msg->key.ascii == ' ' ||
+ (utolower(msg->key.ascii) >= 'a' &&
+ utolower(msg->key.ascii) <= 'z') ||
+ (utolower(msg->key.ascii) >= '0' &&
+ utolower(msg->key.ascii) <= '9')) {
+ if (ji_clock - fileview->isearch_clock > ISEARCH_KEYPRESS_INTERVAL_MSECS)
+ ustrcpy(fileview->isearch, empty_string);
+
+ usprintf(fileview->isearch+ustrsize(fileview->isearch),
+ "%c", msg->key.ascii);
+
+ {
+ int i, chrs = ustrlen(fileview->isearch);
+ JLink link = jlist_nth_link(fileview->list,
+ (select >= 0) ? select: 0);
+
+ for (i=select; i<=bottom; ++i, link=link->next) {
+ FileItem *fi = link->data;
+ if (ustrnicmp(fileitem_get_displayname(fi),
+ fileview->isearch,
+ chrs) == 0) {
+ select = i;
+ break;
+ }
+ }
+ }
+ fileview->isearch_clock = ji_clock;
+ /* go to fileview_select_index... */
+ }
+ else
+ return FALSE;
}
fileview_select_index(widget, MID(0, select, bottom));
diff --git a/src/widgets/paledit.c b/src/widgets/paledit.c
index 7fcf778f4..abbbecdc9 100644
--- a/src/widgets/paledit.c
+++ b/src/widgets/paledit.c
@@ -348,7 +348,7 @@ static bool palette_editor_msg_proc(JWidget widget, JMessage msg)
&msg->reqsize.w, &msg->reqsize.h);
return TRUE;
- case JM_CHAR:
+ case JM_KEYPRESSED:
if (jwidget_has_focus (widget)) {
/* other keys */
if ((palette_editor->color[1] >= 0) &&
diff --git a/src/widgets/statebar.c b/src/widgets/statebar.c
index 7d71b4b9e..8beee171a 100644
--- a/src/widgets/statebar.c
+++ b/src/widgets/statebar.c
@@ -48,72 +48,72 @@ enum {
ACTION_LAST,
};
-static bool status_bar_msg_proc(JWidget widget, JMessage msg);
+static bool statusbar_msg_proc(JWidget widget, JMessage msg);
static int slider_change_signal(JWidget widget, int user_data);
static void button_command(JWidget widget, void *data);
-static void update_from_layer(StatusBar *status_bar);
+static void update_from_layer(StatusBar *statusbar);
-JWidget status_bar_new(void)
+JWidget statusbar_new(void)
{
#define BUTTON_NEW(name, text, data) \
(name) = jbutton_new(text); \
- (name)->user_data[0] = status_bar; \
+ (name)->user_data[0] = statusbar; \
jbutton_add_command_data((name), button_command, (void *)(data));
#define ICON_NEW(name, icon, action) \
BUTTON_NEW((name), NULL, (action)); \
add_gfxicon_to_button((name), (icon), JI_CENTER | JI_MIDDLE);
- JWidget widget = jwidget_new(status_bar_type());
- StatusBar *status_bar = jnew(StatusBar, 1);
+ JWidget widget = jwidget_new(statusbar_type());
+ StatusBar *statusbar = jnew(StatusBar, 1);
- jwidget_add_hook(widget, status_bar_type(),
- status_bar_msg_proc, status_bar);
+ jwidget_add_hook(widget, statusbar_type(),
+ statusbar_msg_proc, statusbar);
jwidget_focusrest(widget, TRUE);
{
JWidget box1, box2;
- status_bar->widget = widget;
- status_bar->timeout = 0;
- status_bar->progress = jlist_new();
+ statusbar->widget = widget;
+ statusbar->timeout = 0;
+ statusbar->progress = jlist_new();
/* construct the commands box */
box1 = jbox_new(JI_HORIZONTAL);
box2 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
- BUTTON_NEW(status_bar->b_layer, "*Current Layer*", ACTION_LAYER);
- status_bar->slider = jslider_new(0, 255, 255);
- ICON_NEW(status_bar->b_first, GFX_ANI_FIRST, ACTION_FIRST);
- ICON_NEW(status_bar->b_prev, GFX_ANI_PREV, ACTION_PREV);
- ICON_NEW(status_bar->b_play, GFX_ANI_PLAY, ACTION_PLAY);
- ICON_NEW(status_bar->b_next, GFX_ANI_NEXT, ACTION_NEXT);
- ICON_NEW(status_bar->b_last, GFX_ANI_LAST, ACTION_LAST);
+ BUTTON_NEW(statusbar->b_layer, "*Current Layer*", ACTION_LAYER);
+ statusbar->slider = jslider_new(0, 255, 255);
+ ICON_NEW(statusbar->b_first, GFX_ANI_FIRST, ACTION_FIRST);
+ ICON_NEW(statusbar->b_prev, GFX_ANI_PREV, ACTION_PREV);
+ ICON_NEW(statusbar->b_play, GFX_ANI_PLAY, ACTION_PLAY);
+ ICON_NEW(statusbar->b_next, GFX_ANI_NEXT, ACTION_NEXT);
+ ICON_NEW(statusbar->b_last, GFX_ANI_LAST, ACTION_LAST);
- HOOK(status_bar->slider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
- jwidget_set_min_size(status_bar->slider, JI_SCREEN_W/5, 0);
+ HOOK(statusbar->slider, JI_SIGNAL_SLIDER_CHANGE, slider_change_signal, 0);
+ jwidget_set_min_size(statusbar->slider, JI_SCREEN_W/5, 0);
jwidget_noborders(box1);
jwidget_noborders(box2);
- jwidget_expansive(status_bar->b_layer, TRUE);
- jwidget_add_child(box1, status_bar->b_layer);
- jwidget_add_child(box1, status_bar->slider);
- jwidget_add_child(box2, status_bar->b_first);
- jwidget_add_child(box2, status_bar->b_prev);
- jwidget_add_child(box2, status_bar->b_play);
- jwidget_add_child(box2, status_bar->b_next);
- jwidget_add_child(box2, status_bar->b_last);
+ jwidget_expansive(statusbar->b_layer, TRUE);
+ jwidget_add_child(box1, statusbar->b_layer);
+ jwidget_add_child(box1, statusbar->slider);
+ jwidget_add_child(box2, statusbar->b_first);
+ jwidget_add_child(box2, statusbar->b_prev);
+ jwidget_add_child(box2, statusbar->b_play);
+ jwidget_add_child(box2, statusbar->b_next);
+ jwidget_add_child(box2, statusbar->b_last);
jwidget_add_child(box1, box2);
- status_bar->commands_box = box1;
+ statusbar->commands_box = box1;
}
return widget;
}
-int status_bar_type(void)
+int statusbar_type(void)
{
static int type = 0;
if (!type)
@@ -121,16 +121,16 @@ int status_bar_type(void)
return type;
}
-StatusBar *status_bar_data(JWidget widget)
+StatusBar *statusbar_data(JWidget widget)
{
- return jwidget_get_data(widget, status_bar_type());
+ return jwidget_get_data(widget, statusbar_type());
}
-void status_bar_set_text(JWidget widget, int msecs, const char *format, ...)
+void statusbar_set_text(JWidget widget, int msecs, const char *format, ...)
{
- StatusBar *status_bar = status_bar_data(widget);
+ StatusBar *statusbar = statusbar_data(widget);
- if ((ji_clock > status_bar->timeout) || (msecs > 0)) {
+ if ((ji_clock > statusbar->timeout) || (msecs > 0)) {
char buf[256];
va_list ap;
@@ -142,39 +142,46 @@ void status_bar_set_text(JWidget widget, int msecs, const char *format, ...)
jfree(widget->text);
widget->text = buf ? jstrdup(buf) : NULL;
- status_bar->timeout = ji_clock + msecs;
+ statusbar->timeout = ji_clock + msecs;
jwidget_dirty(widget);
}
}
-void status_bar_update(JWidget widget)
+void statusbar_show_color(JWidget statusbar, int msecs, int imgtype, color_t color)
{
- StatusBar *status_bar = status_bar_data(widget);
-
- update_from_layer(status_bar);
+ char buf[128];
+ color_to_formalstring(imgtype, color, buf, sizeof(buf), TRUE);
+ statusbar_set_text(statusbar, msecs, "%s %s", _("Color"), buf);
}
-Progress *progress_new(JWidget status_bar)
+void statusbar_update(JWidget widget)
+{
+ StatusBar *statusbar = statusbar_data(widget);
+
+ update_from_layer(statusbar);
+}
+
+Progress *progress_new(JWidget statusbar)
{
Progress *progress = jnew(Progress, 1);
if (!progress)
return NULL;
- progress->status_bar = status_bar;
+ progress->statusbar = statusbar;
progress->pos = 0.0f;
- jlist_append(status_bar_data(status_bar)->progress,
+ jlist_append(statusbar_data(statusbar)->progress,
progress);
- jwidget_dirty(status_bar);
+ jwidget_dirty(statusbar);
return progress;
}
void progress_free(Progress *progress)
{
- jlist_remove(status_bar_data(progress->status_bar)->progress,
+ jlist_remove(statusbar_data(progress->statusbar)->progress,
progress);
- jwidget_dirty(progress->status_bar);
+ jwidget_dirty(progress->statusbar);
jfree(progress);
}
@@ -183,42 +190,42 @@ void progress_update(Progress *progress, float progress_pos)
{
if (progress->pos != progress_pos) {
progress->pos = progress_pos;
- jwidget_dirty(progress->status_bar);
+ jwidget_dirty(progress->statusbar);
}
}
-static bool status_bar_msg_proc(JWidget widget, JMessage msg)
+static bool statusbar_msg_proc(JWidget widget, JMessage msg)
{
- StatusBar *status_bar = status_bar_data(widget);
+ StatusBar *statusbar = statusbar_data(widget);
switch (msg->type) {
case JM_DESTROY: {
JLink link;
- JI_LIST_FOR_EACH(status_bar->progress, link) {
+ JI_LIST_FOR_EACH(statusbar->progress, link) {
jfree(link->data);
}
- jlist_free(status_bar->progress);
+ jlist_free(statusbar->progress);
- jfree(status_bar);
+ jfree(statusbar);
break;
}
case JM_REQSIZE:
- msg->reqsize.w = msg->reqsize.h =
- 2 + jwidget_get_text_height(widget) + 2;
+ msg->reqsize.w =
+ msg->reqsize.h = 2 + jwidget_get_text_height(widget) + 2;
return TRUE;
case JM_SETPOS:
jrect_copy(widget->rc, &msg->setpos.rect);
- jwidget_set_rect(status_bar->commands_box, widget->rc);
+ jwidget_set_rect(statusbar->commands_box, widget->rc);
return TRUE;
case JM_CLOSE:
- if (!jwidget_has_child(widget, status_bar->commands_box)) {
+ if (!jwidget_has_child(widget, statusbar->commands_box)) {
/* append the "commands_box" to destroy it in the jwidget_free */
- jwidget_add_child(widget, status_bar->commands_box);
+ jwidget_add_child(widget, statusbar->commands_box);
}
break;
@@ -243,7 +250,7 @@ static bool status_bar_msg_proc(JWidget widget, JMessage msg)
}
/* draw progress bar */
- if (!jlist_empty(status_bar->progress)) {
+ if (!jlist_empty(statusbar->progress)) {
int width = 64;
int y1, y2;
int x = rc->x2 - (width+4);
@@ -252,7 +259,7 @@ static bool status_bar_msg_proc(JWidget widget, JMessage msg)
y1 = rc->y1;
y2 = rc->y2-1;
- JI_LIST_FOR_EACH(status_bar->progress, link) {
+ JI_LIST_FOR_EACH(statusbar->progress, link) {
Progress *progress = link->data;
int u = (int)((float)(width-2)*progress->pos);
u = MID(0, u, width-2);
@@ -274,40 +281,40 @@ static bool status_bar_msg_proc(JWidget widget, JMessage msg)
}
case JM_MOUSEENTER:
- if (!jwidget_has_child(widget, status_bar->commands_box)) {
+ if (!jwidget_has_child(widget, statusbar->commands_box)) {
Sprite *sprite = current_sprite;
if (!sprite) {
- jwidget_disable(status_bar->b_first);
- jwidget_disable(status_bar->b_prev);
- jwidget_disable(status_bar->b_play);
- jwidget_disable(status_bar->b_next);
- jwidget_disable(status_bar->b_last);
+ jwidget_disable(statusbar->b_first);
+ jwidget_disable(statusbar->b_prev);
+ jwidget_disable(statusbar->b_play);
+ jwidget_disable(statusbar->b_next);
+ jwidget_disable(statusbar->b_last);
}
else {
- jwidget_enable(status_bar->b_first);
- jwidget_enable(status_bar->b_prev);
- jwidget_enable(status_bar->b_play);
- jwidget_enable(status_bar->b_next);
- jwidget_enable(status_bar->b_last);
+ jwidget_enable(statusbar->b_first);
+ jwidget_enable(statusbar->b_prev);
+ jwidget_enable(statusbar->b_play);
+ jwidget_enable(statusbar->b_next);
+ jwidget_enable(statusbar->b_last);
}
- update_from_layer(status_bar);
+ update_from_layer(statusbar);
- jwidget_add_child(widget, status_bar->commands_box);
+ jwidget_add_child(widget, statusbar->commands_box);
jwidget_dirty(widget);
}
break;
case JM_MOUSELEAVE:
- if (jwidget_has_child(widget, status_bar->commands_box)) {
+ if (jwidget_has_child(widget, statusbar->commands_box)) {
/* if we want restore the state-bar and the slider doesn't have
the capture... */
- if (jmanager_get_capture() != status_bar->slider) {
+ if (jmanager_get_capture() != statusbar->slider) {
/* exit from command mode */
jmanager_free_focus();
- jwidget_remove_child(widget, status_bar->commands_box);
+ jwidget_remove_child(widget, statusbar->commands_box);
jwidget_dirty(widget);
}
}
@@ -378,7 +385,7 @@ static void button_command(JWidget widget, void *data)
}
}
-static void update_from_layer(StatusBar *status_bar)
+static void update_from_layer(StatusBar *statusbar)
{
Sprite *sprite = current_sprite;
Cel *cel;
@@ -387,23 +394,23 @@ static void update_from_layer(StatusBar *status_bar)
if (sprite && sprite->layer) {
char buf[512];
usprintf(buf, "[%d] %s", sprite->frame, sprite->layer->name);
- jwidget_set_text(status_bar->b_layer, buf);
- jwidget_enable(status_bar->b_layer);
+ jwidget_set_text(statusbar->b_layer, buf);
+ jwidget_enable(statusbar->b_layer);
}
else {
- jwidget_set_text(status_bar->b_layer, "Nothing");
- jwidget_disable(status_bar->b_layer);
+ jwidget_set_text(statusbar->b_layer, "Nothing");
+ jwidget_disable(statusbar->b_layer);
}
/* opacity layer */
if (sprite && sprite->layer &&
sprite->layer->gfxobj.type == GFXOBJ_LAYER_IMAGE &&
(cel = layer_get_cel(sprite->layer, sprite->frame))) {
- jslider_set_value(status_bar->slider, MID(0, cel->opacity, 255));
- jwidget_enable(status_bar->slider);
+ jslider_set_value(statusbar->slider, MID(0, cel->opacity, 255));
+ jwidget_enable(statusbar->slider);
}
else {
- jslider_set_value(status_bar->slider, 0);
- jwidget_disable(status_bar->slider);
+ jslider_set_value(statusbar->slider, 0);
+ jwidget_disable(statusbar->slider);
}
}
diff --git a/src/widgets/statebar.h b/src/widgets/statebar.h
index ffa443c66..008dbfa60 100644
--- a/src/widgets/statebar.h
+++ b/src/widgets/statebar.h
@@ -21,9 +21,11 @@
#include "jinete/jbase.h"
+#include "modules/color.h"
+
typedef struct Progress
{
- JWidget status_bar;
+ JWidget statusbar;
float pos;
} Progress;
@@ -46,19 +48,20 @@ typedef struct StatusBar
JWidget b_last; /* go to last frame */
} StatusBar;
-/* status_bar */
+/* statusbar */
-JWidget status_bar_new(void);
-int status_bar_type(void);
+JWidget statusbar_new(void);
+int statusbar_type(void);
-StatusBar *status_bar_data(JWidget status_bar);
+StatusBar *statusbar_data(JWidget statusbar);
-void status_bar_set_text(JWidget status_bar, int msecs, const char *format, ...);
-void status_bar_update(JWidget status_bar);
+void statusbar_set_text(JWidget statusbar, int msecs, const char *format, ...);
+void statusbar_show_color(JWidget statusbar, int msecs, int imgtype, color_t color);
+void statusbar_update(JWidget statusbar);
/* progress */
-Progress *progress_new(JWidget status_bar);
+Progress *progress_new(JWidget statusbar);
void progress_free(Progress *progress);
void progress_update(Progress *progress, float progress_pos);
diff --git a/src/widgets/tabs.c b/src/widgets/tabs.c
index 7412c2520..06f64ee62 100644
--- a/src/widgets/tabs.c
+++ b/src/widgets/tabs.c
@@ -46,7 +46,7 @@ typedef struct Tabs
JList list_of_tabs;
Tab *hot;
Tab *selected;
- void (*select_callback)(void *data);
+ void (*select_callback)(JWidget tabs, void *data);
int timer_id;
int scroll_x;
/* int hot_arrow; */
@@ -72,7 +72,7 @@ static void tab_free(Tab *tab);
/* Tabs */
/**************************************************************/
-JWidget tabs_new(void (*select_callback)(void *data))
+JWidget tabs_new(void (*select_callback)(JWidget tabs, void *data))
{
JWidget widget = jwidget_new(tabs_type());
Tabs *tabs = jnew0(Tabs, 1);
@@ -101,6 +101,8 @@ JWidget tabs_new(void (*select_callback)(void *data))
jwidget_add_hook(tabs->button_left, tabs_type(), tabs_button_msg_proc, (void *)-1);
jwidget_add_hook(tabs->button_right, tabs_type(), tabs_button_msg_proc, (void *)+1);
+ jwidget_set_bg_color(widget, ji_color_face());
+
return widget;
}
@@ -161,13 +163,23 @@ void tabs_select_tab(JWidget widget, void *data)
Tabs *tabs = jwidget_get_data(widget, tabs_type());
Tab *tab = get_tab_by_data(widget, data);
- if (tab) {
+ if (tab != NULL) {
tabs->selected = tab;
make_tab_visible(widget, tab);
jwidget_dirty(widget);
}
}
+void *tabs_get_selected_tab(JWidget widget)
+{
+ Tabs *tabs = jwidget_get_data(widget, tabs_type());
+
+ if (tabs->selected != NULL)
+ return tabs->selected->data;
+ else
+ return NULL;
+}
+
static int tabs_type(void)
{
static int type = 0;
@@ -241,7 +253,7 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
bottom = ji_color_facelight();
}
- hline(ji_screen, box->x1, box->y1, box->x2-1, ji_color_face());
+ hline(ji_screen, box->x1, box->y1, box->x2-1, widget->bg_color);
rectfill(ji_screen, box->x1+1, box->y1+1, box->x2-2, box->y2-1, face);
hline(ji_screen, box->x1, rect->y2-1, box->x2-1, ji_color_selected());
@@ -262,7 +274,7 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
/* fill the gap to the right-side */
if (box->x1 < rect->x2) {
rectfill(ji_screen, box->x1, rect->y1, rect->x2-1, rect->y2-3,
- ji_color_face());
+ widget->bg_color);
hline(ji_screen, box->x1, rect->y2-2, rect->x2-1, ji_color_facelight());
hline(ji_screen, box->x1, rect->y2-1, rect->x2-1, ji_color_selected());
}
@@ -296,7 +308,7 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
jwidget_dirty(widget);
if (tabs->selected && tabs->select_callback)
- (*tabs->select_callback)(tabs->selected->data);
+ (*tabs->select_callback)(widget, tabs->selected->data);
}
return TRUE;
@@ -315,6 +327,17 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
break;
}
+ case JM_SIGNAL:
+ if (msg->signal.num == JI_SIGNAL_SET_FONT) {
+ JLink link;
+
+ JI_LIST_FOR_EACH(tabs->list_of_tabs, link) {
+ Tab *tab = link->data;
+ tab->width = CALC_TAB_WIDTH(widget, tab);
+ }
+ }
+ break;
+
}
return FALSE;
@@ -426,14 +449,7 @@ static void set_scroll_x(JWidget widget, int scroll_x)
jwidget_dirty(widget);
}
- PRINTF("max_x = %d\n", max_x);
- PRINTF("widget->rc->x1 = %d\n", widget->rc->x1);
- PRINTF("widget->rc->y1 = %d\n", widget->rc->y1);
- PRINTF("widget->rc->x2 = %d\n", widget->rc->x2);
- PRINTF("widget->rc->y2 = %d\n", widget->rc->y2);
-
/* we need scroll buttons? */
-/* if (max_x > 0 && widget->rc->x2 > 0) { */
if (max_x > 0) {
/* add childs */
if (!HAS_ARROWS) {
diff --git a/src/widgets/tabs.h b/src/widgets/tabs.h
index 3d2224ef6..6df077556 100644
--- a/src/widgets/tabs.h
+++ b/src/widgets/tabs.h
@@ -21,7 +21,7 @@
#include "jinete/jbase.h"
-JWidget tabs_new(void (*select_callback)(void *data));
+JWidget tabs_new(void (*select_callback)(JWidget tabs, void *data));
void tabs_append_tab(JWidget widget, const char *text, void *data);
void tabs_remove_tab(JWidget widget, void *data);
@@ -29,5 +29,6 @@ void tabs_remove_tab(JWidget widget, void *data);
void tabs_set_text_for_tab(JWidget widget, const char *text, void *data);
void tabs_select_tab(JWidget widget, void *data);
+void *tabs_get_selected_tab(JWidget widget);
#endif /* WIDGETS_TABS_H */
diff --git a/src/widgets/toolbar.c b/src/widgets/toolbar.c
index a21560e68..700277c71 100644
--- a/src/widgets/toolbar.c
+++ b/src/widgets/toolbar.c
@@ -34,7 +34,7 @@
static int group_change_signal(JWidget widget, int user_data);
static void conf_command(JWidget widget);
-JWidget tool_bar_new(int align)
+JWidget toolbar_new(int align)
{
#define ICONS_LIST \
GFX_TOOL_MARKER, \
@@ -87,7 +87,7 @@ JWidget tool_bar_new(int align)
return box;
}
-void tool_bar_update(JWidget widget)
+void toolbar_update(JWidget widget)
{
JWidget group = widget->user_data[0];
int c;
diff --git a/src/widgets/toolbar.h b/src/widgets/toolbar.h
index 17c45314c..0bc09d482 100644
--- a/src/widgets/toolbar.h
+++ b/src/widgets/toolbar.h
@@ -21,8 +21,8 @@
#include "jinete/jbase.h"
-JWidget tool_bar_new(int align);
+JWidget toolbar_new(int align);
-void tool_bar_update(JWidget toolbar);
+void toolbar_update(JWidget toolbar);
#endif /* WIDGETS_TOOLBAR_H */