Update the 'release' branch

git-svn-id: svn://pulkomandy.tk/GrafX2/branches/release@1027 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-09-12 15:20:05 +00:00
commit 4ec373dba6
92 changed files with 26985 additions and 23640 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -12,6 +12,12 @@
002F3A2E09D0888800EBEB88 /* SDLMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A2C09D0888800EBEB88 /* SDLMain.m */; }; 002F3A2E09D0888800EBEB88 /* SDLMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A2C09D0888800EBEB88 /* SDLMain.m */; };
002F3A3F09D088BA00EBEB88 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A3E09D088BA00EBEB88 /* main.c */; }; 002F3A3F09D088BA00EBEB88 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A3E09D088BA00EBEB88 /* main.c */; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
F5142653101F6CC5006CF3C4 /* font_Classic.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F514264D101F6CB8006CF3C4 /* font_Classic.png */; };
F5142654101F6CC5006CF3C4 /* font_Fairlight.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F514264E101F6CB8006CF3C4 /* font_Fairlight.png */; };
F5142655101F6CC5006CF3C4 /* font_Fun.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F514264F101F6CB9006CF3C4 /* font_Fun.png */; };
F5142656101F6CC5006CF3C4 /* font_Melon.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F5142650101F6CB9006CF3C4 /* font_Melon.png */; };
F5142657101F6CC5006CF3C4 /* skin_classic.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F5142651101F6CB9006CF3C4 /* skin_classic.png */; };
F5142658101F6CC5006CF3C4 /* skin_modern.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F5142652101F6CB9006CF3C4 /* skin_modern.png */; };
F51CBD2E0EC8A3E1005C06AC /* 5pxtinyfont.png in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */; }; F51CBD2E0EC8A3E1005C06AC /* 5pxtinyfont.png in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */; };
F51CBD2F0EC8A3E1005C06AC /* colorfont.pcx in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2C0EC8A3E1005C06AC /* colorfont.pcx */; }; F51CBD2F0EC8A3E1005C06AC /* colorfont.pcx in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2C0EC8A3E1005C06AC /* colorfont.pcx */; };
F51CBD300EC8A3E1005C06AC /* Tuffy.ttf in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2D0EC8A3E1005C06AC /* Tuffy.ttf */; }; F51CBD300EC8A3E1005C06AC /* Tuffy.ttf in Copy fonts */ = {isa = PBXBuildFile; fileRef = F51CBD2D0EC8A3E1005C06AC /* Tuffy.ttf */; };
@ -52,8 +58,6 @@
F5B19BA30EA4BE3E003F4BA4 /* shade.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8B0EA4BE3E003F4BA4 /* shade.c */; }; F5B19BA30EA4BE3E003F4BA4 /* shade.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8B0EA4BE3E003F4BA4 /* shade.c */; };
F5B19BA40EA4BE3E003F4BA4 /* special.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8C0EA4BE3E003F4BA4 /* special.c */; }; F5B19BA40EA4BE3E003F4BA4 /* special.c in Sources */ = {isa = PBXBuildFile; fileRef = F5B19B8C0EA4BE3E003F4BA4 /* special.c */; };
F5B19BE10EA4C65A003F4BA4 /* gfx2.cfg in Resources */ = {isa = PBXBuildFile; fileRef = F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */; }; F5B19BE10EA4C65A003F4BA4 /* gfx2.cfg in Resources */ = {isa = PBXBuildFile; fileRef = F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */; };
F5B19BE10EA4C65A003F4BA5 /* base.gif in Copy skins */ = {isa = PBXBuildFile; fileRef = F5B19BDF0EA4C65A003F4BA5 /* base.gif */; };
F5B19BE10EA4C65A003F4BA6 /* ilkke.png in Copy skins */ = {isa = PBXBuildFile; fileRef = F5B19BDF0EA4C65A003F4BA6 /* ilkke.png */; };
F5B19C1D0EA4D71C003F4BA4 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */; }; F5B19C1D0EA4D71C003F4BA4 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */; };
F5B19C3D0EA4DC91003F4BA4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */; }; F5B19C3D0EA4DC91003F4BA4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */; };
F5B1EE850EAD0F4E00B087B5 /* gfx2def.ini in Resources */ = {isa = PBXBuildFile; fileRef = F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */; }; F5B1EE850EAD0F4E00B087B5 /* gfx2def.ini in Resources */ = {isa = PBXBuildFile; fileRef = F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */; };
@ -104,6 +108,22 @@
name = "Copy Frameworks into .app bundle"; name = "Copy Frameworks into .app bundle";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
F514264B101F6C5B006CF3C4 /* Copy skins */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = skins;
dstSubfolderSpec = 7;
files = (
F5142653101F6CC5006CF3C4 /* font_Classic.png in Copy skins */,
F5142654101F6CC5006CF3C4 /* font_Fairlight.png in Copy skins */,
F5142655101F6CC5006CF3C4 /* font_Fun.png in Copy skins */,
F5142656101F6CC5006CF3C4 /* font_Melon.png in Copy skins */,
F5142657101F6CC5006CF3C4 /* skin_classic.png in Copy skins */,
F5142658101F6CC5006CF3C4 /* skin_modern.png in Copy skins */,
);
name = "Copy skins";
runOnlyForDeploymentPostprocessing = 0;
};
F5A33F1D0EC8A26C00F8052D /* Copy fonts */ = { F5A33F1D0EC8A26C00F8052D /* Copy fonts */ = {
isa = PBXCopyFilesBuildPhase; isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -119,18 +139,6 @@
name = "Copy fonts"; name = "Copy fonts";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
F5A33F1D0EC8A26C00F8052E /* Copy skins */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = skins;
dstSubfolderSpec = 7;
files = (
F5B19BE10EA4C65A003F4BA5 /* base.gif in Copy skins */,
F5B19BE10EA4C65A003F4BA6 /* ilkke.png in Copy skins */,
);
name = "Copy skins";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -145,6 +153,12 @@
32CA4F630368D1EE00C91783 /* Grafx2_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Grafx2_Prefix.pch; sourceTree = "<group>"; }; 32CA4F630368D1EE00C91783 /* Grafx2_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Grafx2_Prefix.pch; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* Grafx2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Grafx2.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8D1107320486CEB800E47090 /* Grafx2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Grafx2.app; sourceTree = BUILT_PRODUCTS_DIR; };
F514264D101F6CB8006CF3C4 /* font_Classic.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = font_Classic.png; path = skins/font_Classic.png; sourceTree = "<group>"; };
F514264E101F6CB8006CF3C4 /* font_Fairlight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = font_Fairlight.png; path = skins/font_Fairlight.png; sourceTree = "<group>"; };
F514264F101F6CB9006CF3C4 /* font_Fun.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = font_Fun.png; path = skins/font_Fun.png; sourceTree = "<group>"; };
F5142650101F6CB9006CF3C4 /* font_Melon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = font_Melon.png; path = skins/font_Melon.png; sourceTree = "<group>"; };
F5142651101F6CB9006CF3C4 /* skin_classic.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = skin_classic.png; path = skins/skin_classic.png; sourceTree = "<group>"; };
F5142652101F6CB9006CF3C4 /* skin_modern.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = skin_modern.png; path = skins/skin_modern.png; sourceTree = "<group>"; };
F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = 5pxtinyfont.png; path = fonts/5pxtinyfont.png; sourceTree = "<group>"; }; F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = 5pxtinyfont.png; path = fonts/5pxtinyfont.png; sourceTree = "<group>"; };
F51CBD2C0EC8A3E1005C06AC /* colorfont.pcx */ = {isa = PBXFileReference; lastKnownFileType = file; name = colorfont.pcx; path = fonts/colorfont.pcx; sourceTree = "<group>"; }; F51CBD2C0EC8A3E1005C06AC /* colorfont.pcx */ = {isa = PBXFileReference; lastKnownFileType = file; name = colorfont.pcx; path = fonts/colorfont.pcx; sourceTree = "<group>"; };
F51CBD2D0EC8A3E1005C06AC /* Tuffy.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = Tuffy.ttf; path = fonts/Tuffy.ttf; sourceTree = "<group>"; }; F51CBD2D0EC8A3E1005C06AC /* Tuffy.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = Tuffy.ttf; path = fonts/Tuffy.ttf; sourceTree = "<group>"; };
@ -186,8 +200,6 @@
F5B19B8B0EA4BE3E003F4BA4 /* shade.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = shade.c; sourceTree = "<group>"; }; F5B19B8B0EA4BE3E003F4BA4 /* shade.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = shade.c; sourceTree = "<group>"; };
F5B19B8C0EA4BE3E003F4BA4 /* special.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = special.c; sourceTree = "<group>"; }; F5B19B8C0EA4BE3E003F4BA4 /* special.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = special.c; sourceTree = "<group>"; };
F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gfx2.cfg; sourceTree = "<group>"; }; F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gfx2.cfg; sourceTree = "<group>"; };
F5B19BDF0EA4C65A003F4BA5 /* base.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = base.gif; path = skins/base.gif; sourceTree = "<group>"; };
F5B19BDF0EA4C65A003F4BA6 /* ilkke.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ilkke.png; path = skins/ilkke.png; sourceTree = "<group>"; };
F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = SYSTEM_DEVELOPER_DIR; }; F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = SYSTEM_DEVELOPER_DIR; };
F5B19C3C0EA4DC91003F4BA4 /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; F5B19C3C0EA4DC91003F4BA4 /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = gfx2def.ini; sourceTree = "<group>"; }; F5B1EE840EAD0F4E00B087B5 /* gfx2def.ini */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = gfx2def.ini; sourceTree = "<group>"; };
@ -260,6 +272,12 @@
29B97314FDCFA39411CA2CEA /* Grafx2 */ = { 29B97314FDCFA39411CA2CEA /* Grafx2 */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F514264D101F6CB8006CF3C4 /* font_Classic.png */,
F514264E101F6CB8006CF3C4 /* font_Fairlight.png */,
F514264F101F6CB9006CF3C4 /* font_Fun.png */,
F5142650101F6CB9006CF3C4 /* font_Melon.png */,
F5142651101F6CB9006CF3C4 /* skin_classic.png */,
F5142652101F6CB9006CF3C4 /* skin_modern.png */,
F539315D0FE171C3003CB103 /* pversion.c */, F539315D0FE171C3003CB103 /* pversion.c */,
F5CDCE310F6EA6D600B31F63 /* pxdouble.c */, F5CDCE310F6EA6D600B31F63 /* pxdouble.c */,
F5AC28B90F4873C700455509 /* hotkeys.c */, F5AC28B90F4873C700455509 /* hotkeys.c */,
@ -294,8 +312,6 @@
F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */, F5B19C3B0EA4DC91003F4BA4 /* InfoPlist.strings */,
F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */, F5B19C1C0EA4D71C003F4BA4 /* CoreFoundation.framework */,
F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */, F5B19BDF0EA4C65A003F4BA4 /* gfx2.cfg */,
F5B19BDF0EA4C65A003F4BA5 /* base.gif */,
F5B19BDF0EA4C65A003F4BA6 /* ilkke.png */,
F5B19B7B0EA4BE3E003F4BA4 /* graph.c */, F5B19B7B0EA4BE3E003F4BA4 /* graph.c */,
F5B19B7C0EA4BE3E003F4BA4 /* init.c */, F5B19B7C0EA4BE3E003F4BA4 /* init.c */,
F5B19B7D0EA4BE3E003F4BA4 /* io.c */, F5B19B7D0EA4BE3E003F4BA4 /* io.c */,
@ -366,7 +382,7 @@
002F39FD09D0883400EBEB89 /* Copy Frameworks into .app bundle */, 002F39FD09D0883400EBEB89 /* Copy Frameworks into .app bundle */,
002F39FD09D0883400EBEB8A /* Copy Frameworks into .app bundle */, 002F39FD09D0883400EBEB8A /* Copy Frameworks into .app bundle */,
F5A33F1D0EC8A26C00F8052D /* Copy fonts */, F5A33F1D0EC8A26C00F8052D /* Copy fonts */,
F5A33F1D0EC8A26C00F8052E /* Copy skins */, F514264B101F6C5B006CF3C4 /* Copy skins */,
); );
buildRules = ( buildRules = (
); );

View File

@ -18,9 +18,9 @@
}; };
002F3A3E09D088BA00EBEB88 /* main.c */ = { 002F3A3E09D088BA00EBEB88 /* main.c */ = {
uiCtxt = { uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1060, 11476}}"; sepNavIntBoundsRect = "{{0, 0}, {1044, 15086}}";
sepNavSelRange = "{0, 0}"; sepNavSelRange = "{19535, 0}";
sepNavVisRect = "{{0, 0}, {867, 536}}"; sepNavVisRect = "{{0, 10961}, {867, 536}}";
sepNavWindowFrame = "{{14, 76}, {906, 665}}"; sepNavWindowFrame = "{{14, 76}, {906, 665}}";
}; };
}; };
@ -29,7 +29,6 @@
activeExecutable = F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */; activeExecutable = F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */;
activeTarget = 8D1107260486CEB800E47090 /* Grafx2 */; activeTarget = 8D1107260486CEB800E47090 /* Grafx2 */;
addToTargets = ( addToTargets = (
8D1107260486CEB800E47090 /* Grafx2 */,
); );
breakpointsGroup = F5B19B700EA4BDA9003F4BA4 /* XCBreakpointsBucket */; breakpointsGroup = F5B19B700EA4BDA9003F4BA4 /* XCBreakpointsBucket */;
codeSenseManager = F5B19B6A0EA4BD79003F4BA4 /* Code sense */; codeSenseManager = F5B19B6A0EA4BD79003F4BA4 /* Code sense */;
@ -70,14 +69,15 @@
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Built_ColumnID; PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Built_ColumnID;
PBXFileTableDataSourceColumnWidthsKey = ( PBXFileTableDataSourceColumnWidthsKey = (
20, 20,
229, 99,
20, 20,
48, 48,
43, 43,
43, 43,
20, 20,
79, 264,
88, 10,
20,
); );
PBXFileTableDataSourceColumnsKey = ( PBXFileTableDataSourceColumnsKey = (
PBXFileDataSource_FiletypeID, PBXFileDataSource_FiletypeID,
@ -89,6 +89,7 @@
PBXFileDataSource_Target_ColumnID, PBXFileDataSource_Target_ColumnID,
PBXFileDataSource_Path_ColumnID, PBXFileDataSource_Path_ColumnID,
PBXFileDataSource_Comments_ColumnID, PBXFileDataSource_Comments_ColumnID,
PBXFileDataSource_SCM_ColumnID,
); );
}; };
PBXConfiguration.PBXFileTableDataSource3.PBXFindDataSource = { PBXConfiguration.PBXFileTableDataSource3.PBXFindDataSource = {
@ -165,8 +166,8 @@
PBXFileDataSource_Warnings_ColumnID, PBXFileDataSource_Warnings_ColumnID,
); );
}; };
PBXPerProjectTemplateStateSaveDate = 266433807; PBXPerProjectTemplateStateSaveDate = 270495112;
PBXWorkspaceStateSaveDate = 266433807; PBXWorkspaceStateSaveDate = 270495112;
}; };
sourceControlManager = F5B19B690EA4BD79003F4BA4 /* Source Control */; sourceControlManager = F5B19B690EA4BD79003F4BA4 /* Source Control */;
userBuildSettings = { userBuildSettings = {
@ -187,6 +188,11 @@
F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */, F5B19B5D0EA4BD57003F4BA4 /* Grafx2 */,
); );
}; };
F51CBD2B0EC8A3E1005C06AC /* 5pxtinyfont.png */ = {
uiCtxt = {
sepNavWindowFrame = "{{15, 25}, {971, 716}}";
};
};
F5A33E690EC893F800F8052D /* 8pxfont.png */ = { F5A33E690EC893F800F8052D /* 8pxfont.png */ = {
uiCtxt = { uiCtxt = {
sepNavWindowFrame = "{{15, 76}, {906, 665}}"; sepNavWindowFrame = "{{15, 76}, {906, 665}}";
@ -256,10 +262,10 @@
}; };
F5B19B7B0EA4BE3E003F4BA4 /* graph.c */ = { F5B19B7B0EA4BE3E003F4BA4 /* graph.c */ = {
uiCtxt = { uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1620, 118579}}"; sepNavIntBoundsRect = "{{0, 0}, {1140, 52782}}";
sepNavSelRange = "{16112, 36}"; sepNavSelRange = "{6769, 0}";
sepNavVisRect = "{{0, 9964}, {867, 536}}"; sepNavVisRect = "{{0, 0}, {867, 536}}";
sepNavWindowFrame = "{{15, 76}, {906, 665}}"; sepNavWindowFrame = "{{14, 76}, {906, 665}}";
}; };
}; };
F5B19B7C0EA4BE3E003F4BA4 /* init.c */ = { F5B19B7C0EA4BE3E003F4BA4 /* init.c */ = {
@ -296,10 +302,10 @@
}; };
F5B19B890EA4BE3E003F4BA4 /* sdlscreen.c */ = { F5B19B890EA4BE3E003F4BA4 /* sdlscreen.c */ = {
uiCtxt = { uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1580, 11571}}"; sepNavIntBoundsRect = "{{0, 0}, {1396, 4351}}";
sepNavSelRange = "{0, 0}"; sepNavSelRange = "{2375, 0}";
sepNavVisRect = "{{0, 0}, {867, 536}}"; sepNavVisRect = "{{0, 1072}, {867, 536}}";
sepNavWindowFrame = "{{61, 34}, {906, 665}}"; sepNavWindowFrame = "{{35, 15}, {906, 665}}";
}; };
}; };
F5B19C3C0EA4DC91003F4BA4 /* English */ = { F5B19C3C0EA4DC91003F4BA4 /* English */ = {

View File

@ -188,9 +188,9 @@
<array/> <array/>
<key>PerspectiveWidths</key> <key>PerspectiveWidths</key>
<array> <array>
<integer>970</integer> <integer>971</integer>
<integer>970</integer> <integer>971</integer>
<integer>970</integer> <integer>971</integer>
</array> </array>
<key>Perspectives</key> <key>Perspectives</key>
<array> <array>
@ -247,7 +247,7 @@
<dict> <dict>
<key>PBXSmartGroupTreeModuleColumnWidthsKey</key> <key>PBXSmartGroupTreeModuleColumnWidthsKey</key>
<array> <array>
<real>305</real> <real>345</real>
</array> </array>
<key>PBXSmartGroupTreeModuleColumnsKey_v4</key> <key>PBXSmartGroupTreeModuleColumnsKey_v4</key>
<array> <array>
@ -259,7 +259,10 @@
<key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key> <key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key>
<array> <array>
<string>29B97314FDCFA39411CA2CEA</string> <string>29B97314FDCFA39411CA2CEA</string>
<string>29B97317FDCFA39411CA2CEA</string>
<string>1C37FBAC04509CD000000102</string> <string>1C37FBAC04509CD000000102</string>
<string>F56B73F7101F6D9500B6D9A4</string>
<string>F56B7443101FA1C600B6D9A4</string>
</array> </array>
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key> <key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array> <array>
@ -268,7 +271,7 @@
</array> </array>
</array> </array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key> <key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 124}, {305, 575}}</string> <string>{{0, 0}, {345, 600}}</string>
</dict> </dict>
<key>PBXTopSmartGroupGIDs</key> <key>PBXTopSmartGroupGIDs</key>
<array/> <array/>
@ -278,17 +281,17 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{0, 0}, {322, 593}}</string> <string>{{0, 0}, {362, 618}}</string>
<key>GroupTreeTableConfiguration</key> <key>GroupTreeTableConfiguration</key>
<array> <array>
<string>MainColumn</string> <string>MainColumn</string>
<real>305</real> <real>345</real>
</array> </array>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXSmartGroupTreeModule</string> <string>PBXSmartGroupTreeModule</string>
<key>Proportion</key> <key>Proportion</key>
<string>322pt</string> <string>362pt</string>
</dict> </dict>
<dict> <dict>
<key>Dock</key> <key>Dock</key>
@ -299,7 +302,7 @@
<key>PBXProjectModuleGUID</key> <key>PBXProjectModuleGUID</key>
<string>F5A33EBD0EC89C3000F8052D</string> <string>F5A33EBD0EC89C3000F8052D</string>
<key>PBXProjectModuleLabel</key> <key>PBXProjectModuleLabel</key>
<string>asm pthread_mutex_lock 0x90001a38</string> <string></string>
<key>PBXSplitModuleInNavigatorKey</key> <key>PBXSplitModuleInNavigatorKey</key>
<dict> <dict>
<key>Split0</key> <key>Split0</key>
@ -307,7 +310,7 @@
<key>PBXProjectModuleGUID</key> <key>PBXProjectModuleGUID</key>
<string>F5A33EBE0EC89C3000F8052D</string> <string>F5A33EBE0EC89C3000F8052D</string>
<key>PBXProjectModuleLabel</key> <key>PBXProjectModuleLabel</key>
<string>asm pthread_mutex_lock 0x90001a38</string> <string></string>
</dict> </dict>
<key>SplitCount</key> <key>SplitCount</key>
<string>1</string> <string>1</string>
@ -320,7 +323,7 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{0, 0}, {643, 0}}</string> <string>{{0, 0}, {604, 0}}</string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXNavigatorGroup</string> <string>PBXNavigatorGroup</string>
@ -329,7 +332,7 @@
</dict> </dict>
<dict> <dict>
<key>Proportion</key> <key>Proportion</key>
<string>588pt</string> <string>613pt</string>
<key>Tabs</key> <key>Tabs</key>
<array> <array>
<dict> <dict>
@ -343,7 +346,7 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{10, 27}, {643, 561}}</string> <string>{{10, 27}, {604, 586}}</string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>XCDetailModule</string> <string>XCDetailModule</string>
@ -359,7 +362,7 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{10, 27}, {650, 590}}</string> <string>{{10, 27}, {644, 586}}</string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXProjectFindModule</string> <string>PBXProjectFindModule</string>
@ -375,7 +378,7 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{10, 31}, {603, 297}}</string> <string>{{10, 27}, {644, 586}}</string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXCVSModule</string> <string>PBXCVSModule</string>
@ -384,7 +387,7 @@
</dict> </dict>
</array> </array>
<key>Proportion</key> <key>Proportion</key>
<string>643pt</string> <string>604pt</string>
</dict> </dict>
</array> </array>
<key>Name</key> <key>Name</key>
@ -402,11 +405,11 @@
</array> </array>
<key>TableOfContents</key> <key>TableOfContents</key>
<array> <array>
<string>F5D646000F487ECB007E515F</string> <string>F56B7444101FA1C600B6D9A4</string>
<string>1CA23ED40692098700951B8B</string> <string>1CA23ED40692098700951B8B</string>
<string>F5D646010F487ECB007E515F</string> <string>F56B7445101FA1C600B6D9A4</string>
<string>F5A33EBD0EC89C3000F8052D</string> <string>F5A33EBD0EC89C3000F8052D</string>
<string>F5D646020F487ECB007E515F</string> <string>F56B7446101FA1C600B6D9A4</string>
<string>1CA23EDF0692099D00951B8B</string> <string>1CA23EDF0692099D00951B8B</string>
<string>1CA23EE00692099D00951B8B</string> <string>1CA23EE00692099D00951B8B</string>
<string>1CA23EE10692099D00951B8B</string> <string>1CA23EE10692099D00951B8B</string>
@ -468,18 +471,24 @@
<key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key> <key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key>
<array> <array>
<string>29B97314FDCFA39411CA2CEA</string> <string>29B97314FDCFA39411CA2CEA</string>
<string>F5B19C3B0EA4DC91003F4BA4</string>
<string>080E96DDFE201D6D7F000001</string> <string>080E96DDFE201D6D7F000001</string>
<string>29B97315FDCFA39411CA2CEA</string> <string>29B97315FDCFA39411CA2CEA</string>
<string>29B97317FDCFA39411CA2CEA</string> <string>29B97317FDCFA39411CA2CEA</string>
<string>29B97323FDCFA39411CA2CEA</string>
<string>1058C7A0FEA54F0111CA2CBB</string>
<string>1058C7A2FEA54F0111CA2CBB</string>
<string>19C28FACFE9D520D11CA2CBB</string>
</array> </array>
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key> <key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array> <array>
<array> <array>
<integer>42</integer>
<integer>0</integer> <integer>0</integer>
</array> </array>
</array> </array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key> <key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 0}, {275, 583}}</string> <string>{{0, 475}, {275, 600}}</string>
</dict> </dict>
<key>PBXTopSmartGroupGIDs</key> <key>PBXTopSmartGroupGIDs</key>
<array/> <array/>
@ -489,14 +498,14 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{0, 0}, {292, 601}}</string> <string>{{0, 0}, {292, 618}}</string>
<key>GroupTreeTableConfiguration</key> <key>GroupTreeTableConfiguration</key>
<array> <array>
<string>MainColumn</string> <string>MainColumn</string>
<real>275</real> <real>275</real>
</array> </array>
<key>RubberWindowFrame</key> <key>RubberWindowFrame</key>
<string>65 75 944 642 0 0 1024 746 </string> <string>151 75 971 659 0 0 1024 746 </string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXSmartGroupTreeModule</string> <string>PBXSmartGroupTreeModule</string>
@ -533,9 +542,9 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{0, 0}, {647, 0}}</string> <string>{{0, 0}, {674, 0}}</string>
<key>RubberWindowFrame</key> <key>RubberWindowFrame</key>
<string>65 75 944 642 0 0 1024 746 </string> <string>151 75 971 659 0 0 1024 746 </string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXNavigatorGroup</string> <string>PBXNavigatorGroup</string>
@ -544,14 +553,14 @@
</dict> </dict>
<dict> <dict>
<key>Proportion</key> <key>Proportion</key>
<string>596pt</string> <string>613pt</string>
<key>Tabs</key> <key>Tabs</key>
<array> <array>
<dict> <dict>
<key>ContentConfiguration</key> <key>ContentConfiguration</key>
<dict> <dict>
<key>PBXBuildLogShowsTranscriptDefaultKey</key> <key>PBXBuildLogShowsTranscriptDefaultKey</key>
<string>{{0, 5}, {647, 564}}</string> <string>{{0, 5}, {674, 581}}</string>
<key>PBXProjectModuleGUID</key> <key>PBXProjectModuleGUID</key>
<string>XCMainBuildResultsModuleGUID</string> <string>XCMainBuildResultsModuleGUID</string>
<key>PBXProjectModuleLabel</key> <key>PBXProjectModuleLabel</key>
@ -564,9 +573,9 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{10, 27}, {647, 569}}</string> <string>{{10, 27}, {674, 586}}</string>
<key>RubberWindowFrame</key> <key>RubberWindowFrame</key>
<string>65 75 944 642 0 0 1024 746 </string> <string>151 75 971 659 0 0 1024 746 </string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXBuildResultsModule</string> <string>PBXBuildResultsModule</string>
@ -628,7 +637,7 @@
</dict> </dict>
</array> </array>
<key>Proportion</key> <key>Proportion</key>
<string>647pt</string> <string>674pt</string>
</dict> </dict>
</array> </array>
<key>Name</key> <key>Name</key>
@ -646,14 +655,14 @@
</array> </array>
<key>TableOfContents</key> <key>TableOfContents</key>
<array> <array>
<string>F53931560FE170BC003CB103</string> <string>F56B7447101FA1C600B6D9A4</string>
<string>1CA23EE50692099D00951B8B</string> <string>1CA23EE50692099D00951B8B</string>
<string>F53931570FE170BC003CB103</string> <string>F56B7448101FA1C600B6D9A4</string>
<string>F5A33EC20EC89C3000F8052D</string> <string>F5A33EC20EC89C3000F8052D</string>
<string>F53931580FE170BC003CB103</string> <string>F56B7449101FA1C600B6D9A4</string>
<string>XCMainBuildResultsModuleGUID</string> <string>XCMainBuildResultsModuleGUID</string>
<string>1CA23EE80692099D00951B8B</string> <string>1CA23EE80692099D00951B8B</string>
<string>F53931590FE170BC003CB103</string> <string>F56B744A101FA1C600B6D9A4</string>
</array> </array>
<key>ToolbarConfiguration</key> <key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.buildAndRun</string> <string>xcode.toolbar.config.buildAndRun</string>
@ -697,7 +706,7 @@
<key>GeometryConfiguration</key> <key>GeometryConfiguration</key>
<dict> <dict>
<key>Frame</key> <key>Frame</key>
<string>{{0, 0}, {1323, 0}}</string> <string>{{0, 0}, {971, 0}}</string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXDebugCLIModule</string> <string>PBXDebugCLIModule</string>
@ -721,8 +730,8 @@
<string>yes</string> <string>yes</string>
<key>sizes</key> <key>sizes</key>
<array> <array>
<string>{{0, 0}, {641, 197}}</string> <string>{{0, 0}, {470, 295}}</string>
<string>{{641, 0}, {682, 197}}</string> <string>{{470, 0}, {501, 295}}</string>
</array> </array>
</dict> </dict>
<key>VerticalSplitView</key> <key>VerticalSplitView</key>
@ -737,8 +746,8 @@
<string>yes</string> <string>yes</string>
<key>sizes</key> <key>sizes</key>
<array> <array>
<string>{{0, 0}, {1323, 197}}</string> <string>{{0, 0}, {971, 295}}</string>
<string>{{0, 197}, {1323, 211}}</string> <string>{{0, 295}, {971, 318}}</string>
</array> </array>
</dict> </dict>
</dict> </dict>
@ -760,12 +769,12 @@
<key>DebugSTDIOWindowFrame</key> <key>DebugSTDIOWindowFrame</key>
<string>{{200, 200}, {500, 300}}</string> <string>{{200, 200}, {500, 300}}</string>
<key>Frame</key> <key>Frame</key>
<string>{{0, 5}, {1323, 408}}</string> <string>{{0, 5}, {971, 613}}</string>
</dict> </dict>
<key>Module</key> <key>Module</key>
<string>PBXDebugSessionModule</string> <string>PBXDebugSessionModule</string>
<key>Proportion</key> <key>Proportion</key>
<string>408pt</string> <string>613pt</string>
</dict> </dict>
</array> </array>
<key>Name</key> <key>Name</key>
@ -784,15 +793,15 @@
</array> </array>
<key>TableOfContents</key> <key>TableOfContents</key>
<array> <array>
<string>F5AED0700F1999130090A93F</string> <string>F56B744B101FA1C600B6D9A4</string>
<string>1CCC7628064C1048000F2A68</string> <string>1CCC7628064C1048000F2A68</string>
<string>1CCC7629064C1048000F2A68</string> <string>1CCC7629064C1048000F2A68</string>
<string>F5AED0710F1999130090A93F</string> <string>F56B744C101FA1C600B6D9A4</string>
<string>F5AED0720F1999130090A93F</string> <string>F56B744D101FA1C600B6D9A4</string>
<string>F5AED0730F1999130090A93F</string> <string>F56B744E101FA1C600B6D9A4</string>
<string>F5AED0740F1999130090A93F</string> <string>F56B744F101FA1C600B6D9A4</string>
<string>F5AED0410F1989EC0090A93F</string> <string>F56B7409101F6DEB00B6D9A4</string>
<string>F5AED0750F1999130090A93F</string> <string>F56B7450101FA1C600B6D9A4</string>
</array> </array>
<key>ToolbarConfiguration</key> <key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.debug</string> <string>xcode.toolbar.config.debug</string>
@ -801,7 +810,7 @@
<key>PerspectivesBarVisible</key> <key>PerspectivesBarVisible</key>
<true/> <true/>
<key>PinnedNavigatorIdentifier</key> <key>PinnedNavigatorIdentifier</key>
<string>F539315B0FE170D5003CB103</string> <string>F56B743E101F7E4F00B6D9A4</string>
<key>ShelfIsVisible</key> <key>ShelfIsVisible</key>
<false/> <false/>
<key>SourceDescription</key> <key>SourceDescription</key>
@ -824,10 +833,11 @@
<integer>5</integer> <integer>5</integer>
<key>WindowOrderList</key> <key>WindowOrderList</key>
<array> <array>
<string>F56B7450101FA1C600B6D9A4</string>
<string>/Users/xx/Grafx2/Grafx2.xcodeproj</string> <string>/Users/xx/Grafx2/Grafx2.xcodeproj</string>
</array> </array>
<key>WindowString</key> <key>WindowString</key>
<string>65 75 944 642 0 0 1024 746 </string> <string>151 75 971 659 0 0 1024 746 </string>
<key>WindowTools</key> <key>WindowTools</key>
<array> <array>
<dict> <dict>

View File

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>English</string> <string>English</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>Grafx2</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string></string> <string></string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>http://grafx2.googlecode.com/</string> <string>com.googlecode.grafx2</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>${PRODUCT_NAME}</string> <string>Grafx2</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -1,5 +1,6 @@
# Grafx2 - The Ultimate 256-color bitmap paint program # Grafx2 - The Ultimate 256-color bitmap paint program
# #
# Copyright 2009 Per Olofsson
# Copyright 2008 Peter Gordon # Copyright 2008 Peter Gordon
# Copyright 2008 Yves Rizoud # Copyright 2008 Yves Rizoud
# Copyright 2007 Adrien Destugues # Copyright 2007 Adrien Destugues
@ -31,6 +32,8 @@
### PLATFORM DETECTION AND CONFIGURATION ### ### PLATFORM DETECTION AND CONFIGURATION ###
PLATFORMOBJ =
# There is no uname under windows, but we can guess we are there with the COMSPEC env.var # There is no uname under windows, but we can guess we are there with the COMSPEC env.var
# Windows specific # Windows specific
ifdef COMSPEC ifdef COMSPEC
@ -45,8 +48,7 @@ ifdef COMSPEC
OBJDIR = obj/win32 OBJDIR = obj/win32
# Resources (icon) # Resources (icon)
WINDRES = windres.exe WINDRES = windres.exe
OBJRES = $(OBJDIR)/winres.o PLATFORMOBJ = $(OBJDIR)/winres.o
CFGOBJRES = $(OBJDIR)/wincfgres.o
PLATFORM = win32 PLATFORM = win32
PLATFORMFILES = SDL.dll SDL_image.dll libpng13.dll zlib1.dll gfx2.ico $(TTFLIBS) #some misc files we have to add to the release archive under windows. PLATFORMFILES = SDL.dll SDL_image.dll libpng13.dll zlib1.dll gfx2.ico $(TTFLIBS) #some misc files we have to add to the release archive under windows.
ZIP = zip ZIP = zip
@ -62,13 +64,36 @@ else
RMDIR = rmdir RMDIR = rmdir
CP = cp CP = cp
BIN = grafx2 BIN = grafx2
COPT = -Wall -c -gstabs -mcrt=newlib `sdl-config --cflags` -D__USE_INLINE__ $(TTFCOPT) COPT = -Wall -c -gstabs -mcrt=newlib `sdl-config --cflags` -I/SDK/Local/common/include/SDL -D__USE_INLINE__ $(TTFCOPT)
LOPT = `sdl-config --libs` -lSDL_image -lpng -ljpeg -lz $(TTFLOPT) -lft2 LOPT = `sdl-config --libs` -lSDL_image -lpng -ljpeg -lz $(TTFLOPT) -lft2
CC = gcc CC = gcc
OBJDIR = obj/amiga OBJDIR = obj/amiga
ZIP = lha ZIP = lha
ZIPOPT = a ZIPOPT = a
else ifeq ($(PLATFORM),Darwin)
#Mac OS X specific
DELCOMMAND = rm -rf
MKDIR = mkdir -p
RMDIR = rmdir
CP = cp
ZIP = zip
PLATFORMFILES = gfx2.png
BIN = grafx2
# Where the SDL frameworks are located
FWDIR = /Library/Frameworks
SDLCOPT = -arch i386 -I$(FWDIR)/SDL.framework/Headers -I$(FWDIR)/SDL_image.framework/Headers -I$(FWDIR)/SDL_ttf.framework/Headers -D_THREAD_SAFE
SDLLOPT = -arch i386 -L/usr/lib -framework SDL -framework SDL_image -framework SDL_ttf -framework Cocoa -framework Carbon -framework OpenGL
COPT = -D__macosx__ -D__linux__ -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -std=c99 -c -g $(SDLCOPT) $(TTFCOPT) -I/usr/X11/include
LOPT = $(SDLLOPT) -L/usr/X11/lib -R/usr/X11/lib -lpng
# Use gcc for compiling. Use ncc to build a callgraph and analyze the code.
CC = gcc
#CC = nccgen -ncgcc -ncld -ncfabs
OBJDIR = obj/macosx
PLATFORMOBJ = $(OBJDIR)/SDLMain.o
X11LOPT =
MACAPPEXE = Grafx2.app/Contents/MacOS/Grafx2
else ifeq ($(PLATFORM),AROS) else ifeq ($(PLATFORM),AROS)
#AROS specific #AROS specific
DELCOMMAND = rm -rf DELCOMMAND = rm -rf
@ -185,7 +210,7 @@ else
# Compiles a regular linux exectutable for the native platform # Compiles a regular linux exectutable for the native platform
BIN = grafx2 BIN = grafx2
COPT = -W -Wall -Wdeclaration-after-statement -pedantic -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT) COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT)
LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng
# Use gcc for compiling. Use ncc to build a callgraph and analyze the code. # Use gcc for compiling. Use ncc to build a callgraph and analyze the code.
CC = gcc CC = gcc
@ -225,9 +250,30 @@ endif
.PHONY : all debug release clean depend zip version force install uninstall .PHONY : all debug release clean depend zip version force install uninstall
# This is the list of the objects we want to build. Dependancies are built by "make depend" automatically. # This is the list of the objects we want to build. Dependancies are built by "make depend" automatically.
OBJ = $(OBJDIR)/main.o $(OBJDIR)/init.o $(OBJDIR)/graph.o $(OBJDIR)/sdlscreen.o $(OBJDIR)/misc.o $(OBJDIR)/special.o $(OBJDIR)/buttons.o $(OBJDIR)/palette.o $(OBJDIR)/help.o $(OBJDIR)/operatio.o $(OBJDIR)/pages.o $(OBJDIR)/loadsave.o $(OBJDIR)/readline.o $(OBJDIR)/engine.o $(OBJDIR)/filesel.o $(OBJDIR)/op_c.o $(OBJDIR)/readini.o $(OBJDIR)/saveini.o $(OBJDIR)/shade.o $(OBJDIR)/keyboard.o $(OBJDIR)/io.o $(OBJDIR)/version.o $(OBJDIR)/text.o $(OBJDIR)/SFont.o $(OBJDIR)/setup.o $(OBJDIR)/pxsimple.o $(OBJDIR)/pxtall.o $(OBJDIR)/pxwide.o $(OBJDIR)/pxdouble.o $(OBJDIR)/pxtriple.o $(OBJDIR)/pxtall2.o $(OBJDIR)/pxwide2.o $(OBJDIR)/pxquad.o $(OBJDIR)/windows.o $(OBJDIR)/brush.o $(OBJDIR)/realpath.o $(OBJDIR)/mountlist.o $(OBJDIR)/input.o $(OBJDIR)/hotkeys.o $(OBJDIR)/transform.o $(OBJDIR)/pversion.o OBJ = $(OBJDIR)/main.o $(OBJDIR)/init.o $(OBJDIR)/graph.o $(OBJDIR)/sdlscreen.o $(OBJDIR)/misc.o $(OBJDIR)/special.o $(OBJDIR)/buttons.o $(OBJDIR)/palette.o $(OBJDIR)/help.o $(OBJDIR)/operatio.o $(OBJDIR)/pages.o $(OBJDIR)/loadsave.o $(OBJDIR)/readline.o $(OBJDIR)/engine.o $(OBJDIR)/filesel.o $(OBJDIR)/op_c.o $(OBJDIR)/readini.o $(OBJDIR)/saveini.o $(OBJDIR)/shade.o $(OBJDIR)/keyboard.o $(OBJDIR)/io.o $(OBJDIR)/version.o $(OBJDIR)/text.o $(OBJDIR)/SFont.o $(OBJDIR)/setup.o $(OBJDIR)/pxsimple.o $(OBJDIR)/pxtall.o $(OBJDIR)/pxwide.o $(OBJDIR)/pxdouble.o $(OBJDIR)/pxtriple.o $(OBJDIR)/pxtall2.o $(OBJDIR)/pxwide2.o $(OBJDIR)/pxquad.o $(OBJDIR)/windows.o $(OBJDIR)/brush.o $(OBJDIR)/realpath.o $(OBJDIR)/mountlist.o $(OBJDIR)/input.o $(OBJDIR)/hotkeys.o $(OBJDIR)/transform.o $(OBJDIR)/pversion.o $(PLATFORMOBJ)
SKIN_FILES = skins/skin_classic.png skins/skin_modern.png skins/font_Classic.png skins/font_Fun.png
ifeq ($(PLATFORM),Darwin)
all : $(MACAPPEXE)
$(MACAPPEXE) : $(BIN)
rm -rf Grafx2.app
mkdir -p Grafx2.app Grafx2.app/Contents Grafx2.app/Contents/Frameworks Grafx2.app/Contents/MacOS Grafx2.app/Contents/Resources
echo 'APPL????' > Grafx2.app/Contents/PkgInfo
cp Info.plist Grafx2.app/Contents
cp -r English.lproj Grafx2.app/Contents/Resources
cp -r fonts Grafx2.app/Contents/Resources
cp -r skins Grafx2.app/Contents/Resources
cp -r gfx2.cfg Grafx2.app/Contents/Resources
cp -r gfx2def.ini Grafx2.app/Contents/Resources
cp -Rp $(FWDIR)/SDL.framework Grafx2.app/Contents/Frameworks
cp -Rp $(FWDIR)/SDL_image.framework Grafx2.app/Contents/Frameworks
cp -Rp $(FWDIR)/SDL_ttf.framework Grafx2.app/Contents/Frameworks
cp $(BIN) $(MACAPPEXE)
else
all : $(BIN) all : $(BIN)
endif
debug : $(BIN) debug : $(BIN)
@ -237,17 +283,22 @@ release : version $(BIN)
# Create a zip archive ready for upload to the website, including binaries and sourcecode # Create a zip archive ready for upload to the website, including binaries and sourcecode
ziprelease: version $(BIN) release ziprelease: version $(BIN) release
tar cvzf src-svn`svnversion | sed 's/:/-/'`.tgz --transform 's,^,src/,g' *.c *.h Makefile Makefile.dep gfx2.ico echo `sed "s/.*=\"\(.*\)\";/\1/" pversion.c`.`svnversion` | tr " :" "_-" | sed -e s/\\(wip\\)\\\\./\\1/I > $(OBJDIR)/versiontag
$(ZIP) $(ZIPOPT) grafx2-svn`svnversion | sed 's/:/-/'`$(TTFLABEL)-$(PLATFORM).$(ZIP) $(BIN) gfx2def.ini skins/base.gif gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt fonts/8pxfont.png doc/README-zlib1.txt doc/README-SDL.txt doc/README-SDL_image.txt doc/README-SDL_ttf.txt fonts/Tuffy.ttf src-svn`svnversion | sed 's/:/-/'`.tgz $(PLATFORMFILES)
$(DELCOMMAND) src-svn`svnversion | sed 's/:/-/'`.tgz
tar cvzf grafx2-svn`svnversion | sed 's/:/-/'`$(TTFLABEL)-src.tgz --transform 's,^,grafx2/,g' *.c *.h Makefile Makefile.dep gfx2def.ini skins/base.gif gfx2.ico gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt misc/grafx2.1 misc/grafx2.xpm misc/grafx2.desktop fonts/8pxfont.png fonts/Tuffy.ttf
$(BIN) : $(OBJ) $(OBJRES) tar cvzf "src-`cat $(OBJDIR)/versiontag`.tgz" --transform 's,^,src/,g' *.c *.h Makefile Makefile.dep gfx2.ico
$(CC) $(OBJ) $(OBJRES) -o $(BIN) $(LOPT) $(ZIP) $(ZIPOPT) "grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-$(PLATFORM).$(ZIP)" $(BIN) gfx2def.ini $(SKIN_FILES) gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt fonts/8pxfont.png doc/README-zlib1.txt doc/README-SDL.txt doc/README-SDL_image.txt doc/README-SDL_ttf.txt fonts/Tuffy.ttf src-`cat $(OBJDIR)/versiontag`.tgz $(PLATFORMFILES)
$(DELCOMMAND) "src-`cat $(OBJDIR)/versiontag`.tgz"
tar cvzf "grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-src.tgz" --transform 's,^,grafx2/,g' *.c *.h Makefile Makefile.dep gfx2def.ini $(SKIN_FILES) gfx2.ico gfx2.gif doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt misc/grafx2.1 misc/grafx2.xpm misc/grafx2.desktop fonts/8pxfont.png fonts/Tuffy.ttf
$(DELCOMMAND) "$(OBJDIR)/versiontag"
testsed :
$(BIN) : $(OBJ)
$(CC) $(OBJ) -o $(BIN) $(LOPT)
# SVN revision number # SVN revision number
version.c : version.c :
echo "char SVN_revision[]=\"`svnversion`\";" > version.c echo "char SVN_revision[]=\"`svnversion .`\";" > version.c
ifeq ($(LABEL),) ifeq ($(LABEL),)
else else
echo "char Program_version[]=\"$(LABEL)\";" > pversion.c echo "char Program_version[]=\"$(LABEL)\";" > pversion.c
@ -265,10 +316,14 @@ else
$(DELCOMMAND) pversion.c $(DELCOMMAND) pversion.c
endif endif
$(OBJDIR)/%.o : $(OBJDIR)/%.o : %.c
$(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR)) $(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR))
$(CC) $(COPT) -c $*.c -o $(OBJDIR)/$*.o $(CC) $(COPT) -c $*.c -o $(OBJDIR)/$*.o
$(OBJDIR)/%.o : %.m
$(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR))
$(CC) $(COPT) -c $*.m -o $(OBJDIR)/$*.o
depend : depend :
$(CC) -MM *.c | sed 's:^[^ ]:$$(OBJDIR)/&:' > Makefile.dep $(CC) -MM *.c | sed 's:^[^ ]:$$(OBJDIR)/&:' > Makefile.dep
@ -277,7 +332,7 @@ $(OBJDIR)/winres.o : gfx2.ico
echo "1 ICON \"gfx2.ico\"" | $(WINDRES) -o $(OBJDIR)/winres.o echo "1 ICON \"gfx2.ico\"" | $(WINDRES) -o $(OBJDIR)/winres.o
clean : clean :
$(DELCOMMAND) $(OBJ) $(OBJDIR)/version.o $(OBJRES) $(DELCOMMAND) $(OBJ)
$(DELCOMMAND) $(BIN) $(DELCOMMAND) $(BIN)
# Linux installation of the program # Linux installation of the program
@ -298,7 +353,7 @@ install : $(BIN)
$(CP) gfx2def.ini $(DESTDIR)$(datadir)/grafx2/ $(CP) gfx2def.ini $(DESTDIR)$(datadir)/grafx2/
$(CP) gfx2.gif $(DESTDIR)$(datadir)/grafx2/ $(CP) gfx2.gif $(DESTDIR)$(datadir)/grafx2/
$(CP) fonts/* $(DESTDIR)$(datadir)/grafx2/fonts/ $(CP) fonts/* $(DESTDIR)$(datadir)/grafx2/fonts/
$(CP) skins/base.gif $(DESTDIR)$(datadir)/grafx2/skins/ $(CP) $(SKIN_FILES) $(DESTDIR)$(datadir)/grafx2/skins/
# Icon and desktop file for debian # Icon and desktop file for debian
$(CP) misc/grafx2.desktop $(DESTDIR)$(datadir)/applications/ $(CP) misc/grafx2.desktop $(DESTDIR)$(datadir)/applications/
$(CP) misc/grafx2.xpm $(DESTDIR)$(datadir)/icons/ $(CP) misc/grafx2.xpm $(DESTDIR)$(datadir)/icons/
@ -312,7 +367,9 @@ uninstall :
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/gfx2.gif $(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/gfx2.gif
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/fonts/* $(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/fonts/*
$(if $(wildcard $(DESTDIR)$(datadir)/grafx2/fonts),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2/fonts) $(if $(wildcard $(DESTDIR)$(datadir)/grafx2/fonts),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2/fonts)
$(DELCOMMAND) $(DESTDIR)$(datadir)/grafx2/skins/base.gif cd $(DESTDIR)$(datadir)/grafx2
$(DELCOMMAND) $(SKIN_FILES)
cd ..
$(if $(wildcard $(DESTDIR)$(datadir)/grafx2/skins),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2/skins) $(if $(wildcard $(DESTDIR)$(datadir)/grafx2/skins),,$(RMDIR) $(DESTDIR)$(datadir)/grafx2/skins)
# Icon and desktop file for debian # Icon and desktop file for debian
$(DELCOMMAND) $(DESTDIR)$(datadir)/applications/grafx2.desktop $(DELCOMMAND) $(DESTDIR)$(datadir)/applications/grafx2.desktop

205
brush.c
View File

@ -123,7 +123,8 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
int position; int position;
byte * temp; byte * temp;
if (!(is_preview && Mouse_K)) // Si bouton enfoncé & preview > pas de dessin if (is_preview==0 || Mouse_K==0) // pas de curseur si on est en preview et
// en train de cliquer
switch (Paintbrush_shape) switch (Paintbrush_shape)
{ {
case PAINTBRUSH_SHAPE_POINT : // !!! TOUJOURS EN PREVIEW !!! case PAINTBRUSH_SHAPE_POINT : // !!! TOUJOURS EN PREVIEW !!!
@ -151,7 +152,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
end_counter_x=start_x_counter+width; end_counter_x=start_x_counter+width;
end_counter_y=start_y_counter+height; end_counter_y=start_y_counter+height;
if (is_preview) if (is_preview != 0)
{ {
if ( (width>0) && (height>0) ) if ( (width>0) && (height>0) )
Display_brush_color( Display_brush_color(
@ -165,7 +166,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
Brush_width Brush_width
); );
if (Main_magnifier_mode) if (Main_magnifier_mode != 0)
{ {
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width, Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,
&height &height
@ -196,9 +197,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
} }
else else
{ {
if ((Smear_mode) && (Shade_table==Shade_table_left)) if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
{ {
if (Smear_start) if (Smear_start != 0)
{ {
if ((width>0) && (height>0)) if ((width>0) && (height>0))
{ {
@ -275,7 +276,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
start_y_counter=start_y-(y-Brush_offset_Y); start_y_counter=start_y-(y-Brush_offset_Y);
end_counter_x=start_x_counter+width; end_counter_x=start_x_counter+width;
end_counter_y=start_y_counter+height; end_counter_y=start_y_counter+height;
if (is_preview) if (is_preview != 0)
{ {
if ( (width>0) && (height>0) ) if ( (width>0) && (height>0) )
Display_brush_mono(start_x-Main_offset_X, Display_brush_mono(start_x-Main_offset_X,
@ -285,7 +286,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
Back_color,Fore_color, Back_color,Fore_color,
Brush_width); Brush_width);
if (Main_magnifier_mode) if (Main_magnifier_mode != 0)
{ {
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height); Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
start_x_counter=start_x-(x-Brush_offset_X); start_x_counter=start_x-(x-Brush_offset_X);
@ -314,9 +315,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
} }
else else
{ {
if ((Smear_mode) && (Shade_table==Shade_table_left)) if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
{ {
if (Smear_start) if (Smear_start != 0)
{ {
if ((width>0) && (height>0)) if ((width>0) && (height>0))
{ {
@ -377,7 +378,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
start_y_counter=start_y-(y-Paintbrush_offset_Y); start_y_counter=start_y-(y-Paintbrush_offset_Y);
end_counter_x=start_x_counter+width; end_counter_x=start_x_counter+width;
end_counter_y=start_y_counter+height; end_counter_y=start_y_counter+height;
if (is_preview) if (is_preview != 0)
{ {
temp=Brush; temp=Brush;
Brush=Paintbrush_sprite; Brush=Paintbrush_sprite;
@ -390,7 +391,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
0,Fore_color, 0,Fore_color,
MAX_PAINTBRUSH_SIZE); MAX_PAINTBRUSH_SIZE);
if (Main_magnifier_mode) if (Main_magnifier_mode != 0)
{ {
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height); Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
start_x_counter=start_x-(x-Paintbrush_offset_X); start_x_counter=start_x-(x-Paintbrush_offset_X);
@ -419,9 +420,9 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
} }
else else
{ {
if ((Smear_mode) && (Shade_table==Shade_table_left)) if ((Smear_mode != 0) && (Shade_table==Shade_table_left))
{ {
if (Smear_start) if (Smear_start != 0)
{ {
if ((width>0) && (height>0)) if ((width>0) && (height>0))
{ {
@ -444,10 +445,13 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
{ {
temp_color=Read_pixel_from_current_screen(x_pos,y_pos); temp_color=Read_pixel_from_current_screen(x_pos,y_pos);
position=(counter_y*Smear_brush_width)+counter_x; position=(counter_y*Smear_brush_width)+counter_x;
if ( (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x]) // Le pinceau sert de masque pour dire quels pixels on doit traiter dans le rectangle if ( (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x] != 0)
&& (counter_y<Smear_max_Y) && (counter_x<Smear_max_X) // On clippe l'effet smear entre Smear_Min et Smear_Max // Le pinceau sert de masque pour dire quels pixels on doit traiter dans le rectangle
&& (counter_y>=Smear_min_Y) && (counter_x>=Smear_min_X) ) && (counter_y<Smear_max_Y) && (counter_x<Smear_max_X)
Display_pixel(x_pos,y_pos,Smear_brush[position]); && (counter_y>=Smear_min_Y) && (counter_x>=Smear_min_X)
// On clippe l'effet smear entre Smear_Min et Smear_Max
)
Display_pixel(x_pos,y_pos,Smear_brush[position]);
Smear_brush[position]=temp_color; Smear_brush[position]=temp_color;
} }
Update_part_of_screen(start_x, start_y, width, height); Update_part_of_screen(start_x, start_y, width, height);
@ -464,7 +468,7 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
for (y_pos=start_y,counter_y=start_y_counter;counter_y<end_counter_y;y_pos++,counter_y++) for (y_pos=start_y,counter_y=start_y_counter;counter_y<end_counter_y;y_pos++,counter_y++)
for (x_pos=start_x,counter_x=start_x_counter;counter_x<end_counter_x;x_pos++,counter_x++) for (x_pos=start_x,counter_x=start_x_counter;counter_x<end_counter_x;x_pos++,counter_x++)
{ {
if (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x]) if (Paintbrush_sprite[(MAX_PAINTBRUSH_SIZE*counter_y)+counter_x] != 0)
Display_pixel(x_pos,y_pos,color); Display_pixel(x_pos,y_pos,color);
} }
Update_part_of_screen(start_x,start_y,width,height); Update_part_of_screen(start_x,start_y,width,height);
@ -473,6 +477,69 @@ void Display_paintbrush(short x,short y,byte color,byte is_preview)
} }
} }
///
/// Changes the Brush size, discarding its previous content.
/// @return 0 OK, 1 Failed
byte Realloc_brush(word new_brush_width, word new_brush_height)
{
byte return_code=0;
if ( (((long)Brush_height)*Brush_width) !=
(((long)new_brush_height)*new_brush_width) )
{
free(Brush);
Brush=(byte *)malloc(((long)new_brush_height)*new_brush_width);
if (Brush == NULL)
{
Error(0);
return_code=1;
Brush=(byte *)malloc(1*1);
if(Brush == NULL)
{
Error(ERROR_MEMORY);
exit(ERROR_MEMORY);
}
new_brush_height=new_brush_width=1;
*Brush=Fore_color;
}
}
Brush_width=new_brush_width;
Brush_height=new_brush_height;
free(Smear_brush);
Smear_brush_width=(Brush_width>MAX_PAINTBRUSH_SIZE)?Brush_width:MAX_PAINTBRUSH_SIZE;
Smear_brush_height=(Brush_height>MAX_PAINTBRUSH_SIZE)?Brush_height:MAX_PAINTBRUSH_SIZE;
Smear_brush=(byte *)malloc(((long)Smear_brush_height)*Smear_brush_width);
if (Smear_brush == NULL) // Failed to allocate the smear brush
{
Error(0);
return_code=1;
free(Brush);
Brush=(byte *)malloc(1*1);
if(Brush == NULL)
{
Error(ERROR_MEMORY);
exit(ERROR_MEMORY);
}
Brush_height=1;
Brush_width=1;
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
if(Smear_brush == NULL)
{
Error(ERROR_MEMORY);
exit(ERROR_MEMORY);
}
Smear_brush_height=MAX_PAINTBRUSH_SIZE;
Smear_brush_width=MAX_PAINTBRUSH_SIZE;
}
return return_code;
}
// -- Effacer le pinceau -- // // -- Effacer le pinceau -- //
// //
void Hide_paintbrush(short x,short y) void Hide_paintbrush(short x,short y)
@ -495,11 +562,11 @@ void Hide_paintbrush(short x,short y)
//short counter_x; // Position X (dans la brosse/pinceau) en cours //short counter_x; // Position X (dans la brosse/pinceau) en cours
//d'affichage //d'affichage
//short counter_y; // Position Y (dans la brosse/pinceau) en cours d'affichage //short counter_y; // Position Y (dans la brosse/pinceau) en cours d'affichage
short end_counter_x; // Position X ou s'arrête l'affichade de la brosse/pinceau short end_counter_x; // Position X ou s'arrête l'affichage de la brosse/pinceau
short end_counter_y; // Position Y ou s'arrête l'affichade de la brosse/pinceau short end_counter_y; // Position Y ou s'arrête l'affichage de la brosse/pinceau
byte * temp; byte * temp;
if (!Mouse_K) if (Mouse_K == 0)
switch (Paintbrush_shape) switch (Paintbrush_shape)
{ {
case PAINTBRUSH_SHAPE_POINT : case PAINTBRUSH_SHAPE_POINT :
@ -531,7 +598,7 @@ void Hide_paintbrush(short x,short y)
width,height,Back_color, width,height,Back_color,
Main_image_width); Main_image_width);
if (Main_magnifier_mode) if (Main_magnifier_mode != 0)
{ {
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height); Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
start_x_counter=start_x; start_x_counter=start_x;
@ -577,7 +644,7 @@ void Hide_paintbrush(short x,short y)
Main_image_width); Main_image_width);
} }
if (Main_magnifier_mode) if (Main_magnifier_mode != 0)
{ {
Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height); Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height);
start_x_counter=start_x; start_x_counter=start_x;
@ -651,46 +718,12 @@ void Capture_brush(short start_x,short start_y,short end_x,short end_y,short cle
if (start_y+new_brush_height>Main_image_height) if (start_y+new_brush_height>Main_image_height)
new_brush_height=Main_image_height-start_y; new_brush_height=Main_image_height-start_y;
if ( (((long)Brush_height)*Brush_width) != Realloc_brush(new_brush_width, new_brush_height);
(((long)new_brush_height)*new_brush_width) )
{
free(Brush);
Brush=(byte *)malloc(((long)new_brush_height)*new_brush_width);
if (!Brush)
{
Error(0);
Brush=(byte *)malloc(1*1);
new_brush_height=new_brush_width=1;
*Brush=Fore_color;
}
}
Brush_width=new_brush_width;
Brush_height=new_brush_height;
free(Smear_brush);
Smear_brush_width=(Brush_width>MAX_PAINTBRUSH_SIZE)?Brush_width:MAX_PAINTBRUSH_SIZE;
Smear_brush_height=(Brush_height>MAX_PAINTBRUSH_SIZE)?Brush_height:MAX_PAINTBRUSH_SIZE;
Smear_brush=(byte *)malloc(((long)Smear_brush_height)*Smear_brush_width);
if (!Smear_brush) // On ne peut même pas allouer la brosse du smear!
{
Error(0);
free(Brush);
Brush=(byte *)malloc(1*1);
Brush_height=1;
Brush_width=1;
Smear_brush=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE);
Smear_brush_height=MAX_PAINTBRUSH_SIZE;
Smear_brush_width=MAX_PAINTBRUSH_SIZE;
}
Copy_image_to_brush(start_x,start_y,Brush_width,Brush_height,Main_image_width); Copy_image_to_brush(start_x,start_y,Brush_width,Brush_height,Main_image_width);
// On regarde s'il faut effacer quelque chose: // On regarde s'il faut effacer quelque chose:
if (clear) if (clear != 0)
{ {
for (y_pos=start_y;y_pos<start_y+Brush_height;y_pos++) for (y_pos=start_y;y_pos<start_y+Brush_height;y_pos++)
for (x_pos=start_x;x_pos<start_x+Brush_width;x_pos++) for (x_pos=start_x;x_pos<start_x+Brush_width;x_pos++)
@ -716,7 +749,7 @@ void Rotate_90_deg()
new_brush=(byte *)malloc(((long)Brush_height)*Brush_width); new_brush=(byte *)malloc(((long)Brush_height)*Brush_width);
if (new_brush) if (new_brush)
{ {
Rotate_90_deg_lowlevel(Brush,new_brush,Brush_width,Brush_height); Rotate_90_deg_lowlevel(Brush,/*@out@*/ new_brush,Brush_width,Brush_height);
free(Brush); free(Brush);
Brush=new_brush; Brush=new_brush;
@ -767,7 +800,7 @@ void Remap_brush(void)
// conversion puisque elles n'existent pas dans la brosse, donc elles // conversion puisque elles n'existent pas dans la brosse, donc elles
// ne seront pas utilisées par Remap_brush_LOWLEVEL. // ne seront pas utilisées par Remap_brush_LOWLEVEL.
for (color=0;color<=255;color++) for (color=0;color<=255;color++)
if (used[color]) if (used[color] != 0)
used[color]=Best_color(Spare_palette[color].R,Spare_palette[color].G,Spare_palette[color].B); used[color]=Best_color(Spare_palette[color].R,Spare_palette[color].G,Spare_palette[color].B);
// Il reste une couleur non calculée dans la table qu'il faut mettre à // Il reste une couleur non calculée dans la table qu'il faut mettre à
@ -808,13 +841,9 @@ void Outline_brush(void)
// On copie la brosse courante dans la nouvelle // On copie la brosse courante dans la nouvelle
Copy_part_of_image_to_another(Brush, // source Copy_part_of_image_to_another(Brush, // source
0, 0, 0, 0, Brush_width, Brush_height, Brush_width,
Brush_width, new_brush, // Destination
Brush_height, 1, 1, width);
Brush_width,
new_brush, // Destination
1, 1,
width);
// On intervertit la nouvelle et l'ancienne brosse: // On intervertit la nouvelle et l'ancienne brosse:
temp=Brush; temp=Brush;
@ -835,23 +864,20 @@ void Outline_brush(void)
{ {
if (temp[((y_pos-1)*width)+x_pos-1]==Back_color) if (temp[((y_pos-1)*width)+x_pos-1]==Back_color)
{ {
if (state) if (state != 0)
{ {
Pixel_in_brush(x_pos,y_pos,Fore_color); Pixel_in_brush(x_pos,y_pos,Fore_color);
state=0; state=0;
} }
} }
else else if (state == 0)
{ {
if (!state) Pixel_in_brush(x_pos-1,y_pos,Fore_color);
{ state=1;
Pixel_in_brush(x_pos-1,y_pos,Fore_color);
state=1;
}
} }
} }
// Cas du dernier pixel à droite de la ligne // Cas du dernier pixel à droite de la ligne
if (state) if (state != 0)
Pixel_in_brush(x_pos,y_pos,Fore_color); Pixel_in_brush(x_pos,y_pos,Fore_color);
} }
@ -863,23 +889,20 @@ void Outline_brush(void)
{ {
if (temp[((y_pos-1)*width)+x_pos-1]==Back_color) if (temp[((y_pos-1)*width)+x_pos-1]==Back_color)
{ {
if (state) if (state != 0)
{ {
Pixel_in_brush(x_pos,y_pos,Fore_color); Pixel_in_brush(x_pos,y_pos,Fore_color);
state=0; state=0;
} }
} }
else else if (state == 0)
{ {
if (!state)
{
Pixel_in_brush(x_pos,y_pos-1,Fore_color); Pixel_in_brush(x_pos,y_pos-1,Fore_color);
state=1; state=1;
}
} }
} }
// Cas du dernier pixel en bas de la colonne // Cas du dernier pixel en bas de la colonne
if (state) if (state != 0)
Pixel_in_brush(x_pos,y_pos,Fore_color); Pixel_in_brush(x_pos,y_pos,Fore_color);
} }
} }
@ -903,7 +926,7 @@ void Outline_brush(void)
void Nibble_brush(void) void Nibble_brush(void)
{ {
long /*Pos,*/x_pos,y_pos; long x_pos,y_pos;
byte state; byte state;
byte * new_brush; byte * new_brush;
byte * temp; byte * temp;
@ -946,7 +969,7 @@ void Nibble_brush(void)
{ {
if (temp[((y_pos+1)*width)+x_pos+1]==Back_color) if (temp[((y_pos+1)*width)+x_pos+1]==Back_color)
{ {
if (state) if (state != 0)
{ {
if (x_pos>0) if (x_pos>0)
Pixel_in_brush(x_pos-1,y_pos,Back_color); Pixel_in_brush(x_pos-1,y_pos,Back_color);
@ -955,7 +978,7 @@ void Nibble_brush(void)
} }
else else
{ {
if (!state) if (state == 0)
{ {
Pixel_in_brush(x_pos,y_pos,Back_color); Pixel_in_brush(x_pos,y_pos,Back_color);
state=1; state=1;
@ -984,7 +1007,7 @@ void Nibble_brush(void)
} }
else else
{ {
if (!state) if (state == 0)
{ {
Pixel_in_brush(x_pos,y_pos,Back_color); Pixel_in_brush(x_pos,y_pos,Back_color);
state=1; state=1;
@ -1021,7 +1044,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
short start_y=Limit_bottom+1; short start_y=Limit_bottom+1;
short end_x=Limit_left-1; short end_x=Limit_left-1;
short end_y=Limit_top-1; short end_y=Limit_top-1;
short temp; unsigned short temp;
short x_pos; short x_pos;
short y_pos; short y_pos;
word new_brush_width; word new_brush_width;
@ -1029,10 +1052,10 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
// On recherche les bornes de la brosse: // On recherche les bornes de la brosse:
for (temp=0; temp<vertices; temp++) for (temp=0; temp<2*vertices; temp+=2)
{ {
x_pos=points[temp<<1]; x_pos=points[temp];
y_pos=points[(temp<<1)+1]; y_pos=points[temp+1];
if (x_pos<start_x) if (x_pos<start_x)
start_x=x_pos; start_x=x_pos;
if (x_pos>end_x) if (x_pos>end_x)
@ -1079,6 +1102,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
Error(0); Error(0);
Brush=(byte *)malloc(1*1); Brush=(byte *)malloc(1*1);
if(Brush==NULL) Error(ERROR_MEMORY);
new_brush_height=new_brush_width=1; new_brush_height=new_brush_width=1;
*Brush=Fore_color; *Brush=Fore_color;
} }
@ -1097,6 +1121,7 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
free(Brush); free(Brush);
Brush=(byte *)malloc(1*1); Brush=(byte *)malloc(1*1);
if(Brush==NULL) Error(ERROR_MEMORY);
Brush_height=1; Brush_height=1;
Brush_width=1; Brush_width=1;

View File

@ -105,4 +105,12 @@ void Nibble_brush(void);
*/ */
void Capture_brush_with_lasso(int vertices, short * points,short clear); void Capture_brush_with_lasso(int vertices, short * points,short clear);
///
/// Changes the Brush size, discarding its previous content.
/// @return 0 OK, 1 Failed
byte Realloc_brush(word new_brush_width, word new_brush_height);
#endif #endif

1305
buttons.c

File diff suppressed because it is too large Load Diff

View File

@ -353,6 +353,11 @@ void Button_Snap_mode(void);
*/ */
void Button_Grid_menu(void); void Button_Grid_menu(void);
/*!
Callback to toggle the grid visible in the magnified view.
*/
void Button_Show_grid(void);
// Mode trame (Sieve) // Mode trame (Sieve)
/*! /*!
@ -425,6 +430,17 @@ void Button_Tiling_mode(void);
Displays the tiling setup menu. Displays the tiling setup menu.
*/ */
void Button_Tiling_menu(void); void Button_Tiling_menu(void);
/*!
Callback for the command that turns off all drawaing effects.
*/
void Effects_off(void);
/*!
Command that sets the transparency level.
*/
void Transparency_set(byte amount);
// Menu des effets // Menu des effets
/*! /*!
@ -568,6 +584,11 @@ void Button_Autosave(void);
*/ */
void Button_Settings(void); void Button_Settings(void);
/*!
Display the skin selector window.
*/
void Button_Skins(void);
// Annulation de la dernière modification // Annulation de la dernière modification
/*! /*!
@ -621,7 +642,7 @@ void Save_picture(byte image);
/*! /*!
Generic color tagging menu, for various effects. Generic color tagging menu, for various effects.
*/ */
void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section); void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section, word close_shortcut );
/*! /*!
@ -635,5 +656,7 @@ void Button_Smooth_menu(void);
*/ */
void Button_Smear_mode(void); void Button_Smear_mode(void);
void Button_Brush_container(void);
#endif #endif

56
const.h
View File

@ -33,7 +33,7 @@
#define BETA1 98 ///< Version number for gfx2.cfg (3/4) #define BETA1 98 ///< Version number for gfx2.cfg (3/4)
#define BETA2 0 ///< Version number for gfx2.cfg (4/4) #define BETA2 0 ///< Version number for gfx2.cfg (4/4)
#define MAX_VIDEO_MODES 100 ///< Maximum number of video modes Grafx2 can propose. #define MAX_VIDEO_MODES 100 ///< Maximum number of video modes Grafx2 can propose.
#define NB_SHORTCUTS 134 ///< Number of actions that can have a key combination associated to it. #define NB_SHORTCUTS 159 ///< Number of actions that can have a key combination associated to it.
#define NB_ZOOM_FACTORS 12 ///< Number of zoom levels available in the magnifier. #define NB_ZOOM_FACTORS 12 ///< Number of zoom levels available in the magnifier.
#define MENU_WIDTH 254 ///< Width of the menu (not counting the palette) #define MENU_WIDTH 254 ///< Width of the menu (not counting the palette)
#define MENU_HEIGHT 44 ///< Height of the menu. #define MENU_HEIGHT 44 ///< Height of the menu.
@ -58,13 +58,18 @@
#define DEFAULT_ZOOM_FACTOR 4 ///< Initial zoom factor for the magnifier. #define DEFAULT_ZOOM_FACTOR 4 ///< Initial zoom factor for the magnifier.
#define MAX_PATH_CHARACTERS 260 ///< Number of characters for a file+complete path. Adapt to your OS... #define MAX_PATH_CHARACTERS 260 ///< Number of characters for a file+complete path. Adapt to your OS...
#define NB_BOOKMARKS 4 ///< Number of bookmark buttons in Save/Load screen. #define NB_BOOKMARKS 4 ///< Number of bookmark buttons in Save/Load screen.
// Character to show a right arrow, used when editing long strings. It's present in ::GFX_system_font // Character to show a right arrow, used when editing long strings. It's present in ::Gfx->System_font
#define RIGHT_TRIANGLE_CHARACTER 16 #define RIGHT_TRIANGLE_CHARACTER 16
// Character to show a left arrow, used when editing long strings. It's present in ::GFX_system_font // Character to show a left arrow, used when editing long strings. It's present in ::Gfx->System_font
#define LEFT_TRIANGLE_CHARACTER 17 #define LEFT_TRIANGLE_CHARACTER 17
/// Character to display in menus for an ellipsis. /// Character to display in menus for an ellipsis.
#define ELLIPSIS_CHARACTER '…' #define ELLIPSIS_CHARACTER '…'
#define BRUSH_CONTAINER_PREVIEW_WIDTH 16 ///< Size for preview of a brush in Brush container
#define BRUSH_CONTAINER_PREVIEW_HEIGHT 16 ///< Size for preview of a brush in Brush container
#define BRUSH_CONTAINER_COLUMNS 4 ///< Number of columns in the Brush container
#define BRUSH_CONTAINER_ROWS 3 ///< Number of rows in the Brush container
/// ///
/// We force the dynamic backup page allocation to leave a minimum of /// We force the dynamic backup page allocation to leave a minimum of
/// 256Kb of free memory, to allow the rest of the program to work safely. /// 256Kb of free memory, to allow the rest of the program to work safely.
@ -90,14 +95,14 @@
// -- File formats // -- File formats
#ifndef __no_pnglib__ #ifndef __no_pnglib__
#define NB_KNOWN_FORMATS 13 ///< Total number of known file formats. #define NB_KNOWN_FORMATS 15 ///< Total number of known file formats.
#define NB_FORMATS_LOAD 13 ///< Number of file formats that grafx2 can load. #define NB_FORMATS_LOAD 15 ///< Number of file formats that grafx2 can load.
#define NB_FORMATS_SAVE 13 ///< Number of file formats that grafx2 can save. #define NB_FORMATS_SAVE 15 ///< Number of file formats that grafx2 can save.
#else #else
// Without pnglib // Without pnglib
#define NB_KNOWN_FORMATS 12 ///< Total number of known file formats. #define NB_KNOWN_FORMATS 14 ///< Total number of known file formats.
#define NB_FORMATS_LOAD 12 ///< Number of file formats that grafx2 can load. #define NB_FORMATS_LOAD 14 ///< Number of file formats that grafx2 can load.
#define NB_FORMATS_SAVE 12 ///< Number of file formats that grafx2 can save. #define NB_FORMATS_SAVE 14 ///< Number of file formats that grafx2 can save.
#endif #endif
/// List of file formats recognized by grafx2 /// List of file formats recognized by grafx2
@ -114,8 +119,10 @@ enum FILE_FORMATS
FORMAT_PI1, FORMAT_PI1,
FORMAT_PC1, FORMAT_PC1,
FORMAT_CEL, FORMAT_CEL,
FORMAT_NEO,
FORMAT_KCF, FORMAT_KCF,
FORMAT_PAL, FORMAT_PAL,
FORMAT_C64,
FORMAT_PNG FORMAT_PNG
}; };
@ -209,7 +216,8 @@ enum PAINTBRUSH_SHAPES
PAINTBRUSH_SHAPE_MISC, ///< A raw monochrome bitmap, can't be resized. This must be the last of the preset paintbrush types. PAINTBRUSH_SHAPE_MISC, ///< A raw monochrome bitmap, can't be resized. This must be the last of the preset paintbrush types.
PAINTBRUSH_SHAPE_POINT, ///< Used to reduce the paintbrush to a single pixel, during operations like colorpicker. PAINTBRUSH_SHAPE_POINT, ///< Used to reduce the paintbrush to a single pixel, during operations like colorpicker.
PAINTBRUSH_SHAPE_COLOR_BRUSH, ///< User's brush, in color mode PAINTBRUSH_SHAPE_COLOR_BRUSH, ///< User's brush, in color mode
PAINTBRUSH_SHAPE_MONO_BRUSH ///< User's brush, in mono mode PAINTBRUSH_SHAPE_MONO_BRUSH, ///< User's brush, in mono mode
PAINTBRUSH_SHAPE_MAX ///< Upper limit.
}; };
/// Normal resting state for a menu button. /// Normal resting state for a menu button.
@ -241,7 +249,7 @@ enum CHUNKS_CFG
CHUNK_MAX CHUNK_MAX
}; };
/// Identifiers for the 8x8 icons of ::GFX_icon_sprite (these are unused now) /// Identifiers for the 8x8 icons of ::Gfx->Icon_sprite (most are unused now)
enum ICON_TYPES enum ICON_TYPES
{ {
ICON_FLOPPY_3_5=0, ///< 3½" Floppy disk ICON_FLOPPY_3_5=0, ///< 3½" Floppy disk
@ -271,7 +279,6 @@ enum BUTTON_NUMBERS
BUTTON_CIRCLES, BUTTON_CIRCLES,
BUTTON_FILLCIRC, BUTTON_FILLCIRC,
BUTTON_GRADRECT, BUTTON_GRADRECT,
BUTTON_GRADMENU,
BUTTON_SPHERES, BUTTON_SPHERES,
BUTTON_BRUSH, BUTTON_BRUSH,
BUTTON_POLYBRUSH, BUTTON_POLYBRUSH,
@ -374,8 +381,33 @@ enum SPECIAL_ACTIONS
SPECIAL_SMOOTH_MODE, SPECIAL_SMOOTH_MODE,
SPECIAL_SMOOTH_MENU, SPECIAL_SMOOTH_MENU,
SPECIAL_SMEAR_MODE, SPECIAL_SMEAR_MODE,
SPECIAL_EFFECTS_OFF,
SPECIAL_TILING_MODE, SPECIAL_TILING_MODE,
SPECIAL_TRANSPARENCY_1,
SPECIAL_TRANSPARENCY_2,
SPECIAL_TRANSPARENCY_3,
SPECIAL_TRANSPARENCY_4,
SPECIAL_TRANSPARENCY_5,
SPECIAL_TRANSPARENCY_6,
SPECIAL_TRANSPARENCY_7,
SPECIAL_TRANSPARENCY_8,
SPECIAL_TRANSPARENCY_9,
SPECIAL_TRANSPARENCY_0,
SPECIAL_TILING_MENU, ///< This must be the last of the "effects" family SPECIAL_TILING_MENU, ///< This must be the last of the "effects" family
SPECIAL_ZOOM_1,
SPECIAL_ZOOM_2,
SPECIAL_ZOOM_3,
SPECIAL_ZOOM_4,
SPECIAL_ZOOM_5,
SPECIAL_ZOOM_6,
SPECIAL_ZOOM_8,
SPECIAL_ZOOM_10,
SPECIAL_ZOOM_12,
SPECIAL_ZOOM_14,
SPECIAL_ZOOM_16,
SPECIAL_ZOOM_18,
SPECIAL_ZOOM_20,
SPECIAL_SHOW_GRID,
NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts
}; };

View File

@ -52,7 +52,7 @@ executable; You can normally find it in a packed archive whose name begins by
the Subversion repository: the Subversion repository:
http://grafx2.googlecode.com/svn/trunk/ http://grafx2.googlecode.com/svn/trunk/
or you can find the latest versions as packed archives: or you can find the latest versions as packed archives:
http://code.google.com/p/grafx2/downloads/list http://code.google.com/p/grafx2/wiki/Downloads
=== COMPILING === === COMPILING ===
@ -76,17 +76,18 @@ Sends greetings and glops to pouet.net : http://pouet.net/prod.php?which=51865
=== HISTORY === === HISTORY ===
Short revision history : Short revision history :
* 06/2009 2.0 Completed the features planned by Sunset Design. * 09/2009 2.1 GUI improvements and some new features.
* 04/2009 2.0b99.0% Many new features and critical fixes. * 06/2009 2.0 Completed the features planned by Sunset Design.
* 01/2009 2.0b98.0% Now running Linux, Windows, Mac OS X, BeOS, Haiku, * 04/2009 2.0b99.0% Many new features and critical fixes.
AmigaOS 3.x and 4, MorphOS, SkyOS and gp2x. * 01/2009 2.0b98.0% Now running Linux, Windows, Mac OS X, BeOS, Haiku,
* 10/2008 2.0b97.0% Our first public beta release. AmigaOS 3.x and 4, MorphOS, SkyOS and gp2x.
* 07/2008 Our first public alpha release, Windows and Linux only * 10/2008 2.0b97.0% Our first public beta release.
* 04/2007 Start of this project and port to SDL. * 07/2008 Our first public alpha release, Windows and Linux only
* 2001 Sunset Design releases the source under the GNU GPL. * 04/2007 Start of this project and port to SDL.
* 12/1999 2.0b96.5% Last release from Sunset Design. * 2001 Sunset Design releases the source under the GNU GPL.
* 11/1996 2.0b90% First public release, at the Wired'96. * 12/1999 2.0b96.5% Last release from Sunset Design.
* 09/1995 Project starts. * 11/1996 2.0b90% First public release, at the Wired'96.
* 09/1995 Project starts.
Check http://code.google.com/p/grafx2/source/list for (very) detailed changelog. Check http://code.google.com/p/grafx2/source/list for (very) detailed changelog.
Check http://code.google.com/p/grafx2/wiki/History for an overview of the new Check http://code.google.com/p/grafx2/wiki/History for an overview of the new

716
engine.c
View File

@ -75,8 +75,7 @@ char * Menu_tooltip[NB_BUTTONS]=
"Filled rectangles ", "Filled rectangles ",
"Empty circles / ellipses", "Empty circles / ellipses",
"Filled circles / ellips.", "Filled circles / ellips.",
"Grad. rectangles ", "Grad. rect / Grad. menu ",
"Gradation menu ",
"Grad. spheres / ellipses", "Grad. spheres / ellipses",
"Brush grab. / Restore ", "Brush grab. / Restore ",
"Lasso / Restore brush ", "Lasso / Restore brush ",
@ -89,13 +88,13 @@ char * Menu_tooltip[NB_BUTTONS]=
"Go / Copy to other page ", "Go / Copy to other page ",
"Save as / Save ", "Save as / Save ",
"Load / Re-load ", "Load / Re-load ",
"Settings ", "Settings / Skins ",
"Clear / with backcolor ", "Clear / with backcolor ",
"Help / Statistics ", "Help / Statistics ",
"Undo / Redo ", "Undo / Redo ",
"Kill current page ", "Kill current page ",
"Quit ", "Quit ",
"Palette editor ", "Palette editor / setup ",
"Scroll pal. bkwd / Fast ", "Scroll pal. bkwd / Fast ",
"Scroll pal. fwd / Fast ", "Scroll pal. fwd / Fast ",
"Color #" , "Color #" ,
@ -108,6 +107,7 @@ void Save_background(byte **buffer, int x_pos, int y_pos, int width, int height)
int index; int index;
if(*buffer != NULL) DEBUG("WARNING : buffer already allocated !!!",0); if(*buffer != NULL) DEBUG("WARNING : buffer already allocated !!!",0);
*buffer=(byte *) malloc(width*Menu_factor_X*height*Menu_factor_Y*Pixel_width); *buffer=(byte *) malloc(width*Menu_factor_X*height*Menu_factor_Y*Pixel_width);
if(*buffer==NULL) Error(0);
for (index=0; index<(height*Menu_factor_Y); index++) for (index=0; index<(height*Menu_factor_Y); index++)
Read_line(x_pos,y_pos+index,width*Menu_factor_X,(*buffer)+((int)index*width*Menu_factor_X*Pixel_width)); Read_line(x_pos,y_pos+index,width*Menu_factor_X,(*buffer)+((int)index*width*Menu_factor_X*Pixel_width));
} }
@ -119,6 +119,7 @@ void Restore_background(byte *buffer, int x_pos, int y_pos, int width, int heigh
for (index=0; index<height*Menu_factor_Y; index++) for (index=0; index<height*Menu_factor_Y; index++)
Display_line_fast(x_pos,y_pos+index,width*Menu_factor_X,buffer+((int)index*width*Menu_factor_X*Pixel_width)); Display_line_fast(x_pos,y_pos+index,width*Menu_factor_X,buffer+((int)index*width*Menu_factor_X*Pixel_width));
free(buffer); free(buffer);
buffer = NULL;
} }
///Draw a pixel in a saved screen block (when you sort colors in the palette, for example) ///Draw a pixel in a saved screen block (when you sort colors in the palette, for example)
@ -211,74 +212,74 @@ void Draw_menu_button_frame(byte btn_number,byte pressed)
case BUTTON_SHAPE_RECTANGLE : case BUTTON_SHAPE_RECTANGLE :
// On colorie le point haut droit // On colorie le point haut droit
Pixel_in_menu(end_x,start_y,color_diagonal); Pixel_in_menu(end_x,start_y,color_diagonal);
GFX_menu_block[start_y][end_x]=color_diagonal; Gfx->Menu_block[start_y][end_x]=color_diagonal;
// On colorie le point bas gauche // On colorie le point bas gauche
Pixel_in_menu(start_x,end_y,color_diagonal); Pixel_in_menu(start_x,end_y,color_diagonal);
GFX_menu_block[end_y][start_x]=color_diagonal; Gfx->Menu_block[end_y][start_x]=color_diagonal;
// On colorie la partie haute // On colorie la partie haute
for (x_pos=start_x;x_pos<=end_x-1;x_pos++) for (x_pos=start_x;x_pos<=end_x-1;x_pos++)
{ {
Pixel_in_menu(x_pos,start_y,color_top_left); Pixel_in_menu(x_pos,start_y,color_top_left);
GFX_menu_block[start_y][x_pos]=color_top_left; Gfx->Menu_block[start_y][x_pos]=color_top_left;
} }
for (y_pos=start_y+1;y_pos<=end_y-1;y_pos++) for (y_pos=start_y+1;y_pos<=end_y-1;y_pos++)
{ {
// On colorie la partie gauche // On colorie la partie gauche
Pixel_in_menu(start_x,y_pos,color_top_left); Pixel_in_menu(start_x,y_pos,color_top_left);
GFX_menu_block[y_pos][start_x]=color_top_left; Gfx->Menu_block[y_pos][start_x]=color_top_left;
// On colorie la partie droite // On colorie la partie droite
Pixel_in_menu(end_x,y_pos,color_bottom_right); Pixel_in_menu(end_x,y_pos,color_bottom_right);
GFX_menu_block[y_pos][end_x]=color_bottom_right; Gfx->Menu_block[y_pos][end_x]=color_bottom_right;
} }
// On colorie la partie basse // On colorie la partie basse
for (x_pos=start_x+1;x_pos<=end_x;x_pos++) for (x_pos=start_x+1;x_pos<=end_x;x_pos++)
{ {
Pixel_in_menu(x_pos,end_y,color_bottom_right); Pixel_in_menu(x_pos,end_y,color_bottom_right);
GFX_menu_block[end_y][x_pos]=color_bottom_right; Gfx->Menu_block[end_y][x_pos]=color_bottom_right;
} }
break; break;
case BUTTON_SHAPE_TRIANGLE_TOP_LEFT: case BUTTON_SHAPE_TRIANGLE_TOP_LEFT:
// On colorie le point haut droit // On colorie le point haut droit
Pixel_in_menu(end_x,start_y,color_diagonal); Pixel_in_menu(end_x,start_y,color_diagonal);
GFX_menu_block[start_y][end_x]=color_diagonal; Gfx->Menu_block[start_y][end_x]=color_diagonal;
// On colorie le point bas gauche // On colorie le point bas gauche
Pixel_in_menu(start_x,end_y,color_diagonal); Pixel_in_menu(start_x,end_y,color_diagonal);
GFX_menu_block[end_y][start_x]=color_diagonal; Gfx->Menu_block[end_y][start_x]=color_diagonal;
// On colorie le coin haut gauche // On colorie le coin haut gauche
for (x_pos=0;x_pos<Buttons_Pool[btn_number].Width;x_pos++) for (x_pos=0;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
{ {
Pixel_in_menu(start_x+x_pos,start_y,color_top_left); Pixel_in_menu(start_x+x_pos,start_y,color_top_left);
GFX_menu_block[start_y][start_x+x_pos]=color_top_left; Gfx->Menu_block[start_y][start_x+x_pos]=color_top_left;
Pixel_in_menu(start_x,start_y+x_pos,color_top_left); Pixel_in_menu(start_x,start_y+x_pos,color_top_left);
GFX_menu_block[start_y+x_pos][start_x]=color_top_left; Gfx->Menu_block[start_y+x_pos][start_x]=color_top_left;
} }
// On colorie la diagonale // On colorie la diagonale
for (x_pos=1;x_pos<Buttons_Pool[btn_number].Width;x_pos++) for (x_pos=1;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
{ {
Pixel_in_menu(start_x+x_pos,end_y-x_pos,color_bottom_right); Pixel_in_menu(start_x+x_pos,end_y-x_pos,color_bottom_right);
GFX_menu_block[end_y-x_pos][start_x+x_pos]=color_bottom_right; Gfx->Menu_block[end_y-x_pos][start_x+x_pos]=color_bottom_right;
} }
break; break;
case BUTTON_SHAPE_TRIANGLE_BOTTOM_RIGHT: case BUTTON_SHAPE_TRIANGLE_BOTTOM_RIGHT:
// On colorie le point haut droit // On colorie le point haut droit
Pixel_in_menu(end_x,start_y,color_diagonal); Pixel_in_menu(end_x,start_y,color_diagonal);
GFX_menu_block[start_y][end_x]=color_diagonal; Gfx->Menu_block[start_y][end_x]=color_diagonal;
// On colorie le point bas gauche // On colorie le point bas gauche
Pixel_in_menu(start_x,end_y,color_diagonal); Pixel_in_menu(start_x,end_y,color_diagonal);
GFX_menu_block[end_y][start_x]=color_diagonal; Gfx->Menu_block[end_y][start_x]=color_diagonal;
// On colorie la diagonale // On colorie la diagonale
for (x_pos=1;x_pos<Buttons_Pool[btn_number].Width;x_pos++) for (x_pos=1;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
{ {
Pixel_in_menu(start_x+x_pos,end_y-x_pos,color_top_left); Pixel_in_menu(start_x+x_pos,end_y-x_pos,color_top_left);
GFX_menu_block[end_y-x_pos][start_x+x_pos]=color_top_left; Gfx->Menu_block[end_y-x_pos][start_x+x_pos]=color_top_left;
} }
// On colorie le coin bas droite // On colorie le coin bas droite
for (x_pos=0;x_pos<Buttons_Pool[btn_number].Width;x_pos++) for (x_pos=0;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
{ {
Pixel_in_menu(end_x-x_pos,end_y,color_bottom_right); Pixel_in_menu(end_x-x_pos,end_y,color_bottom_right);
GFX_menu_block[end_y][end_x-x_pos]=color_bottom_right; Gfx->Menu_block[end_y][end_x-x_pos]=color_bottom_right;
Pixel_in_menu(end_x,end_y-x_pos,color_bottom_right); Pixel_in_menu(end_x,end_y-x_pos,color_bottom_right);
GFX_menu_block[end_y-x_pos][end_x]=color_bottom_right; Gfx->Menu_block[end_y-x_pos][end_x]=color_bottom_right;
} }
} }
if (Menu_is_visible) if (Menu_is_visible)
@ -372,6 +373,9 @@ void Select_button(int btn_number,byte click)
// the unselection of all "Tool" buttons. // the unselection of all "Tool" buttons.
if (btn_number==BUTTON_ADJUST && click==RIGHT_SIDE) if (btn_number==BUTTON_ADJUST && click==RIGHT_SIDE)
break; break;
// Same case with the Grad. Rectangle button.
if (btn_number==BUTTON_GRADRECT && click==RIGHT_SIDE)
break;
// Pour chaque bouton: // Pour chaque bouton:
for (b=0; b<NB_BUTTONS; b++) for (b=0; b<NB_BUTTONS; b++)
// S'il est de la même famille // S'il est de la même famille
@ -774,7 +778,7 @@ void Main_handler(void)
Key=0; Key=0;
break; break;
case SPECIAL_EXCLUDE_COLORS_MENU : // Exclude colors menu case SPECIAL_EXCLUDE_COLORS_MENU : // Exclude colors menu
Menu_tag_colors("Tag colors to exclude",Exclude_color,&temp,1, NULL); Menu_tag_colors("Tag colors to exclude",Exclude_color,&temp,1, NULL, SPECIAL_EXCLUDE_COLORS_MENU);
Key=0; Key=0;
break; break;
case SPECIAL_INVERT_SIEVE : case SPECIAL_INVERT_SIEVE :
@ -821,6 +825,10 @@ void Main_handler(void)
Button_Grid_menu(); Button_Grid_menu();
Key=0; Key=0;
break; break;
case SPECIAL_SHOW_GRID :
Button_Show_grid();
Key=0;
break;
case SPECIAL_SIEVE_MODE : case SPECIAL_SIEVE_MODE :
Button_Sieve_mode(); Button_Sieve_mode();
Key=0; Key=0;
@ -857,6 +865,102 @@ void Main_handler(void)
Button_Tiling_menu(); Button_Tiling_menu();
Key=0; Key=0;
break; break;
case SPECIAL_EFFECTS_OFF :
Effects_off();
Key=0;
break;
case SPECIAL_TRANSPARENCY_1 :
Transparency_set(1);
Key=0;
break;
case SPECIAL_TRANSPARENCY_2 :
Transparency_set(2);
Key=0;
break;
case SPECIAL_TRANSPARENCY_3 :
Transparency_set(3);
Key=0;
break;
case SPECIAL_TRANSPARENCY_4 :
Transparency_set(4);
Key=0;
break;
case SPECIAL_TRANSPARENCY_5 :
Transparency_set(5);
Key=0;
break;
case SPECIAL_TRANSPARENCY_6 :
Transparency_set(6);
Key=0;
break;
case SPECIAL_TRANSPARENCY_7 :
Transparency_set(7);
Key=0;
break;
case SPECIAL_TRANSPARENCY_8 :
Transparency_set(8);
Key=0;
break;
case SPECIAL_TRANSPARENCY_9 :
Transparency_set(9);
Key=0;
break;
case SPECIAL_TRANSPARENCY_0 :
Transparency_set(0);
Key=0;
break;
case SPECIAL_ZOOM_1 :
Zoom_set(-1);
Key=0;
break;
case SPECIAL_ZOOM_2 :
Zoom_set(0);
Key=0;
break;
case SPECIAL_ZOOM_3 :
Zoom_set(1);
Key=0;
break;
case SPECIAL_ZOOM_4 :
Zoom_set(2);
Key=0;
break;
case SPECIAL_ZOOM_5 :
Zoom_set(3);
Key=0;
break;
case SPECIAL_ZOOM_6 :
Zoom_set(4);
Key=0;
break;
case SPECIAL_ZOOM_8 :
Zoom_set(5);
Key=0;
break;
case SPECIAL_ZOOM_10 :
Zoom_set(6);
Key=0;
break;
case SPECIAL_ZOOM_12 :
Zoom_set(7);
Key=0;
break;
case SPECIAL_ZOOM_14 :
Zoom_set(8);
Key=0;
break;
case SPECIAL_ZOOM_16 :
Zoom_set(9);
Key=0;
break;
case SPECIAL_ZOOM_18 :
Zoom_set(10);
Key=0;
break;
case SPECIAL_ZOOM_20 :
Zoom_set(11);
Key=0;
break;
default : // Gestion des touches de raccourci de bouton: default : // Gestion des touches de raccourci de bouton:
// Pour chaque bouton // Pour chaque bouton
shortcut_button=-1; shortcut_button=-1;
@ -1132,6 +1236,7 @@ void Close_window(void)
T_Scroller_button * temp3; T_Scroller_button * temp3;
T_Special_button * temp4; T_Special_button * temp4;
T_Dropdown_button * temp5; T_Dropdown_button * temp5;
T_List_button * temp6;
Hide_cursor(); Hide_cursor();
@ -1166,6 +1271,12 @@ void Close_window(void)
free(Window_dropdown_button_list); free(Window_dropdown_button_list);
Window_dropdown_button_list=temp5; Window_dropdown_button_list=temp5;
} }
while (Window_list_button_list)
{
temp6=Window_list_button_list->Next;
free(Window_list_button_list);
Window_list_button_list=temp6;
}
if (Windows_open != 1) if (Windows_open != 1)
{ {
@ -1613,6 +1724,42 @@ void Window_dropdown_clear_items(T_Dropdown_button * dropdown)
} }
} }
//----------------------- Create a List control -----------------------
// These controls are special. They work over two controls previously created:
// - entry_button is the textual area where the list values will be printed.
// - scroller is a scroller button attached to it
T_List_button * Window_set_list_button(T_Special_button * entry_button, T_Scroller_button * scroller, Func_draw_list_item draw_list_item)
{
T_List_button *temp;
temp=(T_List_button *)malloc(sizeof(T_List_button));
temp->Number =++Window_nb_buttons;
temp->List_start = 0;
temp->Cursor_position = 0;
temp->Entry_button = entry_button;
temp->Scroller = scroller;
temp->Draw_list_item = draw_list_item;
temp->Next=Window_list_button_list;
Window_list_button_list=temp;
return temp;
}
void Window_redraw_list(T_List_button * list)
{
int i;
for (i=Min(list->Scroller->Nb_visibles-1, list->Scroller->Nb_elements-1); i>=0; i--)
{
list->Draw_list_item(
list->Entry_button->Pos_X,
list->Entry_button->Pos_Y + i * 8,
list->List_start + i,
i == list->Cursor_position);
}
}
//----------------------- Ouverture d'un pop-up ----------------------- //----------------------- Ouverture d'un pop-up -----------------------
void Open_popup(word x_pos, word y_pos, word width,word height) void Open_popup(word x_pos, word y_pos, word width,word height)
@ -1676,7 +1823,8 @@ void Close_popup(void)
T_Palette_button * temp2; T_Palette_button * temp2;
T_Scroller_button * temp3; T_Scroller_button * temp3;
T_Special_button * temp4; T_Special_button * temp4;
T_Dropdown_button * temp5; T_Dropdown_button * temp5;
T_List_button * temp6;
Hide_cursor(); Hide_cursor();
@ -1711,7 +1859,13 @@ void Close_popup(void)
free(Window_dropdown_button_list); free(Window_dropdown_button_list);
Window_dropdown_button_list=temp5; Window_dropdown_button_list=temp5;
} }
while (Window_list_button_list)
{
temp6=Window_list_button_list->Next;
free(Window_list_button_list);
Window_list_button_list=temp6;
}
if (Windows_open != 1) if (Windows_open != 1)
{ {
// Restore de ce que la fenêtre cachait // Restore de ce que la fenêtre cachait
@ -1843,6 +1997,7 @@ void Get_color_behind_window(byte * color, byte * click)
char str[25]; char str[25];
byte cursor_was_hidden; byte cursor_was_hidden;
Hide_cursor(); Hide_cursor();
cursor_was_hidden=Cursor_hidden; cursor_was_hidden=Cursor_hidden;
@ -1933,15 +2088,15 @@ void Move_window(short dx, short dy)
{ {
short new_x=Mouse_X-dx; short new_x=Mouse_X-dx;
short new_y=Mouse_Y-dy; short new_y=Mouse_Y-dy;
short old_x; short old_x;
short old_y; short old_y;
short width=Window_width*Menu_factor_X; short width=Window_width*Menu_factor_X;
short height=Window_height*Menu_factor_Y; short height=Window_height*Menu_factor_Y;
short a; short a;
byte b; byte b;
byte *buffer=NULL; byte *buffer=NULL;
Hide_cursor(); Hide_cursor();
Horizontal_XOR_line(new_x,new_y,width); Horizontal_XOR_line(new_x,new_y,width);
Vertical_XOR_line(new_x,new_y+1,height-2); Vertical_XOR_line(new_x,new_y+1,height-2);
@ -2179,8 +2334,11 @@ short Window_dropdown_on_click(T_Dropdown_button *Button)
Window_attribute2=item->Number; Window_attribute2=item->Number;
if (Button->Display_choice) if (Button->Display_choice)
{ {
// Mettre à jour automatiquement le libellé de la dropdown // Automatically update the label of the dropdown list.
Print_in_window(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,item->Label,MC_Black,MC_Light); int text_length = (Button->Width-4-(Button->Display_arrow?8:0))/8;
// Clear original label area
Window_rectangle(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,text_length*8,8,MC_Light);
Print_in_window_limited(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,item->Label,text_length ,MC_Black,MC_Light);
} }
return Button->Number; return Button->Number;
} }
@ -2221,7 +2379,7 @@ short Window_normal_button_onclick(word x_pos, word y_pos, word width, word heig
} }
} }
// --- Renvoie le numéro du bouton clicke (-1:hors de la fenêtre, 0:aucun) --- // --- Returns the number of the clicked button (-1:out of the window, 0:none) ---
short Window_get_clicked_button(void) short Window_get_clicked_button(void)
{ {
T_Normal_button * temp1; T_Normal_button * temp1;
@ -2234,11 +2392,13 @@ short Window_get_clicked_button(void)
Window_attribute1=Mouse_K; Window_attribute1=Mouse_K;
// Test du click sur les boutons normaux // Test click on normal buttons
for (temp1=Window_normal_button_list; temp1; temp1=temp1->Next) for (temp1=Window_normal_button_list; temp1; temp1=temp1->Next)
{ {
if (Window_click_in_rectangle(temp1->Pos_X,temp1->Pos_Y,temp1->Pos_X+temp1->Width-1,temp1->Pos_Y+temp1->Height-1)) if ((Input_sticky_control == 0 || Input_sticky_control == temp1->Number)
&& Window_click_in_rectangle(temp1->Pos_X,temp1->Pos_Y,temp1->Pos_X+temp1->Width-1,temp1->Pos_Y+temp1->Height-1))
{ {
Input_sticky_control = temp1->Number;
if (temp1->Repeatable) if (temp1->Repeatable)
{ {
Hide_cursor(); Hide_cursor();
@ -2254,135 +2414,145 @@ short Window_get_clicked_button(void)
} }
} }
// Test du click sur les zones "palette" // Test click on "Palette" buttons
for (temp2=Window_palette_button_list; temp2; temp2=temp2->Next) for (temp2=Window_palette_button_list; temp2; temp2=temp2->Next)
{ {
if (Window_click_in_rectangle(temp2->Pos_X+5,temp2->Pos_Y+3,temp2->Pos_X+160,temp2->Pos_Y+82)) if ((Input_sticky_control == 0 || Input_sticky_control == temp2->Number)
&& Window_click_in_rectangle(temp2->Pos_X+5,temp2->Pos_Y+3,temp2->Pos_X+160,temp2->Pos_Y+82))
{ {
// On stocke dans Attribut2 le numero de couleur cliqué Input_sticky_control = temp2->Number;
// We store the clicked color in Attribute2
Window_attribute2 = (((Mouse_X-Window_pos_X)/Menu_factor_X)-(temp2->Pos_X+2)) / 10 * 16 + Window_attribute2 = (((Mouse_X-Window_pos_X)/Menu_factor_X)-(temp2->Pos_X+2)) / 10 * 16 +
(((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-(temp2->Pos_Y+3)) / 5; (((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-(temp2->Pos_Y+3)) / 5;
return temp2->Number; return temp2->Number;
} }
} }
// Test du click sur les barres de défilement // Test click oin slider/scroller bars
for (temp3=Window_scroller_button_list; temp3; temp3=temp3->Next) for (temp3=Window_scroller_button_list; temp3; temp3=temp3->Next)
{ {
if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1)) // Button Up arrow
if ((Input_sticky_control == 0 || Input_sticky_control == (temp3->Number|1024))
&& Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+10))
{ {
// Button flèche Haut Input_sticky_control = temp3->Number | 1024;
if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+10)) Hide_cursor();
Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
if (temp3->Position)
{ {
Hide_cursor(); temp3->Position--;
Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11); Window_attribute1=1;
Window_attribute2=temp3->Position;
if (temp3->Position) Window_draw_slider(temp3);
{
temp3->Position--;
Window_attribute1=1;
Window_attribute2=temp3->Position;
Window_draw_slider(temp3);
}
else
Window_attribute1=0;
Display_cursor();
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
Hide_cursor();
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
Display_cursor();
} }
else else
// Button flèche Bas Window_attribute1=0;
if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1))
Display_cursor();
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
Hide_cursor();
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
Display_cursor();
return (Window_attribute1)? temp3->Number : 0;
}
// Button Down arrow
if ((Input_sticky_control == 0 || Input_sticky_control == (temp3->Number|2048))
&& Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1))
{
Input_sticky_control = temp3->Number | 2048;
Hide_cursor();
Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
if (temp3->Position+temp3->Nb_visibles<temp3->Nb_elements)
{ {
Hide_cursor(); temp3->Position++;
Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11); Window_attribute1=2;
Window_attribute2=temp3->Position;
if (temp3->Position+temp3->Nb_visibles<temp3->Nb_elements) Window_draw_slider(temp3);
{
temp3->Position++;
Window_attribute1=2;
Window_attribute2=temp3->Position;
Window_draw_slider(temp3);
}
else
Window_attribute1=0;
Display_cursor();
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
Hide_cursor();
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
Display_cursor();
} }
else else
// Jauge
if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+12,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-13))
{
if (temp3->Nb_elements>temp3->Nb_visibles)
{
// S'il y a la place de faire scroller le curseur:
max_slider_height=(temp3->Height-24);
// Window_attribute2 reçoit la position dans la jauge correspondant au click
Window_attribute2 =(Mouse_Y-Window_pos_Y) / Menu_factor_Y;
Window_attribute2-=(temp3->Pos_Y+12+((temp3->Cursor_height-1)>>1));
Window_attribute2*=(temp3->Nb_elements-temp3->Nb_visibles);
if (Window_attribute2<0)
Window_attribute2=0;
else
{
Window_attribute2 =Round_div(Window_attribute2,max_slider_height-temp3->Cursor_height);
if (Window_attribute2+temp3->Nb_visibles>temp3->Nb_elements)
Window_attribute2=temp3->Nb_elements-temp3->Nb_visibles;
}
// Si le curseur de la jauge bouge:
if (temp3->Position!=Window_attribute2)
{
temp3->Position=Window_attribute2;
Window_attribute1=3;
Hide_cursor();
Window_draw_slider(temp3);
Display_cursor();
}
else
// Si le curseur de la jauge ne bouge pas:
Window_attribute1=0;
}
else
// S'il n'y a pas la place de bouger le curseur de la jauge:
Window_attribute1=0;
}
else
// Le click se situe dans la zone de la jauge mais n'est sur aucune
// des 3 parties importantes de la jauge
Window_attribute1=0; Window_attribute1=0;
Display_cursor();
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
Hide_cursor();
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
Display_cursor();
return (Window_attribute1)? temp3->Number : 0; return (Window_attribute1)? temp3->Number : 0;
} }
// Middle slider
if ((Input_sticky_control == temp3->Number) || (Input_sticky_control==0 &&
Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+12,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-13)))
{
Input_sticky_control = temp3->Number;
if (temp3->Nb_elements>temp3->Nb_visibles)
{
// If there is enough room to make the cursor move:
max_slider_height=(temp3->Height-24);
// Window_attribute2 receives the position of the cursor.
Window_attribute2 =(Mouse_Y-Window_pos_Y) / Menu_factor_Y;
Window_attribute2-=(temp3->Pos_Y+12+((temp3->Cursor_height-1)>>1));
Window_attribute2*=(temp3->Nb_elements-temp3->Nb_visibles);
if (Window_attribute2<0)
Window_attribute2=0;
else
{
Window_attribute2 =Round_div(Window_attribute2,max_slider_height-temp3->Cursor_height);
if (Window_attribute2+temp3->Nb_visibles>temp3->Nb_elements)
Window_attribute2=temp3->Nb_elements-temp3->Nb_visibles;
}
// If the cursor moved
if (temp3->Position!=Window_attribute2)
{
temp3->Position=Window_attribute2;
Window_attribute1=3;
Hide_cursor();
Window_draw_slider(temp3);
Display_cursor();
}
else
// If the cursor moved
Window_attribute1=0;
}
else
// If there's not enough room to make the cursor move:
Window_attribute1=0;
return (Window_attribute1)? temp3->Number : 0;
}
} }
// Test du click sur une zone spéciale // Test click on a special button
for (temp4=Window_special_button_list; temp4; temp4=temp4->Next) for (temp4=Window_special_button_list; temp4; temp4=temp4->Next)
{ {
if (Window_click_in_rectangle(temp4->Pos_X,temp4->Pos_Y,temp4->Pos_X+temp4->Width-1,temp4->Pos_Y+temp4->Height-1)) if ((Input_sticky_control == 0 || Input_sticky_control == temp4->Number)
return temp4->Number; && Window_click_in_rectangle(temp4->Pos_X,temp4->Pos_Y,temp4->Pos_X+temp4->Width-1,temp4->Pos_Y+temp4->Height-1))
{
Input_sticky_control = temp4->Number;
return temp4->Number;
}
} }
// Test du click sur une dropdown // Test click on a dropdown box
for (temp5=Window_dropdown_button_list; temp5; temp5=temp5->Next) for (temp5=Window_dropdown_button_list; temp5; temp5=temp5->Next)
{ {
if (Window_click_in_rectangle(temp5->Pos_X,temp5->Pos_Y,temp5->Pos_X+temp5->Width-1,temp5->Pos_Y+temp5->Height-1)) if ((Input_sticky_control == 0 || Input_sticky_control == temp5->Number)
&& Window_click_in_rectangle(temp5->Pos_X,temp5->Pos_Y,temp5->Pos_X+temp5->Width-1,temp5->Pos_Y+temp5->Height-1))
{ {
Input_sticky_control = temp5->Number;
if (Mouse_K & temp5->Active_button) if (Mouse_K & temp5->Active_button)
return Window_dropdown_on_click(temp5); return Window_dropdown_on_click(temp5);
else else
@ -2440,7 +2610,25 @@ short Window_get_button_shortcut(void)
temp=temp->Next; temp=temp->Next;
} }
} }
// Handle arrow keys, end/home, and mouse wheel that have
// a certain behavior if a list control is present.
if (Window_list_button_list)
{
T_List_button *list = Window_list_button_list;
// If there's more than one of such control, only capture
// events if the mouse cursor is over it.
if (list->Next)
{
// to do
}
}
return 0; return 0;
} }
@ -2450,31 +2638,275 @@ short Window_clicked_button(void)
if(!Get_input())SDL_Delay(20); if(!Get_input())SDL_Delay(20);
// Gestion des clicks // Handle clicks
if (Mouse_K) if (Mouse_K)
{ {
if ((Mouse_X<Window_pos_X) || (Mouse_Y<Window_pos_Y) if ((Mouse_X<Window_pos_X) || (Mouse_Y<Window_pos_Y)
|| (Mouse_X>=Window_pos_X+(Window_width*Menu_factor_X)) || (Mouse_X>=Window_pos_X+(Window_width*Menu_factor_X))
|| (Mouse_Y>=Window_pos_Y+(Window_height*Menu_factor_Y))) || (Mouse_Y>=Window_pos_Y+(Window_height*Menu_factor_Y)))
return -1; {
if (Input_sticky_control == 0 || Input_sticky_control == -1)
{
Input_sticky_control = -1;
return -1;
}
else
{
return 0;
}
}
if (!Input_sticky_control && Mouse_Y < Window_pos_Y+(12*Menu_factor_Y))
{
Move_window(Mouse_X-Window_pos_X,Mouse_Y-Window_pos_Y);
}
else else
{ {
if (Mouse_Y < Window_pos_Y+(12*Menu_factor_Y)) short clicked_button;
Move_window(Mouse_X-Window_pos_X,Mouse_Y-Window_pos_Y); T_List_button * list;
else
return Window_get_clicked_button(); // Check which controls was clicked (by rectangular area)
clicked_button = Window_get_clicked_button();
// Check if it's part of a list control
for (list=Window_list_button_list; list!=NULL; list=list->Next)
{
if (list->Entry_button->Number == clicked_button)
{
// Click in the textual part of a list.
short clicked_line;
clicked_line = (((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-list->Entry_button->Pos_Y)>>3;
if (clicked_line == list->Cursor_position || // Same as before
clicked_line >= list->Scroller->Nb_elements) // Below last line
return 0;
Hide_cursor();
// Redraw one item as disabled
if (list->Cursor_position>=0 && list->Cursor_position<list->Scroller->Nb_visibles)
list->Draw_list_item(
list->Entry_button->Pos_X,
list->Entry_button->Pos_Y + list->Cursor_position * 8,
list->List_start + list->Cursor_position,
0);
list->Cursor_position = clicked_line;
// Redraw one item as enabled
if (list->Cursor_position>=0 && list->Cursor_position<list->Scroller->Nb_visibles)
list->Draw_list_item(
list->Entry_button->Pos_X,
list->Entry_button->Pos_Y + list->Cursor_position * 8,
list->List_start + list->Cursor_position,
1);
Display_cursor();
// Store the selected value as attribute2
Window_attribute2=list->List_start + list->Cursor_position;
// Return the control ID of the list.
return list->Number;
}
else if (list->Scroller->Number == clicked_button)
{
// Click in the scroller part of a list
if (list->List_start == list->Scroller->Position)
return 0; // Didn't actually move
// Update scroller indices
list->Cursor_position += list->List_start;
list->List_start = list->Scroller->Position;
list->Cursor_position -= list->List_start;
// Need to redraw all
Hide_cursor();
Window_redraw_list(list);
Display_cursor();
}
}
return clicked_button;
} }
} }
// Gestion des touches // Intercept keys
if (Key) if (Key)
{ {
T_List_button * list;
Button=Window_get_button_shortcut(); Button=Window_get_button_shortcut();
if (Button) if (Button)
{ {
Key=0; Key=0;
return Button; return Button;
} }
// Check if there's a list control and the keys can control it
for (list=Window_list_button_list; list!=NULL; list=list->Next)
{
// FIXME: Make only one list have the keyboard focus.
if (1)
{
if (Key==SDLK_UP && (list->Cursor_position+list->List_start)>0)
{
Key=0;
Hide_cursor();
list->Cursor_position--;
if (list->Cursor_position<0)
{
list->List_start=list->List_start+list->Cursor_position;
list->Cursor_position=0;
// Mise à jour du scroller
list->Scroller->Position=list->List_start;
Window_draw_slider(list->Scroller);
}
Window_redraw_list(list);
Display_cursor();
// Store the selected value as attribute2
Window_attribute2=list->List_start + list->Cursor_position;
// Return the control ID of the list.
return list->Number;
}
if (Key==SDLK_DOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
{
Key=0;
Hide_cursor();
list->Cursor_position++;
if (list->Cursor_position>(list->Scroller->Nb_visibles-1))
{
list->List_start=list->List_start+list->Cursor_position-(list->Scroller->Nb_visibles-1);
list->Cursor_position=(list->Scroller->Nb_visibles-1);
// Mise à jour du scroller
list->Scroller->Position=list->List_start;
Window_draw_slider(list->Scroller);
}
Window_redraw_list(list);
Display_cursor();
// Store the selected value as attribute2
Window_attribute2=list->List_start + list->Cursor_position;
// Return the control ID of the list.
return list->Number;
}
if (Key==SDLK_HOME && (list->Cursor_position!=0 || list->List_start!=0))
{
Key=0;
Hide_cursor();
list->Cursor_position=0;
list->List_start=0;
// Mise à jour du scroller
list->Scroller->Position=list->List_start;
Window_draw_slider(list->Scroller);
Window_redraw_list(list);
Display_cursor();
// Store the selected value as attribute2
Window_attribute2=list->List_start + list->Cursor_position;
// Return the control ID of the list.
return list->Number;
}
if (Key==SDLK_END && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
{
Key=0;
Hide_cursor();
list->Cursor_position=(list->Scroller->Nb_elements-1)-list->List_start;
if (list->Cursor_position>(list->Scroller->Nb_visibles-1))
{
list->List_start=list->List_start+list->Cursor_position-(list->Scroller->Nb_visibles-1);
list->Cursor_position=(list->Scroller->Nb_visibles-1);
// Mise à jour du scroller
list->Scroller->Position=list->List_start;
Window_draw_slider(list->Scroller);
}
Window_redraw_list(list);
Display_cursor();
// Store the selected value as attribute2
Window_attribute2=list->List_start + list->Cursor_position;
// Return the control ID of the list.
return list->Number;
}
if (Key==SDLK_PAGEDOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
{
Key=0;
Hide_cursor();
if (list->Scroller->Nb_elements<list->Scroller->Nb_visibles)
{
list->Cursor_position=list->Scroller->Nb_elements-1;
}
else if(list->Cursor_position!=list->Scroller->Nb_visibles-1)
{
list->Cursor_position=list->Scroller->Nb_visibles-1;
}
else
{
list->List_start+=list->Scroller->Nb_visibles;
if (list->List_start+list->Scroller->Nb_visibles>list->Scroller->Nb_elements)
{
list->List_start=list->Scroller->Nb_elements-list->Scroller->Nb_visibles;
}
// Mise à jour du scroller
list->Scroller->Position=list->List_start;
Window_draw_slider(list->Scroller);
}
Window_redraw_list(list);
Display_cursor();
// Store the selected value as attribute2
Window_attribute2=list->List_start + list->Cursor_position;
// Return the control ID of the list.
return list->Number;
}
if (Key==SDLK_PAGEUP && (list->Cursor_position+list->List_start)>0)
{
Key=0;
Hide_cursor();
if(list->Cursor_position!=0)
{
list->Cursor_position=0;
}
else
{
list->List_start-=list->Scroller->Nb_visibles;
if (list->List_start<0)
{
list->List_start=0;
}
// Mise à jour du scroller
list->Scroller->Position=list->List_start;
Window_draw_slider(list->Scroller);
}
Window_redraw_list(list);
Display_cursor();
// Store the selected value as attribute2
Window_attribute2=list->List_start + list->Cursor_position;
// Return the control ID of the list.
return list->Number;
}
if (Key == KEY_MOUSEWHEELUP && list->List_start>0)
{
list->Cursor_position+=list->List_start;
if (list->List_start>=3)
list->List_start-=3;
else
list->List_start=0;
list->Cursor_position-=list->List_start;
// On affiche à nouveau la liste
Hide_cursor();
Window_redraw_list(list);
// Mise à jour du scroller
list->Scroller->Position=list->List_start;
Window_draw_slider(list->Scroller);
Display_cursor();
}
if (Key==KEY_MOUSEWHEELDOWN && list->List_start<list->Scroller->Nb_elements-list->Scroller->Nb_visibles)
{
list->Cursor_position+=list->List_start;
list->List_start+=3;
if (list->List_start+list->Scroller->Nb_visibles>list->Scroller->Nb_elements)
{
list->List_start=list->Scroller->Nb_elements-list->Scroller->Nb_visibles;
}
list->Cursor_position-=list->List_start;
// On affiche à nouveau la liste
Hide_cursor();
Window_redraw_list(list);
// Mise à jour du scroller
list->Scroller->Position=list->List_start;
Window_draw_slider(list->Scroller);
Display_cursor();
}
}
}
} }
return 0; return 0;

174
engine.h
View File

@ -1,80 +1,94 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file engine.h ///@file engine.h
/// Utility functions for the menu and all windows. /// Utility functions for the menu and all windows.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Main_handler (void); #ifndef __ENGINE_H__
void Draw_menu_button_frame(byte btn_number,byte pressed); #define __ENGINE_H__
void Unselect_button (int btn_number);
void Select_button (int btn_number,byte click); #include "struct.h"
void Open_window (word width,word height, char * title);
void Close_window (void); void Main_handler (void);
void Draw_menu_button_frame(byte btn_number,byte pressed);
void Open_popup (word x_pos, word y_pos, word width, word height); void Unselect_button (int btn_number);
void Close_popup (void); void Select_button (int btn_number,byte click);
void Open_window (word width,word height, char * title);
void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height, void Close_window (void);
char * title,byte undersc_letter,byte clickable);
void Window_select_normal_button(word x_pos,word y_pos,word width,word height); void Open_popup (word x_pos, word y_pos, word width, word height);
void Window_unselect_normal_button(word x_pos,word y_pos,word width,word height); void Close_popup (void);
void Window_draw_palette_bouton(word x_pos,word y_pos);
void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height,
void Compute_slider_cursor_height(T_Scroller_button * button); char * title,byte undersc_letter,byte clickable);
void Window_draw_slider(T_Scroller_button * button); void Window_select_normal_button(word x_pos,word y_pos,word width,word height);
void Window_draw_scroller_bouton(T_Scroller_button * button); void Window_unselect_normal_button(word x_pos,word y_pos,word width,word height);
void Window_draw_palette_bouton(word x_pos,word y_pos);
void Window_input_content(T_Special_button * button, char * content);
void Window_clear_input_button(T_Special_button * button); void Compute_slider_cursor_height(T_Scroller_button * button);
void Window_draw_input_bouton(word x_pos,word y_pos,word width_in_characters); void Window_draw_slider(T_Scroller_button * button);
void Window_draw_scroller_bouton(T_Scroller_button * button);
T_Normal_button * Window_set_normal_button(word x_pos, word y_pos,
word width, word height, void Window_input_content(T_Special_button * button, char * content);
char * title,byte undersc_letter, void Window_clear_input_button(T_Special_button * button);
byte clickable, word shortcut); void Window_draw_input_bouton(word x_pos,word y_pos,word width_in_characters);
T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos,
word width, word height, T_Normal_button * Window_set_normal_button(word x_pos, word y_pos,
char * title,byte undersc_letter, word width, word height,
byte clickable, word shortcut); char * title,byte undersc_letter,
byte clickable, word shortcut);
T_Palette_button * Window_set_palette_button(word x_pos, word y_pos); T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos,
void Window_clear_tags(void); word width, word height,
void Tag_color_range(byte start,byte end); char * title,byte undersc_letter,
byte clickable, word shortcut);
T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
word height, T_Palette_button * Window_set_palette_button(word x_pos, word y_pos);
word nb_elements, void Window_clear_tags(void);
word nb_elements_visible, void Tag_color_range(byte start,byte end);
word initial_position);
T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,word height); T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
T_Special_button * Window_set_input_button(word x_pos,word y_pos,word width_in_characters); word height, word nb_elements, word nb_elements_visible,
T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,word height,word dropdown_width,const char *label,byte display_choice,byte display_centered,byte display_arrow,byte active_button); word initial_position);
void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number, const char *label); T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,
void Window_dropdown_clear_items(T_Dropdown_button * dropdown); word height);
byte Window_click_in_rectangle(short start_x,short start_y,short end_x,short end_y); T_Special_button * Window_set_input_button(word x_pos,word y_pos,
short Wait_click_in_palette(T_Palette_button * button); word width_in_characters);
void Get_color_behind_window(byte * color, byte * click); T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,
word height,word dropdown_width,const char *label,byte display_choice,
short Window_clicked_button(void); byte display_centered,byte display_arrow,byte active_button);
int Button_under_mouse(void); void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number,
short Window_get_clicked_button(void); const char *label);
void Remap_window_backgrounds(byte * conversion_table, int Min_Y, int Max_Y); void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
void Pixel_background(int x_pos, int y_pos, byte color); T_List_button * Window_set_list_button(T_Special_button * entry_button,
T_Scroller_button * scroller, Func_draw_list_item draw_list_item);
void Window_redraw_list(T_List_button * list);
byte Window_click_in_rectangle(short start_x,short start_y,short end_x,
short end_y);
short Wait_click_in_palette(T_Palette_button * button);
void Get_color_behind_window(byte * color, byte * click);
short Window_clicked_button(void);
int Button_under_mouse(void);
short Window_get_clicked_button(void);
void Remap_window_backgrounds(byte * conversion_table, int Min_Y, int Max_Y);
void Pixel_background(int x_pos, int y_pos, byte color);
#endif

346
filesel.c
View File

@ -64,14 +64,58 @@
#define SELECTED_DIRECTORY_COLOR MC_Light // color du texte pour une ligne de repértoire sélectionnée #define SELECTED_DIRECTORY_COLOR MC_Light // color du texte pour une ligne de repértoire sélectionnée
#define SELECTED_BACKGROUND_COLOR MC_Dark // color du fond pour une ligne sélectionnée #define SELECTED_BACKGROUND_COLOR MC_Dark // color du fond pour une ligne sélectionnée
// -- Fileselector data
T_Fileselector Filelist;
// Conventions: // Conventions:
// //
// * Le fileselect modifie le répertoire courant. Ceci permet de n'avoir // * Le fileselect modifie le répertoire courant. Ceci permet de n'avoir
// qu'un findfirst dans le répertoire courant à faire: // qu'un findfirst dans le répertoire courant à faire:
void Recount_files(T_Fileselector *list)
{
T_Fileselector_item *item;
list->Nb_files=0;
list->Nb_directories=0;
list->Nb_elements=0;
for (item = list->First; item != NULL; item = item->Next)
{
if (item->Type == 0)
list->Nb_files ++;
else
list->Nb_directories ++;
list->Nb_elements ++;
}
if (list->Index)
{
free(list->Index);
list->Index = NULL;
}
if (list->Nb_elements>0)
{
int i;
list->Index = (T_Fileselector_item **) malloc(list->Nb_elements * sizeof(T_Fileselector_item **));
if (list->Index)
{
// Fill the index
for (item = list->First, i=0; item != NULL; item = item->Next, i++)
{
list->Index[i] = item;
}
}
// If the malloc failed, we're probably in trouble, but I don't know
// how to recover from that..I'll just make the index bulletproof.
}
}
// -- Déstruction de la liste chaînée --------------------------------------- // -- Destruction de la liste chaînée ---------------------------------------
void Free_fileselector_list(void) void Free_fileselector_list(T_Fileselector *list)
// Cette procédure détruit la chaine des fichiers. Elle doit être appelée // Cette procédure détruit la chaine des fichiers. Elle doit être appelée
// avant de rappeler la fonction Read_list_of_files, ainsi qu'en fin de // avant de rappeler la fonction Read_list_of_files, ainsi qu'en fin de
// programme. // programme.
@ -79,23 +123,19 @@ void Free_fileselector_list(void)
// Pointeur temporaire de destruction // Pointeur temporaire de destruction
T_Fileselector_item * temp_item; T_Fileselector_item * temp_item;
while (Filelist!=NULL) while (list->First!=NULL)
{ {
// On mémorise l'adresse du premier élément de la liste // On mémorise l'adresse du premier élément de la liste
temp_item =Filelist; temp_item =list->First;
// On fait avancer la tête de la liste // On fait avancer la tête de la liste
Filelist=Filelist->Next; list->First=list->First->Next;
// Et on efface l'ancien premier élément de la liste // Et on efface l'ancien premier élément de la liste
free(temp_item); free(temp_item);
} }
Recount_files(list);
} }
char * Format_filename(const char * fname, int type)
///
/// Formats a display name for a file, directory, or similar name (drive, volume).
/// The returned value is a pointer to a single static buffer of 19 characters
/// including the '\0'.
char * Format_filename(char * fname, int type)
{ {
static char result[19]; static char result[19];
int c; int c;
@ -148,7 +188,7 @@ char * Format_filename(char * fname, int type)
// -- Rajouter a la liste des elements de la liste un element --------------- // -- Rajouter a la liste des elements de la liste un element ---------------
void Add_element_to_list(char * fname, int type) void Add_element_to_list(T_Fileselector *list, const char * fname, int type)
// Cette procedure ajoute a la liste chainee un fichier passé en argument. // Cette procedure ajoute a la liste chainee un fichier passé en argument.
{ {
// Pointeur temporaire d'insertion // Pointeur temporaire d'insertion
@ -162,12 +202,12 @@ void Add_element_to_list(char * fname, int type)
strcpy(temp_item->Full_name,fname); strcpy(temp_item->Full_name,fname);
temp_item->Type = type; temp_item->Type = type;
temp_item->Next =Filelist; temp_item->Next =list->First;
temp_item->Previous=NULL; temp_item->Previous=NULL;
if (Filelist!=NULL) if (list->First!=NULL)
Filelist->Previous=temp_item; list->First->Previous=temp_item;
Filelist=temp_item; list->First=temp_item;
} }
// -- Vérification si un fichier a l'extension demandée. // -- Vérification si un fichier a l'extension demandée.
@ -203,11 +243,11 @@ int Check_extension(const char *filename, char * filter)
// -- Lecture d'une liste de fichiers --------------------------------------- // -- Lecture d'une liste de fichiers ---------------------------------------
void Read_list_of_files(byte selected_format) void Read_list_of_files(T_Fileselector *list, byte selected_format)
// Cette procédure charge dans la liste chainée les fichiers dont l'extension // Cette procédure charge dans la liste chainée les fichiers dont l'extension
// correspond au format demandé. // correspond au format demandé.
{ {
DIR* Repertoire_Courant; //Répertoire courant DIR* current_directory; //Répertoire courant
struct dirent* entry; // Structure de lecture des éléments struct dirent* entry; // Structure de lecture des éléments
char * filter = "*"; // Extension demandée char * filter = "*"; // Extension demandée
struct stat Infos_enreg; struct stat Infos_enreg;
@ -218,15 +258,13 @@ void Read_list_of_files(byte selected_format)
filter = File_formats[selected_format-1].Extension; filter = File_formats[selected_format-1].Extension;
// Ensuite, on vide la liste actuelle: // Ensuite, on vide la liste actuelle:
Free_fileselector_list(); Free_fileselector_list(list);
// Après effacement, il ne reste ni fichier ni répertoire dans la liste // Après effacement, il ne reste ni fichier ni répertoire dans la liste
Filelist_nb_files=0;
Filelist_nb_directories=0;
// On lit tous les répertoires: // On lit tous les répertoires:
current_path=getcwd(NULL,0); current_path=getcwd(NULL,0);
Repertoire_Courant=opendir(current_path); current_directory=opendir(current_path);
while ((entry=readdir(Repertoire_Courant))) while ((entry=readdir(current_directory)))
{ {
// On ignore le répertoire courant // On ignore le répertoire courant
if ( !strcmp(entry->d_name, ".")) if ( !strcmp(entry->d_name, "."))
@ -243,8 +281,8 @@ void Read_list_of_files(byte selected_format)
!isHidden(entry))) !isHidden(entry)))
{ {
// On rajoute le répertoire à la liste // On rajoute le répertoire à la liste
Add_element_to_list(entry->d_name, 1); Add_element_to_list(list, entry->d_name, 1);
Filelist_nb_directories++; list->Nb_directories++;
} }
else if (S_ISREG(Infos_enreg.st_mode) && //Il s'agit d'un fichier else if (S_ISREG(Infos_enreg.st_mode) && //Il s'agit d'un fichier
(Config.Show_hidden_files || //Il n'est pas caché (Config.Show_hidden_files || //Il n'est pas caché
@ -253,21 +291,21 @@ void Read_list_of_files(byte selected_format)
if (Check_extension(entry->d_name, filter)) if (Check_extension(entry->d_name, filter))
{ {
// On rajoute le fichier à la liste // On rajoute le fichier à la liste
Add_element_to_list(entry->d_name, 0); Add_element_to_list(list, entry->d_name, 0);
Filelist_nb_files++; list->Nb_files++;
} }
} }
} }
#if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__) #if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__)
Add_element_to_list("/",1); // on amiga systems, / means parent. And there is no .. Add_element_to_list(list, "/",1); // on amiga systems, / means parent. And there is no ..
Filelist_nb_directories ++; list->Nb_directories ++;
#endif #endif
closedir(Repertoire_Courant); closedir(current_directory);
free(current_path); free(current_path);
Filelist_nb_elements=Filelist_nb_directories+Filelist_nb_files; Recount_files(list);
} }
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
@ -290,14 +328,14 @@ void bstrtostr( BSTR in, STRPTR out, TEXT max )
#endif #endif
// -- Lecture d'une liste de lecteurs / volumes ----------------------------- // -- Lecture d'une liste de lecteurs / volumes -----------------------------
void Read_list_of_drives(void) void Read_list_of_drives(T_Fileselector *list)
{ {
// Empty the current content of fileselector: // Empty the current content of fileselector:
Free_fileselector_list(); Free_fileselector_list(list);
// Reset number of items // Reset number of items
Filelist_nb_files=0; list->Nb_files=0;
Filelist_nb_directories=0; list->Nb_directories=0;
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
{ {
@ -311,8 +349,8 @@ void Read_list_of_drives(void)
{ {
bstrtostr( dl->dol_Name, tmp, 254 ); bstrtostr( dl->dol_Name, tmp, 254 );
strcat( tmp, ":" ); strcat( tmp, ":" );
Add_element_to_list( tmp, 2 ); Add_element_to_list(list, tmp, 2 );
Filelist_nb_directories++; list->Nb_directories++;
} }
UnLockDosList( LDF_VOLUMES | LDF_READ ); UnLockDosList( LDF_VOLUMES | LDF_READ );
} }
@ -354,8 +392,8 @@ void Read_list_of_drives(void)
break; break;
} }
drive_name[0]='A'+bit_index; drive_name[0]='A'+bit_index;
Add_element_to_list(drive_name,2); Add_element_to_list(list, drive_name,2);
Filelist_nb_directories++; list->Nb_directories++;
drive_index++; drive_index++;
} }
} }
@ -368,7 +406,7 @@ void Read_list_of_drives(void)
// Ensuite on utilise read_file_system_list pour compléter // Ensuite on utilise read_file_system_list pour compléter
struct mount_entry* Liste_points_montage; struct mount_entry* mount_points_list;
struct mount_entry* next; struct mount_entry* next;
#if defined(__BEOS__) || defined(__HAIKU__) #if defined(__BEOS__) || defined(__HAIKU__)
@ -376,42 +414,42 @@ void Read_list_of_drives(void)
#else #else
char * home_dir = getenv("HOME"); char * home_dir = getenv("HOME");
#endif #endif
Add_element_to_list("/", 2); Add_element_to_list(list, "/", 2);
Filelist_nb_directories++; list->Nb_directories++;
if(home_dir) if(home_dir)
{ {
Add_element_to_list(home_dir, 2); Add_element_to_list(list, home_dir, 2);
Filelist_nb_directories++; list->Nb_directories++;
} }
Liste_points_montage = read_file_system_list(0); mount_points_list = read_file_system_list(0);
while(Liste_points_montage != NULL) while(mount_points_list != NULL)
{ {
if(Liste_points_montage->me_dummy == 0 && strcmp(Liste_points_montage->me_mountdir,"/") && strcmp(Liste_points_montage->me_mountdir,"/home")) if(mount_points_list->me_dummy == 0 && strcmp(mount_points_list->me_mountdir,"/") && strcmp(mount_points_list->me_mountdir,"/home"))
{ {
Add_element_to_list(Liste_points_montage->me_mountdir,2); Add_element_to_list(list, mount_points_list->me_mountdir,2);
Filelist_nb_directories++; list->Nb_directories++;
} }
next = Liste_points_montage -> me_next; next = mount_points_list -> me_next;
#if !(defined(__macosx__) || defined(__FreeBSD__)) #if !(defined(__macosx__) || defined(__FreeBSD__))
free(Liste_points_montage -> me_type); free(mount_points_list -> me_type);
#endif #endif
free(Liste_points_montage -> me_devname); free(mount_points_list -> me_devname);
free(Liste_points_montage -> me_mountdir); free(mount_points_list -> me_mountdir);
free(Liste_points_montage); free(mount_points_list);
Liste_points_montage = next; mount_points_list = next;
} }
} }
#endif #endif
Filelist_nb_elements=Filelist_nb_directories+Filelist_nb_files; Recount_files(list);
} }
// -- Tri de la liste des fichiers et répertoires --------------------------- // -- Tri de la liste des fichiers et répertoires ---------------------------
void Sort_list_of_files(void) void Sort_list_of_files(T_Fileselector *list)
// Tri la liste chainée existante dans l'ordre suivant: // Tri la liste chainée existante dans l'ordre suivant:
// //
// * Les répertoires d'abord, dans l'ordre alphabétique de leur nom // * Les répertoires d'abord, dans l'ordre alphabétique de leur nom
@ -424,16 +462,15 @@ void Sort_list_of_files(void)
T_Fileselector_item * next_item; T_Fileselector_item * next_item;
T_Fileselector_item * next_to_next_item; T_Fileselector_item * next_to_next_item;
// Avant de trier quoi que ce soit, on vérifie qu'il y ait suffisamment // Check there are at least two elements before sorting
// d'éléments pour qu'il soit possibles qu'ils soient en désordre: if (list->First && list->First->Next)
if (Filelist_nb_elements>1)
{ {
do do
{ {
// Par défaut, on considère que la liste est triée // Par défaut, on considère que la liste est triée
list_is_sorted=1; list_is_sorted=1;
current_item=Filelist; current_item=list->First;
next_item=current_item->Next; next_item=current_item->Next;
while ( (current_item!=NULL) && (next_item!=NULL) ) while ( (current_item!=NULL) && (next_item!=NULL) )
@ -478,8 +515,8 @@ void Sort_list_of_files(void)
next_to_next_item->Previous=current_item; next_to_next_item->Previous=current_item;
// On fait bien attention à modifier la tête de liste en cas de besoin // On fait bien attention à modifier la tête de liste en cas de besoin
if (current_item==Filelist) if (current_item==list->First)
Filelist=next_item; list->First=next_item;
// Ensuite, on se prépare à étudier les éléments précédents: // Ensuite, on se prépare à étudier les éléments précédents:
current_item=prev_item; current_item=prev_item;
@ -499,11 +536,38 @@ void Sort_list_of_files(void)
} }
while (!list_is_sorted); while (!list_is_sorted);
} }
// Force a recount / re-index
Recount_files(list);
}
T_Fileselector_item * Get_item_by_index(T_Fileselector *list, short index)
{
// Safety
if (index >= list->Nb_elements)
index=list->Nb_elements-1;
if (list->Index)
{
return list->Index[index];
}
else
{
// Index not available.
// Can only happen in case of malloc error.
// Fall back anyway on iterative search
T_Fileselector_item * item = list->First;
for (;index>0;index--)
item = item->Next;
return item;
}
} }
// -- Affichage des éléments de la liste de fichier / répertoire ------------ // -- Affichage des éléments de la liste de fichier / répertoire ------------
void Display_file_list(short offset_first,short selector_offset) void Display_file_list(T_Fileselector *list, short offset_first,short selector_offset)
// //
// offset_first = Décalage entre le premier fichier visible dans le // offset_first = Décalage entre le premier fichier visible dans le
// sélecteur et le premier fichier de la liste // sélecteur et le premier fichier de la liste
@ -519,12 +583,10 @@ void Display_file_list(short offset_first,short selector_offset)
// On vérifie s'il y a au moins 1 fichier dans la liste: // On vérifie s'il y a au moins 1 fichier dans la liste:
if (Filelist_nb_elements>0) if (list->Nb_elements>0)
{ {
// On commence par chercher à pointer sur le premier fichier visible: // On commence par chercher à pointer sur le premier fichier visible:
current_item=Filelist; current_item = Get_item_by_index(list, offset_first);
for (;offset_first>0;offset_first--)
current_item=current_item->Next;
// Pour chacun des 10 éléments inscriptibles à l'écran // Pour chacun des 10 éléments inscriptibles à l'écran
for (index=0;index<10;index++) for (index=0;index<10;index++)
@ -566,7 +628,7 @@ void Display_file_list(short offset_first,short selector_offset)
// -- Récupérer le libellé d'un élément de la liste ------------------------- // -- Récupérer le libellé d'un élément de la liste -------------------------
void Get_selected_item(short offset_first,short selector_offset,char * label,int *type) void Get_selected_item(T_Fileselector *list, short offset_first,short selector_offset,char * label,int *type)
// //
// offset_first = Décalage entre le premier fichier visible dans le // offset_first = Décalage entre le premier fichier visible dans le
// sélecteur et le premier fichier de la liste // sélecteur et le premier fichier de la liste
@ -582,13 +644,11 @@ void Get_selected_item(short offset_first,short selector_offset,char * label,int
T_Fileselector_item * current_item; T_Fileselector_item * current_item;
// On vérifie s'il y a au moins 1 fichier dans la liste: // On vérifie s'il y a au moins 1 fichier dans la liste:
if (Filelist_nb_elements>0) if (list->Nb_elements>0)
{ {
int i; // On commence par chercher à pointer sur le premier fichier visible:
// Ensuite, on saute autant d'éléments que le décalage demandé:
current_item=Filelist; current_item = Get_item_by_index(list, offset_first + selector_offset);
for (i=0; i<Filelist_nb_elements && i<(offset_first+selector_offset);i++)
current_item=current_item->Next;
// On recopie la chaîne // On recopie la chaîne
strcpy(label, current_item->Full_name); strcpy(label, current_item->Full_name);
@ -605,12 +665,12 @@ void Selector_scroll_down(short * offset_first,short * selector_offset)
// Fait scroller vers le bas le sélecteur de fichier... (si possible) // Fait scroller vers le bas le sélecteur de fichier... (si possible)
{ {
if ( ((*selector_offset)<9) if ( ((*selector_offset)<9)
&& ( (*selector_offset)+1 < Filelist_nb_elements ) ) && ( (*selector_offset)+1 < Filelist.Nb_elements ) )
// Si la sélection peut descendre // Si la sélection peut descendre
Display_file_list(*offset_first,++(*selector_offset)); Display_file_list(&Filelist, *offset_first,++(*selector_offset));
else // Sinon, descendre la fenêtre (si possible) else // Sinon, descendre la fenêtre (si possible)
if ((*offset_first)+10<Filelist_nb_elements) if ((*offset_first)+10<Filelist.Nb_elements)
Display_file_list(++(*offset_first),*selector_offset); Display_file_list(&Filelist, ++(*offset_first),*selector_offset);
} }
@ -619,38 +679,38 @@ void Selector_scroll_up(short * offset_first,short * selector_offset)
{ {
if ((*selector_offset)>0) if ((*selector_offset)>0)
// Si la sélection peut monter // Si la sélection peut monter
Display_file_list(*offset_first,--(*selector_offset)); Display_file_list(&Filelist, *offset_first,--(*selector_offset));
else // Sinon, monter la fenêtre (si possible) else // Sinon, monter la fenêtre (si possible)
if ((*offset_first)>0) if ((*offset_first)>0)
Display_file_list(--(*offset_first),*selector_offset); Display_file_list(&Filelist, --(*offset_first),*selector_offset);
} }
void Selector_page_down(short * offset_first,short * selector_offset, short lines) void Selector_page_down(short * offset_first,short * selector_offset, short lines)
{ {
if (Filelist_nb_elements-1>*offset_first+*selector_offset) if (Filelist.Nb_elements-1>*offset_first+*selector_offset)
{ {
if (*selector_offset<9) if (*selector_offset<9)
{ {
if (Filelist_nb_elements<10) if (Filelist.Nb_elements<10)
{ {
*offset_first=0; *offset_first=0;
*selector_offset=Filelist_nb_elements-1; *selector_offset=Filelist.Nb_elements-1;
} }
else *selector_offset=9; else *selector_offset=9;
} }
else else
{ {
if (Filelist_nb_elements>*offset_first+18) if (Filelist.Nb_elements>*offset_first+18)
*offset_first+=lines; *offset_first+=lines;
else else
{ {
*offset_first=Filelist_nb_elements-10; *offset_first=Filelist.Nb_elements-10;
*selector_offset=9; *selector_offset=9;
} }
} }
} }
Display_file_list(*offset_first,*selector_offset); Display_file_list(&Filelist, *offset_first,*selector_offset);
} }
@ -668,29 +728,29 @@ void Selector_page_up(short * offset_first,short * selector_offset, short lines)
*offset_first=0; *offset_first=0;
} }
} }
Display_file_list(*offset_first,*selector_offset); Display_file_list(&Filelist, *offset_first,*selector_offset);
} }
void Selector_end(short * offset_first,short * selector_offset) void Selector_end(short * offset_first,short * selector_offset)
{ {
if (Filelist_nb_elements<10) if (Filelist.Nb_elements<10)
{ {
*offset_first=0; *offset_first=0;
*selector_offset=Filelist_nb_elements-1; *selector_offset=Filelist.Nb_elements-1;
} }
else else
{ {
*offset_first=Filelist_nb_elements-10; *offset_first=Filelist.Nb_elements-10;
*selector_offset=9; *selector_offset=9;
} }
Display_file_list(*offset_first,*selector_offset); Display_file_list(&Filelist, *offset_first,*selector_offset);
} }
void Selector_home(short * offset_first,short * selector_offset) void Selector_home(short * offset_first,short * selector_offset)
{ {
Display_file_list((*offset_first)=0,(*selector_offset)=0); Display_file_list(&Filelist, (*offset_first)=0,(*selector_offset)=0);
} }
@ -705,8 +765,8 @@ short Compute_click_offset_in_fileselector(void)
short computed_offset; short computed_offset;
computed_offset=(((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-95)>>3; computed_offset=(((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-95)>>3;
if (computed_offset>=Filelist_nb_elements) if (computed_offset>=Filelist.Nb_elements)
computed_offset=Filelist_nb_elements-1; computed_offset=Filelist.Nb_elements-1;
return computed_offset; return computed_offset;
} }
@ -800,22 +860,21 @@ void Print_filename_in_fileselector(void)
int Selected_type; // Utilisé pour mémoriser le type d'entrée choisi int Selected_type; // Utilisé pour mémoriser le type d'entrée choisi
// dans le selecteur de fichier. // dans le selecteur de fichier.
void Prepare_and_display_filelist(short Position, short offset, void Prepare_and_display_filelist(short Position, short offset, T_Scroller_button * button)
T_Scroller_button * button)
{ {
button->Nb_elements=Filelist_nb_elements; button->Nb_elements=Filelist.Nb_elements;
button->Position=Position; button->Position=Position;
Compute_slider_cursor_height(button); Compute_slider_cursor_height(button);
Window_draw_slider(button); Window_draw_slider(button);
// On efface les anciens noms de fichier: // On efface les anciens noms de fichier:
Window_rectangle(8-1,95-1,144+2,80+2,MC_Black); Window_rectangle(8-1,95-1,144+2,80+2,MC_Black);
// On affiche les nouveaux: // On affiche les nouveaux:
Display_file_list(Position,offset); Display_file_list(&Filelist, Position,offset);
Update_window_area(8-1,95-1,144+2,80+2); Update_window_area(8-1,95-1,144+2,80+2);
// On récupère le nom du schmilblick à "accéder" // On récupère le nom du schmilblick à "accéder"
Get_selected_item(Position,offset,Main_filename,&Selected_type); Get_selected_item(&Filelist, Position,offset,Main_filename,&Selected_type);
// On affiche le nouveau nom de fichier // On affiche le nouveau nom de fichier
Print_filename_in_fileselector(); Print_filename_in_fileselector();
// On affiche le nom du répertoire courant // On affiche le nom du répertoire courant
@ -825,8 +884,8 @@ void Prepare_and_display_filelist(short Position, short offset,
void Reload_list_of_files(byte filter, T_Scroller_button * button) void Reload_list_of_files(byte filter, T_Scroller_button * button)
{ {
Read_list_of_files(filter); Read_list_of_files(&Filelist, filter);
Sort_list_of_files(); Sort_list_of_files(&Filelist);
// //
// Check and fix the fileselector positions, because // Check and fix the fileselector positions, because
// the directory content may have changed. // the directory content may have changed.
@ -834,20 +893,20 @@ void Reload_list_of_files(byte filter, T_Scroller_button * button)
// Make the offset absolute // Make the offset absolute
Main_fileselector_offset += Main_fileselector_position; Main_fileselector_offset += Main_fileselector_position;
// Ensure it's within limits // Ensure it's within limits
if (Main_fileselector_offset >= Filelist_nb_elements) if (Main_fileselector_offset >= Filelist.Nb_elements)
{ {
Main_fileselector_offset = Filelist_nb_elements-1; Main_fileselector_offset = Filelist.Nb_elements-1;
} }
// Ensure the position doesn't show "too many files" // Ensure the position doesn't show "too many files"
if (Main_fileselector_position!=0 && Main_fileselector_position>(Filelist_nb_elements-10)) if (Main_fileselector_position!=0 && Main_fileselector_position>(Filelist.Nb_elements-10))
{ {
if (Filelist_nb_elements<10) if (Filelist.Nb_elements<10)
{ {
Main_fileselector_position=0; Main_fileselector_position=0;
} }
else else
{ {
Main_fileselector_position=Filelist_nb_elements-10; Main_fileselector_position=Filelist.Nb_elements-10;
} }
} }
// Restore the offset as relative to the position. // Restore the offset as relative to the position.
@ -870,7 +929,7 @@ void Scroll_fileselector(T_Scroller_button * file_scroller)
Window_draw_slider(file_scroller); Window_draw_slider(file_scroller);
} }
// On récupére le nom du schmilblick à "accéder" // On récupére le nom du schmilblick à "accéder"
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type); Get_selected_item(&Filelist, Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
if (strcmp(old_filename,Main_filename)) if (strcmp(old_filename,Main_filename))
New_preview_is_needed=1; New_preview_is_needed=1;
@ -880,12 +939,12 @@ void Scroll_fileselector(T_Scroller_button * file_scroller)
} }
short Find_file_in_fileselector(char * fname) short Find_file_in_fileselector(T_Fileselector *list, char * fname)
{ {
T_Fileselector_item * current_item; T_Fileselector_item * current_item;
short index; short index;
for (index=0, current_item=Filelist; for (index=0, current_item=list->First;
((current_item!=NULL) && (strcmp(current_item->Full_name,fname))); ((current_item!=NULL) && (strcmp(current_item->Full_name,fname)));
index++,current_item=current_item->Next); index++,current_item=current_item->Next);
@ -897,18 +956,18 @@ void Highlight_file(char * fname)
{ {
short index; short index;
index=Find_file_in_fileselector(fname); index=Find_file_in_fileselector(&Filelist, fname);
if ((Filelist_nb_elements<=10) || (index<5)) if ((Filelist.Nb_elements<=10) || (index<5))
{ {
Main_fileselector_position=0; Main_fileselector_position=0;
Main_fileselector_offset=index; Main_fileselector_offset=index;
} }
else else
{ {
if (index>=Filelist_nb_elements-5) if (index>=Filelist.Nb_elements-5)
{ {
Main_fileselector_position=Filelist_nb_elements-10; Main_fileselector_position=Filelist.Nb_elements-10;
Main_fileselector_offset=index-Main_fileselector_position; Main_fileselector_offset=index-Main_fileselector_position;
} }
else else
@ -920,18 +979,16 @@ void Highlight_file(char * fname)
} }
char FFF_best_name[MAX_PATH_CHARACTERS]; char * Find_filename_match(T_Fileselector *list, char * fname)
char * Find_filename_match(char * fname)
{ {
char * best_name_ptr; char * best_name_ptr;
T_Fileselector_item * current_item; T_Fileselector_item * current_item;
byte matching_letters=0; byte matching_letters=0;
byte counter; byte counter;
strcpy(FFF_best_name,Main_filename);
best_name_ptr=NULL; best_name_ptr=NULL;
for (current_item=Filelist; current_item!=NULL; current_item=current_item->Next) for (current_item=list->First; current_item!=NULL; current_item=current_item->Next)
{ {
if ( (!Config.Find_file_fast) if ( (!Config.Find_file_fast)
|| (Config.Find_file_fast==(current_item->Type+1)) ) || (Config.Find_file_fast==(current_item->Type+1)) )
@ -941,7 +998,6 @@ char * Find_filename_match(char * fname)
if (counter>matching_letters) if (counter>matching_letters)
{ {
matching_letters=counter; matching_letters=counter;
strcpy(FFF_best_name,current_item->Full_name);
best_name_ptr=current_item->Full_name; best_name_ptr=current_item->Full_name;
} }
} }
@ -974,6 +1030,12 @@ byte Button_Load_or_Save(byte load, byte image)
char quicksearch_filename[MAX_PATH_CHARACTERS]=""; char quicksearch_filename[MAX_PATH_CHARACTERS]="";
char save_filename[MAX_PATH_CHARACTERS]; char save_filename[MAX_PATH_CHARACTERS];
char * most_matching_filename; char * most_matching_filename;
short window_shortcut;
if (image)
window_shortcut = load?(0x100+BUTTON_LOAD):(0x100+BUTTON_SAVE);
else
window_shortcut = load?SPECIAL_LOAD_BRUSH:SPECIAL_SAVE_BRUSH;
initial_palette=(T_Components *)malloc(sizeof(T_Palette)); initial_palette=(T_Components *)malloc(sizeof(T_Palette));
memcpy(initial_palette,Main_palette,sizeof(T_Palette)); memcpy(initial_palette,Main_palette,sizeof(T_Palette));
@ -1140,12 +1202,12 @@ byte Button_Load_or_Save(byte load, byte image)
break; break;
case 3 : // Delete case 3 : // Delete
if (Filelist_nb_elements && (*Main_filename!='.') && Selected_type!=2) if (Filelist.Nb_elements && (*Main_filename!='.') && Selected_type!=2)
{ {
char * message; char * message;
Hide_cursor(); Hide_cursor();
// On affiche une demande de confirmation // On affiche une demande de confirmation
if (Main_fileselector_position+Main_fileselector_offset>=Filelist_nb_directories) if (Main_fileselector_position+Main_fileselector_offset>=Filelist.Nb_directories)
{ {
message="Delete file ?"; message="Delete file ?";
} }
@ -1156,7 +1218,7 @@ byte Button_Load_or_Save(byte load, byte image)
if (Confirmation_box(message)) if (Confirmation_box(message))
{ {
// Si c'est un fichier // Si c'est un fichier
if (Main_fileselector_position+Main_fileselector_offset>=Filelist_nb_directories) if (Main_fileselector_position+Main_fileselector_offset>=Filelist.Nb_directories)
// On efface le fichier (si on peut) // On efface le fichier (si on peut)
temp=(!remove(Main_filename)); temp=(!remove(Main_filename));
else // Si c'est un repertoire else // Si c'est un repertoire
@ -1166,7 +1228,7 @@ byte Button_Load_or_Save(byte load, byte image)
if (temp) // temp indique si l'effacement s'est bien passé if (temp) // temp indique si l'effacement s'est bien passé
{ {
// On remonte si c'était le dernier élément de la liste // On remonte si c'était le dernier élément de la liste
if (Main_fileselector_position+Main_fileselector_offset==Filelist_nb_elements-1) if (Main_fileselector_position+Main_fileselector_offset==Filelist.Nb_elements-1)
{ {
if (Main_fileselector_position) if (Main_fileselector_position)
Main_fileselector_position--; Main_fileselector_position--;
@ -1177,7 +1239,7 @@ byte Button_Load_or_Save(byte load, byte image)
else // Si ce n'était pas le dernier, il faut faire gaffe à ce else // Si ce n'était pas le dernier, il faut faire gaffe à ce
{ // que ses copains d'en dessous ne remontent pas trop. { // que ses copains d'en dessous ne remontent pas trop.
if ( (Main_fileselector_position) if ( (Main_fileselector_position)
&& (Main_fileselector_position+10==Filelist_nb_elements) ) && (Main_fileselector_position+10==Filelist.Nb_elements) )
{ {
Main_fileselector_position--; Main_fileselector_position--;
Main_fileselector_offset++; Main_fileselector_offset++;
@ -1214,11 +1276,11 @@ byte Button_Load_or_Save(byte load, byte image)
Main_fileselector_offset=temp; Main_fileselector_offset=temp;
// On récupére le nom du schmilblick à "accéder" // On récupére le nom du schmilblick à "accéder"
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type); Get_selected_item(&Filelist, Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
// On affiche le nouveau nom de fichier // On affiche le nouveau nom de fichier
Print_filename_in_fileselector(); Print_filename_in_fileselector();
// On affiche à nouveau la liste // On affiche à nouveau la liste
Display_file_list(Main_fileselector_position,Main_fileselector_offset); Display_file_list(&Filelist, Main_fileselector_position,Main_fileselector_offset);
// On vient de changer de nom de fichier, donc on doit s'appreter // On vient de changer de nom de fichier, donc on doit s'appreter
// a rafficher une preview // a rafficher une preview
@ -1231,8 +1293,8 @@ byte Button_Load_or_Save(byte load, byte image)
// faut mettre le nom de fichier au nom du répertoire. Sinon, dans // faut mettre le nom de fichier au nom du répertoire. Sinon, dans
// certains cas, on risque de sauvegarder avec le nom du fichier // certains cas, on risque de sauvegarder avec le nom du fichier
// actuel au lieu de changer de répertoire. // actuel au lieu de changer de répertoire.
if (Main_fileselector_position+Main_fileselector_offset<Filelist_nb_directories) if (Main_fileselector_position+Main_fileselector_offset<Filelist.Nb_directories)
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type); Get_selected_item(&Filelist, Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
has_clicked_ok=1; has_clicked_ok=1;
New_preview_is_needed=1; New_preview_is_needed=1;
@ -1247,11 +1309,11 @@ byte Button_Load_or_Save(byte load, byte image)
Hide_cursor(); Hide_cursor();
Main_fileselector_position=Window_attribute2; Main_fileselector_position=Window_attribute2;
// On récupére le nom du schmilblick à "accéder" // On récupére le nom du schmilblick à "accéder"
Get_selected_item(Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type); Get_selected_item(&Filelist, Main_fileselector_position,Main_fileselector_offset,Main_filename,&Selected_type);
// On affiche le nouveau nom de fichier // On affiche le nouveau nom de fichier
Print_filename_in_fileselector(); Print_filename_in_fileselector();
// On affiche à nouveau la liste // On affiche à nouveau la liste
Display_file_list(Main_fileselector_position,Main_fileselector_offset); Display_file_list(&Filelist, Main_fileselector_position,Main_fileselector_offset);
Display_cursor(); Display_cursor();
New_preview_is_needed=1; New_preview_is_needed=1;
*quicksearch_filename=0; *quicksearch_filename=0;
@ -1345,8 +1407,8 @@ byte Button_Load_or_Save(byte load, byte image)
Main_fileselector_position=0; Main_fileselector_position=0;
Main_fileselector_offset=0; Main_fileselector_offset=0;
// Affichage des premiers fichiers visibles: // Affichage des premiers fichiers visibles:
Read_list_of_drives(); Read_list_of_drives(&Filelist);
Sort_list_of_files(); Sort_list_of_files(&Filelist);
Prepare_and_display_filelist(Main_fileselector_position,Main_fileselector_offset,file_scroller); Prepare_and_display_filelist(Main_fileselector_position,Main_fileselector_offset,file_scroller);
Display_cursor(); Display_cursor();
New_preview_is_needed=1; New_preview_is_needed=1;
@ -1485,7 +1547,7 @@ byte Button_Load_or_Save(byte load, byte image)
case SDLK_BACKSPACE : // Backspace case SDLK_BACKSPACE : // Backspace
*quicksearch_filename=0; *quicksearch_filename=0;
// Si le choix ".." est bien en tête des propositions... // Si le choix ".." est bien en tête des propositions...
if (!strcmp(Filelist->Full_name,PARENT_DIR)) if (!strcmp(Filelist.First->Full_name,PARENT_DIR))
{ {
// On va dans le répertoire parent. // On va dans le répertoire parent.
strcpy(Main_filename,PARENT_DIR); strcpy(Main_filename,PARENT_DIR);
@ -1494,7 +1556,7 @@ byte Button_Load_or_Save(byte load, byte image)
} }
Key=0; Key=0;
break; break;
default: // Autre => On se place sur le nom de fichier qui correspond default:
if (clicked_button<=0) if (clicked_button<=0)
{ {
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
@ -1502,12 +1564,18 @@ byte Button_Load_or_Save(byte load, byte image)
Window_help(load?BUTTON_LOAD:BUTTON_SAVE, NULL); Window_help(load?BUTTON_LOAD:BUTTON_SAVE, NULL);
break; break;
} }
if (Is_shortcut(Key,window_shortcut))
{
clicked_button=2;
break;
}
// Autre => On se place sur le nom de fichier qui correspond
temp=strlen(quicksearch_filename); temp=strlen(quicksearch_filename);
if (Key_ANSI>= ' ' && Key_ANSI < 255 && temp<50) if (Key_ANSI>= ' ' && Key_ANSI < 255 && temp<50)
{ {
quicksearch_filename[temp]=Key_ANSI; quicksearch_filename[temp]=Key_ANSI;
quicksearch_filename[temp+1]='\0'; quicksearch_filename[temp+1]='\0';
most_matching_filename=Find_filename_match(quicksearch_filename); most_matching_filename=Find_filename_match(&Filelist, quicksearch_filename);
if ( (most_matching_filename) ) if ( (most_matching_filename) )
{ {
temp=Main_fileselector_position+Main_fileselector_offset; temp=Main_fileselector_position+Main_fileselector_offset;
@ -1552,8 +1620,8 @@ byte Button_Load_or_Save(byte load, byte image)
getcwd(Main_current_directory,256); getcwd(Main_current_directory,256);
// On lit le nouveau répertoire // On lit le nouveau répertoire
Read_list_of_files(Main_format); Read_list_of_files(&Filelist, Main_format);
Sort_list_of_files(); Sort_list_of_files(&Filelist);
// On place la barre de sélection sur le répertoire d'où l'on vient // On place la barre de sélection sur le répertoire d'où l'on vient
Highlight_file(previous_directory); Highlight_file(previous_directory);
} }
@ -1614,7 +1682,7 @@ byte Button_Load_or_Save(byte load, byte image)
if (Timer_state==1) // Il faut afficher la preview if (Timer_state==1) // Il faut afficher la preview
{ {
if ( (Main_fileselector_position+Main_fileselector_offset>=Filelist_nb_directories) && (Filelist_nb_elements) ) if ( (Main_fileselector_position+Main_fileselector_offset>=Filelist.Nb_directories) && (Filelist.Nb_elements) )
{ {
strcpy(Main_file_directory,Main_current_directory); strcpy(Main_file_directory,Main_current_directory);
@ -1661,7 +1729,7 @@ byte Button_Load_or_Save(byte load, byte image)
Unselect_button((load)?BUTTON_LOAD:BUTTON_SAVE); Unselect_button((load)?BUTTON_LOAD:BUTTON_SAVE);
Display_cursor(); Display_cursor();
Free_fileselector_list(); Free_fileselector_list(&Filelist);
Pixel_load_function=Pixel_load_in_current_screen; Pixel_load_function=Pixel_load_in_current_screen;

View File

@ -1,25 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file filesel.h ///@file filesel.h
/// Fileselector window, used for loading and saving images and brushes. /// Fileselector window, used for loading and saving images and brushes.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef __FILESEL_H__
byte Button_Load_or_Save(byte load, byte image); #define __FILESEL_H__
#include "struct.h"
byte Button_Load_or_Save(byte load, byte image);
void Add_element_to_list(T_Fileselector *list, const char * fname, int type);
///
/// Formats a display name for a file, directory, or similar name (drive, volume).
/// The returned value is a pointer to a single static buffer of 19 characters
/// including the '\0'.
char * Format_filename(const char * fname, int type);
void Free_fileselector_list(T_Fileselector *list);
void Sort_list_of_files(T_Fileselector *list);
void Recount_files(T_Fileselector *list);
T_Fileselector_item * Get_item_by_index(T_Fileselector *list, short index);
short Find_file_in_fileselector(T_Fileselector *list, char * fname);
#endif

BIN
gfx2.cfg

Binary file not shown.

View File

@ -76,13 +76,6 @@
; the menus and tool-bar | des menus et de la barre d'outils ; the menus and tool-bar | des menus et de la barre d'outils
Menu_ratio = 1 ; (default 1) Menu_ratio = 1 ; (default 1)
; Font: | Police de caractères (fonte):
; 1: Classic | 1: Classique
; 2: Fun | 2: Fun
Font = 1 ; (default 1)
[FILE_SELECTOR] # [SELECTEUR_DE_FICHIERS] [FILE_SELECTOR] # [SELECTEUR_DE_FICHIERS]
; Show hidden files and | Afficher les fichiers et répertoires ; Show hidden files and | Afficher les fichiers et répertoires
@ -269,12 +262,15 @@
Default_window_size = 640,480 ; (default '640,480') Default_window_size = 640,480 ; (default '640,480')
; This setting allows you merge successive mouse movements into a single ; This setting allows you merge successive mouse movements into a single
; mouse movement. Ideally you should leave it at zero, but if you have an ; mouse movement. You should only use it if you are using a mouse which
; extremely fast mouse and you see the mouse cursor lagging WHEN YOU'RE NOT ; reports at 200Hz or more, and you experience lag when using discontinuous
; DRAWING, you may want to set it to 1, 2 or more, so that GrafX2 skips small ; hand-drawing with large brushes (this tool tries to paste the brush and
; steps. A very high value (100) guarantees that Grafx2 merges all the mouse ; update the screen on each new mouse position) In this case, set this to 2
; steps into a single one. ; or more, to ignore some intermediate mouse reports when a more recent one
Merge_movement = 100 ; (default 100) ; is present.
; Note that with a value superior to 1, you lose precision with continuous
; hand-drawing, as intermediate mouse positions are skipped.
Merge_movement = 0 ; (default 0)
; Number of columns in the palette of the menu bar. Can be any number from ; Number of columns in the palette of the menu bar. Can be any number from
; 1 to 256. If there is not enough room, the program will display less ; 1 to 256. If there is not enough room, the program will display less
@ -312,4 +308,36 @@
; OS isn't able to do it by itself. (ie: Windows) ; OS isn't able to do it by itself. (ie: Windows)
Window_position = 9999,9999; (Default 9999,9999 which means: NA) Window_position = 9999,9999; (Default 9999,9999 which means: NA)
; This is the time (in milliseconds) between two clicks for Grafx2 to
; recognize a double-click. Double-click is used mostly in the palette
; area of the menu: double-click a color to open the palette.
Double_click_speed = 500; (Default 500)
; When you press two digit keys in rapid succession (ex: 3 8), Grafx2
; sets transparency to 38% (instead of 30% then 80%). This setting
; allows you to set the maximum delay between two keypresses for
; GrafX2 to recognize them as a combo.
Double_key_speed = 500; (Default 500)
; Name of the skinfile you want to | Nom du fichier skin que vous voulez
; use. | utiliser.
; Default : (empty to let the program choose)
Skin_file =
; Name of the font file (8x8) you | Nom du fichier police de caractère
; want to use. | 8x8 utilisée dans les menus.
; Default : (empty to let the program choose)
Font_file =
; This determines the color value for the grid. Each pixel of
; the grid will be displayed by XOR-ing the original color with
; the value of this setting.
; For example, if you always paint 16-color images, you can set it
; to 16 so the color of the grid are 16 for 0, 17 for 1, etc.
; Then you can set colors 16-31 as lighter/darker variants
; of your original palette, resulting in a pretty grid !
;
; Valid values are 1 to 255.
Grid_XOR_color = 255; (Default 255)
; end of configuration ; end of configuration

View File

@ -63,9 +63,6 @@ GFX2_GLOBAL T_Video_mode Video_mode[MAX_VIDEO_MODES];
/// Actual number of video modes in ::Video_mode. /// Actual number of video modes in ::Video_mode.
GFX2_GLOBAL int Nb_video_modes; GFX2_GLOBAL int Nb_video_modes;
/// A default 256-color palette.
GFX2_GLOBAL T_Palette Default_palette;
// -- Menu colors // -- Menu colors
GFX2_GLOBAL byte MC_Black; ///< Index of color to use as "black" in the GUI menus. GFX2_GLOBAL byte MC_Black; ///< Index of color to use as "black" in the GUI menus.
@ -81,6 +78,7 @@ GFX2_GLOBAL T_Components Fav_menu_colors[4];
GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position. GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position.
GFX2_GLOBAL word Mouse_Y; ///< Current mouse cursor position. GFX2_GLOBAL word Mouse_Y; ///< Current mouse cursor position.
GFX2_GLOBAL byte Mouse_K; ///< Current mouse buttons state. Bitfield: 1 for RMB, 2 for LMB. GFX2_GLOBAL byte Mouse_K; ///< Current mouse buttons state. Bitfield: 1 for RMB, 2 for LMB.
GFX2_GLOBAL byte Keyboard_click_allowed; ///< Set to 0 when you edit a textfield so you can use space without exiting it
/// Helper macro to take only one button when both are pressed (LMB has priority) /// Helper macro to take only one button when both are pressed (LMB has priority)
#define Mouse_K_unique (Mouse_K==0?0:(Mouse_K&1?1:(Mouse_K&2?2:0))) #define Mouse_K_unique (Mouse_K==0?0:(Mouse_K&1?1:(Mouse_K&2?2:0)))
@ -139,14 +137,8 @@ GFX2_GLOBAL byte Cursor_hidden;
GFX2_GLOBAL byte Cursor_in_menu; GFX2_GLOBAL byte Cursor_in_menu;
/// Boolean, means the cursor was hovering over a menu GUI element. /// Boolean, means the cursor was hovering over a menu GUI element.
GFX2_GLOBAL byte Cursor_in_menu_previous; GFX2_GLOBAL byte Cursor_in_menu_previous;
/// X coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_WIDTH
GFX2_GLOBAL word Cursor_offset_X[NB_CURSOR_SPRITES];
/// Y coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_HEIGHT
GFX2_GLOBAL word Cursor_offset_Y[NB_CURSOR_SPRITES];
/// Graphic resources for the mouse cursor.
GFX2_GLOBAL byte GFX_cursor_sprite[NB_CURSOR_SPRITES][CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH];
/// Storage for the graphics under the mouse cursor. Used by ::Hide_cursor and ::Display_cursor /// Storage for the graphics under the mouse cursor. Used by ::Hide_cursor and ::Display_cursor
GFX2_GLOBAL byte CURSOR_BACKGROUND[CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH]; GFX2_GLOBAL byte Cursor_background[CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH];
// -- Paintbrush data // -- Paintbrush data
@ -164,18 +156,6 @@ GFX2_GLOBAL byte Paintbrush_hidden;
GFX2_GLOBAL short Paintbrush_X; GFX2_GLOBAL short Paintbrush_X;
/// Cordinate of the preview paintbrush in image space. /// Cordinate of the preview paintbrush in image space.
GFX2_GLOBAL short Paintbrush_Y; GFX2_GLOBAL short Paintbrush_Y;
/// Graphic resources for the preset paintbrushes.
GFX2_GLOBAL byte GFX_paintbrush_sprite [NB_PAINTBRUSH_SPRITES][PAINTBRUSH_HEIGHT][PAINTBRUSH_WIDTH];
/// Width of the preset paintbrushes.
GFX2_GLOBAL word Preset_paintbrush_width[NB_PAINTBRUSH_SPRITES];
/// Height of the preset paintbrushes.
GFX2_GLOBAL word Preset_paintbrush_height[NB_PAINTBRUSH_SPRITES];
/// Type of the preset paintbrush: index in enum PAINTBRUSH_SHAPES
GFX2_GLOBAL byte Paintbrush_type[NB_PAINTBRUSH_SPRITES];
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_width[]/2
GFX2_GLOBAL word Preset_paintbrush_offset_X[NB_PAINTBRUSH_SPRITES];
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_height[]/2
GFX2_GLOBAL word Preset_paintbrush_offset_Y[NB_PAINTBRUSH_SPRITES];
/// Pixel data of the current brush /// Pixel data of the current brush
GFX2_GLOBAL byte * Paintbrush_sprite; GFX2_GLOBAL byte * Paintbrush_sprite;
/// Current paintbrush's width /// Current paintbrush's width
@ -548,6 +528,11 @@ GFX2_GLOBAL T_Dropdown_button * Window_stack_dropdown_button_list[8];
/// List of dropdown buttons in the topmost window. /// List of dropdown buttons in the topmost window.
#define Window_dropdown_button_list Window_stack_dropdown_button_list[Windows_open-1] #define Window_dropdown_button_list Window_stack_dropdown_button_list[Windows_open-1]
GFX2_GLOBAL T_List_button * Window_stack_list_button_list[8];
/// List of list buttons in the topmost window.
#define Window_list_button_list Window_stack_list_button_list[Windows_open-1]
GFX2_GLOBAL int Window_stack_attribute1[8]; GFX2_GLOBAL int Window_stack_attribute1[8];
/// ///
@ -660,6 +645,8 @@ GFX2_GLOBAL byte Stencil[256];
/// Boolean, true when the Grid mode is active. /// Boolean, true when the Grid mode is active.
GFX2_GLOBAL byte Snap_mode; GFX2_GLOBAL byte Snap_mode;
/// Boolean, true when the Grid is displayed in zoomed view.
GFX2_GLOBAL byte Show_grid;
/// Width of the grid in Grid mode. /// Width of the grid in Grid mode.
GFX2_GLOBAL word Snap_width; GFX2_GLOBAL word Snap_width;
/// Height of the grid in Grid mode. /// Height of the grid in Grid mode.
@ -675,8 +662,6 @@ GFX2_GLOBAL word Snap_offset_Y;
GFX2_GLOBAL byte Sieve_mode; GFX2_GLOBAL byte Sieve_mode;
/// Sprite of the sieve pattern. It's actually an array of booleans. /// Sprite of the sieve pattern. It's actually an array of booleans.
GFX2_GLOBAL byte Sieve[16][16]; GFX2_GLOBAL byte Sieve[16][16];
/// Preset sieve patterns, stored as binary (one word per line)
GFX2_GLOBAL word GFX_sieve_pattern[12][16];
/// Width of the sieve pattern, in Sieve mode. /// Width of the sieve pattern, in Sieve mode.
GFX2_GLOBAL short Sieve_width; GFX2_GLOBAL short Sieve_width;
/// Height of the sieve pattern, in Sieve mode. /// Height of the sieve pattern, in Sieve mode.
@ -810,40 +795,14 @@ GFX2_GLOBAL byte File_in_command_line;
/// Boolean, true if Grafx2 was run with a command-line argument to set a resolution on startup (overrides config) /// Boolean, true if Grafx2 was run with a command-line argument to set a resolution on startup (overrides config)
GFX2_GLOBAL byte Resolution_in_command_line; GFX2_GLOBAL byte Resolution_in_command_line;
// - Graphic skin data // - Graphic
/// Bitmap data for the menu, a single rectangle. /// Pointer to the font selected for menus.
GFX2_GLOBAL byte GFX_menu_block[MENU_HEIGHT][MENU_WIDTH];
/// Bitmap data for the icons that are displayed over the menu.
GFX2_GLOBAL byte GFX_menu_sprite[NB_MENU_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
/// Bitmap data for the different "effects" icons.
GFX2_GLOBAL byte GFX_effect_sprite[NB_EFFECTS_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
/// Bitmap data for the Grafx2 logo that appears on splash screen. All 256 colors allowed.
GFX2_GLOBAL byte * GFX_logo_grafx2;
/// Bitmap data for the classic 8x8 font used in menus etc.
GFX2_GLOBAL byte GFX_system_font[256*8*8];
/// Bitmap data for the "fun" 8x8 font used in menus etc.
GFX2_GLOBAL byte GFX_fun_font [256*8*8];
/// Bitmap data for the 6x8 font used in help screens.
GFX2_GLOBAL byte GFX_help_font_norm [256][6][8];
/// Bitmap data for the 6x8 font used in help screens ("bold" verstion).
GFX2_GLOBAL byte GFX_bold_font [256][6][8];
// 12
// 34
/// Bitmap data for the title font used in help screens. Top-left quarter.
GFX2_GLOBAL byte GFX_help_font_t1 [64][6][8];
/// Bitmap data for the title font used in help screens. Top-right quarter.
GFX2_GLOBAL byte GFX_help_font_t2 [64][6][8];
/// Bitmap data for the title font used in help screens. Bottom-left quarter.
GFX2_GLOBAL byte GFX_help_font_t3 [64][6][8];
/// Bitmap data for the title font used in help screens. Bottom-right quarter.
GFX2_GLOBAL byte GFX_help_font_t4 [64][6][8];
/// Bitmap data for the small 8x8 icons.
GFX2_GLOBAL byte GFX_icon_sprite[NB_ICON_SPRITES][ICON_SPRITE_HEIGHT][ICON_SPRITE_WIDTH];
/// Pointer to the font selected for menus. It's either ::GFX_system_font or ::GFX_fun_font
GFX2_GLOBAL byte * Menu_font; GFX2_GLOBAL byte * Menu_font;
/// Pointer to the current active skin.
GFX2_GLOBAL T_Gui_skin * Gfx;
// -- Help data // -- Help data
/// Index of the ::Help_section shown by the Help screen. /// Index of the ::Help_section shown by the Help screen.
@ -873,6 +832,8 @@ GFX2_GLOBAL short Colorpicker_X;
/// Position of the colorpicker tool, in image coordinates. /// Position of the colorpicker tool, in image coordinates.
GFX2_GLOBAL short Colorpicker_Y; GFX2_GLOBAL short Colorpicker_Y;
/// Brush container
GFX2_GLOBAL T_Brush_template Brush_container[BRUSH_CONTAINER_COLUMNS*BRUSH_CONTAINER_ROWS];
#ifdef GLOBAL_VARIABLES #ifdef GLOBAL_VARIABLES
byte CURSOR_FOR_OPERATION[NB_OPERATIONS]= byte CURSOR_FOR_OPERATION[NB_OPERATIONS]=
@ -921,21 +882,11 @@ GFX2_GLOBAL short Colorpicker_Y;
/// each operation, and for each mouse state (no button,left button,right button) /// each operation, and for each mouse state (no button,left button,right button)
GFX2_GLOBAL struct GFX2_GLOBAL struct
{ {
byte Hide_cursor; ///< Boolean: Need to hide/unhide cursor during this step
Func_action Action; ///< Function to call Func_action Action; ///< Function to call
byte Hide_cursor; ///< Boolean: Need to hide/unhide cursor during this step
byte Fast_mouse; ///< Operation should take shortcuts with mouse movements
} Operation[NB_OPERATIONS][3][OPERATION_STACK_SIZE]; } Operation[NB_OPERATIONS][3][OPERATION_STACK_SIZE];
// -- Fileselector data
/// Number of elements in the current fileselector's ::Filelist
GFX2_GLOBAL short Filelist_nb_elements;
/// Number of files in the current fileselector's ::Filelist
GFX2_GLOBAL short Filelist_nb_files;
/// Number of directories in the current fileselector's ::Filelist
GFX2_GLOBAL short Filelist_nb_directories;
/// Head of the linked list for the fileselector.
GFX2_GLOBAL T_Fileselector_item * Filelist;
// -- misc // -- misc
/// ///

277
graph.c
View File

@ -107,6 +107,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
if(effective_Y + effective_h > Menu_Y) if(effective_Y + effective_h > Menu_Y)
effective_h = Menu_Y - effective_Y; effective_h = Menu_Y - effective_Y;
/* /*
SDL_Rect r; SDL_Rect r;
r.x=effective_X; r.x=effective_X;
@ -136,7 +137,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
} }
else else
effective_X += Main_separator_position + SEPARATOR_WIDTH*Menu_factor_X; effective_X += Main_separator_position + SEPARATOR_WIDTH*Menu_factor_X;
diff = effective_X+effective_w-Screen_width; diff = effective_X+effective_w-Min(Screen_width, Main_X_zoom+(Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor);
if (diff>0) if (diff>0)
{ {
effective_w -=diff; effective_w -=diff;
@ -153,7 +154,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
return; return;
effective_Y = 0; effective_Y = 0;
} }
diff = effective_Y+effective_h-Menu_Y; diff = effective_Y+effective_h-Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor);
if (diff>0) if (diff>0)
{ {
effective_h -=diff; effective_h -=diff;
@ -161,6 +162,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
return; return;
} }
// Très utile pour le debug :) // Très utile pour le debug :)
/*SDL_Rect r; /*SDL_Rect r;
r.x=effective_X; r.x=effective_X;
@ -169,6 +171,7 @@ void Update_part_of_screen(short x, short y, short width, short height)
r.w=effective_w; r.w=effective_w;
SDL_FillRect(Screen_SDL,&r,3);*/ SDL_FillRect(Screen_SDL,&r,3);*/
Redraw_grid(effective_X,effective_Y,effective_w,effective_h);
Update_rect(effective_X,effective_Y,effective_w,effective_h); Update_rect(effective_X,effective_Y,effective_w,effective_h);
} }
} }
@ -468,7 +471,7 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio)
Clear_border(MC_Black); // Requires up-to-date Screen_* and Pixel_* Clear_border(MC_Black); // Requires up-to-date Screen_* and Pixel_*
// Taille des menus // Set menu size (software zoom)
if (Screen_width/320 > Screen_height/200) if (Screen_width/320 > Screen_height/200)
factor=Screen_height/200; factor=Screen_height/200;
else else
@ -476,28 +479,32 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio)
switch (Config.Ratio) switch (Config.Ratio)
{ {
case 1: // adapter tout case 1: // Always the biggest possible
Menu_factor_X=factor; Menu_factor_X=factor;
Menu_factor_Y=factor; Menu_factor_Y=factor;
break; break;
case 2: // adapter légèrement case 2: // Only keep the aspect ratio
Menu_factor_X=factor-1; Menu_factor_X=factor-1;
if (Menu_factor_X<1) Menu_factor_X=1; if (Menu_factor_X<1) Menu_factor_X=1;
Menu_factor_Y=factor-1; Menu_factor_Y=factor-1;
if (Menu_factor_Y<1) Menu_factor_Y=1; if (Menu_factor_Y<1) Menu_factor_Y=1;
break; break;
default: // ne pas adapter case 0: // Always smallest possible
Menu_factor_X=1; Menu_factor_X=1;
Menu_factor_Y=1; Menu_factor_Y=1;
break;
default: // Stay below some reasonable size
Menu_factor_X=Min(factor,abs(Config.Ratio));
Menu_factor_Y=Min(factor,abs(Config.Ratio));
} }
if (Pixel_height>Pixel_width && Screen_width>=Menu_factor_X*2*320) if (Pixel_height>Pixel_width && Screen_width>=Menu_factor_X*2*320)
Menu_factor_X*=2; Menu_factor_X*=2;
else if (Pixel_width>Pixel_height && Screen_height>=Menu_factor_Y*2*200) else if (Pixel_width>Pixel_height && Screen_height>=Menu_factor_Y*2*200)
Menu_factor_Y*=2; Menu_factor_Y*=2;
if (Horizontal_line_buffer) free(Horizontal_line_buffer);
free(Horizontal_line_buffer); Horizontal_line_buffer=(byte *)malloc(Pixel_width *
Horizontal_line_buffer=(byte *)malloc(Pixel_width*((Screen_width>Main_image_width)?Screen_width:Main_image_width)); ((Screen_width>Main_image_width)?Screen_width:Main_image_width));
Set_palette(Main_palette); Set_palette(Main_palette);
@ -677,6 +684,7 @@ void Get_colors_from_brush(void)
Display_all_screen(); Display_all_screen();
Display_menu(); Display_menu();
Display_cursor(); Display_cursor();
End_of_modification();
Main_image_is_modified=1; Main_image_is_modified=1;
} }
@ -994,7 +1002,18 @@ void Fill_general(byte fill_color)
// par l'utilisation de "Display_pixel()", et que les autres... eh bein // par l'utilisation de "Display_pixel()", et que les autres... eh bein
// on n'y a jamais touché à l'écran les autres: ils sont donc corrects. // on n'y a jamais touché à l'écran les autres: ils sont donc corrects.
if(Main_magnifier_mode)
{
short w,h;
w=Min(Screen_width-Main_X_zoom, (Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor);
h=Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor);
Redraw_grid(Main_X_zoom,0,w,h);
}
Update_rect(0,0,0,0); Update_rect(0,0,0,0);
End_of_modification();
} }
} }
@ -1005,11 +1024,32 @@ void Fill_general(byte fill_color)
////////////////////////// avec gestion de previews ////////////////////////// ////////////////////////// avec gestion de previews //////////////////////////
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Data used by ::Init_permanent_draw() and ::Pixel_figure_permanent()
static Uint32 Permanent_draw_next_refresh=0;
static int Permanent_draw_count=0;
void Init_permanent_draw(void)
{
Permanent_draw_count = 0;
Permanent_draw_next_refresh = SDL_GetTicks() + 100;
}
// Affichage d'un point de façon définitive (utilisation du pinceau) // Affichage d'un point de façon définitive (utilisation du pinceau)
void Pixel_figure_permanent(word x_pos,word y_pos,byte color) void Pixel_figure_permanent(word x_pos,word y_pos,byte color)
{ {
Display_paintbrush(x_pos,y_pos,color,0); Display_paintbrush(x_pos,y_pos,color,0);
Permanent_draw_count ++;
// Check every 8 pixels
if (! (Permanent_draw_count&7))
{
Uint32 now = SDL_GetTicks();
if (now>= Permanent_draw_next_refresh)
{
Permanent_draw_next_refresh = now+100;
Flush_update();
}
}
} }
// Affichage d'un point de façon définitive // Affichage d'un point de façon définitive
@ -1151,6 +1191,7 @@ void Draw_empty_circle_general(short center_x,short center_y,short radius,byte c
void Draw_empty_circle_permanent(short center_x,short center_y,short radius,byte color) void Draw_empty_circle_permanent(short center_x,short center_y,short radius,byte color)
{ {
Pixel_figure=Pixel_figure_permanent; Pixel_figure=Pixel_figure_permanent;
Init_permanent_draw();
Draw_empty_circle_general(center_x,center_y,radius,color); Draw_empty_circle_general(center_x,center_y,radius,color);
Update_part_of_screen(center_x - radius, center_y - radius, 2* radius+1, 2*radius+1); Update_part_of_screen(center_x - radius, center_y - radius, 2* radius+1, 2*radius+1);
} }
@ -1293,6 +1334,7 @@ void Draw_empty_ellipse_general(short center_x,short center_y,short horizontal_r
void Draw_empty_ellipse_permanent(short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color) void Draw_empty_ellipse_permanent(short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color)
{ {
Pixel_figure=Pixel_figure_permanent; Pixel_figure=Pixel_figure_permanent;
Init_permanent_draw();
Draw_empty_ellipse_general(center_x,center_y,horizontal_radius,vertical_radius,color); Draw_empty_ellipse_general(center_x,center_y,horizontal_radius,vertical_radius,color);
Update_part_of_screen(center_x - horizontal_radius, center_y - vertical_radius, 2* horizontal_radius+1, 2*vertical_radius+1); Update_part_of_screen(center_x - horizontal_radius, center_y - vertical_radius, 2* horizontal_radius+1, 2*vertical_radius+1);
} }
@ -1356,46 +1398,132 @@ void Draw_filled_ellipse(short center_x,short center_y,short horizontal_radius,s
* TRACÉ DE LIGNES * * TRACÉ DE LIGNES *
******************/ ******************/
void Clamp_coordinates_45_degrees(short ax, short ay, short* bx, short* by) /// Alters bx and by so the (AX,AY)-(BX,BY) segment becomes either horizontal,
// Modifie bx et by pour que la ligne AXAY - BXBY soit /// vertical, 45degrees, or isometrical for pixelart (ie 2:1 ratio)
// - une droite horizontale void Clamp_coordinates_regular_angle(short ax, short ay, short* bx, short* by)
// - une droite verticale
// - une droite avec une pente de 45 degrés
{ {
int dx, dy; int dx, dy;
float tan; float angle;
dx = (*bx)-ax; dx = *bx-ax;
dy = ay- *by; // On prend l'opposée car à l'écran les Y sont positifs en bas, et en maths, positifs en haut dy = *by-ay;
if (dx==0) return; // On est en lockx et de toutes façons le X n'a pas bougé, on sort tout de suite pour éviter une méchante division par 0 // No mouse move: no need to clamp anything
if (dx==0 || dy == 0) return;
tan = (float)dy/(float)dx; // Determine angle (heading)
angle = atan2(dx, dy);
// Get absolute values, useful from now on:
//dx=abs(dx);
//dy=abs(dy);
// Negative Y
if (angle < M_PI*(-15.0/16.0) || angle > M_PI*(15.0/16.0))
{
*bx=ax;
*by=ay + dy;
}
// Iso close to negative Y
else if (angle < M_PI*(-13.0/16.0))
{
dy=dy | 1; // Round up to next odd number
*bx=ax + dy/2;
*by=ay + dy;
}
// 45deg
else if (angle < M_PI*(-11.0/16.0))
{
*by = (*by + ay + dx)/2;
*bx = ax - ay + *by;
}
// Iso close to negative X
else if (angle < M_PI*(-9.0/16.0))
{
dx=dx | 1; // Round up to next odd number
*bx=ax + dx;
*by=ay + dx/2;
}
// Negative X
else if (angle < M_PI*(-7.0/16.0))
{
*bx=ax + dx;
*by=ay;
}
// Iso close to negative X
else if (angle < M_PI*(-5.0/16.0))
{
dx=dx | 1; // Round up to next odd number
*bx=ax + dx;
*by=ay - dx/2;
}
// 45 degrees
else if (angle < M_PI*(-3.0/16.0))
{
*by = (*by + ay - dx)/2;
*bx = ax + ay - *by;
}
// Iso close to positive Y
else if (angle < M_PI*(-1.0/16.0))
{
dy=dy | 1; // Round up to next odd number
*bx=ax - dy/2;
*by=ay + dy;
}
// Positive Y
else if (angle < M_PI*(1.0/16.0))
{
*bx=ax;
*by=ay + dy;
}
// Iso close to positive Y
else if (angle < M_PI*(3.0/16.0))
{
dy=dy | 1; // Round up to next odd number
*bx=ax + dy/2;
*by=ay + dy;
}
// 45 degrees
else if (angle < M_PI*(5.0/16.0))
{
*by = (*by + ay + dx)/2;
*bx = ax - ay + *by;
}
// Iso close to positive X
else if (angle < M_PI*(7.0/16.0))
{
dx=dx | 1; // Round up to next odd number
*bx=ax + dx;
*by=ay + dx/2;
}
// Positive X
else if (angle < M_PI*(9.0/16.0))
{
*bx=ax + dx;
*by=ay;
}
// Iso close to positive X
else if (angle < M_PI*(11.0/16.0))
{
dx=dx | 1; // Round up to next odd number
*bx=ax + dx;
*by=ay - dx/2;
}
// 45 degrees
else if (angle < M_PI*(13.0/16.0))
{
*by = (*by + ay - dx)/2;
*bx = ax + ay - *by;
}
// Iso close to negative Y
else //if (angle < M_PI*(15.0/16.0))
{
dy=dy | 1; // Round up to next odd number
*bx=ax - dy/2;
*by=ay + dy;
}
if (tan <= 0.4142 && tan >= -0.4142) return;
{
// Cas 1 : Lock Y
*by = ay;
}
else if ( tan > 0.4142 && tan < 2.4142)
{
// Cas 2 : dy=dx
*by = (*by + ay - dx)/2;
*bx = ax + ay - *by;
}
else if (tan < -0.4142 && tan >= -2.4142)
{
// Cas 8 : dy = -dx
*by = (*by + ay + dx)/2;
*bx = ax - ay + *by;
}
else
{
// Cas 3 : Lock X
*bx = ax;
}
return;
} }
// -- Tracer général d'une ligne ------------------------------------------ // -- Tracer général d'une ligne ------------------------------------------
@ -1406,8 +1534,7 @@ void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte
short incr_x,incr_y; short incr_x,incr_y;
short i,cumul; short i,cumul;
short delta_x,delta_y; short delta_x,delta_y;
x_pos=start_x; x_pos=start_x;
y_pos=start_y; y_pos=start_y;
@ -1471,11 +1598,12 @@ void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte
// -- Tracer définitif d'une ligne -- // -- Tracer définitif d'une ligne --
void Draw_line_permanet(short start_x,short start_y,short end_x,short end_y, byte color) void Draw_line_permanent(short start_x,short start_y,short end_x,short end_y, byte color)
{ {
int w = end_x-start_x, h = end_y - start_y; int w = end_x-start_x, h = end_y - start_y;
Pixel_figure=Pixel_figure_permanent; Pixel_figure=Pixel_figure_permanent;
Init_permanent_draw();
Draw_line_general(start_x,start_y,end_x,end_y,color); Draw_line_general(start_x,start_y,end_x,end_y,color);
Update_part_of_screen((start_x<end_x)?start_x:end_x,(start_y<end_y)?start_y:end_y,abs(w)+1,abs(h)+1); Update_part_of_screen((start_x<end_x)?start_x:end_x,(start_y<end_y)?start_y:end_y,abs(w)+1,abs(h)+1);
} }
@ -1555,18 +1683,20 @@ void Draw_empty_rectangle(short start_x,short start_y,short end_x,short end_y,by
} }
// On trace le rectangle: // On trace le rectangle:
Init_permanent_draw();
for (x_pos=start_x;x_pos<=end_x;x_pos++) for (x_pos=start_x;x_pos<=end_x;x_pos++)
Display_paintbrush(x_pos,start_y,color,0); {
Pixel_figure_permanent(x_pos,start_y,color);
Pixel_figure_permanent(x_pos, end_y,color);
}
for (y_pos=start_y+1;y_pos<end_y;y_pos++) for (y_pos=start_y+1;y_pos<end_y;y_pos++)
{ {
Display_paintbrush(start_x,y_pos,color,0); Pixel_figure_permanent(start_x,y_pos,color);
Display_paintbrush( end_x,y_pos,color,0); Pixel_figure_permanent( end_x,y_pos,color);
} }
for (x_pos=start_x;x_pos<=end_x;x_pos++)
Display_paintbrush(x_pos, end_y,color,0);
#if defined(__macosx__) || defined(__FreeBSD__) #if defined(__macosx__) || defined(__FreeBSD__)
Update_part_of_screen(start_x,end_x,end_x-start_x,end_y-start_y); Update_part_of_screen(start_x,end_x,end_x-start_x,end_y-start_y);
#endif #endif
@ -1670,6 +1800,7 @@ void Draw_curve_permanent(short x1, short y1,
byte color) byte color)
{ {
Pixel_figure=Pixel_figure_permanent; Pixel_figure=Pixel_figure_permanent;
Init_permanent_draw();
Draw_curve_general(x1,y1,x2,y2,x3,y3,x4,y4,color); Draw_curve_general(x1,y1,x2,y2,x3,y3,x4,y4,color);
} }
@ -2685,3 +2816,41 @@ byte Effect_smooth(word x,word y,__attribute__((unused)) byte color)
Read_pixel_from_current_screen(x,y); // C'est bien l'écran courant et pas Read_pixel_from_current_screen(x,y); // C'est bien l'écran courant et pas
// l'écran feedback car il s'agit de ne // l'écran feedback car il s'agit de ne
} // pas modifier l'écran courant. } // pas modifier l'écran courant.
void Horizontal_grid_line(word x_pos,word y_pos,word width)
{
int x;
for (x=!(x_pos&1);x<width;x+=2)
Pixel(x_pos+x, y_pos, *((y_pos-1)*Pixel_height*VIDEO_LINE_WIDTH+x_pos*Pixel_width+Screen_pixels+x*Pixel_width)^Config.Grid_XOR_color);
}
void Vertical_grid_line(word x_pos,word y_pos,word height)
{
int y;
for (y=!(y_pos&1);y<height;y+=2)
Pixel(x_pos, y_pos+y, *(Screen_pixels+(x_pos*Pixel_width-1)+(y_pos*Pixel_height+y*Pixel_height)*VIDEO_LINE_WIDTH)^Config.Grid_XOR_color);
}
// Tile Grid
void Redraw_grid(short x, short y, unsigned short w, unsigned short h)
{
int row, col;
if (!Show_grid)
return;
row=y+((Snap_height*1000-(y-0)/Main_magnifier_factor-Main_magnifier_offset_Y+Snap_offset_Y-1)%Snap_height)*Main_magnifier_factor+Main_magnifier_factor-1;
while (row < y+h)
{
Horizontal_grid_line(x, row, w);
row+= Snap_height*Main_magnifier_factor;
}
col=x+((Snap_width*1000-(x-Main_X_zoom)/Main_magnifier_factor-Main_magnifier_offset_X+Snap_offset_X-1)%Snap_width)*Main_magnifier_factor+Main_magnifier_factor-1;
while (col < x+w)
{
Vertical_grid_line(col, y, h);
col+= Snap_width*Main_magnifier_factor;
}
}

View File

@ -66,9 +66,9 @@ void Draw_empty_ellipse_preview (short center_x,short center_y,short horizontal
void Hide_empty_ellipse_preview (short center_x,short center_y,short horizontal_radius,short vertical_radius); void Hide_empty_ellipse_preview (short center_x,short center_y,short horizontal_radius,short vertical_radius);
void Draw_filled_ellipse (short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color); void Draw_filled_ellipse (short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color);
void Clamp_coordinates_45_degrees(short ax, short ay, short* bx, short* by); void Clamp_coordinates_regular_angle(short ax, short ay, short* bx, short* by);
void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte color); void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte color);
void Draw_line_permanet (short start_x,short start_y,short end_x,short end_y,byte color); void Draw_line_permanent (short start_x,short start_y,short end_x,short end_y,byte color);
void Draw_line_preview (short start_x,short start_y,short end_x,short end_y,byte color); void Draw_line_preview (short start_x,short start_y,short end_x,short end_y,byte color);
void Draw_line_preview_xor(short start_x,short start_y,short end_x,short end_y,byte color); void Draw_line_preview_xor(short start_x,short start_y,short end_x,short end_y,byte color);
void Draw_line_preview_xorback(short start_x,short start_y,short end_x,short end_y,byte color); void Draw_line_preview_xorback(short start_x,short start_y,short end_x,short end_y,byte color);
@ -108,3 +108,5 @@ void Remap_picture(void);
extern Func_pixel Pixel_figure; extern Func_pixel Pixel_figure;
void Update_part_of_screen(short x, short y, short width, short height); void Update_part_of_screen(short x, short y, short width, short height);
void Redraw_grid(short x, short y, unsigned short w, unsigned short h);

43
help.c
View File

@ -119,7 +119,7 @@ void Window_set_shortcut(int action_id)
while (Ordering[order_index]!=action_id) while (Ordering[order_index]!=action_id)
{ {
order_index++; order_index++;
if (order_index>=134) if (order_index>=NB_SHORTCUTS)
{ {
Error(0); Error(0);
return; return;
@ -130,7 +130,7 @@ void Window_set_shortcut(int action_id)
while (ConfigKey[config_index].Number!=order_index) while (ConfigKey[config_index].Number!=order_index)
{ {
config_index++; config_index++;
if (config_index>=134) if (config_index>=NB_SHORTCUTS)
{ {
Error(0); Error(0);
return; return;
@ -278,7 +278,21 @@ void Display_help(void)
else if (line_type == 'K') else if (line_type == 'K')
{ {
const char *hyperlink; const char *hyperlink;
const char * escaped_percent_pos;
// Determine link position:
link_position = strstr(line,"%s") - line; link_position = strstr(line,"%s") - line;
// Adjust for any escaped %% that would precede it.
escaped_percent_pos = line;
do
{
escaped_percent_pos = strstr(escaped_percent_pos,"%%");
if (escaped_percent_pos && escaped_percent_pos - line < link_position)
{
link_position--;
escaped_percent_pos+=2;
}
} while (escaped_percent_pos);
//
hyperlink=Keyboard_shortcut_value(Help_section[Current_help_section].Help_table[start_line + line_index].Line_parameter); hyperlink=Keyboard_shortcut_value(Help_section[Current_help_section].Help_table[start_line + line_index].Line_parameter);
link_size=strlen(hyperlink); link_size=strlen(hyperlink);
snprintf(buffer, 44, line, hyperlink); snprintf(buffer, 44, line, hyperlink);
@ -309,27 +323,27 @@ void Display_help(void)
if (line_type=='T') if (line_type=='T')
{ {
if (line[char_index/2]>'_' || line[char_index/2]<' ') if (line[char_index/2]>'_' || line[char_index/2]<' ')
char_pixel=&(GFX_help_font_norm['!'][0][0]); // Caractère pas géré char_pixel=&(Gfx->Help_font_norm['!'][0][0]); // Caractère pas géré
else if (char_index & 1) else if (char_index & 1)
char_pixel=&(GFX_help_font_t2[(unsigned char)(line[char_index/2])-' '][0][0]); char_pixel=&(Gfx->Help_font_t2[(unsigned char)(line[char_index/2])-' '][0][0]);
else else
char_pixel=&(GFX_help_font_t1[(unsigned char)(line[char_index/2])-' '][0][0]); char_pixel=&(Gfx->Help_font_t1[(unsigned char)(line[char_index/2])-' '][0][0]);
} }
else if (line_type=='-') else if (line_type=='-')
{ {
if (line[char_index/2]>'_' || line[char_index/2]<' ') if (line[char_index/2]>'_' || line[char_index/2]<' ')
char_pixel=&(GFX_help_font_norm['!'][0][0]); // Caractère pas géré char_pixel=&(Gfx->Help_font_norm['!'][0][0]); // Caractère pas géré
else if (char_index & 1) else if (char_index & 1)
char_pixel=&(GFX_help_font_t4[(unsigned char)(line[char_index/2])-' '][0][0]); char_pixel=&(Gfx->Help_font_t4[(unsigned char)(line[char_index/2])-' '][0][0]);
else else
char_pixel=&(GFX_help_font_t3[(unsigned char)(line[char_index/2])-' '][0][0]); char_pixel=&(Gfx->Help_font_t3[(unsigned char)(line[char_index/2])-' '][0][0]);
} }
else if (line_type=='S') else if (line_type=='S')
char_pixel=&(GFX_bold_font[(unsigned char)(line[char_index])][0][0]); char_pixel=&(Gfx->Bold_font[(unsigned char)(line[char_index])][0][0]);
else if (line_type=='N' || line_type=='K') else if (line_type=='N' || line_type=='K')
char_pixel=&(GFX_help_font_norm[(unsigned char)(line[char_index])][0][0]); char_pixel=&(Gfx->Help_font_norm[(unsigned char)(line[char_index])][0][0]);
else else
char_pixel=&(GFX_help_font_norm['!'][0][0]); // Un garde-fou en cas de probleme char_pixel=&(Gfx->Help_font_norm['!'][0][0]); // Un garde-fou en cas de probleme
for (x=0;x<6;x++) for (x=0;x<6;x++)
for (repeat_menu_x_factor=0;repeat_menu_x_factor<Menu_factor_X;repeat_menu_x_factor++) for (repeat_menu_x_factor=0;repeat_menu_x_factor<Menu_factor_X;repeat_menu_x_factor++)
@ -571,11 +585,12 @@ void Window_help(int section, const char *sub_section)
} }
break; break;
} }
if (Is_shortcut(Key,0x100+BUTTON_HELP))
clicked_button=1;
} }
while ((clicked_button!=1) && (Key!=SDLK_RETURN)); while ((clicked_button!=1) && (Key!=SDLK_RETURN));
if(Key==SDLK_RETURN) Key=0; Key=0;
Close_window(); Close_window();
Unselect_button(BUTTON_HELP); Unselect_button(BUTTON_HELP);
Display_cursor(); Display_cursor();
@ -684,6 +699,8 @@ void Button_Stats(void)
do do
{ {
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
if (Is_shortcut(Key,0x200+BUTTON_HELP))
clicked_button=1;
} }
while ( (clicked_button!=1) && (Key!=SDLK_RETURN) ); while ( (clicked_button!=1) && (Key!=SDLK_RETURN) );

96
help.h
View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file help.h ///@file help.h
/// Functions related to the help browser. The help data is in helpfile.h /// Functions related to the help browser. The help data is in helpfile.h
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef __HELP_H_ #ifndef __HELP_H_
#define __HELP_H_ #define __HELP_H_
/*! /*!
Called to open the help window with the keyboard shortcut. Called to open the help window with the keyboard shortcut.
If the mouse is over a button, its contextual help will be displayed. If the mouse is over a button, its contextual help will be displayed.
Else, the default helpscreen will be shown. Else, the default helpscreen will be shown.
*/ */
void Button_Help(void); void Button_Help(void);
/*! /*!
Displays and runs the "Statistics" window Displays and runs the "Statistics" window
*/ */
void Button_Stats(void); void Button_Stats(void);
/*! /*!
Displays and runs the "Help / About..." window Displays and runs the "Help / About..." window
@param section Number of the help section page to display (equals the button number the mouse was hovering for the contextual help), -1 for the main help page. @param section Number of the help section page to display (equals the button number the mouse was hovering for the contextual help), -1 for the main help page.
@param sub_section Help sub-section title (the page will be scrolled so this title is at the top). @param sub_section Help sub-section title (the page will be scrolled so this title is at the top).
*/ */
void Window_help(int section, const char * sub_section); void Window_help(int section, const char * sub_section);
#endif #endif

4885
helpfile.h

File diff suppressed because it is too large Load Diff

2695
hotkeys.c

File diff suppressed because it is too large Load Diff

1098
init.c

File diff suppressed because it is too large Load Diff

75
init.h
View File

@ -1,32 +1,43 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file init.h ///@file init.h
/// Initialization (and some de-initialization) functions. /// Initialization (and some de-initialization) functions.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Load_graphics(const char * skin_file); T_Gui_skin *Load_graphics(const char * skin_file);
void Init_buttons(void); void Init_buttons(void);
void Init_operations(void); void Init_operations(void);
int Load_CFG(int reload_all); void Init_brush_container(void);
int Save_CFG(void); int Load_CFG(int reload_all);
void Set_all_video_modes(void); int Save_CFG(void);
void Set_config_defaults(void); void Set_all_video_modes(void);
void Init_sighandler(void); void Set_config_defaults(void);
void Init_sighandler(void);
extern char Gui_loading_error_message[512];
///
/// Loads a 8x8 monochrome font, the kind used in all menus and screens.
/// This function allocates the memory, and returns a pointer to it when
/// successful.
/// If an error is encountered, it frees what needs it, prints an error message
/// in ::Gui_loading_error_message, and returns NULL.
byte * Load_font(const char * font_name);

137
input.c
View File

@ -31,6 +31,15 @@
void Handle_window_resize(SDL_ResizeEvent event); void Handle_window_resize(SDL_ResizeEvent event);
void Handle_window_exit(SDL_QuitEvent event); void Handle_window_exit(SDL_QuitEvent event);
// public Globals (available as extern)
int Input_sticky_control = 0;
int Snap_axis = 0;
int Snap_axis_origin_X;
int Snap_axis_origin_Y;
// --
byte Directional_up; byte Directional_up;
byte Directional_up_right; byte Directional_up_right;
byte Directional_right; byte Directional_right;
@ -39,10 +48,12 @@ byte Directional_down;
byte Directional_down_left; byte Directional_down_left;
byte Directional_left; byte Directional_left;
byte Directional_up_left; byte Directional_up_left;
byte Directional_click;
long Directional_delay; long Directional_delay;
long Directional_last_move; long Directional_last_move;
long Directional_step; long Directional_step;
short Mouse_count; // Number of mouse movements received in the current Get_input() int Mouse_moved; ///< Boolean, Set to true if any cursor movement occurs.
word Input_new_mouse_X; word Input_new_mouse_X;
word Input_new_mouse_Y; word Input_new_mouse_Y;
@ -71,7 +82,7 @@ short Joybutton_right_click=0; // Button number that serves as right-click
int Is_shortcut(word Key, word function) int Is_shortcut(word Key, word function)
{ {
if (Key == 0) if (Key == 0 || function == 0xFFFF)
return 0; return 0;
if (function & 0x100) if (function & 0x100)
@ -101,19 +112,20 @@ int Is_shortcut(word Key, word function)
int Move_cursor_with_constraints() int Move_cursor_with_constraints()
{ {
int feedback=0; int feedback=0;
byte bl=0;//BL va indiquer si on doit corriger la position du curseur int mouse_blocked=0; ///< Boolean, Set to true if mouse movement was clipped.
// Clip mouse to the editing area. There can be a border when using big // Clip mouse to the editing area. There can be a border when using big
// pixels, if the SDL screen dimensions are not factors of the pixel size. // pixels, if the SDL screen dimensions are not factors of the pixel size.
if (Input_new_mouse_Y>=Screen_height) if (Input_new_mouse_Y>=Screen_height)
{ {
Input_new_mouse_Y=Screen_height-1; Input_new_mouse_Y=Screen_height-1;
bl=1; mouse_blocked=1;
} }
if (Input_new_mouse_X>=Screen_width) if (Input_new_mouse_X>=Screen_width)
{ {
Input_new_mouse_X=Screen_width-1; Input_new_mouse_X=Screen_width-1;
bl=1; mouse_blocked=1;
} }
//Gestion "avancée" du curseur: interdire la descente du curseur dans le //Gestion "avancée" du curseur: interdire la descente du curseur dans le
//menu lorsqu'on est en train de travailler dans l'image //menu lorsqu'on est en train de travailler dans l'image
@ -125,7 +137,7 @@ int Move_cursor_with_constraints()
if(Menu_Y<=Input_new_mouse_Y) if(Menu_Y<=Input_new_mouse_Y)
{ {
//On bloque le curseur en fin d'image //On bloque le curseur en fin d'image
bl++; mouse_blocked=1;
Input_new_mouse_Y=Menu_Y-1; //La ligne !!au-dessus!! du menu Input_new_mouse_Y=Menu_Y-1; //La ligne !!au-dessus!! du menu
} }
@ -135,7 +147,7 @@ int Move_cursor_with_constraints()
{ {
if(Input_new_mouse_X>=Main_separator_position) if(Input_new_mouse_X>=Main_separator_position)
{ {
bl++; mouse_blocked=1;
Input_new_mouse_X=Main_separator_position-1; Input_new_mouse_X=Main_separator_position-1;
} }
} }
@ -143,7 +155,7 @@ int Move_cursor_with_constraints()
{ {
if(Input_new_mouse_X<Main_X_zoom) if(Input_new_mouse_X<Main_X_zoom)
{ {
bl++; mouse_blocked=1;
Input_new_mouse_X=Main_X_zoom; Input_new_mouse_X=Main_X_zoom;
} }
} }
@ -153,25 +165,36 @@ int Move_cursor_with_constraints()
(Input_new_mouse_Y != Mouse_Y) || (Input_new_mouse_Y != Mouse_Y) ||
(Input_new_mouse_K != Mouse_K)) (Input_new_mouse_K != Mouse_K))
{ {
// On every change of mouse state
if ((Input_new_mouse_K != Mouse_K)) if ((Input_new_mouse_K != Mouse_K))
feedback=1; {
Hide_cursor(); // On efface le curseur AVANT de le déplacer... feedback=1;
if (Input_new_mouse_K == 0)
Input_sticky_control = 0;
}
// Hide cursor, because even just a click change needs it
if (!Mouse_moved)
{
Mouse_moved++;
// Hide cursor (erasing icon and brush on screen
// before changing the coordinates.
Hide_cursor();
}
if (Input_new_mouse_X != Mouse_X || Input_new_mouse_Y != Mouse_Y) if (Input_new_mouse_X != Mouse_X || Input_new_mouse_Y != Mouse_Y)
{ {
Mouse_X=Input_new_mouse_X; Mouse_X=Input_new_mouse_X;
Mouse_Y=Input_new_mouse_Y; Mouse_Y=Input_new_mouse_Y;
if (bl)
Set_mouse_position();
} }
Mouse_K=Input_new_mouse_K; Mouse_K=Input_new_mouse_K;
Compute_paintbrush_coordinates();
Display_cursor();
Mouse_count++; if (Mouse_moved > Config.Mouse_merge_movement)
if (Mouse_count>Config.Mouse_merge_movement) if (! Operation[Current_operation][Mouse_K_unique]
feedback=1; [Operation_stack_size].Fast_mouse)
feedback=1;
} }
if (mouse_blocked)
Set_mouse_position();
return feedback; return feedback;
} }
@ -296,6 +319,7 @@ int Handle_mouse_release(SDL_MouseButtonEvent event)
Input_new_mouse_K &= ~2; Input_new_mouse_K &= ~2;
break; break;
} }
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
@ -327,14 +351,16 @@ int Handle_key_press(SDL_KeyboardEvent event)
Directional_right=1; Directional_right=1;
return 0; return 0;
} }
else if(Is_shortcut(Key,SPECIAL_CLICK_LEFT)) else if(Is_shortcut(Key,SPECIAL_CLICK_LEFT) && Keyboard_click_allowed > 0)
{ {
Input_new_mouse_K=1; Input_new_mouse_K=1;
Directional_click=1;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
else if(Is_shortcut(Key,SPECIAL_CLICK_RIGHT)) else if(Is_shortcut(Key,SPECIAL_CLICK_RIGHT) && Keyboard_click_allowed > 0)
{ {
Input_new_mouse_K=2; Input_new_mouse_K=2;
Directional_click=2;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
@ -344,44 +370,60 @@ int Handle_key_press(SDL_KeyboardEvent event)
int Release_control(int key_code, int modifier) int Release_control(int key_code, int modifier)
{ {
int need_feedback = 0;
if(key_code == (Config_Key[SPECIAL_MOUSE_UP][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_UP][0]&modifier) || if (modifier == MOD_SHIFT)
key_code == (Config_Key[SPECIAL_MOUSE_UP][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_UP][1]&modifier)) {
// Disable "snap axis" mode
Snap_axis = 0;
need_feedback = 1;
}
if((key_code && key_code == (Config_Key[SPECIAL_MOUSE_UP][0]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_UP][0]&modifier) ||
(key_code && key_code == (Config_Key[SPECIAL_MOUSE_UP][1]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_UP][1]&modifier))
{ {
Directional_up=0; Directional_up=0;
} }
if(key_code == (Config_Key[SPECIAL_MOUSE_DOWN][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_DOWN][0]&modifier) || if((key_code && key_code == (Config_Key[SPECIAL_MOUSE_DOWN][0]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_DOWN][0]&modifier) ||
key_code == (Config_Key[SPECIAL_MOUSE_DOWN][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_DOWN][1]&modifier)) (key_code && key_code == (Config_Key[SPECIAL_MOUSE_DOWN][1]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_DOWN][1]&modifier))
{ {
Directional_down=0; Directional_down=0;
} }
if(key_code == (Config_Key[SPECIAL_MOUSE_LEFT][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_LEFT][0]&modifier) || if((key_code && key_code == (Config_Key[SPECIAL_MOUSE_LEFT][0]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_LEFT][0]&modifier) ||
key_code == (Config_Key[SPECIAL_MOUSE_LEFT][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_LEFT][1]&modifier)) (key_code && key_code == (Config_Key[SPECIAL_MOUSE_LEFT][1]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_LEFT][1]&modifier))
{ {
Directional_left=0; Directional_left=0;
} }
if(key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_RIGHT][0]&modifier) || if((key_code && key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][0]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_RIGHT][0]&modifier) ||
key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_RIGHT][1]&modifier)) (key_code && key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][1]&0x0FFF)) || (Config_Key[SPECIAL_MOUSE_RIGHT][1]&modifier))
{ {
Directional_right=0; Directional_right=0;
} }
if(key_code == (Config_Key[SPECIAL_CLICK_LEFT][0]&0x0FFF) || (Config_Key[SPECIAL_CLICK_LEFT][0]&modifier) || if((key_code && key_code == (Config_Key[SPECIAL_CLICK_LEFT][0]&0x0FFF)) || (Config_Key[SPECIAL_CLICK_LEFT][0]&modifier) ||
key_code == (Config_Key[SPECIAL_CLICK_LEFT][1]&0x0FFF) || (Config_Key[SPECIAL_CLICK_LEFT][1]&modifier)) (key_code && key_code == (Config_Key[SPECIAL_CLICK_LEFT][1]&0x0FFF)) || (Config_Key[SPECIAL_CLICK_LEFT][1]&modifier))
{ {
Input_new_mouse_K &= ~1; if (Directional_click & 1)
return Move_cursor_with_constraints(); {
Directional_click &= ~1;
Input_new_mouse_K &= ~1;
return Move_cursor_with_constraints() || need_feedback;
}
} }
if(key_code == (Config_Key[SPECIAL_CLICK_RIGHT][0]&0x0FFF) || (Config_Key[SPECIAL_CLICK_RIGHT][0]&modifier) || if((key_code && key_code == (Config_Key[SPECIAL_CLICK_RIGHT][0]&0x0FFF)) || (Config_Key[SPECIAL_CLICK_RIGHT][0]&modifier) ||
key_code == (Config_Key[SPECIAL_CLICK_RIGHT][1]&0x0FFF) || (Config_Key[SPECIAL_CLICK_RIGHT][1]&modifier)) (key_code && key_code == (Config_Key[SPECIAL_CLICK_RIGHT][1]&0x0FFF)) || (Config_Key[SPECIAL_CLICK_RIGHT][1]&modifier))
{ {
Input_new_mouse_K &= ~2; if (Directional_click & 2)
return Move_cursor_with_constraints(); {
Directional_click &= ~2;
Input_new_mouse_K &= ~2;
return Move_cursor_with_constraints() || need_feedback;
}
} }
// Other keys don't need to be released : they are handled as "events" and procesed only once. // Other keys don't need to be released : they are handled as "events" and procesed only once.
// These clicks are apart because they need to be continuous (ie move while key pressed) // These clicks are apart because they need to be continuous (ie move while key pressed)
// We are relying on "hardware" keyrepeat to achieve that. // We are relying on "hardware" keyrepeat to achieve that.
return 0; return need_feedback;
} }
@ -614,10 +656,12 @@ int Get_input(void)
{ {
SDL_Event event; SDL_Event event;
int user_feedback_required = 0; // Flag qui indique si on doit arrêter de traiter les évènements ou si on peut enchainer int user_feedback_required = 0; // Flag qui indique si on doit arrêter de traiter les évènements ou si on peut enchainer
Key_ANSI = 0; Key_ANSI = 0;
Key = 0; Key = 0;
Mouse_count=0; Mouse_moved=0;
Input_new_mouse_X = Mouse_X;
Input_new_mouse_Y = Mouse_Y;
// Process as much events as possible without redrawing the screen. // Process as much events as possible without redrawing the screen.
// This mostly allows us to merge mouse events for people with an high // This mostly allows us to merge mouse events for people with an high
@ -734,11 +778,20 @@ int Get_input(void)
} }
} }
} }
// Vidage de toute mise à jour de l'affichage à l'écran qui serait encore en attente. // If the cursor was moved since last update,
// (c'est fait ici car on est sur que cette function est apellée partout ou on a besoin d'interragir avec l'utilisateur) // it was erased, so we need to redraw it (with the preview brush)
if (Mouse_moved)
{
Compute_paintbrush_coordinates();
Display_cursor();
}
// Commit any pending screen update.
// This is done in this function because it's called after reading
// some user input.
Flush_update(); Flush_update();
return user_feedback_required;
return (Mouse_moved!=0) || user_feedback_required;
} }
void Adjust_mouse_sensitivity(word fullscreen) void Adjust_mouse_sensitivity(word fullscreen)

14
input.h
View File

@ -40,3 +40,17 @@ int Is_shortcut(word Key, word function);
void Adjust_mouse_sensitivity(word fullscreen); void Adjust_mouse_sensitivity(word fullscreen);
void Set_mouse_position(void); void Set_mouse_position(void);
///
/// This holds the ID of the GUI control that the mouse
/// is manipulating. The input system will reset it to zero
/// when mouse button is released, but it's the engine
/// that will record and retrieve a real control ID.
extern int Input_sticky_control;
/// Allows locking movement to X or Y axis: 0=normal, 1=lock on next move, 2=locked horizontally, 3=locked vertically.
extern int Snap_axis;
/// For the :Snap_axis mode, sets the origin's point (in image coordinates)
extern int Snap_axis_origin_X;
/// For the :Snap_axis mode, sets the origin's point (in image coordinates)
extern int Snap_axis_origin_Y;

View File

@ -11,7 +11,7 @@
;Name and file ;Name and file
Name "Grafx2" Name "Grafx2"
OutFile "grafx2-2.0-svn853-win32.exe" OutFile "grafx2-2.1.1026.win32.exe"
;Default installation folder ;Default installation folder
InstallDir "$PROGRAMFILES\Grafx2" InstallDir "$PROGRAMFILES\Grafx2"
@ -60,7 +60,7 @@ Section "Grafx2" SecProgram
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
;ADD YOUR OWN FILES HERE... ;ADD YOUR OWN FILES HERE...
File ..\grafx2.exe File ..\grafx2.exe
File ..\src-svn853.tgz File ..\src-2.1.1026.tgz
File ..\gfx2.gif File ..\gfx2.gif
File ..\gfx2def.ini File ..\gfx2def.ini
File ..\SDL_image.dll File ..\SDL_image.dll
@ -70,7 +70,10 @@ Section "Grafx2" SecProgram
File ..\zlib1.dll File ..\zlib1.dll
File ..\libpng13.dll File ..\libpng13.dll
SetOutPath "$INSTDIR\skins" SetOutPath "$INSTDIR\skins"
File ..\skins\base.gif File ..\skins\font_Classic.png
File ..\skins\font_Fun.png
File ..\skins\skin_classic.png
File ..\skins\skin_modern.png
SetOutPath "$INSTDIR\doc" SetOutPath "$INSTDIR\doc"
File ..\doc\README.txt File ..\doc\README.txt
File ..\doc\COMPILING.txt File ..\doc\COMPILING.txt
@ -97,7 +100,7 @@ Section "Grafx2" SecProgram
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \
"URLInfoAbout" "http://grafx2.googlecode.com" "URLInfoAbout" "http://grafx2.googlecode.com"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \
"DisplayVersion" "2.0 final" "DisplayVersion" "2.1.1026"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \
"NoModify" 1 "NoModify" 1
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Grafx2-SDL" \
@ -139,7 +142,7 @@ Section "un.SecProgram"
;ADD YOUR OWN FILES HERE... ;ADD YOUR OWN FILES HERE...
Delete "$INSTDIR\grafx2.exe" Delete "$INSTDIR\grafx2.exe"
Delete "$INSTDIR\src-svn853.tgz" Delete "$INSTDIR\src-2.1.1026.tgz"
Delete "$INSTDIR\gfx2.gif" Delete "$INSTDIR\gfx2.gif"
Delete "$INSTDIR\gfx2def.ini" Delete "$INSTDIR\gfx2def.ini"
Delete "$INSTDIR\SDL_image.dll" Delete "$INSTDIR\SDL_image.dll"
@ -159,7 +162,10 @@ Section "un.SecProgram"
Delete "$INSTDIR\fonts\8pxfont.png" Delete "$INSTDIR\fonts\8pxfont.png"
Delete "$INSTDIR\fonts\Tuffy.ttf" Delete "$INSTDIR\fonts\Tuffy.ttf"
RMDir "$INSTDIR\fonts" RMDir "$INSTDIR\fonts"
Delete "$INSTDIR\skins\base.gif" Delete "$INSTDIR\skins\font_Classic.png"
Delete "$INSTDIR\skins\font_Fun.png"
Delete "$INSTDIR\skins\skin_classic.png"
Delete "$INSTDIR\skins\skin_modern.png"
RMDir "$INSTDIR\skins" RMDir "$INSTDIR\skins"
Delete "$INSTDIR\Uninstall.exe" Delete "$INSTDIR\Uninstall.exe"

10
io.c
View File

@ -243,16 +243,16 @@ int File_length_file(FILE * file)
void For_each_file(const char * directory_name, void Callback(const char *)) void For_each_file(const char * directory_name, void Callback(const char *))
{ {
// Pour scan de répertoire // Pour scan de répertoire
DIR* Repertoire_Courant; //Répertoire courant DIR* current_directory; //Répertoire courant
struct dirent* entry; // Structure de lecture des éléments struct dirent* entry; // Structure de lecture des éléments
char full_filename[MAX_PATH_CHARACTERS]; char full_filename[MAX_PATH_CHARACTERS];
int filename_position; int filename_position;
strcpy(full_filename, directory_name); strcpy(full_filename, directory_name);
Repertoire_Courant=opendir(directory_name); current_directory=opendir(directory_name);
if(Repertoire_Courant == NULL) return; // Répertoire invalide ... if(current_directory == NULL) return; // Répertoire invalide ...
strcat(full_filename, PATH_SEPARATOR); strcat(full_filename, PATH_SEPARATOR);
filename_position = strlen(full_filename); filename_position = strlen(full_filename);
while ((entry=readdir(Repertoire_Courant))) while ((entry=readdir(current_directory)))
{ {
struct stat Infos_enreg; struct stat Infos_enreg;
strcpy(&full_filename[filename_position], entry->d_name); strcpy(&full_filename[filename_position], entry->d_name);
@ -262,6 +262,6 @@ void For_each_file(const char * directory_name, void Callback(const char *))
Callback(full_filename); Callback(full_filename);
} }
} }
closedir(Repertoire_Courant); closedir(current_directory);
} }

1300
keyboard.c

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +1,75 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file keyboard.h ///@file keyboard.h
/// Functions to convert bewteen the SDL key formats and the keycode we use /// Functions to convert bewteen the SDL key formats and the keycode we use
/// in grafx2. /// in grafx2.
/// The keycode we're using is generalized to handle mouse and joystick shortcuts /// The keycode we're using is generalized to handle mouse and joystick shortcuts
/// as well. The format can be broken down as: /// as well. The format can be broken down as:
/// - 0x0000 + a number between 0 and SDLK_LAST (about 324) : the SDL "sym" key number. /// - 0x0000 + a number between 0 and SDLK_LAST (about 324) : the SDL "sym" key number.
/// - 0x0000 + SDLK_LAST+1: Mouse middle button. /// - 0x0000 + SDLK_LAST+1: Mouse middle button.
/// - 0x0000 + SDLK_LAST+2: Mouse wheel up. /// - 0x0000 + SDLK_LAST+2: Mouse wheel up.
/// - 0x0000 + SDLK_LAST+3: Mouse wheel down. /// - 0x0000 + SDLK_LAST+3: Mouse wheel down.
/// - 0x0000 + SDLK_LAST+4+B : Joystick button number "B", starting at B=0. /// - 0x0000 + SDLK_LAST+4+B : Joystick button number "B", starting at B=0.
/// - 0x0800 + a number between 0 and 0x7FF: The scancode key number, for keys which have no "sym", such as keys from multimedia keyboards, and "fn" and "Thinkpad" key for a laptop. /// - 0x0800 + a number between 0 and 0x7FF: The scancode key number, for keys which have no "sym", such as keys from multimedia keyboards, and "fn" and "Thinkpad" key for a laptop.
/// Add 0x1000 for the Shift modifier MOD_SHIFT /// Add 0x1000 for the Shift modifier MOD_SHIFT
/// Add 0x2000 for the Control modifier ::MOD_CONTROL /// Add 0x2000 for the Control modifier ::MOD_CONTROL
/// Add 0x4000 for the Alt modifier ::MOD_ALT /// Add 0x4000 for the Alt modifier ::MOD_ALT
/// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key) /// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/*! /*!
Convert an SDL keysym to an ANSI/ASCII character. Convert an SDL keysym to an ANSI/ASCII character.
This is used to type text and numeric values in input boxes. This is used to type text and numeric values in input boxes.
@param keysym SDL symbol to convert @param keysym SDL symbol to convert
*/ */
word Keysym_to_ANSI(SDL_keysym keysym); word Keysym_to_ANSI(SDL_keysym keysym);
/*! /*!
Convert an SDL keysym to an internal keycode number. Convert an SDL keysym to an internal keycode number.
This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode. This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode.
We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things. We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things.
See the notice at the beginning of keyboard.h for the format of a keycode. See the notice at the beginning of keyboard.h for the format of a keycode.
@param keysym SDL symbol to convert @param keysym SDL symbol to convert
*/ */
word Keysym_to_keycode(SDL_keysym keysym); word Keysym_to_keycode(SDL_keysym keysym);
/*! /*!
Helper function to convert between SDL system and the old coding for PC keycodes. Helper function to convert between SDL system and the old coding for PC keycodes.
This is only used to convert configuration files from the DOS version of This is only used to convert configuration files from the DOS version of
Grafx2, where keyboard codes are in in the IBM PC AT form. Grafx2, where keyboard codes are in in the IBM PC AT form.
@param scancode Scancode to convert @param scancode Scancode to convert
*/ */
word Key_for_scancode(word scancode); word Key_for_scancode(word scancode);
/*! /*!
Returns key name in a string. Used to display them in the helpscreens and in the keymapper window. Returns key name in a string. Used to display them in the helpscreens and in the keymapper window.
@param Key keycode of the key to translate, including modifiers @param Key keycode of the key to translate, including modifiers
*/ */
const char * Key_name(word Key); const char * Key_name(word Key);
/*! /*!
Gets the modifiers in our format from the SDL_Mod information. Gets the modifiers in our format from the SDL_Mod information.
Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CONTROL Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CONTROL
@param mod SDL modifiers state @param mod SDL modifiers state
*/ */
word Key_modifiers(SDLMod mod); word Key_modifiers(SDLMod mod);

1099
loadsave.c

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +1,60 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file loadsave.h ///@file loadsave.h
/// Saving and loading different picture formats. /// Saving and loading different picture formats.
/// Also handles showing the preview in fileselectors. /// Also handles showing the preview in fileselectors.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Pixel_load_in_current_screen(word x_pos,word y_pos,byte color); void Pixel_load_in_current_screen(word x_pos,word y_pos,byte color);
void Pixel_load_in_preview (word x_pos,word y_pos,byte color); void Pixel_load_in_preview (word x_pos,word y_pos,byte color);
void Pixel_load_in_brush (word x_pos,word y_pos,byte color); void Pixel_load_in_brush (word x_pos,word y_pos,byte color);
void Get_full_filename(char * filename, byte is_colorix_format); void Get_full_filename(char * filename, byte is_colorix_format);
/// ///
/// High-level picture loading function. /// High-level picture loading function.
/// Handles loading an image or a brush, or previewing only. /// Handles loading an image or a brush, or previewing only.
/// @param image true if the fileselector is the one for loading images (not brush) /// @param image true if the fileselector is the one for loading images (not brush)
void Load_image(byte image); void Load_image(byte image);
/// ///
/// High-level picture saving function. /// High-level picture saving function.
/// @param image true if the image should be saved (instead of the brush) /// @param image true if the image should be saved (instead of the brush)
void Save_image(byte image); void Save_image(byte image);
/// Data for an image file format. /// Data for an image file format.
typedef struct { typedef struct {
char *Extension; ///< Three-letter file extension char *Extension; ///< Three-letter file extension
Func_action Test; ///< Function which tests if the file is of this format Func_action Test; ///< Function which tests if the file is of this format
Func_action Load; ///< Function which loads an image of this format Func_action Load; ///< Function which loads an image of this format
Func_action Save; ///< Function which saves an image of this format Func_action Save; ///< Function which saves an image of this format
byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette. byte Backup_done; ///< Boolean, true if this format saves all the image, and considers it backed up. Set false for formats which only save the palette.
byte Comment; ///< This file format allows a text comment byte Comment; ///< This file format allows a text comment
} T_Format; } T_Format;
/// Array of the known file formats /// Array of the known file formats
extern T_Format File_formats[NB_KNOWN_FORMATS]; extern T_Format File_formats[NB_KNOWN_FORMATS];
/// ///
/// Function which attempts to save backups of the images (main and spare), /// Function which attempts to save backups of the images (main and spare),
/// called in case of SIGSEGV. /// called in case of SIGSEGV.
void Image_emergency_backup(void); void Image_emergency_backup(void);
/// Pixel ratio of last loaded image: one of :PIXEL_SIMPLE, :PIXEL_WIDE or :PIXEL_TALL
extern enum PIXEL_RATIO Ratio_of_loaded_image;

83
main.c
View File

@ -76,7 +76,7 @@
#endif #endif
// filename for the current GUI skin file. // filename for the current GUI skin file.
static char Gui_skin_file[MAX_PATH_CHARACTERS]= "skins" PATH_SEPARATOR "base.gif"; static char Gui_skin_file[MAX_PATH_CHARACTERS];
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles --- //--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
void Display_syntax(void) void Display_syntax(void)
@ -344,6 +344,7 @@ int Init_program(int argc,char * argv[])
strcpy(Main_file_directory,Main_current_directory); strcpy(Main_file_directory,Main_current_directory);
strcpy(Main_filename,"NO_NAME.GIF"); strcpy(Main_filename,"NO_NAME.GIF");
Main_fileformat=DEFAULT_FILEFORMAT; Main_fileformat=DEFAULT_FILEFORMAT;
// On initialise les données sur le nom de fichier de l'image de brouillon: // On initialise les données sur le nom de fichier de l'image de brouillon:
strcpy(Spare_current_directory,Main_current_directory); strcpy(Spare_current_directory,Main_current_directory);
strcpy(Spare_file_directory,Main_file_directory); strcpy(Spare_file_directory,Main_file_directory);
@ -355,7 +356,7 @@ int Init_program(int argc,char * argv[])
Brush_fileformat =Main_fileformat; Brush_fileformat =Main_fileformat;
// On initialise ce qu'il faut pour que les fileselects ne plantent pas: // On initialise ce qu'il faut pour que les fileselects ne plantent pas:
Filelist=NULL; // Au début, il n'y a pas de fichiers dans la liste
Main_fileselector_position=0; // Au début, le fileselect est en haut de la liste des fichiers Main_fileselector_position=0; // Au début, le fileselect est en haut de la liste des fichiers
Main_fileselector_offset=0; // Au début, le fileselect est en haut de la liste des fichiers Main_fileselector_offset=0; // Au début, le fileselect est en haut de la liste des fichiers
Main_format=0; Main_format=0;
@ -398,6 +399,7 @@ int Init_program(int argc,char * argv[])
Spare_magnifier_width=0; Spare_magnifier_width=0;
Spare_magnifier_offset_X=0; Spare_magnifier_offset_X=0;
Spare_magnifier_offset_Y=0; Spare_magnifier_offset_Y=0;
Keyboard_click_allowed = 0;
// SDL // SDL
if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0)
@ -406,6 +408,7 @@ int Init_program(int argc,char * argv[])
printf("Couldn't initialize SDL.\n"); printf("Couldn't initialize SDL.\n");
return(0); return(0);
} }
Joystick = SDL_JoystickOpen(0); Joystick = SDL_JoystickOpen(0);
SDL_EnableKeyRepeat(250, 32); SDL_EnableKeyRepeat(250, 32);
SDL_EnableUNICODE(SDL_ENABLE); SDL_EnableUNICODE(SDL_ENABLE);
@ -439,18 +442,18 @@ int Init_program(int argc,char * argv[])
Set_all_video_modes(); Set_all_video_modes();
Pixel_ratio=PIXEL_SIMPLE; Pixel_ratio=PIXEL_SIMPLE;
// On initialise les données sur l'état du programme: // On initialise les données sur l'état du programme:
// Donnée sur la sortie du programme: // Donnée sur la sortie du programme:
Quit_is_required=0; Quit_is_required=0;
Quitting=0; Quitting=0;
// Données sur l'état du menu: // Données sur l'état du menu:
Pixel_in_menu=Pixel_in_toolbar; Pixel_in_menu=Pixel_in_toolbar;
Menu_is_visible=1; Menu_is_visible=1;
// Données sur les couleurs et la palette: // Données sur les couleurs et la palette:
First_color_in_palette=0; First_color_in_palette=0;
// Données sur le curseur: // Données sur le curseur:
Cursor_shape=CURSOR_SHAPE_TARGET; Cursor_shape=CURSOR_SHAPE_TARGET;
Cursor_hidden=0; Cursor_hidden=0;
// Données sur le pinceau: // Données sur le pinceau:
Paintbrush_X=0; Paintbrush_X=0;
Paintbrush_Y=0; Paintbrush_Y=0;
Paintbrush_shape=PAINTBRUSH_SHAPE_ROUND; Paintbrush_shape=PAINTBRUSH_SHAPE_ROUND;
@ -510,10 +513,14 @@ int Init_program(int argc,char * argv[])
// Initialisation des opérations // Initialisation des opérations
Init_operations(); Init_operations();
// Initialize the brush container
Init_brush_container();
Windows_open=0; Windows_open=0;
// Charger la configuration des touches // Charger la configuration des touches
Set_config_defaults(); Set_config_defaults();
switch(Load_CFG(1)) switch(Load_CFG(1))
{ {
case ERROR_CFG_MISSING: case ERROR_CFG_MISSING:
@ -533,30 +540,41 @@ int Init_program(int argc,char * argv[])
Analyze_command_line(argc,argv); Analyze_command_line(argc,argv);
// Charger les sprites et la palette // Load sprites, palette etc.
Load_graphics(Gui_skin_file); strcpy(Gui_skin_file,Config.Skin_file);
Gfx = Load_graphics(Gui_skin_file);
if (Gfx == NULL)
{
Gfx = Load_graphics("skin_modern.png");
if (Gfx == NULL)
{
printf("%s", Gui_loading_error_message);
Error(ERROR_GUI_MISSING);
}
}
// Infos sur les trames (Sieve) // Infos sur les trames (Sieve)
Sieve_mode=0; Sieve_mode=0;
Copy_preset_sieve(0); Copy_preset_sieve(0);
// Transfert des valeurs du .INI qui ne changent pas dans des variables // Transfert des valeurs du .INI qui ne changent pas dans des variables
// plus accessibles: // plus accessibles:
Default_palette[MC_Black]=Fav_menu_colors[0]=Config.Fav_menu_colors[0]; Gfx->Default_palette[MC_Black]=Fav_menu_colors[0]=Config.Fav_menu_colors[0];
Default_palette[MC_Dark] =Fav_menu_colors[1]=Config.Fav_menu_colors[1]; Gfx->Default_palette[MC_Dark] =Fav_menu_colors[1]=Config.Fav_menu_colors[1];
Default_palette[MC_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2]; Gfx->Default_palette[MC_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2];
Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3]; Gfx->Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
Compute_optimal_menu_colors(Default_palette); Compute_optimal_menu_colors(Gfx->Default_palette);
Fore_color=MC_White; Fore_color=MC_White;
Back_color=MC_Black; Back_color=MC_Black;
// Prise en compte de la fonte // Font
if (Config.Font) if (!(Menu_font=Load_font(Config.Font_file)))
Menu_font=GFX_fun_font; if (!(Menu_font=Load_font("font_Classic.png")))
else {
Menu_font=GFX_system_font; printf("Unable to open the default font file: %s\n", "font_Classic.png");
Error(ERROR_GUI_MISSING);
}
memcpy(Main_palette,Default_palette,sizeof(T_Palette)); memcpy(Main_palette, Gfx->Default_palette, sizeof(T_Palette));
// Allocation de mémoire pour la brosse // Allocation de mémoire pour la brosse
if (!(Brush =(byte *)malloc( 1* 1))) Error(ERROR_MEMORY); if (!(Brush =(byte *)malloc( 1* 1))) Error(ERROR_MEMORY);
@ -571,7 +589,7 @@ int Init_program(int argc,char * argv[])
starting_videomode=Current_resolution; starting_videomode=Current_resolution;
Horizontal_line_buffer=NULL; Horizontal_line_buffer=NULL;
Screen_width=Screen_height=Current_resolution=0; Screen_width=Screen_height=Current_resolution=0;
Init_mode_video( Init_mode_video(
Video_mode[starting_videomode].Width, Video_mode[starting_videomode].Width,
Video_mode[starting_videomode].Height, Video_mode[starting_videomode].Height,
@ -672,17 +690,24 @@ void Program_shutdown(void)
#endif #endif
// On libère le buffer de gestion de lignes // On libère le buffer de gestion de lignes
free(Horizontal_line_buffer); if(Horizontal_line_buffer) free(Horizontal_line_buffer);
// On libère le pinceau spécial // On libère le pinceau spécial
free(Paintbrush_sprite); if (Paintbrush_sprite) free(Paintbrush_sprite);
// On libère les différents écrans virtuels et brosse: // On libère les différents écrans virtuels et brosse:
free(Brush); if(Brush) free(Brush);
Set_number_of_backups(0); Set_number_of_backups(0);
free(Spare_screen); if(Spare_screen) free(Spare_screen);
free(Main_screen); if(Main_screen) free(Main_screen);
// Free the skin (Gui graphics) data
if (Gfx)
{
free(Gfx);
Gfx=NULL;
}
// On prend bien soin de passer dans le répertoire initial: // On prend bien soin de passer dans le répertoire initial:
if (chdir(Initial_directory)!=-1) if (chdir(Initial_directory)!=-1)
{ {
@ -711,9 +736,9 @@ int main(int argc,char * argv[])
int phoenix2_found=0; int phoenix2_found=0;
char phoenix_filename1[MAX_PATH_CHARACTERS]; char phoenix_filename1[MAX_PATH_CHARACTERS];
char phoenix_filename2[MAX_PATH_CHARACTERS]; char phoenix_filename2[MAX_PATH_CHARACTERS];
if(!Init_program(argc,argv)) if(!Init_program(argc,argv))
{ {
Program_shutdown();
return 0; return 0;
} }
@ -733,6 +758,7 @@ int main(int argc,char * argv[])
strcpy(Main_file_directory,Config_directory); strcpy(Main_file_directory,Config_directory);
strcpy(Main_filename,"phoenix2.img"); strcpy(Main_filename,"phoenix2.img");
chdir(Main_file_directory); chdir(Main_file_directory);
Button_Reload(); Button_Reload();
Main_image_is_modified=1; Main_image_is_modified=1;
Warning_message("Spare page recovered"); Warning_message("Spare page recovered");
@ -756,7 +782,6 @@ int main(int argc,char * argv[])
{ {
if (Config.Opening_message && (!File_in_command_line)) if (Config.Opening_message && (!File_in_command_line))
Button_Message_initial(); Button_Message_initial();
free(GFX_logo_grafx2); // Pas encore utilisé dans le About
if (File_in_command_line) if (File_in_command_line)
{ {

1006
misc.c

File diff suppressed because it is too large Load Diff

301
misc.h
View File

@ -1,150 +1,151 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file misc.h ///@file misc.h
/// Miscellanous unsorted functions. /// Miscellanous unsorted functions.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width); void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width);
void Remap_general_lowlevel(byte * conversion_table,byte * buffer,short width,short height,short buffer_width); void Remap_general_lowlevel(byte * conversion_table,byte * buffer,short width,short height,short buffer_width);
void Scroll_picture(short x_offset,short y_offset); void Scroll_picture(short x_offset,short y_offset);
void Wait_end_of_click(void); void Wait_end_of_click(void);
void Set_color(byte color, byte red, byte green, byte blue); void Set_color(byte color, byte red, byte green, byte blue);
void Set_palette(T_Palette palette); void Set_palette(T_Palette palette);
void Palette_256_to_64(T_Palette palette); void Palette_256_to_64(T_Palette palette);
void Palette_64_to_256(T_Palette palette); void Palette_64_to_256(T_Palette palette);
void Hide_current_image(byte color); void Hide_current_image(byte color);
void Hide_current_image_with_stencil(byte color, byte * stencil); void Hide_current_image_with_stencil(byte color, byte * stencil);
void Slider_timer(byte speed); void Slider_timer(byte speed);
dword Round_div(dword numerator,dword divisor); dword Round_div(dword numerator,dword divisor);
word Count_used_colors(dword * usage); word Count_used_colors(dword * usage);
word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height); word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height);
void Pixel_in_current_screen (word x,word y,byte color); word Count_used_colors_screen_area(dword* usage, word start_x, word start_y, word width, word height);
void Pixel_in_brush (word x,word y,byte color); void Pixel_in_current_screen (word x,word y,byte color);
byte Read_pixel_from_current_screen (word x,word y); void Pixel_in_brush (word x,word y,byte color);
byte Read_pixel_from_spare_screen(word x,word y); byte Read_pixel_from_current_screen (word x,word y);
byte Read_pixel_from_backup_screen (word x,word y); byte Read_pixel_from_spare_screen(word x,word y);
byte Read_pixel_from_feedback_screen (word x,word y); byte Read_pixel_from_backup_screen (word x,word y);
byte Read_pixel_from_brush (word x,word y); byte Read_pixel_from_feedback_screen (word x,word y);
byte Read_pixel_from_brush (word x,word y);
void Ellipse_compute_limites(short horizontal_radius,short vertical_radius);
// Calcule les valeurs suivantes en fonction des deux paramètres: void Ellipse_compute_limites(short horizontal_radius,short vertical_radius);
// // Calcule les valeurs suivantes en fonction des deux paramètres:
// Ellipse_vertical_radius_squared //
// Ellipse_horizontal_radius_squared // Ellipse_vertical_radius_squared
// Ellipse_Limit_High // Ellipse_horizontal_radius_squared
// Ellipse_Limit_Low // Ellipse_Limit_High
// Ellipse_Limit_Low
byte Pixel_in_ellipse(void);
// Indique si le pixel se trouvant à Ellipse_cursor_X pixels byte Pixel_in_ellipse(void);
// (Ellipse_cursor_X>0 = à droite, Ellipse_cursor_X<0 = à gauche) et à // Indique si le pixel se trouvant à Ellipse_cursor_X pixels
// Ellipse_cursor_Y pixels (Ellipse_cursor_Y>0 = en bas, // (Ellipse_cursor_X>0 = à droite, Ellipse_cursor_X<0 = à gauche) et à
// Ellipse_cursor_Y<0 = en haut) du centre se trouve dans l'ellipse en // Ellipse_cursor_Y pixels (Ellipse_cursor_Y>0 = en bas,
// cours. // Ellipse_cursor_Y<0 = en haut) du centre se trouve dans l'ellipse en
// cours.
byte Pixel_in_circle(void);
// Indique si le pixel se trouvant à Circle_cursor_X pixels byte Pixel_in_circle(void);
// (Circle_cursor_X>0 = à droite, Circle_cursor_X<0 = à gauche) et à // Indique si le pixel se trouvant à Circle_cursor_X pixels
// Circle_cursor_Y pixels (Circle_cursor_Y>0 = en bas, // (Circle_cursor_X>0 = à droite, Circle_cursor_X<0 = à gauche) et à
// Circle_cursor_Y<0 = en haut) du centre se trouve dans le cercle en // Circle_cursor_Y pixels (Circle_cursor_Y>0 = en bas,
// cours. // Circle_cursor_Y<0 = en haut) du centre se trouve dans le cercle en
// cours.
// Gestion du chrono dans les fileselects
void Init_chrono(dword delay); // Gestion du chrono dans les fileselects
void Check_timer(void); void Init_chrono(dword delay);
void Check_timer(void);
void Replace_a_color(byte old_color, byte New_color);
void Replace_colors_within_limits(byte * replace_table); void Replace_a_color(byte old_color, byte New_color);
void Replace_colors_within_limits(byte * replace_table);
byte Effect_interpolated_colorize (word x,word y,byte color);
byte Effect_additive_colorize (word x,word y,byte color); byte Effect_interpolated_colorize (word x,word y,byte color);
byte Effect_substractive_colorize(word x,word y,byte color); byte Effect_additive_colorize (word x,word y,byte color);
byte Effect_sieve(word x,word y); byte Effect_substractive_colorize(word x,word y,byte color);
byte Effect_sieve(word x,word y);
///
/// Inverts a pixel buffer, according to a horizontal axis. ///
/// @param src Pointer to the pixel buffer to process. /// Inverts a pixel buffer, according to a horizontal axis.
/// @param width Width of the buffer. /// @param src Pointer to the pixel buffer to process.
/// @param height Height of the buffer. /// @param width Width of the buffer.
void Flip_Y_lowlevel(byte *src, short width, short height); /// @param height Height of the buffer.
void Flip_Y_lowlevel(byte *src, short width, short height);
///
/// Inverts a pixel buffer, according to a vertical axis. ///
/// @param src Pointer to the pixel buffer to process. /// Inverts a pixel buffer, according to a vertical axis.
/// @param width Width of the buffer. /// @param src Pointer to the pixel buffer to process.
/// @param height Height of the buffer. /// @param width Width of the buffer.
void Flip_X_lowlevel(byte *src, short width, short height); /// @param height Height of the buffer.
/// void Flip_X_lowlevel(byte *src, short width, short height);
/// Rotate a pixel buffer by 90 degrees, clockwise. ///
/// @param source Source pixel buffer. /// Rotate a pixel buffer by 90 degrees, clockwise.
/// @param dest Destination pixel buffer. /// @param source Source pixel buffer.
/// @param width Width of the original buffer (height of the destination one). /// @param dest Destination pixel buffer.
/// @param height Height of the original buffer (width of the destination one). /// @param width Width of the original buffer (height of the destination one).
void Rotate_90_deg_lowlevel(byte * source, byte * dest, short width, short height); /// @param height Height of the original buffer (width of the destination one).
/// void Rotate_90_deg_lowlevel(byte * source, byte * dest, short width, short height);
/// Rotate a pixel buffer by 90 degrees, counter-clockwise. ///
/// @param source Source pixel buffer. /// Rotate a pixel buffer by 90 degrees, counter-clockwise.
/// @param dest Destination pixel buffer. /// @param source Source pixel buffer.
/// @param width Width of the original buffer (height of the destination one). /// @param dest Destination pixel buffer.
/// @param height Height of the original buffer (width of the destination one). /// @param width Width of the original buffer (height of the destination one).
void Rotate_270_deg_lowlevel(byte * source, byte * dest, short width, short height); /// @param height Height of the original buffer (width of the destination one).
/// void Rotate_270_deg_lowlevel(byte * source, byte * dest, short width, short height);
/// Rotate a pixel buffer by 180 degrees. ///
/// @param src The pixel buffer (source and destination). /// Rotate a pixel buffer by 180 degrees.
/// @param width Width of the buffer. /// @param src The pixel buffer (source and destination).
/// @param height Height of the buffer. /// @param width Width of the buffer.
void Rotate_180_deg_lowlevel(byte *src, short width, short height); /// @param height Height of the buffer.
void Rotate_180_deg_lowlevel(byte *src, short width, short height);
///
/// Copies an image to another, rescaling it and optionally flipping it. ///
/// @param src_buffer Original image (address of first byte) /// Copies an image to another, rescaling it and optionally flipping it.
/// @param src_width Original image's width in pixels /// @param src_buffer Original image (address of first byte)
/// @param src_height Original image's height in pixels /// @param src_width Original image's width in pixels
/// @param dst_buffer Destination image (address of first byte) /// @param src_height Original image's height in pixels
/// @param dst_width Destination image's width in pixels /// @param dst_buffer Destination image (address of first byte)
/// @param dst_height Destination image's height in pixels /// @param dst_width Destination image's width in pixels
/// @param x_flipped Boolean, true to flip the image horizontally /// @param dst_height Destination image's height in pixels
/// @param y_flipped Boolean, true to flip the image vertically /// @param x_flipped Boolean, true to flip the image horizontally
void Rescale(byte *src_buffer, short src_width, short src_height, byte *dst_buffer, short dst_width, short dst_height, short x_flipped, short y_flipped); /// @param y_flipped Boolean, true to flip the image vertically
void Rescale(byte *src_buffer, short src_width, short src_height, byte *dst_buffer, short dst_width, short dst_height, short x_flipped, short y_flipped);
void Zoom_a_line(byte * original_line,byte * zoomed_line,word factor,word width);
void Copy_part_of_image_to_another(byte * source,word source_x,word source_y,word width,word height,word source_width,byte * dest,word dest_x,word dest_y,word destination_width); void Zoom_a_line(byte * original_line,byte * zoomed_line,word factor,word width);
void Copy_part_of_image_to_another(byte * source,word source_x,word source_y,word width,word height,word source_width,byte * dest,word dest_x,word dest_y,word destination_width);
// -- Gestion du chrono --
byte Timer_state; // State du chrono: 0=Attente d'un Xème de seconde // -- Gestion du chrono --
// 1=Il faut afficher la preview byte Timer_state; // State du chrono: 0=Attente d'un Xème de seconde
// 2=Plus de chrono à gerer pour l'instant // 1=Il faut afficher la preview
dword Timer_delay; // Nombre de 18.2ème de secondes demandés // 2=Plus de chrono à gerer pour l'instant
dword Timer_start; // Heure de départ du chrono dword Timer_delay; // Nombre de 18.2ème de secondes demandés
byte New_preview_is_needed; // Booléen "Il faut relancer le chrono de preview" dword Timer_start; // Heure de départ du chrono
byte New_preview_is_needed; // Booléen "Il faut relancer le chrono de preview"
unsigned long Memory_free(void);
unsigned long Memory_free(void);
void Num2str(dword number,char * str,byte nb_char);
void Num2str(dword number,char * str,byte nb_char);
short Round(float value);
short Round_div_max(short numerator,short divisor); short Round(float value);
short Round_div_max(short numerator,short divisor);
int Min(int a,int b);
int Max(int a,int b); int Min(int a,int b);
int Max(int a,int b);
char* Mode_label(int mode);
int Convert_videomode_arg(const char *argument); char* Mode_label(int mode);
int Convert_videomode_arg(const char *argument);

File diff suppressed because it is too large Load Diff

View File

@ -1,47 +1,47 @@
/* mountlist.h -- declarations for list of mounted file systems /* mountlist.h -- declarations for list of mounted file systems
Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file mountlist.h ///@file mountlist.h
/// A function to enumerate the mounting points in the filesystem. /// A function to enumerate the mounting points in the filesystem.
/// Used to display them in fileselectors. /// Used to display them in fileselectors.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef MOUNTLIST_H_ #ifndef MOUNTLIST_H_
# define MOUNTLIST_H_ # define MOUNTLIST_H_
# include <stdbool.h> # include <stdbool.h>
# include <sys/types.h> # include <sys/types.h>
/* A mount table entry. */ /* A mount table entry. */
struct mount_entry struct mount_entry
{ {
char *me_devname; /* Device node name, including "/dev/". */ char *me_devname; /* Device node name, including "/dev/". */
char *me_mountdir; /* Mount point directory name. */ char *me_mountdir; /* Mount point directory name. */
char *me_type; /* "nfs", "4.2", etc. */ char *me_type; /* "nfs", "4.2", etc. */
dev_t me_dev; /* Device number of me_mountdir. */ dev_t me_dev; /* Device number of me_mountdir. */
unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */ unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */
unsigned int me_remote : 1; /* Nonzero for remote fileystems. */ unsigned int me_remote : 1; /* Nonzero for remote fileystems. */
unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */ unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */
struct mount_entry *me_next; struct mount_entry *me_next;
}; };
struct mount_entry *read_file_system_list (bool need_fs_type); struct mount_entry *read_file_system_list (bool need_fs_type);
#endif #endif

2510
op_c.c

File diff suppressed because it is too large Load Diff

428
op_c.h
View File

@ -1,213 +1,215 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file op_c.h ///@file op_c.h
/// Color reduction and color conversion (24b->8b, RGB<->HSL). /// Color reduction and color conversion (24b->8b, RGB<->HSL).
/// This is called op_c because half of the process was originally /// This is called op_c because half of the process was originally
/// coded in op_asm, in assembler. /// coded in op_asm, in assembler.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef _OP_C_H_ #ifndef _OP_C_H_
#define _OP_C_H_ #define _OP_C_H_
#include "struct.h" #include "struct.h"
//////////////////////////////////////////////// Définition des types de base //////////////////////////////////////////////// Définition des types de base
typedef T_Components * T_Bitmap24B; typedef T_Components * T_Bitmap24B;
typedef byte * T_Bitmap256; typedef byte * T_Bitmap256;
//////////////////////////////////////// Définition d'une table de conversion //////////////////////////////////////// Définition d'une table de conversion
typedef struct typedef struct
{ {
int nbb_r; // Nb de bits de précision sur les rouges int nbb_r; // Nb de bits de précision sur les rouges
int nbb_g; // Nb de bits de précision sur les verts int nbb_g; // Nb de bits de précision sur les verts
int nbb_b; // Nb de bits de précision sur les bleu int nbb_b; // Nb de bits de précision sur les bleu
int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r) int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r)
int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g) int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g)
int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b) int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b)
int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b) int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b)
int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b) int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b)
int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0) int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0)
int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r) int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r)
int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g) int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g)
int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b) int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b)
byte * table; byte * table;
} T_Conversion_table; } T_Conversion_table;
///////////////////////////////////////// Définition d'une table d'occurences ///////////////////////////////////////// Définition d'une table d'occurences
typedef struct typedef struct
{ {
int nbb_r; // Nb de bits de précision sur les rouges int nbb_r; // Nb de bits de précision sur les rouges
int nbb_g; // Nb de bits de précision sur les verts int nbb_g; // Nb de bits de précision sur les verts
int nbb_b; // Nb de bits de précision sur les bleu int nbb_b; // Nb de bits de précision sur les bleu
int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r) int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r)
int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g) int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g)
int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b) int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b)
int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b) int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b)
int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b) int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b)
int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0) int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0)
int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r) int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r)
int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g) int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g)
int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b) int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b)
int * table; int * table;
} T_Occurrence_table; } T_Occurrence_table;
///////////////////////////////////////// Définition d'un ensemble de couleur ///////////////////////////////////////// Définition d'un ensemble de couleur
typedef struct typedef struct S_Cluster
{ {
int occurences; // Nb total d'occurences des couleurs de l'ensemble int occurences; // Nb total d'occurences des couleurs de l'ensemble
// Grande couverture // Grande couverture
byte Rmin,Rmax; byte Rmin,Rmax;
byte Gmin,Vmax; byte Gmin,Vmax;
byte Bmin,Bmax; byte Bmin,Bmax;
// Couverture minimale // Couverture minimale
byte rmin,rmax; byte rmin,rmax;
byte vmin,vmax; byte vmin,vmax;
byte bmin,bmax; byte bmin,bmax;
byte plus_large; // Composante ayant la plus grande variation (0=red,1=green,2=blue) byte plus_large; // Composante ayant la plus grande variation (0=red,1=green,2=blue)
byte r,g,b; // color synthétisant l'ensemble byte r,g,b; // color synthétisant l'ensemble
byte h; // Chrominance byte h; // Chrominance
byte l; // Luminosité byte l; // Luminosité
} T_Cluster;
struct S_Cluster* next;
} T_Cluster;
//////////////////////////////////////// Définition d'un ensemble de clusters
typedef struct //////////////////////////////////////// Définition d'un ensemble de clusters
{
int nb; typedef struct
int nb_max; {
T_Cluster * clusters; int nb;
} T_Cluster_set; int nb_max;
T_Cluster * clusters;
} T_Cluster_set;
///////////////////////////////////////////////////// Définition d'un dégradé
typedef struct ///////////////////////////////////////////////////// Définition d'un dégradé
{
int nb_colors; // Nombre de couleurs dans le dégradé typedef struct
float min; // Chrominance minimale du dégradé {
float max; // Chrominance maximale du dégradé int nb_colors; // Nombre de couleurs dans le dégradé
float hue; // Chrominance moyenne du dégradé float min; // Chrominance minimale du dégradé
} T_Gradient; float max; // Chrominance maximale du dégradé
float hue; // Chrominance moyenne du dégradé
} T_Gradient;
///////////////////////////////////////// Définition d'un ensemble de dégradé
typedef struct ///////////////////////////////////////// Définition d'un ensemble de dégradé
{
int nb; // Nombre de dégradés dans l'ensemble typedef struct
int nb_max; // Nombre maximum de dégradés {
T_Gradient * gradients; // Les dégradés int nb; // Nombre de dégradés dans l'ensemble
} T_Gradient_set; int nb_max; // Nombre maximum de dégradés
T_Gradient * gradients; // Les dégradés
} T_Gradient_set;
/////////////////////////////////////////////////////////////////////////////
///////////////////////////// Méthodes de gestion des tables de conversion //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
///////////////////////////// Méthodes de gestion des tables de conversion //
T_Conversion_table * CT_new(int nbb_r,int nbb_g,int nbb_b); /////////////////////////////////////////////////////////////////////////////
void CT_delete(T_Conversion_table * t);
byte CT_get(T_Conversion_table * t,int r,int g,int b); T_Conversion_table * CT_new(int nbb_r,int nbb_g,int nbb_b);
void CT_set(T_Conversion_table * t,int r,int g,int b,byte i); void CT_delete(T_Conversion_table * t);
byte CT_get(T_Conversion_table * t,int r,int g,int b);
void RGB_to_HSL(int r, int g,int b, byte* h, byte*s, byte* l); void CT_set(T_Conversion_table * t,int r,int g,int b,byte i);
void HSL_to_RGB(byte h, byte s, byte l, byte* r, byte* g, byte* b);
void RGB_to_HSL(int r, int g,int b, byte* h, byte*s, byte* l);
void HSL_to_RGB(byte h, byte s, byte l, byte* r, byte* g, byte* b);
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Méthodes de gestion des tables d'occurence //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Méthodes de gestion des tables d'occurence //
void OT_init(T_Occurrence_table * t); /////////////////////////////////////////////////////////////////////////////
T_Occurrence_table * OT_new(int nbb_r,int nbb_g,int nbb_b);
void OT_delete(T_Occurrence_table * t); void OT_init(T_Occurrence_table * t);
int OT_get(T_Occurrence_table * t,int r,int g,int b); T_Occurrence_table * OT_new(int nbb_r,int nbb_g,int nbb_b);
void OT_inc(T_Occurrence_table * t,int r,int g,int b); void OT_delete(T_Occurrence_table * t);
void OT_count_occurrences(T_Occurrence_table * t,T_Bitmap24B image,int size); int OT_get(T_Occurrence_table * t,int r,int g,int b);
void OT_inc(T_Occurrence_table * t,int r,int g,int b);
void OT_count_occurrences(T_Occurrence_table * t,T_Bitmap24B image,int size);
/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// Méthodes de gestion des clusters //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// Méthodes de gestion des clusters //
void Cluster_analyser(T_Cluster * c,T_Occurrence_table * to); /////////////////////////////////////////////////////////////////////////////
void Cluster_split(T_Cluster * c,T_Cluster * c1,T_Cluster * c2,int hue,T_Occurrence_table * to);
void Cluster_compute_hue(T_Cluster * c,T_Occurrence_table * to); void Cluster_pack(T_Cluster * c,T_Occurrence_table * to);
void Cluster_split(T_Cluster * c,T_Cluster * c1,T_Cluster * c2,int hue,T_Occurrence_table * to);
void Cluster_compute_hue(T_Cluster * c,T_Occurrence_table * to);
/////////////////////////////////////////////////////////////////////////////
//////////////////////////// Méthodes de gestion des ensembles de clusters //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//////////////////////////// Méthodes de gestion des ensembles de clusters //
void CS_Init(T_Cluster_set * cs,T_Occurrence_table * to); /////////////////////////////////////////////////////////////////////////////
T_Cluster_set * CS_New(int nbmax,T_Occurrence_table * to);
void CS_Delete(T_Cluster_set * cs); void CS_Init(T_Cluster_set * cs,T_Occurrence_table * to);
void CS_Get(T_Cluster_set * cs,T_Cluster * c); T_Cluster_set * CS_New(int nbmax,T_Occurrence_table * to);
void CS_Set(T_Cluster_set * cs,T_Cluster * c); void CS_Delete(T_Cluster_set * cs);
void CS_Generate(T_Cluster_set * cs,T_Occurrence_table * to); void CS_Get(T_Cluster_set * cs,T_Cluster * c);
void CS_Compute_colors(T_Cluster_set * cs,T_Occurrence_table * to); void CS_Set(T_Cluster_set * cs,T_Cluster * c);
void CS_Generate_color_table_and_palette(T_Cluster_set * cs,T_Conversion_table * tc,T_Components * palette); void CS_Generate(T_Cluster_set * cs,T_Occurrence_table * to);
void CS_Compute_colors(T_Cluster_set * cs,T_Occurrence_table * to);
///////////////////////////////////////////////////////////////////////////// void CS_Generate_color_table_and_palette(T_Cluster_set * cs,T_Conversion_table * tc,T_Components * palette);
//////////////////////////// Méthodes de gestion des ensembles de dégradés //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//////////////////////////// Méthodes de gestion des ensembles de dégradés //
void GS_Init(T_Gradient_set * ds,T_Cluster_set * cs); /////////////////////////////////////////////////////////////////////////////
T_Gradient_set * GS_New(T_Cluster_set * cs);
void GS_Delete(T_Gradient_set * ds); void GS_Init(T_Gradient_set * ds,T_Cluster_set * cs);
void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs); T_Gradient_set * GS_New(T_Cluster_set * cs);
void GS_Delete(T_Gradient_set * ds);
void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs);
// Convertie avec le plus de précision possible une image 24b en 256c
// Renvoie s'il y a eu une erreur ou pas..
int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette); // Convertie avec le plus de précision possible une image 24b en 256c
// Renvoie s'il y a eu une erreur ou pas..
int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette);
#endif
#endif

10285
operatio.c

File diff suppressed because it is too large Load Diff

View File

@ -1,219 +1,219 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file operatio.h ///@file operatio.h
/// Code for the operations, ie all drawing tools. /// Code for the operations, ie all drawing tools.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Do some housekeeping before starting work on a operation. /// Do some housekeeping before starting work on a operation.
void Start_operation_stack(word new_operation); void Start_operation_stack(word new_operation);
/// Put a value on ::Operation_stack /// Put a value on ::Operation_stack
void Operation_push(short value); void Operation_push(short value);
/// Take a value off ::Operation_stack /// Take a value off ::Operation_stack
void Operation_pop(short * value); void Operation_pop(short * value);
//////////////////////////////////////////////////// OPERATION_CONTINUOUS_DRAW //////////////////////////////////////////////////// OPERATION_CONTINUOUS_DRAW
void Freehand_mode1_1_0(void); void Freehand_mode1_1_0(void);
void Freehand_mode1_1_2(void); void Freehand_mode1_1_2(void);
void Freehand_mode12_0_2(void); void Freehand_mode12_0_2(void);
void Freehand_mode1_2_0(void); void Freehand_mode1_2_0(void);
void Freehand_mode1_2_2(void); void Freehand_mode1_2_2(void);
///////////////////////////////////////////////// OPERATION_DISCONTINUOUS_DRAW ///////////////////////////////////////////////// OPERATION_DISCONTINUOUS_DRAW
void Freehand_mode2_1_0(void); void Freehand_mode2_1_0(void);
void Freehand_mode2_1_2(void); void Freehand_mode2_1_2(void);
void Freehand_mode2_2_0(void); void Freehand_mode2_2_0(void);
void Freehand_mode2_2_2(void); void Freehand_mode2_2_2(void);
////////////////////////////////////////////////////// OPERATION_POINT_DRAW ////////////////////////////////////////////////////// OPERATION_POINT_DRAW
void Freehand_mode3_1_0(void); void Freehand_mode3_1_0(void);
void Freehand_Mode3_2_0(void); void Freehand_Mode3_2_0(void);
void Freehand_mode3_0_1(void); void Freehand_mode3_0_1(void);
///////////////////////////////////////////////////////////// OPERATION_LINE ///////////////////////////////////////////////////////////// OPERATION_LINE
void Line_12_0(void); void Line_12_0(void);
void Line_12_5(void); void Line_12_5(void);
void Line_0_5(void); void Line_0_5(void);
///////////////////////////////////////////////////////////// OPERATION_MAGNIFY ///////////////////////////////////////////////////////////// OPERATION_MAGNIFY
void Magnifier_12_0(void); void Magnifier_12_0(void);
/////////////////////////////////////////////////// OPERATION_RECTANGLE_????? /////////////////////////////////////////////////// OPERATION_RECTANGLE_?????
void Rectangle_12_0(void); void Rectangle_12_0(void);
void Rectangle_12_5(void); void Rectangle_12_5(void);
void Empty_rectangle_0_5(void); void Empty_rectangle_0_5(void);
void Filled_rectangle_0_5(void); void Filled_rectangle_0_5(void);
////////////////////////////////////////////////////// OPERATION_CERCLE_????? ////////////////////////////////////////////////////// OPERATION_CERCLE_?????
void Circle_12_0(void); void Circle_12_0(void);
void Circle_12_5(void); void Circle_12_5(void);
void Empty_circle_0_5(void); void Empty_circle_0_5(void);
void Filled_circle_0_5(void); void Filled_circle_0_5(void);
///////////////////////////////////////////////////// OPERATION_ELLIPSE_????? ///////////////////////////////////////////////////// OPERATION_ELLIPSE_?????
void Ellipse_12_0(void); void Ellipse_12_0(void);
void Ellipse_12_5(void); void Ellipse_12_5(void);
void Empty_ellipse_0_5(void); void Empty_ellipse_0_5(void);
void Filled_ellipse_0_5(void); void Filled_ellipse_0_5(void);
////////////////////////////////////////////////////// OPERATION_GRAB_BRUSH ////////////////////////////////////////////////////// OPERATION_GRAB_BRUSH
void Brush_12_0(void); void Brush_12_0(void);
void Brush_12_5(void); void Brush_12_5(void);
void Brush_0_5(void); void Brush_0_5(void);
///////////////////////////////////////////////////// OPERATION_STRETCH_BRUSH ///////////////////////////////////////////////////// OPERATION_STRETCH_BRUSH
void Stretch_brush_12_0(void); void Stretch_brush_12_0(void);
void Stretch_brush_1_7(void); void Stretch_brush_1_7(void);
void Stretch_brush_0_7(void); void Stretch_brush_0_7(void);
void Stretch_brush_2_7(void); void Stretch_brush_2_7(void);
//////////////////////////////////////////////////// OPERATION_ROTATE_BRUSH //////////////////////////////////////////////////// OPERATION_ROTATE_BRUSH
void Rotate_brush_12_0(void); void Rotate_brush_12_0(void);
void Rotate_brush_1_5(void); void Rotate_brush_1_5(void);
void Rotate_brush_0_5(void); void Rotate_brush_0_5(void);
void Rotate_brush_2_5(void); void Rotate_brush_2_5(void);
///////////////////////////////////////////////////// OPERATION_DISTORT_BRUSH ///////////////////////////////////////////////////// OPERATION_DISTORT_BRUSH
void Distort_brush_0_0(void); void Distort_brush_0_0(void);
void Distort_brush_1_0(void); void Distort_brush_1_0(void);
void Distort_brush_2_0(void); void Distort_brush_2_0(void);
void Distort_brush_1_8(void); void Distort_brush_1_8(void);
void Distort_brush_2_8(void); void Distort_brush_2_8(void);
void Distort_brush_1_9(void); void Distort_brush_1_9(void);
void Distort_brush_0_9(void); void Distort_brush_0_9(void);
//////////////////////////////////////////////////////// OPERATION_POLYBRUSH //////////////////////////////////////////////////////// OPERATION_POLYBRUSH
void Polybrush_12_8(void); void Polybrush_12_8(void);
////////////////////////////////////////////////////////////// OPERATION_FILL ////////////////////////////////////////////////////////////// OPERATION_FILL
void Fill_1_0(void); void Fill_1_0(void);
void Fill_2_0(void); void Fill_2_0(void);
///////////////////////////////////////////////////////// OPERATION_REPLACE ///////////////////////////////////////////////////////// OPERATION_REPLACE
void Replace_1_0(void); void Replace_1_0(void);
void Replace_2_0(void); void Replace_2_0(void);
/////////////////////////////////////////////////////////// OPERATION_COLORPICK /////////////////////////////////////////////////////////// OPERATION_COLORPICK
void Pipette_0_0(void); void Pipette_0_0(void);
void Colorpicker_12_0(void); void Colorpicker_12_0(void);
void Colorpicker_1_1(void); void Colorpicker_1_1(void);
void Colorpicker_2_1(void); void Colorpicker_2_1(void);
void Colorpicker_0_1(void); void Colorpicker_0_1(void);
/////////////////////////////////////////////////////////// OPERATION_K_LIGNE /////////////////////////////////////////////////////////// OPERATION_K_LIGNE
void K_line_12_0(void); void K_line_12_0(void);
void K_line_12_6(void); void K_line_12_6(void);
void K_line_0_6(void); void K_line_0_6(void);
void K_line_12_7(void); void K_line_12_7(void);
/////////////////////////////////////////////////// OPERATION_COURBE_?_POINTS /////////////////////////////////////////////////// OPERATION_COURBE_?_POINTS
void Curve_34_points_1_0(void); void Curve_34_points_1_0(void);
void Curve_34_points_2_0(void); void Curve_34_points_2_0(void);
void Curve_34_points_1_5(void); void Curve_34_points_1_5(void);
void Curve_34_points_2_5(void); void Curve_34_points_2_5(void);
void Curve_4_points_0_5(void); void Curve_4_points_0_5(void);
void Curve_4_points_1_9(void); void Curve_4_points_1_9(void);
void Curve_4_points_2_9(void); void Curve_4_points_2_9(void);
void Curve_3_points_0_5(void); void Curve_3_points_0_5(void);
void Curve_3_points_0_11(void); void Curve_3_points_0_11(void);
void Curve_3_points_12_11(void); void Curve_3_points_12_11(void);
///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH ///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH
void Airbrush_1_0(void); void Airbrush_1_0(void);
void Airbrush_2_0(void); void Airbrush_2_0(void);
void Airbrush_12_2(void); void Airbrush_12_2(void);
void Airbrush_0_2(void); void Airbrush_0_2(void);
//////////////////////////////////////////////////////////// OPERATION_*POLY* //////////////////////////////////////////////////////////// OPERATION_*POLY*
void Polygon_12_0(void); void Polygon_12_0(void);
void Polygon_12_9(void); void Polygon_12_9(void);
void Polyfill_12_0(void); void Polyfill_12_0(void);
void Polyfill_0_8(void); void Polyfill_0_8(void);
void Polyfill_12_8(void); void Polyfill_12_8(void);
void Polyfill_12_9(void); void Polyfill_12_9(void);
void Polyform_12_0(void); void Polyform_12_0(void);
void Polyform_12_8(void); void Polyform_12_8(void);
void Polyform_0_8(void); void Polyform_0_8(void);
void Filled_polyform_12_0(void); void Filled_polyform_12_0(void);
void Filled_polyform_12_8(void); void Filled_polyform_12_8(void);
void Filled_polyform_0_8(void); void Filled_polyform_0_8(void);
void Filled_contour_0_8(void); void Filled_contour_0_8(void);
//////////////////////////////////////////////////////////// OPERATION_SCROLL //////////////////////////////////////////////////////////// OPERATION_SCROLL
void Scroll_12_0(void); void Scroll_12_0(void);
void Scroll_12_4(void); void Scroll_12_4(void);
void Scroll_0_4(void); void Scroll_0_4(void);
//////////////////////////////////////////////////// OPERATION_GRAD_CIRCLE //////////////////////////////////////////////////// OPERATION_GRAD_CIRCLE
void Grad_circle_12_0(void); void Grad_circle_12_0(void);
void Grad_circle_12_6(void); void Grad_circle_12_6(void);
void Grad_circle_0_6(void); void Grad_circle_0_6(void);
void Grad_circle_12_8(void); void Grad_circle_12_8(void);
void Grad_circle_or_ellipse_0_8(void); void Grad_circle_or_ellipse_0_8(void);
////////////////////////////////////////////////// OPERATION_GRAD_ELLIPSE ////////////////////////////////////////////////// OPERATION_GRAD_ELLIPSE
void Grad_ellipse_12_0(void); void Grad_ellipse_12_0(void);
void Grad_ellipse_12_6(void); void Grad_ellipse_12_6(void);
void Grad_ellipse_0_6(void); void Grad_ellipse_0_6(void);
void Grad_ellipse_12_8(void); void Grad_ellipse_12_8(void);
///////////////////////////////////////////////// OPERATION_GRAD_RECTANGLE ///////////////////////////////////////////////// OPERATION_GRAD_RECTANGLE
void Grad_rectangle_12_0(void); void Grad_rectangle_12_0(void);
void Grad_rectangle_12_5(void); void Grad_rectangle_12_5(void);
void Grad_rectangle_0_5(void); void Grad_rectangle_0_5(void);
void Grad_rectangle_0_7(void); void Grad_rectangle_0_7(void);
void Grad_rectangle_12_7(void); void Grad_rectangle_12_7(void);
void Grad_rectangle_12_9(void); void Grad_rectangle_12_9(void);
void Grad_rectangle_0_9(void); void Grad_rectangle_0_9(void);
/////////////////////////////////////////////////// OPERATION_CENTERED_LINES /////////////////////////////////////////////////// OPERATION_CENTERED_LINES
void Centered_lines_12_0(void); void Centered_lines_12_0(void);
void Centered_lines_12_3(void); void Centered_lines_12_3(void);
void Centered_lines_0_3(void); void Centered_lines_0_3(void);
void Centered_lines_12_7(void); void Centered_lines_12_7(void);
void Centered_lines_0_7(void); void Centered_lines_0_7(void);

122
pages.c
View File

@ -49,21 +49,6 @@ void Init_page(T_Page * page)
page->File_directory[0]='\0'; page->File_directory[0]='\0';
page->Filename[0]='\0'; page->Filename[0]='\0';
page->File_format=DEFAULT_FILEFORMAT; page->File_format=DEFAULT_FILEFORMAT;
/*
page->X_offset=0;
page->Y_offset=0;
page->old_offset_x=0;
page->old_offset_y=0;
page->Split=0;
page->X_zoom=0;
page->Separator_proportion=INITIAL_SEPARATOR_PROPORTION;
page->Main_magnifier_mode=0;
page->Main_magnifier_factor=DEFAULT_ZOOM_FACTOR;
page->Main_magnifier_height=0;
page->Main_magnifier_width=0;
page->Main_magnifier_offset_X=0;
page->Main_magnifier_offset_Y=0;
*/
} }
} }
@ -86,35 +71,7 @@ void Download_infos_page_main(T_Page * page)
strcpy(Main_file_directory,page->File_directory); strcpy(Main_file_directory,page->File_directory);
strcpy(Main_filename,page->Filename); strcpy(Main_filename,page->Filename);
Main_fileformat=page->File_format; Main_fileformat=page->File_format;
/*
Main_offset_X=page->X_offset;
Main_offset_Y=page->Y_offset;
// On corrige les décalages en fonction de la dimension de l'écran
if ( (Main_offset_X>0) &&
(Main_offset_X+Screen_width>Main_image_width) )
Main_offset_X=Max(0,Main_image_width-Screen_width);
if ( (Main_offset_Y>0) &&
(Main_offset_Y+Menu_Y>Main_image_height) )
Main_offset_Y=Max(0,Main_image_height-Menu_Y);
Old_main_offset_X=page->old_offset_x;
Old_main_offset_Y=page->old_offset_y;
Main_separator_position=page->Split;
Main_X_zoom=page->X_zoom;
Main_separator_proportion=page->Separator_proportion;
Main_magnifier_mode=page->Main_magnifier_mode;
Main_magnifier_factor=page->Main_magnifier_factor;
Main_magnifier_height=page->Main_magnifier_height;
Main_magnifier_width=page->Main_magnifier_width;
Main_magnifier_offset_X=page->Main_magnifier_offset_X;
Main_magnifier_offset_Y=page->Main_magnifier_offset_Y;
// Comme le facteur de zoom a des chances d'avoir changé, on appelle
// "Change_magnifier_factor".
for (factor_index=0; ZOOM_FACTOR[factor_index]!=Main_magnifier_factor; factor_index++);
Change_magnifier_factor(factor_index);
*/
if (size_is_modified) if (size_is_modified)
{ {
Main_magnifier_mode=0; Main_magnifier_mode=0;
@ -140,21 +97,6 @@ void Upload_infos_page_main(T_Page * page)
strcpy(page->File_directory,Main_file_directory); strcpy(page->File_directory,Main_file_directory);
strcpy(page->Filename,Main_filename); strcpy(page->Filename,Main_filename);
page->File_format=Main_fileformat; page->File_format=Main_fileformat;
/*
page->X_offset=Main_offset_X;
page->Y_offset=Main_offset_Y;
page->old_offset_x=Old_main_offset_X;
page->old_offset_x=Old_main_offset_Y;
page->Split=Main_separator_position;
page->X_zoom=Main_X_zoom;
page->Separator_proportion=Main_separator_proportion;
page->Main_magnifier_mode=Main_magnifier_mode;
page->Main_magnifier_factor=Main_magnifier_factor;
page->Main_magnifier_height=Main_magnifier_height;
page->Main_magnifier_width=Main_magnifier_width;
page->Main_magnifier_offset_X=Main_magnifier_offset_X;
page->Main_magnifier_offset_Y=Main_magnifier_offset_Y;
*/
} }
} }
@ -170,21 +112,6 @@ void Download_infos_page_spare(T_Page * page)
strcpy(Spare_file_directory,page->File_directory); strcpy(Spare_file_directory,page->File_directory);
strcpy(Spare_filename,page->Filename); strcpy(Spare_filename,page->Filename);
Spare_fileformat=page->File_format; Spare_fileformat=page->File_format;
/*
Spare_offset_X=page->X_offset;
Spare_offset_Y=page->Y_offset;
Old_spare_offset_X=page->old_offset_x;
Old_spare_offset_Y=page->old_offset_y;
Spare_separator_position=page->Split;
Spare_X_zoom=page->X_zoom;
Spare_separator_proportion=page->Separator_proportion;
Spare_magnifier_mode=page->Main_magnifier_mode;
Spare_magnifier_factor=page->Main_magnifier_factor;
Spare_magnifier_height=page->Main_magnifier_height;
Spare_magnifier_width=page->Main_magnifier_width;
Spare_magnifier_offset_X=page->Main_magnifier_offset_X;
Spare_magnifier_offset_Y=page->Main_magnifier_offset_Y;
*/
} }
} }
@ -200,21 +127,6 @@ void Upload_infos_page_spare(T_Page * page)
strcpy(page->File_directory,Spare_file_directory); strcpy(page->File_directory,Spare_file_directory);
strcpy(page->Filename,Spare_filename); strcpy(page->Filename,Spare_filename);
page->File_format=Spare_fileformat; page->File_format=Spare_fileformat;
/*
page->X_offset=Spare_offset_X;
page->Y_offset=Spare_offset_Y;
page->old_offset_x=Old_spare_offset_X;
page->old_offset_y=Old_spare_offset_Y;
page->Split=Spare_separator_position;
page->X_zoom=Spare_X_zoom;
page->Separator_proportion=Spare_separator_proportion;
page->Main_magnifier_mode=Spare_magnifier_mode;
page->Main_magnifier_factor=Spare_magnifier_factor;
page->Main_magnifier_height=Spare_magnifier_height;
page->Main_magnifier_width=Spare_magnifier_width;
page->Main_magnifier_offset_X=Spare_magnifier_offset_X;
page->Main_magnifier_offset_Y=Spare_magnifier_offset_Y;
*/
} }
} }
@ -326,14 +238,14 @@ void Backward_in_list_of_pages(T_List_of_pages * list)
{ {
// Cette fonction fait l'équivalent d'un "Undo" dans la liste de pages. // Cette fonction fait l'équivalent d'un "Undo" dans la liste de pages.
// Elle effectue une sorte de ROL (Rotation Left) sur la liste: // Elle effectue une sorte de ROL (Rotation Left) sur la liste:
// ÉÍËÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍ» | // +---+-+-+-+-+-+-+-+-+-+ |
// º0º1³2³3³4³5³6³7³8³9³Aº | // ¦0¦1¦2¦3¦4¦5¦6¦7¦8¦9¦A¦ |
// ÈÍÊÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏͼ | 0=page courante // +---+-+-+-+-+-+-+-+-+-+ | 0=page courante
// ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ |_ A=page la plus ancienne // ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ |_ A=page la plus ancienne
// v v v v v v v v v v v | 1=Dernière page (1er backup) // v v v v v v v v v v v | 1=DerniÞre page (1er backup)
// ÉÍËÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍ» | // +---+-+-+-+-+-+-+-+-+-+ |
// º1º2³3³4³5³6³7³8³9³A³0º | // ¦1¦2¦3¦4¦5¦6¦7¦8¦9¦A¦0¦ |
// ÈÍÊÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏͼ | // +---+-+-+-+-+-+-+-+-+-+ |
// Pour simuler un véritable Undo, l'appelant doit mettre la structure // Pour simuler un véritable Undo, l'appelant doit mettre la structure
// de page courante à jour avant l'appel, puis en réextraire les infos en // de page courante à jour avant l'appel, puis en réextraire les infos en
@ -369,14 +281,14 @@ void Advance_in_list_of_pages(T_List_of_pages * list)
{ {
// Cette fonction fait l'équivalent d'un "Redo" dans la liste de pages. // Cette fonction fait l'équivalent d'un "Redo" dans la liste de pages.
// Elle effectue une sorte de ROR (Rotation Right) sur la liste: // Elle effectue une sorte de ROR (Rotation Right) sur la liste:
// ÉÍËÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍ» | // +-+-+-+-+-+-+-+-+-+-+-+ |
// º0º1³2³3³4³5³6³7³8³9³Aº | // |0|1|2|3|4|5|6|7|8|9|A| |
// ÈÍÊÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏͼ | 0=page courante // +-+-+-+-+-+-+-+-+-+-+-+ | 0=page courante
// ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ |_ A=page la plus ancienne // | | | | | | | | | | | |_ A=page la plus ancienne
// v v v v v v v v v v v | 1=Dernière page (1er backup) // v v v v v v v v v v v | 1=Dernière page (1er backup)
// ÉÍËÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍÑÍ» | // +-+-+-+-+-+-+-+-+-+-+-+ |
// ºAº0³1³2³3³4³5³6³7³8³9º | // |A|0|1|2|3|4|5|6|7|8|9| |
// ÈÍÊÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏÍÏͼ | // +-+-+-+-+-+-+-+-+-+-+-+ |
// Pour simuler un véritable Redo, l'appelant doit mettre la structure // Pour simuler un véritable Redo, l'appelant doit mettre la structure
// de page courante à jour avant l'appel, puis en réextraire les infos en // de page courante à jour avant l'appel, puis en réextraire les infos en
@ -1018,3 +930,7 @@ void * Borrow_memory_from_page(int size)
// Pour que le compilateur ne dise pas qu'il manque une valeur de sortie: // Pour que le compilateur ne dise pas qu'il manque une valeur de sortie:
return 0; return 0;
} }
void End_of_modification(void)
{
}

189
pages.h
View File

@ -1,93 +1,96 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pages.h ///@file pages.h
/// Handler for the Undo/Redo system. /// Handler for the Undo/Redo system.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef _PAGES_H_ #ifndef _PAGES_H_
#define _PAGES_H_ #define _PAGES_H_
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/////////////////////////// GESTION DU BACKUP //////////////////////////// /////////////////////////// BACKUP ///////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// ///
/// GESTION DES PAGES /// INDIVIDUAL PAGES
/// ///
void Init_page(T_Page * page); void Download_infos_page_main(T_Page * page);
void Download_infos_page_main(T_Page * page); void Upload_infos_page_main(T_Page * page);
void Upload_infos_page_main(T_Page * page);
void Download_infos_page_spare(T_Page * page); // private
void Upload_infos_page_spare(T_Page * page); void Init_page(T_Page * page);
void Download_infos_backup(T_List_of_pages * list); void Download_infos_page_spare(T_Page * page);
void Free_a_page(T_Page * page); void Upload_infos_page_spare(T_Page * page);
void Copy_S_page(T_Page * dest,T_Page * source); void Download_infos_backup(T_List_of_pages * list);
int Size_of_a_page(T_Page * page); void Free_a_page(T_Page * page);
void Copy_S_page(T_Page * dest,T_Page * source);
int Size_of_a_page(T_Page * page);
///
/// GESTION DES LISTES DE PAGES
/// ///
/// LISTS OF PAGES
void Init_list_of_pages(T_List_of_pages * list); ///
int Allocate_list_of_pages(T_List_of_pages * list,int size);
void Free_a_list_of_pages(T_List_of_pages * list); void Init_list_of_pages(T_List_of_pages * list);
int Size_of_a_list_of_pages(T_List_of_pages * list); // private
void Backward_in_list_of_pages(T_List_of_pages * list); int Allocate_list_of_pages(T_List_of_pages * list,int size);
void Advance_in_list_of_pages(T_List_of_pages * list); void Free_a_list_of_pages(T_List_of_pages * list);
int New_page_is_possible(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list); int Size_of_a_list_of_pages(T_List_of_pages * list);
void Free_last_page_of_list(T_List_of_pages * list); void Backward_in_list_of_pages(T_List_of_pages * list);
void Create_new_page(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list); void Advance_in_list_of_pages(T_List_of_pages * list);
void Change_page_number_of_list(T_List_of_pages * list,int number); int New_page_is_possible(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
void Free_page_of_a_list(T_List_of_pages * list); void Free_last_page_of_list(T_List_of_pages * list);
void Create_new_page(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
void Change_page_number_of_list(T_List_of_pages * list,int number);
void Free_page_of_a_list(T_List_of_pages * list);
///
/// GESTION DES BACKUPS
///
///
int Init_all_backup_lists(int size,int width,int height); /// BACKUP HIGH-LEVEL FUNCTIONS
void Set_number_of_backups(int nb_backups); ///
int Backup_with_new_dimensions(int upload,int width,int height);
int Backup_and_resize_the_spare(int width,int height); int Init_all_backup_lists(int size,int width,int height);
void Backup(void); void Set_number_of_backups(int nb_backups);
void Undo(void); int Backup_with_new_dimensions(int upload,int width,int height);
void Redo(void); int Backup_and_resize_the_spare(int width,int height);
void Free_current_page(void); void Backup(void);
void Exchange_main_and_spare(void); void Undo(void);
void Redo(void);
void Free_current_page(void); // 'Kill' button
void Exchange_main_and_spare(void);
/// void End_of_modification(void);
/// GESTION DES EMPRUNTS DE MEMOIRE DE PAGE
///
///
int Can_borrow_memory_from_page(int size); /// BORROWING MEMORY FROM PAGE
void * Borrow_memory_from_page(int size); ///
void * Borrow_memory_from_page(int size);
// private
#endif int Can_borrow_memory_from_page(int size);
#endif

4624
palette.c

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +1,42 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file palette.h ///@file palette.h
/// Palette screen, and some palette-related high-level functions. /// Palette screen, and some palette-related high-level functions.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Open the palette menu and handles everything inside it. /// Open the palette menu and handles everything inside it.
void Button_Palette(void); void Button_Palette(void);
/// Open the secondary palette menu and handles it. /// Open the secondary palette menu and handles it.
void Button_Secondary_palette(void); void Button_Secondary_palette(void);
/// Choose the number of graduations for RGB components, from 2 to 256. /// Choose the number of graduations for RGB components, from 2 to 256.
void Set_palette_RGB_scale(int); void Set_palette_RGB_scale(int);
/// ///
/// Scale a component (R, G or B) according to the current RGB graduations. /// Scale a component (R, G or B) according to the current RGB graduations.
/// Returns the resulting value, in the [0-255] range. /// Returns the resulting value, in the [0-255] range.
byte Round_palette_component(byte comp); byte Round_palette_component(byte comp);
/*! /*!
Adds 4 menu colors in the current palette. Adds 4 menu colors in the current palette.
@param color_usage An up-to-date color usage table (byte[256]) (read only) @param color_usage An up-to-date color usage table (byte[256]) (read only)
@param not_picture 0 if the caller is the palette screen, 1 if it's a preview in the file selector. @param not_picture 0 if the caller is the palette screen, 1 if it's a preview in the file selector.
*/ */
void Set_nice_menu_colors(dword * color_usage,int not_picture); void Set_nice_menu_colors(dword * color_usage,int not_picture);

View File

@ -1 +1 @@
char Program_version[]="2.0"; char Program_version[]="2.1";

1001
pxdouble.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxdouble.h ///@file pxdouble.h
/// Renderer for double pixels (2x2). /// Renderer for double pixels (2x2).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_double (word x,word y,byte color); void Pixel_double (word x,word y,byte color);
byte Read_pixel_double (word x,word y); byte Read_pixel_double (word x,word y);
void Block_double (word start_x,word start_y,word width,word height,byte color); void Block_double (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_double (word x,word y,byte color); void Pixel_preview_normal_double (word x,word y,byte color);
void Pixel_preview_magnifier_double (word x,word y,byte color); void Pixel_preview_magnifier_double (word x,word y,byte color);
void Horizontal_XOR_line_double (word x_pos,word y_pos,word width); void Horizontal_XOR_line_double (word x_pos,word y_pos,word width);
void Vertical_XOR_line_double (word x_pos,word y_pos,word height); void Vertical_XOR_line_double (word x_pos,word y_pos,word height);
void Display_brush_color_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_double (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_double (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_double (word width,word height,word image_width); void Display_part_of_screen_double (word width,word height,word image_width);
void Display_line_on_screen_double (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_double (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_double (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_double (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_double(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_double(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_double (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_double (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_double (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_double (word x_pos,word y_pos,word width,byte * line);

1071
pxquad.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxquad.h ///@file pxquad.h
/// Renderer for quadruple pixels (4x4). /// Renderer for quadruple pixels (4x4).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_quad (word x,word y,byte color); void Pixel_quad (word x,word y,byte color);
byte Read_pixel_quad (word x,word y); byte Read_pixel_quad (word x,word y);
void Block_quad (word start_x,word start_y,word width,word height,byte color); void Block_quad (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_quad (word x,word y,byte color); void Pixel_preview_normal_quad (word x,word y,byte color);
void Pixel_preview_magnifier_quad (word x,word y,byte color); void Pixel_preview_magnifier_quad (word x,word y,byte color);
void Horizontal_XOR_line_quad (word x_pos,word y_pos,word width); void Horizontal_XOR_line_quad (word x_pos,word y_pos,word width);
void Vertical_XOR_line_quad (word x_pos,word y_pos,word height); void Vertical_XOR_line_quad (word x_pos,word y_pos,word height);
void Display_brush_color_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_quad (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_quad (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_quad (word width,word height,word image_width); void Display_part_of_screen_quad (word width,word height,word image_width);
void Display_line_on_screen_quad (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_quad (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_quad (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_quad (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_quad(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_quad(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_quad (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_quad (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_quad (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_quad (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_quad (word x_pos,word y_pos,word width,byte * line);

View File

@ -1,470 +1,475 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h> #include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
#include "pxsimple.h" #include "graph.h"
#include "pxsimple.h"
void Pixel_simple (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ void Pixel_simple (word x,word y,byte color)
{ /* Affiche un pixel de la color aux coords x;y à l'écran */
*(Screen_pixels + x + y * VIDEO_LINE_WIDTH)=color; {
} *(Screen_pixels + x + y * VIDEO_LINE_WIDTH)=color;
}
byte Read_pixel_simple (word x,word y)
/* On retourne la couleur du pixel aux coords données */ byte Read_pixel_simple (word x,word y)
{ /* On retourne la couleur du pixel aux coords données */
return *( Screen_pixels + y * VIDEO_LINE_WIDTH + x ); {
} return *( Screen_pixels + y * VIDEO_LINE_WIDTH + x );
}
void Block_simple (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ void Block_simple (word start_x,word start_y,word width,word height,byte color)
{ /* On affiche un rectangle de la couleur donnée */
SDL_Rect rectangle; {
rectangle.x=start_x; SDL_Rect rectangle;
rectangle.y=start_y; rectangle.x=start_x;
rectangle.w=width; rectangle.y=start_y;
rectangle.h=height; rectangle.w=width;
SDL_FillRect(Screen_SDL,&rectangle,color); rectangle.h=height;
} SDL_FillRect(Screen_SDL,&rectangle,color);
}
void Display_part_of_screen_simple (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ void Display_part_of_screen_simple (word width,word height,word image_width)
{ /* Afficher une partie de l'image telle quelle sur l'écran */
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) {
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
int y; byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y;
for(y=height;y!=0;y--)
// Pour chaque ligne for(y=height;y!=0;y--)
{ // Pour chaque ligne
// On fait une copie de la ligne {
memcpy(dest,src,width); // On fait une copie de la ligne
memcpy(dest,src,width);
// On passe à la ligne suivante
src+=image_width; // On passe à la ligne suivante
dest+=VIDEO_LINE_WIDTH; src+=image_width;
} dest+=VIDEO_LINE_WIDTH;
//Update_rect(0,0,width,height); }
} //Update_rect(0,0,width,height);
}
void Pixel_preview_normal_simple (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image void Pixel_preview_normal_simple (word x,word y,byte color)
* dans l'écran, en mode normal (pas en mode loupe) /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* Note: si on modifie cette procédure, il faudra penser à faire également * dans l'écran, en mode normal (pas en mode loupe)
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * Note: si on modifie cette procédure, il faudra penser à faire également
{ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) {
Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color); // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
} Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color);
}
void Pixel_preview_magnifier_simple (word x,word y,byte color)
{ void Pixel_preview_magnifier_simple (word x,word y,byte color)
// Affiche le pixel dans la partie non zoomée {
Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color); // Affiche le pixel dans la partie non zoomée
Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom // Regarde si on doit aussi l'afficher dans la partie zoomée
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom) if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
{ && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
// On est dedans {
int height; // On est dedans
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); int height;
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel if (Menu_Y - y_zoom < Main_magnifier_factor)
// sinon on dépasse sur le menu // On ne doit dessiner qu'un morceau du pixel
height = Menu_Y - y_zoom; // sinon on dépasse sur le menu
else height = Menu_Y - y_zoom;
height = Main_magnifier_factor; else
height = Main_magnifier_factor;
Block_simple(
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, Block_simple(
y_zoom, Main_magnifier_factor, height, color Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
); y_zoom, Main_magnifier_factor, height, color
} );
} }
}
void Horizontal_XOR_line_simple(word x_pos,word y_pos,word width)
{ void Horizontal_XOR_line_simple(word x_pos,word y_pos,word width)
//On calcule la valeur initiale de dest: {
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; //On calcule la valeur initiale de dest:
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
int x;
int x;
for (x=0;x<width;x++)
*(dest+x)=~*(dest+x); for (x=0;x<width;x++)
} *(dest+x)=~*(dest+x);
}
void Vertical_XOR_line_simple(word x_pos,word y_pos,word height)
{ void Vertical_XOR_line_simple(word x_pos,word y_pos,word height)
int i; {
byte color; int i;
for (i=y_pos;i<y_pos+height;i++) byte color;
{ for (i=y_pos;i<y_pos+height;i++)
color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH); {
*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color; color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH);
} *(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color;
} }
}
void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
// dest = Position à l'écran {
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; // dest = Position à l'écran
// src = Position dans la brosse byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
byte* src = Brush + y_offset * brush_width + x_offset; // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset;
word x,y;
word x,y;
// Pour chaque ligne
for(y = height;y > 0; y--) // Pour chaque ligne
{ for(y = height;y > 0; y--)
// Pour chaque pixel {
for(x = width;x > 0; x--) // Pour chaque pixel
{ for(x = width;x > 0; x--)
// On vérifie que ce n'est pas la transparence {
if(*src != transp_color) // On vérifie que ce n'est pas la transparence
{ if(*src != transp_color)
*dest = *src; {
} *dest = *src;
}
// Pixel suivant
src++; dest++; // Pixel suivant
} src++; dest++;
}
// On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH - width; // On passe à la ligne suivante
src = src + brush_width - width; dest = dest + VIDEO_LINE_WIDTH - width;
} src = src + brush_width - width;
Update_rect(x_pos,y_pos,width,height); }
} Update_rect(x_pos,y_pos,width,height);
}
void Display_brush_mono_simple(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, void Display_brush_mono_simple(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) word x_offset, word y_offset, word width, word height,
/* On affiche la brosse en monochrome */ byte transp_color, byte color, word brush_width)
{ /* On affiche la brosse en monochrome */
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à {
// l'écran byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds // l'écran
// la brosse byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
int x,y; // la brosse
int x,y;
for(y=height;y!=0;y--)
//Pour chaque ligne for(y=height;y!=0;y--)
{ //Pour chaque ligne
for(x=width;x!=0;x--) {
//Pour chaque pixel for(x=width;x!=0;x--)
{ //Pour chaque pixel
if (*src!=transp_color) {
*dest=color; if (*src!=transp_color)
*dest=color;
// On passe au pixel suivant
src++; // On passe au pixel suivant
dest++; src++;
} dest++;
}
// On passe à la ligne suivante
src+=brush_width-width; // On passe à la ligne suivante
dest+=VIDEO_LINE_WIDTH-width; src+=brush_width-width;
} dest+=VIDEO_LINE_WIDTH-width;
Update_rect(x_pos,y_pos,width,height); }
} Update_rect(x_pos,y_pos,width,height);
}
void Clear_brush_simple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ void Clear_brush_simple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
byte* dest=Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) {
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) byte* dest=Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
int y; byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y;
for(y=height;y!=0;y--)
// Pour chaque ligne for(y=height;y!=0;y--)
{ // Pour chaque ligne
// On fait une copie de la ligne {
memcpy(dest,src,width); // On fait une copie de la ligne
memcpy(dest,src,width);
// On passe à la ligne suivante
src+=image_width; // On passe à la ligne suivante
dest+=VIDEO_LINE_WIDTH; src+=image_width;
} dest+=VIDEO_LINE_WIDTH;
Update_rect(x_pos,y_pos,width,height); }
} Update_rect(x_pos,y_pos,width,height);
}
// Affiche une brosse (arbitraire) à l'écran
void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) // Affiche une brosse (arbitraire) à l'écran
{ void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
// dest = Position à l'écran {
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; // dest = Position à l'écran
// src = Position dans la brosse byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
byte* src = brush + y_offset * brush_width + x_offset; // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset;
word x,y;
word x,y;
// Pour chaque ligne
for(y = height;y > 0; y--) // Pour chaque ligne
{ for(y = height;y > 0; y--)
// Pour chaque pixel {
for(x = width;x > 0; x--) // Pour chaque pixel
{ for(x = width;x > 0; x--)
// On vérifie que ce n'est pas la transparence {
if(*src != transp_color) // On vérifie que ce n'est pas la transparence
{ if(*src != transp_color)
*dest = *src; {
} *dest = *src;
}
// Pixel suivant
src++; dest++; // Pixel suivant
} src++; dest++;
}
// On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH - width; // On passe à la ligne suivante
src = src + brush_width - width; dest = dest + VIDEO_LINE_WIDTH - width;
} src = src + brush_width - width;
} }
}
void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
// dest = coords a l'écran {
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; // dest = coords a l'écran
int x,y; byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
int x,y;
// Pour chaque ligne
for(y=height;y>0;y--) // Pour chaque ligne
{ for(y=height;y>0;y--)
// Pour chaque pixel {
for(x=width;x>0;x--) // Pour chaque pixel
{ for(x=width;x>0;x--)
*dest = conversion_table[*dest]; {
dest ++; *dest = conversion_table[*dest];
} dest ++;
}
dest = dest + VIDEO_LINE_WIDTH - width;
} dest = dest + VIDEO_LINE_WIDTH - width;
}
Update_rect(x_pos,y_pos,width,height);
} Update_rect(x_pos,y_pos,width,height);
}
void Display_line_on_screen_simple(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */ void Display_line_on_screen_simple(word x_pos,word y_pos,word width,byte * line)
{ /* On affiche toute une ligne de pixels. Utilisé pour les textes. */
memcpy(Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH,line,width); {
} memcpy(Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH,line,width);
}
void Display_transparent_mono_line_on_screen_simple(
word x_pos, word y_pos, word width, byte* line, void Display_transparent_mono_line_on_screen_simple(
byte transp_color, byte color) word x_pos, word y_pos, word width, byte* line,
// Affiche une ligne à l'écran avec une couleur + transparence. byte transp_color, byte color)
// Utilisé par les brosses en mode zoom // Affiche une ligne à l'écran avec une couleur + transparence.
{ // Utilisé par les brosses en mode zoom
byte* dest = Screen_pixels+ y_pos * VIDEO_LINE_WIDTH + x_pos; {
int x; byte* dest = Screen_pixels+ y_pos * VIDEO_LINE_WIDTH + x_pos;
// Pour chaque pixel int x;
for(x=0;x<width;x++) // Pour chaque pixel
{ for(x=0;x<width;x++)
if (transp_color!=*line) {
*dest = color; if (transp_color!=*line)
line ++; // Pixel suivant *dest = color;
dest++; line ++; // Pixel suivant
} dest++;
} }
}
void Read_line_screen_simple(word x_pos,word y_pos,word width,byte * line)
{ void Read_line_screen_simple(word x_pos,word y_pos,word width,byte * line)
memcpy(line,VIDEO_LINE_WIDTH * y_pos + x_pos + Screen_pixels,width); {
} memcpy(line,VIDEO_LINE_WIDTH * y_pos + x_pos + Screen_pixels,width);
}
void Display_part_of_screen_scaled_simple(
word width, // width non zoomée void Display_part_of_screen_scaled_simple(
word height, // height zoomée word width, // width non zoomée
word image_width,byte * buffer) word height, // height zoomée
{ word image_width,byte * buffer)
byte* src = Main_screen + Main_magnifier_offset_Y * image_width {
+ Main_magnifier_offset_X; byte* src = Main_screen + Main_magnifier_offset_Y * image_width
int y = 0; // Ligne en cours de traitement + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer
while(1) // Pour chaque ligne à zoomer
{ while(1)
int x; {
int x;
// On éclate la ligne
Zoom_a_line(src,buffer,Main_magnifier_factor,width); // On éclate la ligne
// On l'affiche Facteur fois, sur des lignes consécutives Zoom_a_line(src,buffer,Main_magnifier_factor,width);
x = Main_magnifier_factor; // On l'affiche Facteur fois, sur des lignes consécutives
// Pour chaque ligne x = Main_magnifier_factor;
do{ // Pour chaque ligne
// On affiche la ligne zoomée do{
Display_line_on_screen_simple( // On affiche la ligne zoomée
Main_X_zoom, y, width*Main_magnifier_factor, Display_line_on_screen_simple(
buffer Main_X_zoom, y, width*Main_magnifier_factor,
); buffer
// On passe à la suivante );
y++; // On passe à la suivante
if(y==height) y++;
{ if(y==height)
Update_rect(Main_X_zoom,0, {
width*Main_magnifier_factor,height); Redraw_grid(Main_X_zoom,0,
return; width*Main_magnifier_factor,height);
} Update_rect(Main_X_zoom,0,
x--; width*Main_magnifier_factor,height);
}while (x > 0); return;
src += image_width; }
} x--;
// ATTENTION on n'arrive jamais ici ! }while (x > 0);
} src += image_width;
}
void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color) // ATTENTION on n'arrive jamais ici !
{ }
byte* src = line;
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color)
{
word x; byte* src = line;
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
// Pour chaque pixel de la ligne
for(x = width;x > 0;x--) word x;
{
if(*src!=transp_color) // Pour chaque pixel de la ligne
*dest = *src; for(x = width;x > 0;x--)
src++; {
dest++; if(*src!=transp_color)
} *dest = *src;
} src++;
dest++;
// Affiche une partie de la brosse couleur zoomée }
void Display_brush_color_zoom_simple(word x_pos,word y_pos, }
word x_offset,word y_offset,
word width, // width non zoomée // Affiche une partie de la brosse couleur zoomée
word end_y_pos,byte transp_color, void Display_brush_color_zoom_simple(word x_pos,word y_pos,
word brush_width, // width réelle de la brosse word x_offset,word y_offset,
byte * buffer) word width, // width non zoomée
{ word end_y_pos,byte transp_color,
byte* src = Brush+y_offset*brush_width + x_offset; word brush_width, // width réelle de la brosse
word y = y_pos; byte * buffer)
byte bx; {
byte* src = Brush+y_offset*brush_width + x_offset;
// Pour chaque ligne word y = y_pos;
while(1) byte bx;
{
Zoom_a_line(src,buffer,Main_magnifier_factor,width); // Pour chaque ligne
// On affiche facteur fois la ligne zoomée while(1)
for(bx=Main_magnifier_factor;bx>0;bx--) {
{ Zoom_a_line(src,buffer,Main_magnifier_factor,width);
Display_transparent_line_on_screen_simple(x_pos,y,width*Main_magnifier_factor,buffer,transp_color); // On affiche facteur fois la ligne zoomée
y++; for(bx=Main_magnifier_factor;bx>0;bx--)
if(y==end_y_pos) {
{ Display_transparent_line_on_screen_simple(x_pos,y,width*Main_magnifier_factor,buffer,transp_color);
return; y++;
} if(y==end_y_pos)
} {
src += brush_width; return;
} }
// ATTENTION zone jamais atteinte }
} src += brush_width;
}
void Display_brush_mono_zoom_simple(word x_pos, word y_pos, // ATTENTION zone jamais atteinte
word x_offset, word y_offset, }
word width, // width non zoomée
word end_y_pos, void Display_brush_mono_zoom_simple(word x_pos, word y_pos,
byte transp_color, byte color, word x_offset, word y_offset,
word brush_width, // width réelle de la brosse word width, // width non zoomée
byte * buffer word end_y_pos,
) byte transp_color, byte color,
word brush_width, // width réelle de la brosse
{ byte * buffer
byte* src = Brush + y_offset * brush_width + x_offset; )
int y=y_pos;
{
//Pour chaque ligne à zoomer : byte* src = Brush + y_offset * brush_width + x_offset;
while(1) int y=y_pos;
{
int bx; //Pour chaque ligne à zoomer :
// src = Ligne originale while(1)
// On éclate la ligne {
Zoom_a_line(src,buffer,Main_magnifier_factor,width); int bx;
// src = Ligne originale
// On affiche la ligne Facteur fois à l'écran (sur des // On éclate la ligne
// lignes consécutives) Zoom_a_line(src,buffer,Main_magnifier_factor,width);
bx = Main_magnifier_factor;
// On affiche la ligne Facteur fois à l'écran (sur des
// Pour chaque ligne écran // lignes consécutives)
do bx = Main_magnifier_factor;
{
// On affiche la ligne zoomée // Pour chaque ligne écran
Display_transparent_mono_line_on_screen_simple( do
x_pos, y, width * Main_magnifier_factor, {
buffer, transp_color, color // On affiche la ligne zoomée
); Display_transparent_mono_line_on_screen_simple(
// On passe à la ligne suivante x_pos, y, width * Main_magnifier_factor,
y++; buffer, transp_color, color
// On vérifie qu'on est pas à la ligne finale );
if(y == end_y_pos) // On passe à la ligne suivante
{ y++;
Update_rect( x_pos, y_pos, // On vérifie qu'on est pas à la ligne finale
width * Main_magnifier_factor, end_y_pos - y_pos ); if(y == end_y_pos)
return; {
} Redraw_grid( x_pos, y_pos,
bx --; width * Main_magnifier_factor, end_y_pos - y_pos );
} Update_rect( x_pos, y_pos,
while (bx > 0); width * Main_magnifier_factor, end_y_pos - y_pos );
return;
// Passage à la ligne suivante dans la brosse aussi }
src+=brush_width; bx --;
} }
} while (bx > 0);
void Clear_brush_scaled_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer) // Passage à la ligne suivante dans la brosse aussi
{ src+=brush_width;
// En fait on va recopier l'image non zoomée dans la partie zoomée ! }
byte* src = Main_screen + y_offset * image_width + x_offset; }
int y = y_pos;
int bx; void Clear_brush_scaled_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{
// Pour chaque ligne à zoomer // En fait on va recopier l'image non zoomée dans la partie zoomée !
while(1){ byte* src = Main_screen + y_offset * image_width + x_offset;
Zoom_a_line(src,buffer,Main_magnifier_factor,width); int y = y_pos;
int bx;
bx=Main_magnifier_factor;
// Pour chaque ligne à zoomer
// Pour chaque ligne while(1){
do{ Zoom_a_line(src,buffer,Main_magnifier_factor,width);
Display_line_on_screen_simple(x_pos,y,
width * Main_magnifier_factor,buffer); bx=Main_magnifier_factor;
// Ligne suivante // Pour chaque ligne
y++; do{
if(y==end_y_pos) Display_line_on_screen_simple(x_pos,y,
{ width * Main_magnifier_factor,buffer);
Update_rect(x_pos,y_pos,
width*Main_magnifier_factor,end_y_pos-y_pos); // Ligne suivante
return; y++;
} if(y==end_y_pos)
bx--; {
}while(bx!=0); Redraw_grid(x_pos,y_pos,
width*Main_magnifier_factor,end_y_pos-y_pos);
src+= image_width; Update_rect(x_pos,y_pos,
} width*Main_magnifier_factor,end_y_pos-y_pos);
} return;
}
bx--;
}while(bx!=0);
src+= image_width;
}
}

View File

@ -1,51 +1,51 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxsimple.h ///@file pxsimple.h
/// Renderer for simple pixels (1x1). This is the normal one. /// Renderer for simple pixels (1x1). This is the normal one.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_simple (word x,word y,byte color); void Pixel_simple (word x,word y,byte color);
byte Read_pixel_simple (word x,word y); byte Read_pixel_simple (word x,word y);
void Block_simple (word start_x,word start_y,word width,word height,byte color); void Block_simple (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_simple (word x,word y,byte color); void Pixel_preview_normal_simple (word x,word y,byte color);
void Pixel_preview_magnifier_simple (word x,word y,byte color); void Pixel_preview_magnifier_simple (word x,word y,byte color);
void Horizontal_XOR_line_simple (word x_pos,word y_pos,word width); void Horizontal_XOR_line_simple (word x_pos,word y_pos,word width);
void Vertical_XOR_line_simple (word x_pos,word y_pos,word height); void Vertical_XOR_line_simple (word x_pos,word y_pos,word height);
void Display_brush_color_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_simple (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_simple (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_simple (word width,word height,word image_width); void Display_part_of_screen_simple (word width,word height,word image_width);
void Display_line_on_screen_simple (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_simple (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_simple (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_simple (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_simple(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_simple(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_simple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_simple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_transparent_mono_line_on_screen_simple( void Display_transparent_mono_line_on_screen_simple(
word x_pos, word y_pos, word width, byte* line, word x_pos, word y_pos, word width, byte* line,
byte transp_color, byte color); byte transp_color, byte color);
void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color); void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color);

913
pxtall.c
View File

@ -1,453 +1,460 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h> #include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
#include "pxtall.h" #include "graph.h"
#include "pxsimple.h" #include "pxtall.h"
#include "pxsimple.h"
#define ZOOMX 1
#define ZOOMY 2 #define ZOOMX 1
#define ZOOMY 2
void Pixel_tall (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ void Pixel_tall (word x,word y,byte color)
{ /* Affiche un pixel de la color aux coords x;y à l'écran */
*(Screen_pixels + x + y*ZOOMY*VIDEO_LINE_WIDTH)=color; {
*(Screen_pixels + x + (y*ZOOMY+1)*VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x + y*ZOOMY*VIDEO_LINE_WIDTH)=color;
} *(Screen_pixels + x + (y*ZOOMY+1)*VIDEO_LINE_WIDTH)=color;
}
byte Read_pixel_tall (word x,word y)
/* On retourne la couleur du pixel aux coords données */ byte Read_pixel_tall (word x,word y)
{ /* On retourne la couleur du pixel aux coords données */
return *( Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x ); {
} return *( Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x );
}
void Block_tall (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ void Block_tall (word start_x,word start_y,word width,word height,byte color)
{ /* On affiche un rectangle de la couleur donnée */
SDL_Rect rectangle; {
rectangle.x=start_x; SDL_Rect rectangle;
rectangle.y=start_y*ZOOMY; rectangle.x=start_x;
rectangle.w=width; rectangle.y=start_y*ZOOMY;
rectangle.h=height*ZOOMY; rectangle.w=width;
SDL_FillRect(Screen_SDL,&rectangle,color); rectangle.h=height*ZOOMY;
} SDL_FillRect(Screen_SDL,&rectangle,color);
}
void Display_part_of_screen_tall (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ void Display_part_of_screen_tall (word width,word height,word image_width)
{ /* Afficher une partie de l'image telle quelle sur l'écran */
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) {
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
int y; byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y;
for(y=height;y!=0;y--)
// Pour chaque ligne for(y=height;y!=0;y--)
{ // Pour chaque ligne
// On fait une copie de la ligne {
memcpy(dest,src,width); // On fait une copie de la ligne
dest+=VIDEO_LINE_WIDTH; memcpy(dest,src,width);
memcpy(dest,src,width); dest+=VIDEO_LINE_WIDTH;
memcpy(dest,src,width);
// On passe à la ligne suivante
src+=image_width; // On passe à la ligne suivante
dest+=VIDEO_LINE_WIDTH; src+=image_width;
} dest+=VIDEO_LINE_WIDTH;
//Update_rect(0,0,width,height); }
} //Update_rect(0,0,width,height);
}
void Pixel_preview_normal_tall (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image void Pixel_preview_normal_tall (word x,word y,byte color)
* dans l'écran, en mode normal (pas en mode loupe) /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* Note: si on modifie cette procédure, il faudra penser à faire également * dans l'écran, en mode normal (pas en mode loupe)
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * Note: si on modifie cette procédure, il faudra penser à faire également
{ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) {
Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color); // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
} Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color);
}
void Pixel_preview_magnifier_tall (word x,word y,byte color)
{ void Pixel_preview_magnifier_tall (word x,word y,byte color)
// Affiche le pixel dans la partie non zoomée {
Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color); // Affiche le pixel dans la partie non zoomée
Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom // Regarde si on doit aussi l'afficher dans la partie zoomée
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom) if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
{ && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
// On est dedans {
int height; // On est dedans
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); int height;
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel if (Menu_Y - y_zoom < Main_magnifier_factor)
// sinon on dépasse sur le menu // On ne doit dessiner qu'un morceau du pixel
height = Menu_Y - y_zoom; // sinon on dépasse sur le menu
else height = Menu_Y - y_zoom;
height = Main_magnifier_factor; else
height = Main_magnifier_factor;
Block_tall(
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, Block_tall(
y_zoom, Main_magnifier_factor, height, color Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
); y_zoom, Main_magnifier_factor, height, color
} );
} }
}
void Horizontal_XOR_line_tall(word x_pos,word y_pos,word width)
{ void Horizontal_XOR_line_tall(word x_pos,word y_pos,word width)
//On calcule la valeur initiale de dest: {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
int x;
int x;
for (x=0;x<width;x++)
*(dest+x)=~*(dest+x); for (x=0;x<width;x++)
*(dest+x)=~*(dest+x);
dest=(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
for (x=0;x<width;x++) dest=(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
*(dest+x)=~*(dest+x); for (x=0;x<width;x++)
} *(dest+x)=~*(dest+x);
}
void Vertical_XOR_line_tall(word x_pos,word y_pos,word height)
{ void Vertical_XOR_line_tall(word x_pos,word y_pos,word height)
int i; {
byte color; int i;
for (i=y_pos*ZOOMY;i<(y_pos+height)*ZOOMY;i++) byte color;
{ for (i=y_pos*ZOOMY;i<(y_pos+height)*ZOOMY;i++)
color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH); {
*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color; color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH);
} *(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=~color;
} }
}
void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
// dest = Position à l'écran {
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos; // dest = Position à l'écran
// src = Position dans la brosse byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
byte* src = Brush + y_offset * brush_width + x_offset; // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset;
word x,y;
word x,y;
// Pour chaque ligne
for(y = height;y > 0; y--) // Pour chaque ligne
{ for(y = height;y > 0; y--)
// Pour chaque pixel {
for(x = width;x > 0; x--) // Pour chaque pixel
{ for(x = width;x > 0; x--)
// On vérifie que ce n'est pas la transparence {
if(*src != transp_color) // On vérifie que ce n'est pas la transparence
{ if(*src != transp_color)
*dest = *src; {
*(dest+VIDEO_LINE_WIDTH) = *src; *dest = *src;
} *(dest+VIDEO_LINE_WIDTH) = *src;
}
// Pixel suivant
src++; dest++; // Pixel suivant
} src++; dest++;
}
// On passe à la ligne suivante
dest = dest + ZOOMY*VIDEO_LINE_WIDTH - width; // On passe à la ligne suivante
src = src + brush_width - width; dest = dest + ZOOMY*VIDEO_LINE_WIDTH - width;
} src = src + brush_width - width;
Update_rect(x_pos,y_pos,width,height); }
} Update_rect(x_pos,y_pos,width,height);
}
void Display_brush_mono_tall(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, void Display_brush_mono_tall(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) word x_offset, word y_offset, word width, word height,
/* On affiche la brosse en monochrome */ byte transp_color, byte color, word brush_width)
{ /* On affiche la brosse en monochrome */
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à {
// l'écran byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds // l'écran
// la brosse byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
int x,y; // la brosse
int x,y;
for(y=height;y!=0;y--)
//Pour chaque ligne for(y=height;y!=0;y--)
{ //Pour chaque ligne
for(x=width;x!=0;x--) {
//Pour chaque pixel for(x=width;x!=0;x--)
{ //Pour chaque pixel
if (*src!=transp_color) {
{ if (*src!=transp_color)
*dest=color; {
*(dest+VIDEO_LINE_WIDTH)=color; *dest=color;
} *(dest+VIDEO_LINE_WIDTH)=color;
}
// On passe au pixel suivant
src++; // On passe au pixel suivant
dest++; src++;
} dest++;
}
// On passe à la ligne suivante
src+=brush_width-width; // On passe à la ligne suivante
dest+=ZOOMY*VIDEO_LINE_WIDTH-width; src+=brush_width-width;
} dest+=ZOOMY*VIDEO_LINE_WIDTH-width;
Update_rect(x_pos,y_pos,width,height); }
} Update_rect(x_pos,y_pos,width,height);
}
void Clear_brush_tall(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ void Clear_brush_tall(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
byte* dest=Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) {
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) byte* dest=Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
int y; byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y;
for(y=height;y!=0;y--)
// Pour chaque ligne for(y=height;y!=0;y--)
{ // Pour chaque ligne
// On fait une copie de la ligne {
memcpy(dest,src,width); // On fait une copie de la ligne
dest+=VIDEO_LINE_WIDTH; memcpy(dest,src,width);
memcpy(dest,src,width); dest+=VIDEO_LINE_WIDTH;
memcpy(dest,src,width);
// On passe à la ligne suivante
src+=image_width; // On passe à la ligne suivante
dest+=VIDEO_LINE_WIDTH; src+=image_width;
} dest+=VIDEO_LINE_WIDTH;
Update_rect(x_pos,y_pos,width,height); }
} Update_rect(x_pos,y_pos,width,height);
}
// Affiche une brosse (arbitraire) à l'écran
void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) // Affiche une brosse (arbitraire) à l'écran
{ void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
// dest = Position à l'écran {
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos; // dest = Position à l'écran
// src = Position dans la brosse byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
byte* src = brush + y_offset * brush_width + x_offset; // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset;
word x,y;
word x,y;
// Pour chaque ligne
for(y = height;y > 0; y--) // Pour chaque ligne
{ for(y = height;y > 0; y--)
// Pour chaque pixel {
for(x = width;x > 0; x--) // Pour chaque pixel
{ for(x = width;x > 0; x--)
// On vérifie que ce n'est pas la transparence {
if(*src != transp_color) // On vérifie que ce n'est pas la transparence
{ if(*src != transp_color)
*dest = *src; {
*(dest+VIDEO_LINE_WIDTH) = *src; *dest = *src;
} *(dest+VIDEO_LINE_WIDTH) = *src;
}
// Pixel suivant
src++; dest++; // Pixel suivant
} src++; dest++;
}
// On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width; // On passe à la ligne suivante
src = src + brush_width - width; dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width;
} src = src + brush_width - width;
} }
}
void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conversion_table)
// dest = coords a l'écran {
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos; // dest = coords a l'écran
int x,y; byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
int x,y;
// Pour chaque ligne
for(y=height*ZOOMY;y>0;y--) // Pour chaque ligne
{ for(y=height*ZOOMY;y>0;y--)
// Pour chaque pixel {
for(x=width;x>0;x--) // Pour chaque pixel
{ for(x=width;x>0;x--)
*dest = conversion_table[*dest]; {
dest ++; *dest = conversion_table[*dest];
} dest ++;
}
dest = dest + VIDEO_LINE_WIDTH - width;
} dest = dest + VIDEO_LINE_WIDTH - width;
}
Update_rect(x_pos,y_pos,width,height);
} Update_rect(x_pos,y_pos,width,height);
}
void Display_line_on_screen_tall(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */ void Display_line_on_screen_tall(word x_pos,word y_pos,word width,byte * line)
{ /* On affiche toute une ligne de pixels. Utilisé pour les textes. */
memcpy(Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width); {
memcpy(Screen_pixels+x_pos+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width); memcpy(Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width);
} memcpy(Screen_pixels+x_pos+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width);
}
void Read_line_screen_tall(word x_pos,word y_pos,word width,byte * line)
{ void Read_line_screen_tall(word x_pos,word y_pos,word width,byte * line)
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY*y_pos + x_pos + Screen_pixels,width); {
} memcpy(line,VIDEO_LINE_WIDTH*ZOOMY*y_pos + x_pos + Screen_pixels,width);
}
void Display_part_of_screen_scaled_tall(
word width, // width non zoomée void Display_part_of_screen_scaled_tall(
word height, // height zoomée word width, // width non zoomée
word image_width,byte * buffer) word height, // height zoomée
{ word image_width,byte * buffer)
byte* src = Main_screen + Main_magnifier_offset_Y * image_width {
+ Main_magnifier_offset_X; byte* src = Main_screen + Main_magnifier_offset_Y * image_width
int y = 0; // Ligne en cours de traitement + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer
while(1) // Pour chaque ligne à zoomer
{ while(1)
int x; {
int x;
// On éclate la ligne
Zoom_a_line(src,buffer,Main_magnifier_factor,width); // On éclate la ligne
// On l'affiche Facteur fois, sur des lignes consécutives Zoom_a_line(src,buffer,Main_magnifier_factor,width);
x = Main_magnifier_factor*ZOOMY; // On l'affiche Facteur fois, sur des lignes consécutives
// Pour chaque ligne x = Main_magnifier_factor*ZOOMY;
do{ // Pour chaque ligne
// On affiche la ligne zoomée do{
Display_line_on_screen_simple( // On affiche la ligne zoomée
Main_X_zoom, y, width*Main_magnifier_factor, Display_line_on_screen_simple(
buffer Main_X_zoom, y, width*Main_magnifier_factor,
); buffer
// On passe à la suivante );
y++; // On passe à la suivante
if(y==height*ZOOMY) y++;
{ if(y==height*ZOOMY)
Update_rect(Main_X_zoom,0, {
width*Main_magnifier_factor,height); Redraw_grid(Main_X_zoom,0,
return; width*Main_magnifier_factor,height);
} Update_rect(Main_X_zoom,0,
x--; width*Main_magnifier_factor,height);
}while (x > 0); return;
src += image_width; }
} x--;
// ATTENTION on n'arrive jamais ici ! }while (x > 0);
} src += image_width;
}
// Affiche une partie de la brosse couleur zoomée // ATTENTION on n'arrive jamais ici !
void Display_brush_color_zoom_tall(word x_pos,word y_pos, }
word x_offset,word y_offset,
word width, // width non zoomée // Affiche une partie de la brosse couleur zoomée
word end_y_pos,byte transp_color, void Display_brush_color_zoom_tall(word x_pos,word y_pos,
word brush_width, // width réelle de la brosse word x_offset,word y_offset,
byte * buffer) word width, // width non zoomée
{ word end_y_pos,byte transp_color,
byte* src = Brush+y_offset*brush_width + x_offset; word brush_width, // width réelle de la brosse
word y = y_pos; byte * buffer)
byte bx; {
byte* src = Brush+y_offset*brush_width + x_offset;
// Pour chaque ligne word y = y_pos;
while(1) byte bx;
{
Zoom_a_line(src,buffer,Main_magnifier_factor,width); // Pour chaque ligne
// On affiche facteur fois la ligne zoomée while(1)
for(bx=Main_magnifier_factor;bx>0;bx--) {
{ Zoom_a_line(src,buffer,Main_magnifier_factor,width);
Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color); // On affiche facteur fois la ligne zoomée
memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main_magnifier_factor); for(bx=Main_magnifier_factor;bx>0;bx--)
y++; {
if(y==end_y_pos) Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color);
{ memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main_magnifier_factor);
return; y++;
} if(y==end_y_pos)
} {
src += brush_width; return;
} }
// ATTENTION zone jamais atteinte }
} src += brush_width;
}
void Display_brush_mono_zoom_tall(word x_pos, word y_pos, // ATTENTION zone jamais atteinte
word x_offset, word y_offset, }
word width, // width non zoomée
word end_y_pos, void Display_brush_mono_zoom_tall(word x_pos, word y_pos,
byte transp_color, byte color, word x_offset, word y_offset,
word brush_width, // width réelle de la brosse word width, // width non zoomée
byte * buffer word end_y_pos,
) byte transp_color, byte color,
word brush_width, // width réelle de la brosse
{ byte * buffer
byte* src = Brush + y_offset * brush_width + x_offset; )
int y=y_pos*ZOOMY;
{
//Pour chaque ligne à zoomer : byte* src = Brush + y_offset * brush_width + x_offset;
while(1) int y=y_pos*ZOOMY;
{
int bx; //Pour chaque ligne à zoomer :
// src = Ligne originale while(1)
// On éclate la ligne {
Zoom_a_line(src,buffer,Main_magnifier_factor,width); int bx;
// src = Ligne originale
// On affiche la ligne Facteur fois à l'écran (sur des // On éclate la ligne
// lignes consécutives) Zoom_a_line(src,buffer,Main_magnifier_factor,width);
bx = Main_magnifier_factor*ZOOMY;
// On affiche la ligne Facteur fois à l'écran (sur des
// Pour chaque ligne écran // lignes consécutives)
do bx = Main_magnifier_factor*ZOOMY;
{
// On affiche la ligne zoomée // Pour chaque ligne écran
Display_transparent_mono_line_on_screen_simple( do
x_pos, y, width * Main_magnifier_factor, {
buffer, transp_color, color // On affiche la ligne zoomée
); Display_transparent_mono_line_on_screen_simple(
// On passe à la ligne suivante x_pos, y, width * Main_magnifier_factor,
y++; buffer, transp_color, color
// On vérifie qu'on est pas à la ligne finale );
if(y == end_y_pos*ZOOMY) // On passe à la ligne suivante
{ y++;
Update_rect( x_pos, y_pos, // On vérifie qu'on est pas à la ligne finale
width * Main_magnifier_factor, end_y_pos - y_pos ); if(y == end_y_pos*ZOOMY)
return; {
} Redraw_grid( x_pos, y_pos,
bx --; width * Main_magnifier_factor, end_y_pos - y_pos );
} Update_rect( x_pos, y_pos,
while (bx > 0); width * Main_magnifier_factor, end_y_pos - y_pos );
return;
// Passage à la ligne suivante dans la brosse aussi }
src+=brush_width; bx --;
} }
} while (bx > 0);
void Clear_brush_scaled_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer) // Passage à la ligne suivante dans la brosse aussi
{ src+=brush_width;
// En fait on va recopier l'image non zoomée dans la partie zoomée ! }
byte* src = Main_screen + y_offset * image_width + x_offset; }
int y = y_pos;
int bx; void Clear_brush_scaled_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{
// Pour chaque ligne à zoomer // En fait on va recopier l'image non zoomée dans la partie zoomée !
while(1){ byte* src = Main_screen + y_offset * image_width + x_offset;
Zoom_a_line(src,buffer,Main_magnifier_factor,width); int y = y_pos;
int bx;
bx=Main_magnifier_factor;
// Pour chaque ligne à zoomer
// Pour chaque ligne while(1){
do{ Zoom_a_line(src,buffer,Main_magnifier_factor,width);
Display_line_on_screen_tall(x_pos,y,
width * Main_magnifier_factor,buffer); bx=Main_magnifier_factor;
// Ligne suivante // Pour chaque ligne
y++; do{
if(y==end_y_pos) Display_line_on_screen_tall(x_pos,y,
{ width * Main_magnifier_factor,buffer);
Update_rect(x_pos,y_pos,
width*Main_magnifier_factor,end_y_pos-y_pos); // Ligne suivante
return; y++;
} if(y==end_y_pos)
bx--; {
}while(bx!=0); Redraw_grid(x_pos,y_pos,
width*Main_magnifier_factor,end_y_pos-y_pos);
src+= image_width; Update_rect(x_pos,y_pos,
} width*Main_magnifier_factor,end_y_pos-y_pos);
} return;
}
bx--;
}while(bx!=0);
src+= image_width;
}
}

View File

@ -1,46 +1,46 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxtall.h ///@file pxtall.h
/// Renderer for tall pixels (1x2). /// Renderer for tall pixels (1x2).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_tall (word x,word y,byte color); void Pixel_tall (word x,word y,byte color);
byte Read_pixel_tall (word x,word y); byte Read_pixel_tall (word x,word y);
void Block_tall (word start_x,word start_y,word width,word height,byte color); void Block_tall (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_tall (word x,word y,byte color); void Pixel_preview_normal_tall (word x,word y,byte color);
void Pixel_preview_magnifier_tall (word x,word y,byte color); void Pixel_preview_magnifier_tall (word x,word y,byte color);
void Horizontal_XOR_line_tall (word x_pos,word y_pos,word width); void Horizontal_XOR_line_tall (word x_pos,word y_pos,word width);
void Vertical_XOR_line_tall (word x_pos,word y_pos,word height); void Vertical_XOR_line_tall (word x_pos,word y_pos,word height);
void Display_brush_color_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_tall (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_tall (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_tall (word width,word height,word image_width); void Display_part_of_screen_tall (word width,word height,word image_width);
void Display_line_on_screen_tall (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_tall (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_tall (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_tall (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_tall(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_tall(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_tall (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_tall (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);

1055
pxtall2.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxtall2.h ///@file pxtall2.h
/// Renderer for double-tall pixels (2x4). /// Renderer for double-tall pixels (2x4).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_tall2 (word x,word y,byte color); void Pixel_tall2 (word x,word y,byte color);
byte Read_pixel_tall2 (word x,word y); byte Read_pixel_tall2 (word x,word y);
void Block_tall2 (word start_x,word start_y,word width,word height,byte color); void Block_tall2 (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_tall2 (word x,word y,byte color); void Pixel_preview_normal_tall2 (word x,word y,byte color);
void Pixel_preview_magnifier_tall2 (word x,word y,byte color); void Pixel_preview_magnifier_tall2 (word x,word y,byte color);
void Horizontal_XOR_line_tall2 (word x_pos,word y_pos,word width); void Horizontal_XOR_line_tall2 (word x_pos,word y_pos,word width);
void Vertical_XOR_line_tall2 (word x_pos,word y_pos,word height); void Vertical_XOR_line_tall2 (word x_pos,word y_pos,word height);
void Display_brush_color_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_tall2 (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_tall2 (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_tall2 (word width,word height,word image_width); void Display_part_of_screen_tall2 (word width,word height,word image_width);
void Display_line_on_screen_tall2 (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_tall2 (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_tall2 (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_tall2 (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_tall2(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_tall2(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_tall2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_tall2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_tall2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_tall2 (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_tall2 (word x_pos,word y_pos,word width,byte * line);

1047
pxtriple.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxtriple.h ///@file pxtriple.h
/// Renderer for triple pixels (3x3). /// Renderer for triple pixels (3x3).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_triple (word x,word y,byte color); void Pixel_triple (word x,word y,byte color);
byte Read_pixel_triple (word x,word y); byte Read_pixel_triple (word x,word y);
void Block_triple (word start_x,word start_y,word width,word height,byte color); void Block_triple (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_triple (word x,word y,byte color); void Pixel_preview_normal_triple (word x,word y,byte color);
void Pixel_preview_magnifier_triple (word x,word y,byte color); void Pixel_preview_magnifier_triple (word x,word y,byte color);
void Horizontal_XOR_line_triple (word x_pos,word y_pos,word width); void Horizontal_XOR_line_triple (word x_pos,word y_pos,word width);
void Vertical_XOR_line_triple (word x_pos,word y_pos,word height); void Vertical_XOR_line_triple (word x_pos,word y_pos,word height);
void Display_brush_color_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_triple (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_triple (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_triple (word width,word height,word image_width); void Display_part_of_screen_triple (word width,word height,word image_width);
void Display_line_on_screen_triple (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_triple (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_triple (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_triple (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_triple(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_triple(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_triple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_triple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_triple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_triple (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_triple (word x_pos,word y_pos,word width,byte * line);

1019
pxwide.c

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +1,49 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxwide.h ///@file pxwide.h
/// Renderer for wide pixels (2x1). /// Renderer for wide pixels (2x1).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_wide (word x,word y,byte color); void Pixel_wide (word x,word y,byte color);
byte Read_pixel_wide (word x,word y); byte Read_pixel_wide (word x,word y);
void Block_wide (word start_x,word start_y,word width,word height,byte color); void Block_wide (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_wide (word x,word y,byte color); void Pixel_preview_normal_wide (word x,word y,byte color);
void Pixel_preview_magnifier_wide (word x,word y,byte color); void Pixel_preview_magnifier_wide (word x,word y,byte color);
void Horizontal_XOR_line_wide (word x_pos,word y_pos,word width); void Horizontal_XOR_line_wide (word x_pos,word y_pos,word width);
void Vertical_XOR_line_wide (word x_pos,word y_pos,word height); void Vertical_XOR_line_wide (word x_pos,word y_pos,word height);
void Display_brush_color_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_wide (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_wide (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_wide (word width,word height,word image_width); void Display_part_of_screen_wide (word width,word height,word image_width);
void Display_line_on_screen_wide (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_wide (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_wide (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_wide (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_wide(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_wide(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_wide (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_wide (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_wide (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_wide (word x_pos,word y_pos,word width,byte * line);
void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color); void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color);

1035
pxwide2.c

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file pxwide2.h ///@file pxwide2.h
/// Renderer for double-wide pixels (4x2). /// Renderer for double-wide pixels (4x2).
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#include "struct.h" #include "struct.h"
void Pixel_wide2 (word x,word y,byte color); void Pixel_wide2 (word x,word y,byte color);
byte Read_pixel_wide2 (word x,word y); byte Read_pixel_wide2 (word x,word y);
void Block_wide2 (word start_x,word start_y,word width,word height,byte color); void Block_wide2 (word start_x,word start_y,word width,word height,byte color);
void Pixel_preview_normal_wide2 (word x,word y,byte color); void Pixel_preview_normal_wide2 (word x,word y,byte color);
void Pixel_preview_magnifier_wide2 (word x,word y,byte color); void Pixel_preview_magnifier_wide2 (word x,word y,byte color);
void Horizontal_XOR_line_wide2 (word x_pos,word y_pos,word width); void Horizontal_XOR_line_wide2 (word x_pos,word y_pos,word width);
void Vertical_XOR_line_wide2 (word x_pos,word y_pos,word height); void Vertical_XOR_line_wide2 (word x_pos,word y_pos,word height);
void Display_brush_color_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_color_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_mono_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width); void Display_brush_mono_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width); void Clear_brush_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_wide2 (word x_pos,word y_pos,word width,word height,byte * conversion_table); void Remap_screen_wide2 (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Display_part_of_screen_wide2 (word width,word height,word image_width); void Display_part_of_screen_wide2 (word width,word height,word image_width);
void Display_line_on_screen_wide2 (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_wide2 (word x_pos,word y_pos,word width,byte * line);
void Read_line_screen_wide2 (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_wide2 (word x_pos,word y_pos,word width,byte * line);
void Display_part_of_screen_scaled_wide2(word width,word height,word image_width,byte * buffer); void Display_part_of_screen_scaled_wide2(word width,word height,word image_width,byte * buffer);
void Display_brush_color_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer); void Display_brush_color_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_mono_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer); void Display_brush_mono_zoom_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_scaled_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer); void Clear_brush_scaled_wide2 (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Display_brush_wide2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width); void Display_brush_wide2 (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_line_on_screen_fast_wide2 (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_wide2 (word x_pos,word y_pos,word width,byte * line);

View File

@ -519,17 +519,10 @@ int Load_INI(T_Config * conf)
if ((return_code=Load_INI_get_values (file,buffer,"Menu_ratio",1,values))) if ((return_code=Load_INI_get_values (file,buffer,"Menu_ratio",1,values)))
goto Erreur_Retour; goto Erreur_Retour;
if ((values[0]<0) || (values[0]>2)) if (values[0]>2)
goto Erreur_ERREUR_INI_CORROMPU; goto Erreur_ERREUR_INI_CORROMPU;
conf->Ratio=values[0]; conf->Ratio=values[0];
if ((return_code=Load_INI_get_values (file,buffer,"Font",1,values)))
goto Erreur_Retour;
if ((values[0]<1) || (values[0]>2))
goto Erreur_ERREUR_INI_CORROMPU;
conf->Font=values[0]-1;
if ((return_code=Load_INI_reach_group(file,buffer,"[FILE_SELECTOR]"))) if ((return_code=Load_INI_reach_group(file,buffer,"[FILE_SELECTOR]")))
goto Erreur_Retour; goto Erreur_Retour;
@ -788,7 +781,7 @@ int Load_INI(T_Config * conf)
break; break;
} }
conf->Palette_vertical=0; conf->Palette_vertical=0;
// Optionnel, vertical palette option (>98.0%) // Optional, vertical palette option (>98.0%)
if (!Load_INI_get_values (file,buffer,"Palette_vertical",1,values)) if (!Load_INI_get_values (file,buffer,"Palette_vertical",1,values))
{ {
if ((values[0]<0) || (values[0]>1)) if ((values[0]<0) || (values[0]>1))
@ -804,7 +797,42 @@ int Load_INI(T_Config * conf)
conf->Window_pos_x = values[0]; conf->Window_pos_x = values[0];
conf->Window_pos_y = values[1]; conf->Window_pos_y = values[1];
} }
conf->Double_click_speed=500;
// Optional, speed of double-click (>2.0)
if (!Load_INI_get_values (file,buffer,"Double_click_speed",1,values))
{
if ((values[0]>0) || (values[0]<=2000))
conf->Double_click_speed=values[0];
}
conf->Double_key_speed=500;
// Optional, speed of double-keypress (>2.0)
if (!Load_INI_get_values (file,buffer,"Double_key_speed",1,values))
{
if ((values[0]>0) || (values[0]<=2000))
conf->Double_key_speed=values[0];
}
// Optional, name of skin file. (>2.0)
if(!Load_INI_get_string(file,buffer,"Skin_file",value_label,1))
conf->Skin_file = strdup(value_label);
else
conf->Skin_file = strdup("skin_modern.png");
// Optional, name of font file. (>2.0)
if(!Load_INI_get_string(file,buffer,"Font_file",value_label,1))
conf->Font_file = strdup(value_label);
else
conf->Font_file = strdup("font_Classic.png");
conf->Grid_XOR_color=255;
// Optional, XOR color for grid overlay (>2.0)
if (!Load_INI_get_values (file,buffer,"Grid_XOR_color",1,values))
{
if ((values[0]>0) || (values[0]<=255))
conf->Grid_XOR_color=values[0];
}
fclose(file); fclose(file);

View File

@ -1,27 +1,27 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file readini.h ///@file readini.h
/// Reading settings in gfx2.ini /// Reading settings in gfx2.ini
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int Load_INI(T_Config * conf); int Load_INI(T_Config * conf);
int Load_INI_seek_pattern(char * buffer,char * pattern); int Load_INI_seek_pattern(char * buffer,char * pattern);
void Load_INI_clear_string(char * str, byte keep_comments); void Load_INI_clear_string(char * str, byte keep_comments);

View File

@ -1,350 +1,353 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
/************************************************************************ /************************************************************************
* * * *
* READLINE (procédure permettant de saisir une chaîne de caractères) * * READLINE (procédure permettant de saisir une chaîne de caractères) *
* * * *
************************************************************************/ ************************************************************************/
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "const.h" #include "const.h"
#include "struct.h" #include "struct.h"
#include "global.h" #include "global.h"
#include "misc.h" #include "misc.h"
#include "errors.h" #include "errors.h"
#include "const.h" #include "const.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "readline.h" #include "readline.h"
#include "windows.h" #include "windows.h"
#include "input.h" #include "input.h"
#define TEXT_COLOR MC_Black #define TEXT_COLOR MC_Black
#define BACKGROUND_COLOR MC_Light #define BACKGROUND_COLOR MC_Light
#define CURSOR_COLOR MC_Black #define CURSOR_COLOR MC_Black
#define CURSOR_BACKGROUND_COLOR MC_Dark #define CURSOR_BACKGROUND_COLOR MC_Dark
// Suppresion d'un caractère à une certaine POSITION dans une CHAINE. // Suppresion d'un caractère à une certaine POSITION dans une CHAINE.
void Remove_character(char * str, byte position) void Remove_character(char * str, byte position)
{ {
for (;str[position]!='\0';position++) for (;str[position]!='\0';position++)
str[position]=str[position+1]; str[position]=str[position+1];
} }
void Insert_character(char * str, char letter, byte position) void Insert_character(char * str, char letter, byte position)
// Insertion d'une LETTRE à une certaine POSITION // Insertion d'une LETTRE à une certaine POSITION
// dans une CHAINE d'une certaine TAILLE. // dans une CHAINE d'une certaine TAILLE.
{ {
char temp_char; char temp_char;
for (;letter!='\0';position++) for (;letter!='\0';position++)
{ {
// On mémorise le caractère qui se trouve en "position" // On mémorise le caractère qui se trouve en "position"
temp_char=str[position]; temp_char=str[position];
// On splotch la lettre à insérer // On splotch la lettre à insérer
str[position]=letter; str[position]=letter;
// On place le caractère mémorisé dans "letter" comme nouvelle lettre à insérer // On place le caractère mémorisé dans "letter" comme nouvelle lettre à insérer
letter=temp_char; letter=temp_char;
} }
// On termine la chaine // On termine la chaine
str[position]='\0'; str[position]='\0';
} }
int Valid_character(int c) int Valid_character(int c)
{ {
// Sous Linux: Seul le / est strictement interdit, mais beaucoup // Sous Linux: Seul le / est strictement interdit, mais beaucoup
// d'autres poseront des problèmes au shell, alors on évite. // d'autres poseront des problèmes au shell, alors on évite.
// Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons. // Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons.
// AmigaOS4: Pas de ':' car utilisé pour les volumes. // AmigaOS4: Pas de ':' car utilisé pour les volumes.
#if defined(__WIN32__) #if defined(__WIN32__)
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'};
#elif defined (__amigaos4__) #elif defined (__amigaos4__)
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'};
#else #else
char forbidden_char[] = {'/', '|', '?', '*', '<', '>'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>'};
#endif #endif
int position; int position;
if (c < ' ' || c > 255) if (c < ' ' || c > 255)
return 0; return 0;
for (position=0; position<(long)sizeof(forbidden_char); position++) for (position=0; position<(long)sizeof(forbidden_char); position++)
if (c == forbidden_char[position]) if (c == forbidden_char[position])
return 0; return 0;
return 1; return 1;
} }
void Display_whole_string(word x_pos,word y_pos,char * str,byte position) void Display_whole_string(word x_pos,word y_pos,char * str,byte position)
{ {
Print_in_window(x_pos,y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); Print_in_window(x_pos,y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
Print_char_in_window(x_pos+(position<<3),y_pos,str[position],CURSOR_COLOR,CURSOR_BACKGROUND_COLOR); Print_char_in_window(x_pos+(position<<3),y_pos,str[position],CURSOR_COLOR,CURSOR_BACKGROUND_COLOR);
} }
/**************************************************************************** /****************************************************************************
* Enhanced super scanf deluxe pro plus giga mieux :-) * * Enhanced super scanf deluxe pro plus giga mieux :-) *
****************************************************************************/ ****************************************************************************/
byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type) byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type)
// Paramètres: // Paramètres:
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre // x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
// str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale) // str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
// max_size : Nombre de caractères logeant dans la zone de saisie // max_size : Nombre de caractères logeant dans la zone de saisie
// input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier // input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier
// Sortie: // Sortie:
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return) // 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
{ {
byte max_size; byte max_size;
// Grosse astuce pour les noms de fichiers: La taille affichée est différente // Grosse astuce pour les noms de fichiers: La taille affichée est différente
// de la taille maximum gérée. // de la taille maximum gérée.
if (input_type == 2) if (input_type == 2)
max_size = 255; max_size = 255;
else else
max_size = visible_size; max_size = visible_size;
return Readline_ex(x_pos,y_pos,str,visible_size,max_size,input_type); return Readline_ex(x_pos,y_pos,str,visible_size,max_size,input_type);
} }
/**************************************************************************** /****************************************************************************
* Enhanced super scanf deluxe pro plus giga mieux :-) * * Enhanced super scanf deluxe pro plus giga mieux :-) *
****************************************************************************/ ****************************************************************************/
byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type) byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type)
// Paramètres: // Paramètres:
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre // x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
// str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale) // str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
// max_size : Nombre de caractères logeant dans la zone de saisie // max_size : Nombre de caractères logeant dans la zone de saisie
// input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier // input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier
// Sortie: // Sortie:
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return) // 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
{ {
char initial_string[256]; char initial_string[256];
char display_string[256]; char display_string[256];
byte position; byte position;
byte size; byte size;
word input_key=0; word input_key=0;
byte is_authorized; byte is_authorized;
byte offset=0; // index du premier caractère affiché byte offset=0; // index du premier caractère affiché
Hide_cursor(); // Si on a commencé à editer par un clic-droit, on vide la chaine.
// Effacement de la chaîne if (Mouse_K==RIGHT_SIDE)
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), str[0]='\0';
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); else if (input_type==1)
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), snprintf(str,10,"%d",atoi(str)); // On tasse la chaine à gauche
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
Wait_end_of_click();
// Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale Keyboard_click_allowed = 0;
strcpy(initial_string,str); Hide_cursor();
// Si on a commencé à editer par un clic-droit, on vide la chaine. // Effacement de la chaîne
if (Mouse_K==RIGHT_SIDE) Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
str[0]='\0'; visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
else if (input_type==1) Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
snprintf(str,10,"%d",atoi(str)); // On tasse la chaine à gauche visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
// Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale
size=strlen(str); strcpy(initial_string,str);
position=(size<max_size)? size:size-1;
if (position-offset>visible_size) size=strlen(str);
offset=position-visible_size+1; position=(size<max_size)? size:size-1;
// Formatage d'une partie de la chaine (si trop longue pour tenir) if (position-offset>visible_size)
strncpy(display_string, str + offset, visible_size); offset=position-visible_size+1;
display_string[visible_size]='\0'; // Formatage d'une partie de la chaine (si trop longue pour tenir)
if (offset>0) strncpy(display_string, str + offset, visible_size);
display_string[0]=LEFT_TRIANGLE_CHARACTER; display_string[visible_size]='\0';
if (visible_size + offset + 1 < size ) if (offset>0)
display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER; display_string[0]=LEFT_TRIANGLE_CHARACTER;
if (visible_size + offset + 1 < size )
Display_whole_string(x_pos,y_pos,display_string,position - offset); display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER;
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3)); Display_whole_string(x_pos,y_pos,display_string,position - offset);
Flush_update(); Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC)) Flush_update();
{
Display_cursor(); while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC) && Mouse_K == 0)
do {
{ Display_cursor();
if(!Get_input()) SDL_Delay(20); do
input_key=Key_ANSI; {
} while(input_key==0); if(!Get_input()) SDL_Delay(20);
Hide_cursor(); input_key=Key_ANSI;
switch (input_key) } while(input_key==0 && Mouse_K == 0);
{ Hide_cursor();
case SDLK_DELETE : // Suppr. switch (input_key)
if (position<size) {
{ case SDLK_DELETE : // Suppr.
Remove_character(str,position); if (position<size)
size--; {
Remove_character(str,position);
// Effacement de la chaîne size--;
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); // Effacement de la chaîne
goto affichage; Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
} visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
break; goto affichage;
case SDLK_LEFT : // Gauche }
if (position>0) break;
{ case SDLK_LEFT : // Gauche
// Effacement de la chaîne if (position>0)
if (position==size) {
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), // Effacement de la chaîne
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); if (position==size)
position--; Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
if (offset > 0 && (position == 0 || position < (offset + 1))) visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
offset--; position--;
goto affichage; if (offset > 0 && (position == 0 || position < (offset + 1)))
} offset--;
break; goto affichage;
case SDLK_RIGHT : // Droite }
if ((position<size) && (position<max_size-1)) break;
{ case SDLK_RIGHT : // Droite
position++; if ((position<size) && (position<max_size-1))
//if (position > visible_size + offset - 2) {
//if (offset + visible_size < max_size && (position == size || (position > visible_size + offset - 2))) position++;
if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size) //if (position > visible_size + offset - 2)
offset++; //if (offset + visible_size < max_size && (position == size || (position > visible_size + offset - 2)))
goto affichage; if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size)
} offset++;
break; goto affichage;
case SDLK_HOME : // Home }
if (position) break;
{ case SDLK_HOME : // Home
// Effacement de la chaîne if (position)
if (position==size) {
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), // Effacement de la chaîne
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); if (position==size)
position = 0; Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
offset = 0; visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
goto affichage; position = 0;
} offset = 0;
break; goto affichage;
case SDLK_END : // End }
if ((position<size) && (position<max_size-1)) break;
{ case SDLK_END : // End
position=(size<max_size)?size:size-1; if ((position<size) && (position<max_size-1))
if (position-offset>visible_size) {
offset=position-visible_size+1; position=(size<max_size)?size:size-1;
goto affichage; if (position-offset>visible_size)
} offset=position-visible_size+1;
break; goto affichage;
case SDLK_BACKSPACE : // Backspace : combinaison de gauche + suppr }
break;
if (position) case SDLK_BACKSPACE : // Backspace : combinaison de gauche + suppr
{
position--; if (position)
if (offset > 0 && (position == 0 || position < (offset + 1))) {
offset--; position--;
Remove_character(str,position); if (offset > 0 && (position == 0 || position < (offset + 1)))
size--; offset--;
// Effacement de la chaîne Remove_character(str,position);
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), size--;
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR); // Effacement de la chaîne
goto affichage; Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
} visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
break; goto affichage;
case SDLK_RETURN : }
break; break;
case SDLK_RETURN :
case KEY_ESC : break;
// On restaure la chaine initiale
strcpy(str,initial_string); case KEY_ESC :
size=strlen(str); // On restaure la chaine initiale
break; strcpy(str,initial_string);
default : size=strlen(str);
if (size<max_size) break;
{ default :
// On va regarder si l'utilisateur le droit de se servir de cette touche if (size<max_size)
is_authorized=0; // On commence par supposer qu'elle est interdite {
switch(input_type) // On va regarder si l'utilisateur le droit de se servir de cette touche
{ is_authorized=0; // On commence par supposer qu'elle est interdite
case 0 : // N'importe quelle chaîne: switch(input_type)
if (input_key>=' ' && input_key<= 255) {
is_authorized=1; case 0 : // N'importe quelle chaîne:
break; if (input_key>=' ' && input_key<= 255)
case 1 : // Nombre is_authorized=1;
if ( (input_key>='0') && (input_key<='9') ) break;
is_authorized=1; case 1 : // Nombre
break; if ( (input_key>='0') && (input_key<='9') )
default : // Nom de fichier is_authorized=1;
// On regarde si la touche est autorisée break;
if ( Valid_character(input_key)) default : // Nom de fichier
is_authorized=1; // On regarde si la touche est autorisée
} // End du "switch(input_type)" if ( Valid_character(input_key))
is_authorized=1;
// Si la touche était autorisée... } // End du "switch(input_type)"
if (is_authorized)
{ // Si la touche était autorisée...
// ... alors on l'insère ... if (is_authorized)
Insert_character(str,input_key,position/*,size*/); {
// ce qui augmente la taille de la chaine // ... alors on l'insère ...
size++; Insert_character(str,input_key,position/*,size*/);
// et qui risque de déplacer le curseur vers la droite // ce qui augmente la taille de la chaine
if (size<max_size) size++;
{ // et qui risque de déplacer le curseur vers la droite
position++; if (size<max_size)
if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size) {
offset++; position++;
} if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size)
// Enfin, on raffiche la chaine offset++;
goto affichage; }
} // End du test d'autorisation de touche // Enfin, on raffiche la chaine
} // End du test de place libre goto affichage;
break; } // End du test d'autorisation de touche
} // End du test de place libre
affichage: break;
size=strlen(str);
// Formatage d'une partie de la chaine (si trop longue pour tenir) affichage:
strncpy(display_string, str + offset, visible_size); size=strlen(str);
display_string[visible_size]='\0'; // Formatage d'une partie de la chaine (si trop longue pour tenir)
if (offset>0) strncpy(display_string, str + offset, visible_size);
display_string[0]=LEFT_TRIANGLE_CHARACTER; display_string[visible_size]='\0';
if (visible_size + offset + 0 < size ) if (offset>0)
display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER; display_string[0]=LEFT_TRIANGLE_CHARACTER;
if (visible_size + offset + 0 < size )
Display_whole_string(x_pos,y_pos,display_string,position - offset); display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER;
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3)); Display_whole_string(x_pos,y_pos,display_string,position - offset);
} // End du "switch(input_key)" Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Flush_update(); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
} // End du "switch(input_key)"
} // End du "while" Flush_update();
// Effacement de la chaîne } // End du "while"
Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), Keyboard_click_allowed = 1;
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
// On raffiche la chaine correctement // Effacement de la chaîne
if (input_type==1) Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
{ visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
if (str[0]=='\0') // On raffiche la chaine correctement
{ if (input_type==1)
strcpy(str,"0"); {
size=1; if (str[0]=='\0')
} {
Print_in_window(x_pos+((max_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); strcpy(str,"0");
} size=1;
else }
{ Print_in_window(x_pos+((max_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR); }
} else
Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y), {
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3)); Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR);
}
return (input_key==SDLK_RETURN); Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
} visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
return (input_key==SDLK_RETURN || Mouse_K != 0);
}

View File

@ -1,44 +1,44 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file readline.h ///@file readline.h
/// Text input functions. /// Text input functions.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// ///
/// Lets the user input a line of text, exit by Esc or Return. /// Lets the user input a line of text, exit by Esc or Return.
/// @param x_pos Coordinates of input, in window coordinates before scaling. /// @param x_pos Coordinates of input, in window coordinates before scaling.
/// @param y_pos Coordinates of input, in window coordinates before scaling. /// @param y_pos Coordinates of input, in window coordinates before scaling.
/// @param str The original string value (will be modified, unless user cancels. /// @param str The original string value (will be modified, unless user cancels.
/// @param visible_size Number of characters visible and editable. /// @param visible_size Number of characters visible and editable.
/// @param input_type 0=string, 1=number, 2=filename (255 editable characters) /// @param input_type 0=string, 1=number, 2=filename (255 editable characters)
/// @return 0 if user cancelled (esc), 1 if accepted (return) /// @return 0 if user cancelled (esc), 1 if accepted (return)
byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type); byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type);
/// ///
/// Lets the user input a line of text, exit by Esc or Return. /// Lets the user input a line of text, exit by Esc or Return.
/// @param x_pos Coordinates of input, in window coordinates before scaling. /// @param x_pos Coordinates of input, in window coordinates before scaling.
/// @param y_pos Coordinates of input, in window coordinates before scaling. /// @param y_pos Coordinates of input, in window coordinates before scaling.
/// @param str The original string value (will be modified, unless user cancels. /// @param str The original string value (will be modified, unless user cancels.
/// @param visible_size Number of characters visible. /// @param visible_size Number of characters visible.
/// @param max_size Number of characters editable. /// @param max_size Number of characters editable.
/// @param input_type 0=string, 1=number, 2=filename (255 editable characters) /// @param input_type 0=string, 1=number, 2=filename (255 editable characters)
/// @return 0 if user cancelled (esc), 1 if accepted (return) /// @return 0 if user cancelled (esc), 1 if accepted (return)
byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type); byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type);

View File

@ -93,6 +93,7 @@ int Save_INI_char_in_value_alphabet(char c)
(c<='z') (c<='z')
) || ) ||
(c == '$') // Symbole d'hexadécimal (c == '$') // Symbole d'hexadécimal
|| (c== '.') // Point (dans les noms de fichiers)
) )
return 1; return 1;
else else
@ -475,11 +476,6 @@ int Save_INI(T_Config * conf)
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Menu_ratio",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Menu_ratio",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=(conf->Font)+1;
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Font",1,values,0)))
goto Erreur_Retour;
if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[FILE_SELECTOR]"))) if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[FILE_SELECTOR]")))
goto Erreur_Retour; goto Erreur_Retour;
@ -635,6 +631,23 @@ int Save_INI(T_Config * conf)
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Window_position",2,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Window_position",2,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=(conf->Double_click_speed);
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Double_click_speed",1,values,0)))
goto Erreur_Retour;
values[0]=(conf->Double_key_speed);
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Double_key_speed",1,values,0)))
goto Erreur_Retour;
if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Skin_file",conf->Skin_file)))
goto Erreur_Retour;
if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Font_file",conf->Font_file)))
goto Erreur_Retour;
values[0]=(conf->Grid_XOR_color);
if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Grid_XOR_color",1,values,0)))
goto Erreur_Retour;
Save_INI_flush(Ancien_fichier,Nouveau_fichier,buffer); Save_INI_flush(Ancien_fichier,Nouveau_fichier,buffer);

View File

@ -1,25 +1,25 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file saveini.h ///@file saveini.h
/// Saving settings in gfx2.ini /// Saving settings in gfx2.ini
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int Save_INI(T_Config * conf); int Save_INI(T_Config * conf);

View File

@ -61,8 +61,9 @@ void Set_mode_SDL(int *width, int *height, int fullscreen)
Screen_pixels=Screen_SDL->pixels; Screen_pixels=Screen_SDL->pixels;
} }
else else
{
DEBUG("Error: Unable to change video mode!",0); DEBUG("Error: Unable to change video mode!",0);
}
SDL_ShowCursor(0); // Hide the SDL mouse cursor, we use our own SDL_ShowCursor(0); // Hide the SDL mouse cursor, we use our own
} }

363
setup.c
View File

@ -1,181 +1,182 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Peter Gordon Copyright 2008 Peter Gordon
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#if defined(__WIN32__) #if defined(__WIN32__)
#include <windows.h> #include <windows.h>
#include <io.h> // Mingw's _mkdir() #include <io.h> // Mingw's _mkdir()
#elif defined(__macosx__) #elif defined(__macosx__)
#import <corefoundation/corefoundation.h> #import <corefoundation/corefoundation.h>
#import <sys/param.h> #import <sys/param.h>
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
#import <sys/param.h> #import <sys/param.h>
#endif #endif
#include "struct.h" #include "struct.h"
#include "io.h" #include "io.h"
#include "setup.h" #include "setup.h"
int Create_ConfigDirectory(char * config_dir) int Create_ConfigDirectory(char * config_dir)
{ {
#ifdef __WIN32__ #ifdef __WIN32__
// Mingw's mkdir has a weird name and only one argument // Mingw's mkdir has a weird name and only one argument
return _mkdir(config_dir); return _mkdir(config_dir);
#else #else
return mkdir(config_dir,S_IRUSR|S_IWUSR|S_IXUSR); return mkdir(config_dir,S_IRUSR|S_IWUSR|S_IXUSR);
#endif #endif
} }
#if defined(__macosx__) || defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #if defined(__macosx__) || defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
#define ARG_UNUSED __attribute__((unused)) #define ARG_UNUSED __attribute__((unused))
#else #else
#define ARG_UNUSED #define ARG_UNUSED
#endif #endif
// Determine which directory contains the executable. // Determine which directory contains the executable.
// IN: Main's argv[0], some platforms need it, some don't. // IN: Main's argv[0], some platforms need it, some don't.
// OUT: Write into program_dir. Trailing / or \ is kept. // OUT: Write into program_dir. Trailing / or \ is kept.
// Note : in fact this is only used to check for the datafiles and fonts in this same directory. // Note : in fact this is only used to check for the datafiles and fonts in
void Set_program_directory(ARG_UNUSED const char * argv0,char * program_dir) // this same directory.
{ void Set_program_directory(ARG_UNUSED const char * argv0,char * program_dir)
#undef ARG_UNUSED {
#undef ARG_UNUSED
// MacOSX
#if defined(__macosx__) // MacOSX
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); #if defined(__macosx__)
CFURLGetFileSystemRepresentation(url,true,(UInt8*)program_dir,MAXPATHLEN); CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFRelease(url); CFURLGetFileSystemRepresentation(url,true,(UInt8*)program_dir,MAXPATHLEN);
// Append trailing slash CFRelease(url);
strcat(program_dir ,"/"); // Append trailing slash
strcat(program_dir ,"/");
// AmigaOS and alike: hard-coded volume name.
#elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) // AmigaOS and alike: hard-coded volume name.
strcpy(program_dir,"PROGDIR:"); #elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
strcpy(program_dir,"PROGDIR:");
// Others: The part of argv[0] before the executable name.
// Keep the last \ or /. // Others: The part of argv[0] before the executable name.
// Note that on Unix, once installed, the executable is called from a shell script // Keep the last \ or /.
// sitting in /usr/local/bin/, this allows argv[0] to contain the full path. // Note that on Unix, once installed, the executable is called from a shell
// On Windows, Mingw32 already provides the full path in all cases. // script sitting in /usr/local/bin/, this allows argv[0] to contain the full
#else // path. On Windows, Mingw32 already provides the full path in all cases.
Extract_path(program_dir, argv0); #else
#endif Extract_path(program_dir, argv0);
} #endif
}
// Determine which directory contains the read-only data.
// IN: The directory containing the executable // Determine which directory contains the read-only data.
// OUT: Write into data_dir. Trailing / or \ is kept. // IN: The directory containing the executable
void Set_data_directory(const char * program_dir, char * data_dir) // OUT: Write into data_dir. Trailing / or \ is kept.
{ void Set_data_directory(const char * program_dir, char * data_dir)
// On all platforms, data is in the executable's directory {
strcpy(data_dir,program_dir); // On all platforms, data is in the executable's directory
// Except MacOSX, here it is stored in a special folder: strcpy(data_dir,program_dir);
#if defined(__macosx__) // Except MacOSX, here it is stored in a special folder:
strcat(data_dir,"Contents/Resources/"); #if defined(__macosx__)
#endif strcat(data_dir,"Contents/Resources/");
} #endif
}
// Determine which directory should store the user's configuration.
// // Determine which directory should store the user's configuration.
// For most Unix and Windows platforms: //
// If a config file already exists in program_dir, it will return it in priority // For most Unix and Windows platforms:
// (Useful for development, and possibly for upgrading from DOS version) // If a config file already exists in program_dir, it will return it in priority
// If the standard directory doesn't exist yet, this function will attempt // (Useful for development, and possibly for upgrading from DOS version)
// to create it ($(HOME)/.grafx2, or %APPDATA%\GrafX2) // If the standard directory doesn't exist yet, this function will attempt
// If it cannot be created, this function will return the executable's // to create it ($(HOME)/.grafx2, or %APPDATA%\GrafX2)
// own directory. // If it cannot be created, this function will return the executable's
// IN: The directory containing the executable // own directory.
// OUT: Write into config_dir. Trailing / or \ is kept. // IN: The directory containing the executable
void Set_config_directory(const char * program_dir, char * config_dir) // OUT: Write into config_dir. Trailing / or \ is kept.
{ void Set_config_directory(const char * program_dir, char * config_dir)
// MacOSX {
#if defined(__macosx__) // AmigaOS4
strcpy(config_dir,program_dir); #if defined(__amigaos4__) || defined(__AROS__)
strcat(config_dir,"Contents/Resources/"); strcpy(config_dir,"PROGDIR:");
// AmigaOS4 // GP2X
#elif defined(__amigaos4__) || defined(__AROS__) #elif defined(__GP2X__)
strcpy(config_dir,"PROGDIR:"); // On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is
// GP2X // on an internal flash chip. So, keep these settings locals.
#elif defined(__GP2X__) strcpy(config_dir,program_dir);
// On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is #else
// on an internal flash chip. So, keep these settings locals. char filename[MAX_PATH_CHARACTERS];
strcpy(config_dir,program_dir);
#else // In priority: check own directory
char filename[MAX_PATH_CHARACTERS]; strcpy(config_dir, program_dir);
strcpy(filename, config_dir);
// In priority: check own directory strcat(filename, "gfx2.cfg");
strcpy(config_dir, program_dir);
strcpy(filename, config_dir); if (!File_exists(filename))
strcat(filename, "gfx2.cfg"); {
char *config_parent_dir;
if (!File_exists(filename)) #if defined(__WIN32__)
{ // "%APPDATA%\GrafX2"
char *config_parent_dir; const char* Config_SubDir = "GrafX2";
#if defined(__WIN32__) config_parent_dir = getenv("APPDATA");
// "%APPDATA%\GrafX2" #elif defined(__BEOS__) || defined(__HAIKU__)
const char* Config_SubDir = "GrafX2"; // "~/.grafx2", the BeOS way
config_parent_dir = getenv("APPDATA"); const char* Config_SubDir = ".grafx2";
#elif defined(__BEOS__) || defined(__HAIKU__) config_parent_dir = getenv("$HOME");
// "~/.grafx2", the BeOS way #elif defined(__macosx__)
const char* Config_SubDir = ".grafx2"; // "~/Library/Preferences/com.googlecode.grafx2"
config_parent_dir = getenv("$HOME"); const char* Config_SubDir = "Library/Preferences/com.googlecode.grafx2";
#else config_parent_dir = getenv("HOME");
// "~/.grafx2" #else
const char* Config_SubDir = ".grafx2"; // "~/.grafx2"
config_parent_dir = getenv("HOME"); const char* Config_SubDir = ".grafx2";
#endif config_parent_dir = getenv("HOME");
#endif
if (config_parent_dir && config_parent_dir[0]!='\0')
{ if (config_parent_dir && config_parent_dir[0]!='\0')
int size = strlen(config_parent_dir); {
strcpy(config_dir, config_parent_dir); int size = strlen(config_parent_dir);
if (config_parent_dir[size-1] != '\\' && config_parent_dir[size-1] != '/') strcpy(config_dir, config_parent_dir);
{ if (config_parent_dir[size-1] != '\\' && config_parent_dir[size-1] != '/')
strcat(config_dir,PATH_SEPARATOR); {
} strcat(config_dir,PATH_SEPARATOR);
strcat(config_dir,Config_SubDir); }
if (Directory_exists(config_dir)) strcat(config_dir,Config_SubDir);
{ if (Directory_exists(config_dir))
// Répertoire trouvé, ok {
strcat(config_dir,PATH_SEPARATOR); // Répertoire trouvé, ok
} strcat(config_dir,PATH_SEPARATOR);
else }
{ else
// Tentative de création {
if (!Create_ConfigDirectory(config_dir)) // Tentative de création
{ if (!Create_ConfigDirectory(config_dir))
// Réussi {
strcat(config_dir,PATH_SEPARATOR); // Réussi
} strcat(config_dir,PATH_SEPARATOR);
else }
{ else
// Echec: on se rabat sur le repertoire de l'executable. {
strcpy(config_dir,program_dir); // Echec: on se rabat sur le repertoire de l'executable.
} strcpy(config_dir,program_dir);
} }
} }
} }
#endif }
} #endif
}

108
setup.h
View File

@ -1,54 +1,54 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Peter Gordon Copyright 2008 Peter Gordon
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Franck Charlet Copyright 2008 Franck Charlet
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file setup.h ///@file setup.h
/// Functions that determine where grafx2 is running, finds its data, and /// Functions that determine where grafx2 is running, finds its data, and
/// reads and writes configuration files. /// reads and writes configuration files.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// ///
/// Determine which directory contains the executable. /// Determine which directory contains the executable.
/// - IN: Main's argv[0], some platforms need it, some don't. /// - IN: Main's argv[0], some platforms need it, some don't.
/// - OUT: Write into program_dir. Trailing / or \ is kept. /// - OUT: Write into program_dir. Trailing / or \ is kept.
/// Note : in fact this is only used to check for the datafiles and fonts in this same directory. /// Note : in fact this is only used to check for the datafiles and fonts in this same directory.
void Set_program_directory(const char * argv0,char * program_dir); void Set_program_directory(const char * argv0,char * program_dir);
/// ///
/// Determine which directory contains the read-only data. /// Determine which directory contains the read-only data.
/// IN: The directory containing the executable /// IN: The directory containing the executable
/// OUT: Write into data_dir. Trailing / or \ is kept. /// OUT: Write into data_dir. Trailing / or \ is kept.
void Set_data_directory(const char * program_dir, char * data_dir); void Set_data_directory(const char * program_dir, char * data_dir);
/// ///
/// Determine which directory should store the user's configuration. /// Determine which directory should store the user's configuration.
/// For most Unix and Windows platforms: /// For most Unix and Windows platforms:
/// If a config file already exists in program_dir, it will return it in priority /// If a config file already exists in program_dir, it will return it in priority
/// (Useful for development, and possibly for upgrading from DOS version) /// (Useful for development, and possibly for upgrading from DOS version)
/// If the standard directory doesn't exist yet, this function will attempt /// If the standard directory doesn't exist yet, this function will attempt
/// to create it ($(HOME)/.grafx2, or %APPDATA%\\GrafX2) /// to create it ($(HOME)/.grafx2, or %APPDATA%\\GrafX2)
/// If it cannot be created, this function will return the executable's /// If it cannot be created, this function will return the executable's
/// own directory. /// own directory.
/// IN: The directory containing the executable /// IN: The directory containing the executable
/// OUT: Write into config_dir. Trailing / or \ is kept. /// OUT: Write into config_dir. Trailing / or \ is kept.
void Set_config_directory(const char * program_dir, char * config_dir); void Set_config_directory(const char * program_dir, char * config_dir);

View File

@ -978,6 +978,8 @@ int Menu_shade(void)
Key=0; Key=0;
Window_help(BUTTON_EFFECTS, "SHADE"); Window_help(BUTTON_EFFECTS, "SHADE");
} }
else if (Is_shortcut(Key,SPECIAL_SHADE_MENU))
clicked_button=5;
} }
} }
while ((clicked_button!=4) && (clicked_button!=5)); while ((clicked_button!=4) && (clicked_button!=5));
@ -1097,6 +1099,8 @@ void Button_Quick_shade_menu(void)
} }
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
Window_help(BUTTON_EFFECTS, "QUICK SHADE"); Window_help(BUTTON_EFFECTS, "QUICK SHADE");
else if (Is_shortcut(Key,SPECIAL_QUICK_SHADE_MENU))
clicked_button=1;
} }
while ((clicked_button!=1) && (clicked_button!=2)); while ((clicked_button!=1) && (clicked_button!=2));

64
shade.h
View File

@ -1,32 +1,32 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file shade.h ///@file shade.h
/// Screens for Shade and Quick-shade settings. /// Screens for Shade and Quick-shade settings.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef SHADE_H_INCLUDED #ifndef SHADE_H_INCLUDED
#define SHADE_H_INCLUDED #define SHADE_H_INCLUDED
void Button_Quick_shade_menu(void); void Button_Quick_shade_menu(void);
int Shade_settings_menu(void); int Shade_settings_menu(void);
#endif // SHADE_H_INCLUDED #endif // SHADE_H_INCLUDED

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

BIN
skins/font_Classic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
skins/font_Fairlight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
skins/font_Fun.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
skins/font_Melon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

BIN
skins/skin_classic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
skins/skin_modern.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

777
special.c
View File

@ -1,364 +1,413 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "const.h" #include "const.h"
#include "struct.h" #include "struct.h"
#include "global.h" #include "global.h"
#include "graph.h" #include "graph.h"
#include "engine.h" #include "engine.h"
#include "windows.h" #include "windows.h"
#include "special.h" #include "special.h"
//---------------------- Modifier le pinceau spécial ------------------------- //---------------------- Modifier le pinceau spécial -------------------------
void Set_paintbrush_size(int width, int height) int Circle_squared_diameter(int diameter)
{ {
int x_pos,y_pos; int result = diameter*diameter;
int x,y; // Trick to make some circles rounder, even though
float radius2; // mathematically incorrect.
if (diameter==3 || diameter==9)
if (width<1) width=1; return result-2;
if (height<1) height=1; if (diameter==11)
if (width>MAX_PAINTBRUSH_SIZE) width=MAX_PAINTBRUSH_SIZE; return result-6;
if (height>MAX_PAINTBRUSH_SIZE) height=MAX_PAINTBRUSH_SIZE; if (diameter==14)
Paintbrush_width=width; return result-4;
Paintbrush_height=height;
Paintbrush_offset_X=Paintbrush_width>>1; return result;
Paintbrush_offset_Y=Paintbrush_height>>1; }
switch (Paintbrush_shape)
{ void Set_paintbrush_size(int width, int height)
case PAINTBRUSH_SHAPE_ROUND : {
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[ int x_pos,y_pos;
radius2*=radius2; int x,y;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) int radius2;
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ if (width<1) width=1;
x=x_pos-Paintbrush_offset_X; if (height<1) height=1;
y=y_pos-Paintbrush_offset_Y; if (width>MAX_PAINTBRUSH_SIZE) width=MAX_PAINTBRUSH_SIZE;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( ((x*x)+(y*y)) < radius2 ); if (height>MAX_PAINTBRUSH_SIZE) height=MAX_PAINTBRUSH_SIZE;
} Paintbrush_width=width;
break; Paintbrush_height=height;
case PAINTBRUSH_SHAPE_SQUARE : Paintbrush_offset_X=Paintbrush_width>>1;
for (x_pos=0,y_pos=0; x_pos<Paintbrush_height; x_pos++,y_pos+=MAX_PAINTBRUSH_SIZE) Paintbrush_offset_Y=Paintbrush_height>>1;
memset(Paintbrush_sprite+y_pos,1,Paintbrush_width); switch (Paintbrush_shape)
break; {
case PAINTBRUSH_SHAPE_SIEVE_ROUND : case PAINTBRUSH_SHAPE_ROUND :
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[ radius2=Circle_squared_diameter(Paintbrush_width);
radius2*=radius2;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0, y=1-Paintbrush_height; y_pos<Paintbrush_height; y_pos++,y+=2)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0, x=1-Paintbrush_width; x_pos<Paintbrush_width; x_pos++,x+=2)
{ {
x=x_pos-Paintbrush_offset_X; Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( ((x*x)+(y*y)) <= radius2 );
y=y_pos-Paintbrush_offset_Y; }
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (!((x_pos+y_pos)&1)) && (((x*x)+(y*y)) < radius2)); break;
} case PAINTBRUSH_SHAPE_SQUARE :
break; for (x_pos=0,y_pos=0; x_pos<Paintbrush_height; x_pos++,y_pos+=MAX_PAINTBRUSH_SIZE)
case PAINTBRUSH_SHAPE_SIEVE_SQUARE: memset(Paintbrush_sprite+y_pos,1,Paintbrush_width);
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) break;
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) case PAINTBRUSH_SHAPE_SIEVE_ROUND :
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=!((x_pos+y_pos)&1); {
break; int reminder=0;
case PAINTBRUSH_SHAPE_PLUS: if (Paintbrush_width==1)
x=Paintbrush_width>>1; reminder = 1;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) radius2=Circle_squared_diameter(Paintbrush_width);
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=((x_pos==x) || (y_pos==x));
break; for (y_pos=0, y=1-Paintbrush_height; y_pos<Paintbrush_height; y_pos++,y+=2)
case PAINTBRUSH_SHAPE_SLASH: for (x_pos=0, x=1-Paintbrush_width; x_pos<Paintbrush_width; x_pos++,x+=2)
x=Paintbrush_width>>1; {
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( ((x_pos+y_pos+reminder)&1) && (((x*x)+(y*y)) < radius2));
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) }
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==(Paintbrush_width-(y_pos+1))); break;
break; }
case PAINTBRUSH_SHAPE_ANTISLASH: case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
x=Paintbrush_width>>1; for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=!((x_pos+y_pos)&1);
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==y_pos); break;
break; case PAINTBRUSH_SHAPE_PLUS:
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR: x=Paintbrush_width>>1;
memset(Paintbrush_sprite,1,Paintbrush_width); for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
break; for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
case PAINTBRUSH_SHAPE_VERTICAL_BAR: Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=((x_pos==x) || (y_pos==x));
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) break;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)]=1; case PAINTBRUSH_SHAPE_SLASH:
break; x=Paintbrush_width>>1;
case PAINTBRUSH_SHAPE_CROSS: for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
x=Paintbrush_width>>1; for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==(Paintbrush_width-(y_pos+1)));
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) break;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (x_pos==y_pos) || (x_pos==(Paintbrush_height-(y_pos+1))) ); case PAINTBRUSH_SHAPE_ANTISLASH:
break; x=Paintbrush_width>>1;
case PAINTBRUSH_SHAPE_DIAMOND: for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
x=Paintbrush_width>>1; for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==y_pos);
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) break;
{ case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
if (x_pos<=x) memset(Paintbrush_sprite,1,Paintbrush_width);
y=x-x_pos; break;
else case PAINTBRUSH_SHAPE_VERTICAL_BAR:
y=x_pos-x; for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
if (y_pos<=x) Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)]=1;
y+=x-y_pos; break;
else case PAINTBRUSH_SHAPE_CROSS:
y+=y_pos-x; x=Paintbrush_width>>1;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(y<=x); for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
} for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
break; Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (x_pos==y_pos) || (x_pos==(Paintbrush_height-(y_pos+1))) );
case PAINTBRUSH_SHAPE_RANDOM: break;
radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[ case PAINTBRUSH_SHAPE_DIAMOND:
radius2*=radius2; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Paintbrush_height; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Paintbrush_width; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
x=x_pos-Paintbrush_offset_X; if (x_pos<=x)
y=y_pos-Paintbrush_offset_Y; y=x-x_pos;
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (((x*x)+(y*y)) < radius2) && (!(rand()&7)) ); else
} y=x_pos-x;
} if (y_pos<=x)
} y+=x-y_pos;
else
void Smaller_paintbrush(void) y+=y_pos-x;
{ Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(y<=x);
if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC) }
&& ( (Paintbrush_width>1) break;
|| (Paintbrush_height>1) ) ) case PAINTBRUSH_SHAPE_RANDOM:
{ // Init with blank
Hide_cursor(); for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
switch (Paintbrush_shape) memset(Paintbrush_sprite+y_pos*MAX_PAINTBRUSH_SIZE,0,Paintbrush_width);
{
case PAINTBRUSH_SHAPE_ROUND: radius2=Circle_squared_diameter(Paintbrush_width);
case PAINTBRUSH_SHAPE_SIEVE_ROUND:
case PAINTBRUSH_SHAPE_CROSS: for (y_pos=0, y=1-Paintbrush_height; y_pos<Paintbrush_height; y_pos++,y+=2)
case PAINTBRUSH_SHAPE_PLUS: for (x_pos=0, x=1-Paintbrush_width; x_pos<Paintbrush_width; x_pos++,x+=2)
case PAINTBRUSH_SHAPE_DIAMOND: {
case PAINTBRUSH_SHAPE_RANDOM: if ((x*x)+(y*y) < radius2 && !(rand()&7))
if (Paintbrush_width&1) {
Set_paintbrush_size(Paintbrush_width-2,Paintbrush_height-2); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=1;
else // This prevents having a pixels that touch each other.
Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1); if (x_pos>0)
break; Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos-1]=0;
case PAINTBRUSH_SHAPE_SQUARE: if (y_pos>0)
case PAINTBRUSH_SHAPE_SLASH: Paintbrush_sprite[((y_pos-1)*MAX_PAINTBRUSH_SIZE)+x_pos]=0;
case PAINTBRUSH_SHAPE_ANTISLASH: }
case PAINTBRUSH_SHAPE_SIEVE_SQUARE: }
Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1); }
break; }
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
Set_paintbrush_size(Paintbrush_width-1,1); void Smaller_paintbrush(void)
break; {
case PAINTBRUSH_SHAPE_VERTICAL_BAR: if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
Set_paintbrush_size(1,Paintbrush_height-1); && ( (Paintbrush_width>1)
} || (Paintbrush_height>1) ) )
Display_paintbrush_in_menu(); {
Display_cursor(); Hide_cursor();
} switch (Paintbrush_shape)
} {
case PAINTBRUSH_SHAPE_CROSS:
void Bigger_paintbrush(void) case PAINTBRUSH_SHAPE_PLUS:
{ case PAINTBRUSH_SHAPE_DIAMOND:
if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC) if (Paintbrush_width&1)
&& ( (Paintbrush_width<MAX_PAINTBRUSH_SIZE) Set_paintbrush_size(Paintbrush_width-2,Paintbrush_height-2);
|| (Paintbrush_height<MAX_PAINTBRUSH_SIZE) ) ) else
{ Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
Hide_cursor(); break;
switch (Paintbrush_shape) case PAINTBRUSH_SHAPE_SQUARE:
{ case PAINTBRUSH_SHAPE_SLASH:
case PAINTBRUSH_SHAPE_ROUND: case PAINTBRUSH_SHAPE_ANTISLASH:
case PAINTBRUSH_SHAPE_SIEVE_ROUND: case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
case PAINTBRUSH_SHAPE_RANDOM: case PAINTBRUSH_SHAPE_ROUND:
case PAINTBRUSH_SHAPE_CROSS: case PAINTBRUSH_SHAPE_SIEVE_ROUND:
case PAINTBRUSH_SHAPE_PLUS: case PAINTBRUSH_SHAPE_RANDOM:
case PAINTBRUSH_SHAPE_DIAMOND: Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
if (Paintbrush_width&1) break;
Set_paintbrush_size(Paintbrush_width+2,Paintbrush_height+2); case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
else Set_paintbrush_size(Paintbrush_width-1,1);
Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1); break;
break; case PAINTBRUSH_SHAPE_VERTICAL_BAR:
case PAINTBRUSH_SHAPE_SQUARE: Set_paintbrush_size(1,Paintbrush_height-1);
case PAINTBRUSH_SHAPE_SLASH: }
case PAINTBRUSH_SHAPE_ANTISLASH: Display_paintbrush_in_menu();
case PAINTBRUSH_SHAPE_SIEVE_SQUARE: Display_cursor();
Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1); }
break; }
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
Set_paintbrush_size(Paintbrush_width+1,1); void Bigger_paintbrush(void)
break; {
case PAINTBRUSH_SHAPE_VERTICAL_BAR: if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
Set_paintbrush_size(1,Paintbrush_height+1); && ( (Paintbrush_width<MAX_PAINTBRUSH_SIZE)
} || (Paintbrush_height<MAX_PAINTBRUSH_SIZE) ) )
Display_paintbrush_in_menu(); {
Display_cursor(); Hide_cursor();
} switch (Paintbrush_shape)
} {
case PAINTBRUSH_SHAPE_CROSS:
case PAINTBRUSH_SHAPE_PLUS:
//--------------------- Increase the ForeColor ----------------------- case PAINTBRUSH_SHAPE_DIAMOND:
void Special_next_forecolor(void) if (Paintbrush_width&1)
{ Set_paintbrush_size(Paintbrush_width+2,Paintbrush_height+2);
Hide_cursor(); else
Set_fore_color(Fore_color+1); Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1);
Display_cursor(); break;
} case PAINTBRUSH_SHAPE_SQUARE:
case PAINTBRUSH_SHAPE_SLASH:
//--------------------- Decrease the ForeColor ----------------------- case PAINTBRUSH_SHAPE_ANTISLASH:
void Special_previous_forecolor(void) case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
{ case PAINTBRUSH_SHAPE_ROUND:
Hide_cursor(); case PAINTBRUSH_SHAPE_SIEVE_ROUND:
Set_fore_color(Fore_color-1); case PAINTBRUSH_SHAPE_RANDOM:
Display_cursor(); Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1);
} break;
case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
//--------------------- Increase the BackColor ----------------------- Set_paintbrush_size(Paintbrush_width+1,1);
void Special_next_backcolor(void) break;
{ case PAINTBRUSH_SHAPE_VERTICAL_BAR:
Hide_cursor(); Set_paintbrush_size(1,Paintbrush_height+1);
Set_back_color(Back_color+1); }
Display_cursor(); Display_paintbrush_in_menu();
} Display_cursor();
}
//--------------------- Decrease the BackColor ----------------------- }
void Special_previous_backcolor(void)
{
Hide_cursor(); //--------------------- Increase the ForeColor -----------------------
Set_back_color(Back_color-1); void Special_next_forecolor(void)
Display_cursor(); {
} Hide_cursor();
Set_fore_color(Fore_color+1);
/// Picks the next foreground color, according to current shade table Display_cursor();
void Special_next_user_forecolor(void) }
{
Hide_cursor(); //--------------------- Decrease the ForeColor -----------------------
Set_fore_color(Shade_table_left[Fore_color]); void Special_previous_forecolor(void)
Display_cursor(); {
} Hide_cursor();
Set_fore_color(Fore_color-1);
/// Picks the previous foreground color, according to current shade table Display_cursor();
void Special_previous_user_forecolor(void) }
{
Hide_cursor(); //--------------------- Increase the BackColor -----------------------
Set_fore_color(Shade_table_right[Fore_color]); void Special_next_backcolor(void)
Display_cursor(); {
} Hide_cursor();
Set_back_color(Back_color+1);
/// Picks the next background color, according to current shade table Display_cursor();
void Special_next_user_backcolor(void) }
{
Hide_cursor(); //--------------------- Decrease the BackColor -----------------------
Set_back_color(Shade_table_left[Back_color]); void Special_previous_backcolor(void)
Display_cursor(); {
} Hide_cursor();
Set_back_color(Back_color-1);
/// Picks the previous background color, according to current shade table Display_cursor();
void Special_previous_user_backcolor(void) }
{
Hide_cursor(); /// Picks the next foreground color, according to current shade table
Set_back_color(Shade_table_right[Back_color]); void Special_next_user_forecolor(void)
Display_cursor(); {
} Hide_cursor();
Set_fore_color(Shade_table_left[Fore_color]);
// ------------------- Scroller l'écran (pas en mode loupe) ------------------ Display_cursor();
void Scroll_screen(short delta_x,short delta_y) }
{
short temp_x_offset; /// Picks the previous foreground color, according to current shade table
short temp_y_offset; void Special_previous_user_forecolor(void)
{
temp_x_offset=Main_offset_X+delta_x; Hide_cursor();
temp_y_offset=Main_offset_Y+delta_y; Set_fore_color(Shade_table_right[Fore_color]);
Display_cursor();
if (temp_x_offset+Screen_width>Main_image_width) }
temp_x_offset=Main_image_width-Screen_width;
if (temp_y_offset+Menu_Y>Main_image_height) /// Picks the next background color, according to current shade table
temp_y_offset=Main_image_height-Menu_Y; void Special_next_user_backcolor(void)
if (temp_x_offset<0) {
temp_x_offset=0; Hide_cursor();
if (temp_y_offset<0) Set_back_color(Shade_table_left[Back_color]);
temp_y_offset=0; Display_cursor();
}
if ( (Main_offset_X!=temp_x_offset) ||
(Main_offset_Y!=temp_y_offset) ) /// Picks the previous background color, according to current shade table
{ void Special_previous_user_backcolor(void)
Hide_cursor(); {
Main_offset_X=temp_x_offset; Hide_cursor();
Main_offset_Y=temp_y_offset; Set_back_color(Shade_table_right[Back_color]);
Display_cursor();
Compute_limits(); }
Compute_paintbrush_coordinates();
// ------------------- Scroller l'écran (pas en mode loupe) ------------------
Display_all_screen(); // <=> Display_screen + Display_image_limits void Scroll_screen(short delta_x,short delta_y)
Display_cursor(); {
} short temp_x_offset;
} short temp_y_offset;
temp_x_offset=Main_offset_X+delta_x;
// ---------------------- Scroller la fenêtre de la loupe -------------------- temp_y_offset=Main_offset_Y+delta_y;
void Scroll_magnifier(short delta_x,short delta_y)
{ if (temp_x_offset+Screen_width>Main_image_width)
short temp_x_offset; temp_x_offset=Main_image_width-Screen_width;
short temp_y_offset; if (temp_y_offset+Menu_Y>Main_image_height)
temp_y_offset=Main_image_height-Menu_Y;
temp_x_offset=Main_magnifier_offset_X+delta_x; if (temp_x_offset<0)
temp_y_offset=Main_magnifier_offset_Y+delta_y; temp_x_offset=0;
if (temp_y_offset<0)
if (temp_x_offset+Main_magnifier_width>Main_image_width) temp_y_offset=0;
temp_x_offset=Main_image_width-Main_magnifier_width;
if (temp_y_offset+Main_magnifier_height>Main_image_height) if ( (Main_offset_X!=temp_x_offset) ||
temp_y_offset=Main_image_height-Main_magnifier_height; (Main_offset_Y!=temp_y_offset) )
if (temp_x_offset<0) {
temp_x_offset=0; Hide_cursor();
if (temp_y_offset<0) Main_offset_X=temp_x_offset;
temp_y_offset=0; Main_offset_Y=temp_y_offset;
if ( (Main_magnifier_offset_X!=temp_x_offset) || Compute_limits();
(Main_magnifier_offset_Y!=temp_y_offset) ) Compute_paintbrush_coordinates();
{
Hide_cursor(); Display_all_screen(); // <=> Display_screen + Display_image_limits
Main_magnifier_offset_X=temp_x_offset; Display_cursor();
Main_magnifier_offset_Y=temp_y_offset; }
}
Position_screen_according_to_zoom();
Compute_limits(); // ---------------------- Scroller la fenêtre de la loupe --------------------
Compute_paintbrush_coordinates(); void Scroll_magnifier(short delta_x,short delta_y)
{
Display_all_screen(); short temp_x_offset;
Display_cursor(); short temp_y_offset;
}
} temp_x_offset=Main_magnifier_offset_X+delta_x;
temp_y_offset=Main_magnifier_offset_Y+delta_y;
// -------------- Changer le Zoom (grâce aux touches [+] et [-]) ------------- if (temp_x_offset+Main_magnifier_width>Main_image_width)
void Zoom(short delta) temp_x_offset=Main_image_width-Main_magnifier_width;
{ if (temp_y_offset+Main_magnifier_height>Main_image_height)
short index; temp_y_offset=Main_image_height-Main_magnifier_height;
for (index=0; ZOOM_FACTOR[index]!=Main_magnifier_factor; index++); if (temp_x_offset<0)
index+=delta; temp_x_offset=0;
if (temp_y_offset<0)
if ( (index>=0) && (index<NB_ZOOM_FACTORS) ) temp_y_offset=0;
{
Hide_cursor(); if ( (Main_magnifier_offset_X!=temp_x_offset) ||
Change_magnifier_factor(index); (Main_magnifier_offset_Y!=temp_y_offset) )
if (Main_magnifier_mode) {
Display_all_screen(); Hide_cursor();
Display_cursor(); Main_magnifier_offset_X=temp_x_offset;
} Main_magnifier_offset_Y=temp_y_offset;
}
Position_screen_according_to_zoom();
Compute_limits();
Compute_paintbrush_coordinates();
Display_all_screen();
Display_cursor();
}
}
// -------------- Changer le Zoom (grâce aux touches [+] et [-]) -------------
void Zoom(short delta)
{
short index;
for (index=0; ZOOM_FACTOR[index]!=Main_magnifier_factor; index++);
index+=delta;
if ( (index>=0) && (index<NB_ZOOM_FACTORS) )
{
Hide_cursor();
Change_magnifier_factor(index);
if (Main_magnifier_mode)
Display_all_screen();
Display_cursor();
}
}
/**
Set zoom value. Negative value means no zoom.
*/
void Zoom_set(int index)
{
Hide_cursor();
if (index<0)
{
/* Zoom 1:1 */
if (Main_magnifier_mode)
Unselect_button(BUTTON_MAGNIFIER);
}
else
{
Change_magnifier_factor(index);
if (!Main_magnifier_mode)
Select_button(BUTTON_MAGNIFIER,1);
Display_all_screen();
}
Display_cursor();
}

View File

@ -1,43 +1,48 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file special.h ///@file special.h
/// Editor functions that can be hooked to a keyboard shortcut, but don't have /// Editor functions that can be hooked to a keyboard shortcut, but don't have
/// a menu button associated to them. /// a menu button associated to them.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void Set_paintbrush_size(int width, int height); void Set_paintbrush_size(int width, int height);
void Smaller_paintbrush(void); void Smaller_paintbrush(void);
void Bigger_paintbrush(void); void Bigger_paintbrush(void);
void Special_next_forecolor(void); void Special_next_forecolor(void);
void Special_previous_forecolor(void); void Special_previous_forecolor(void);
void Special_next_backcolor(void); void Special_next_backcolor(void);
void Special_previous_backcolor(void); void Special_previous_backcolor(void);
void Special_next_user_forecolor(void); void Special_next_user_forecolor(void);
void Special_previous_user_forecolor(void); void Special_previous_user_forecolor(void);
void Special_next_user_backcolor(void); void Special_next_user_backcolor(void);
void Special_previous_user_backcolor(void); void Special_previous_user_backcolor(void);
void Scroll_screen(short delta_x,short delta_y); void Scroll_screen(short delta_x,short delta_y);
void Scroll_magnifier(short delta_x,short delta_y); void Scroll_magnifier(short delta_x,short delta_y);
void Zoom(short delta); void Zoom(short delta);
void Zoom_set(int index);
void Display_stored_brush_in_window(word x,word y,int number);
void Store_brush(int index);
byte Restore_brush(int index);

731
struct.h
View File

@ -1,307 +1,424 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file struct.h ///@file struct.h
/// Structures that can be used in the whole program. /// Structures that can be used in the whole program.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#ifndef _STRUCT_H_ #ifndef _STRUCT_H_
#define _STRUCT_H_ #define _STRUCT_H_
#if defined(__BEOS__) #if defined(__BEOS__)
#include <inttypes.h> #include <inttypes.h>
#else #else
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "const.h" #include "const.h"
// Definition of the base data types
/// 8bit unsigned integer // POSIX calls it strcasecmp, Windows uses stricmp... no ANSI standard.
#define byte uint8_t #ifdef WIN32
/// 16bit unsigned integer #define strcasecmp stricmp
#define word uint16_t #endif
/// 32bit unsigned integer
#define dword uint32_t // Definition of the base data types
/// 64bit unsigned integer /// 8bit unsigned integer
#define qword uint64_t #define byte uint8_t
/// 16bit unsigned integer
// Named function prototypes #define word uint16_t
typedef void (* Func_action) (void); /// 32bit unsigned integer
typedef void (* Func_pixel) (word,word,byte); #define dword uint32_t
typedef byte (* Func_read) (word,word); /// 64bit unsigned integer
typedef void (* Func_clear) (byte); #define qword uint64_t
typedef void (* Func_display) (word,word,word);
typedef byte (* Func_effect) (word,word,byte); // Named function prototypes
typedef void (* Func_block) (word,word,word,word,byte); typedef void (* Func_action) (void);
typedef void (* Func_line_XOR) (word,word,word); typedef void (* Func_pixel) (word,word,byte);
typedef void (* Func_display_brush_color) (word,word,word,word,word,word,byte,word); typedef byte (* Func_read) (word,word);
typedef void (* Func_display_brush_mono) (word,word,word,word,word,word,byte,byte,word); typedef void (* Func_clear) (byte);
typedef void (* Func_gradient) (long,short,short); typedef void (* Func_display) (word,word,word);
typedef void (* Func_remap) (word,word,word,word,byte *); typedef byte (* Func_effect) (word,word,byte);
typedef void (* Func_procsline) (word,word,word,byte *); typedef void (* Func_block) (word,word,word,word,byte);
typedef void (* Func_display_zoom) (word,word,word,byte *); typedef void (* Func_line_XOR) (word,word,word);
typedef void (* Func_display_brush_color_zoom) (word,word,word,word,word,word,byte,word,byte *); typedef void (* Func_display_brush_color) (word,word,word,word,word,word,byte,word);
typedef void (* Func_display_brush_mono_zoom) (word,word,word,word,word,word,byte,byte,word,byte *); typedef void (* Func_display_brush_mono) (word,word,word,word,word,word,byte,byte,word);
typedef void (* Func_draw_brush) (byte *,word,word,word,word,word,word,byte,word); typedef void (* Func_gradient) (long,short,short);
typedef void (* Func_remap) (word,word,word,word,byte *);
/// A set of RGB values. typedef void (* Func_procsline) (word,word,word,byte *);
typedef struct typedef void (* Func_display_zoom) (word,word,word,byte *);
{ typedef void (* Func_display_brush_color_zoom) (word,word,word,word,word,word,byte,word,byte *);
byte R; ///< Red typedef void (* Func_display_brush_mono_zoom) (word,word,word,word,word,word,byte,byte,word,byte *);
byte G; ///< Green typedef void (* Func_draw_brush) (byte *,word,word,word,word,word,word,byte,word);
byte B; ///< Blue typedef void (* Func_draw_list_item) (word,word,word,byte);
}__attribute__ ((__packed__)) T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes).
/// A set of RGB values.
/// A normal rectangular button in windows and menus. typedef struct
typedef struct T_Normal_button {
{ byte R; ///< Red
short Number; ///< Unique identifier for all controls byte G; ///< Green
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. byte B; ///< Blue
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. }__attribute__ ((__packed__)) T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes).
word Width; ///< Width before scaling
word Height; ///< Height before scaling /// A normal rectangular button in windows and menus.
byte Clickable; ///< Boolean, unused. typedef struct T_Normal_button
byte Repeatable; ///< Boolean, true if the button activates repeatedly until you release the mouse button. Used for "+" buttons, for example. {
word Shortcut; ///< Keyboard shortcut that will emulate a click on this button. short Number; ///< Unique identifier for all controls
struct T_Normal_button * Next;///< Pointer to the next normal button of current window. word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
} T_Normal_button; word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
word Width; ///< Width before scaling
/// A window control that shows a complete 256-color palette word Height; ///< Height before scaling
typedef struct T_Palette_button byte Clickable; ///< Boolean, unused.
{ byte Repeatable; ///< Boolean, true if the button activates repeatedly until you release the mouse button. Used for "+" buttons, for example.
short Number; ///< Unique identifier for all controls word Shortcut; ///< Keyboard shortcut that will emulate a click on this button.
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. struct T_Normal_button * Next;///< Pointer to the next normal button of current window.
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. } T_Normal_button;
struct T_Palette_button * Next;///< Pointer to the next palette of current window.
} T_Palette_button; /// A window control that shows a complete 256-color palette
typedef struct T_Palette_button
/// A window control that represents a vertical scrollbar, with a slider, and two arrow buttons. {
typedef struct T_Scroller_button short Number; ///< Unique identifier for all controls
{ word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
short Number; ///< Unique identifier for all controls word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. struct T_Palette_button * Next;///< Pointer to the next palette of current window.
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. } T_Palette_button;
word Height; ///< Height before scaling.
word Nb_elements; ///< Number of distinct values it can take. /// A window control that represents a vertical scrollbar, with a slider, and two arrow buttons.
word Nb_visibles; ///< If this slider is meant to show several elements of a collection, this is their number (otherwise, it's 1). typedef struct T_Scroller_button
word Position; ///< Current position of the slider: which item it's pointing. {
word Cursor_height; ///< Vertical dimension of the slider, in pixels before scaling. short Number; ///< Unique identifier for all controls
struct T_Scroller_button * Next;///< Pointer to the next scroller of current window. word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
} T_Scroller_button; word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
word Height; ///< Height before scaling.
/// word Nb_elements; ///< Number of distinct values it can take.
/// A window control that only has a rectangular "active" area which catches mouse clicks, word Nb_visibles; ///< If this slider is meant to show several elements of a collection, this is their number (otherwise, it's 1).
// but no visible shape. It's used for custom controls where the drawing is done on word Position; ///< Current position of the slider: which item it's pointing.
// a case by case basis. word Cursor_height; ///< Vertical dimension of the slider, in pixels before scaling.
typedef struct T_Special_button struct T_Scroller_button * Next;///< Pointer to the next scroller of current window.
{ } T_Scroller_button;
short Number; ///< Unique identifier for all controls
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. ///
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. /// A window control that only has a rectangular "active" area which catches mouse clicks,
word Width; ///< Width before scaling // but no visible shape. It's used for custom controls where the drawing is done on
word Height; ///< Height before scaling // a case by case basis.
struct T_Special_button * Next;///< Pointer to the next special button of current window. typedef struct T_Special_button
} T_Special_button; {
short Number; ///< Unique identifier for all controls
/// Data for a dropdown item, ie. one proposed choice. word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
typedef struct T_Dropdown_choice word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
{ word Width; ///< Width before scaling
short Number; ///< Value that identifies the choice (for this dropdown only) word Height; ///< Height before scaling
const char * Label; ///< String to display in the dropdown panel struct T_Special_button * Next;///< Pointer to the next special button of current window.
struct T_Dropdown_choice * Next;///< Pointer to the next choice for this dropdown. } T_Special_button;
} T_Dropdown_choice;
/// Data for a dropdown item, ie. one proposed choice.
/// A window control that behaves like a dropdown button. typedef struct T_Dropdown_choice
typedef struct T_Dropdown_button {
{ short Number; ///< Value that identifies the choice (for this dropdown only)
short Number; ///< Unique identifier for all controls const char * Label; ///< String to display in the dropdown panel
word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling. struct T_Dropdown_choice * Next;///< Pointer to the next choice for this dropdown.
word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling. } T_Dropdown_choice;
word Width; ///< Width before scaling
word Height; ///< Height before scaling /// A window control that behaves like a dropdown button.
byte Display_choice; ///< Boolean, true if the engine should print the selected item's label in the dropdown area when the user chooses it. typedef struct T_Dropdown_button
byte Display_centered; ///< Boolean, true to center the labels (otherwise, align left) {
byte Display_arrow; ///< Boolean, true to display a "down" arrow box in top right short Number; ///< Unique identifier for all controls
byte Active_button; ///< Determines which mouse button(s) cause the dropdown panel to open: LEFT_SIDE || RIGHT_SIDE || (LEFT_SIDE|RIGHT_SIDE) word Pos_X; ///< Coordinate for top of button, relative to the window, before scaling.
word Dropdown_width; ///< Width of the dropdown panel when it's open. Use 0 for "same as the dropdown button" word Pos_Y; ///< Coordinate for left of button, relative to the window, before scaling.
T_Dropdown_choice * First_item; ///< Linked list with the choices available for this dropdown. word Width; ///< Width before scaling
struct T_Dropdown_button * Next;///< Pointer to the next dropdown button of current window. word Height; ///< Height before scaling
} T_Dropdown_button; byte Display_choice; ///< Boolean, true if the engine should print the selected item's label in the dropdown area when the user chooses it.
byte Display_centered; ///< Boolean, true to center the labels (otherwise, align left)
/// Data for one item (file, directory) in a fileselector. byte Display_arrow; ///< Boolean, true to display a "down" arrow box in top right
typedef struct T_Fileselector_item byte Active_button; ///< Determines which mouse button(s) cause the dropdown panel to open: LEFT_SIDE || RIGHT_SIDE || (LEFT_SIDE|RIGHT_SIDE)
{ word Dropdown_width; ///< Width of the dropdown panel when it's open. Use 0 for "same as the dropdown button"
char Short_name[19]; ///< Name to display. T_Dropdown_choice * First_item; ///< Linked list with the choices available for this dropdown.
char Full_name[256]; ///< Filesystem value. struct T_Dropdown_button * Next;///< Pointer to the next dropdown button of current window.
byte Type; ///< Type of item: 0 = File, 1 = Directory, 2 = Drive } T_Dropdown_button;
struct T_Fileselector_item * Next; ///< Pointer to next item of the current fileselector. /// Data for one item (file, directory) in a fileselector.
struct T_Fileselector_item * Previous;///< Pointer to previous item of the current fileselector. typedef struct T_Fileselector_item
} T_Fileselector_item; {
char Short_name[19]; ///< Name to display.
/// Data for one line of the "Help" screens. char Full_name[256]; ///< Filesystem value.
typedef struct { byte Type; ///< Type of item: 0 = File, 1 = Directory, 2 = Drive
char Line_type; ///< Kind of line: 'N' for normal line, 'S' for a bold line, 'K' for a line with keyboard shortcut, 'T' and '-' for upper and lower titles.
char * Text; ///< Displayed string. struct T_Fileselector_item * Next; ///< Pointer to next item of the current fileselector.
int Line_parameter; ///< Generic parameter depending on line type. For 'K' lines: a shortcut identifier. For others: unused. struct T_Fileselector_item * Previous;///< Pointer to previous item of the current fileselector.
} T_Help_table; } T_Fileselector_item;
/// Data for one section of the "Help" screens, ie a page. /// Data for a fileselector
typedef struct typedef struct T_Fileselector
{ {
const T_Help_table* Help_table; ///< Pointer to the array of ::T_Help_table that contains the lines /// Number of elements in the current fileselector's ::Filelist
word Length; ///< Size of the array of lines short Nb_elements;
} T_Help_section; /// Number of files in the current fileselector's ::Filelist
short Nb_files;
/// Data for one setting of gradients. Warning, this one is saved/loaded as binary. /// Number of directories in the current fileselector's ::Filelist
typedef struct short Nb_directories;
{ /// Head of the linked list for the fileselector.
byte Start; ///< First color T_Fileselector_item * First;
byte End; ///< Last color /// Index for direct access to element number N
dword Inverse; ///< Boolean, true if the gradient goes in descending order T_Fileselector_item ** Index;
dword Mix; ///< Amount of randomness to add to the mix (0-255) } T_Fileselector;
dword Technique;///< Gradient technique: 0 (no pattern) 1 (dithering), or 2 (big dithering)
} T_Gradient_array; typedef struct T_List_button
{
/// Data for one setting of shade. Warning, this one is saved/loaded as binary. short Number; ///< Unique identifier for all controls
typedef struct short List_start; ///< Index of the font to appear as first line
{ short Cursor_position; ///< Index of the selected line (0=top)
word List[512]; ///< List of entries, each one is either a color (0-255) or -1 for empty.
byte Step; ///< Step to increment/decrement on left-clicks. T_Special_button * Entry_button; ///< Pointer to the associated selection control.
byte Mode; ///< Shade mode: Normal, Loop, or No-saturation see ::SHADE_MODES T_Scroller_button * Scroller; ///< Pointer to the associated scroller
} T_Shade;
Func_draw_list_item Draw_list_item; ///<
/// Data for one fullscreen video mode in configuration file. Warning, this one is saved/loaded as binary.
typedef struct struct T_List_button * Next; ///< Pointer to the next list button of current window.
{ } T_List_button;
byte State; ///< How good is the mode supported. 0:Good (white) 1:OK (light) 2:So-so (dark) 4:User-disabled (black); +128 => System doesn't support it at all.
word Width; ///< Videomode width in pixels. /// Data for one line of the "Help" screens.
word Height;///< Videomode height in pixels. typedef struct {
} __attribute__((__packed__)) T_Config_video_mode; char Line_type; ///< Kind of line: 'N' for normal line, 'S' for a bold line, 'K' for a line with keyboard shortcut, 'T' and '-' for upper and lower titles.
char * Text; ///< Displayed string.
/// Header for gfx2.cfg. Warning, this one is saved/loaded as binary. int Line_parameter; ///< Generic parameter depending on line type. For 'K' lines: a shortcut identifier. For others: unused.
typedef struct } T_Help_table;
{
char Signature[3]; ///< Signature for the file format. "CFG". /// Data for one section of the "Help" screens, ie a page.
byte Version1; ///< Major version number (ex: 2) typedef struct
byte Version2; ///< Minor version number (ex: 0) {
byte Beta1; ///< Major beta version number (ex: 96) const T_Help_table* Help_table; ///< Pointer to the array of ::T_Help_table that contains the lines
byte Beta2; ///< Major beta version number (ex: 5) word Length; ///< Size of the array of lines
} __attribute__((__packed__)) T_Config_header; } T_Help_section;
/// Header for a config chunk in for gfx2.cfg. Warning, this one is saved/loaded as binary. /// Data for one setting of gradients. Warning, this one is saved/loaded as binary.
typedef struct typedef struct
{ {
byte Number; ///< Section identfier. Possible values are in enum ::CHUNKS_CFG byte Start; ///< First color
word Size; ///< Size of the configuration block that follows, in bytes. byte End; ///< Last color
} T_Config_chunk; dword Inverse; ///< Boolean, true if the gradient goes in descending order
dword Mix; ///< Amount of randomness to add to the mix (0-255)
/// Configuration for one keyboard shortcut in gfx2.cfg. Warning, this one is saved/loaded as binary. dword Technique;///< Gradient technique: 0 (no pattern) 1 (dithering), or 2 (big dithering)
typedef struct } T_Gradient_array;
{
word Number; ///< Indicates the shortcut action. This is a number starting from 0, which matches ::T_Key_config.Number /// Data for one setting of shade. Warning, this one is saved/loaded as binary.
word Key; ///< Keyboard shortcut: SDLK_something, or -1 for none typedef struct
word Key2; ///< Alternate keyboard shortcut: SDLK_something, or -1 for none {
} __attribute__((__packed__)) T_Config_shortcut_info; word List[512]; ///< List of entries, each one is either a color (0-255) or -1 for empty.
byte Step; ///< Step to increment/decrement on left-clicks.
/// This structure holds all the settings which are saved and loaded as gfx2.ini. byte Mode; ///< Shade mode: Normal, Loop, or No-saturation see ::SHADE_MODES
typedef struct } T_Shade;
{
byte Font; ///< Boolean, true to use the "fun" font in menus, false to use the classic one. /// Data for one fullscreen video mode in configuration file. Warning, this one is saved/loaded as binary.
int Show_hidden_files; ///< Boolean, true to show hidden files in fileselectors. typedef struct
int Show_hidden_directories; ///< Boolean, true to show hidden directories in fileselectors. {
// int Show_system_directories; ///< (removed when converted from DOS) byte State; ///< How good is the mode supported. 0:Good (white) 1:OK (light) 2:So-so (dark) 4:User-disabled (black); +128 => System doesn't support it at all.
byte Display_image_limits; ///< Boolean, true to display a dotted line at the borders of the image if it's smaller than screen. word Width; ///< Videomode width in pixels.
byte Cursor; ///< Mouse cursor aspect: 1 Solid, 2 Transparent, 3 Thin word Height;///< Videomode height in pixels.
byte Maximize_preview; ///< Boolean, true to make previews in fileselector fit the whole rectangle. } __attribute__((__packed__)) T_Config_video_mode;
byte Auto_set_res; ///< Boolean, true to make grafx2 switch to a new resolution whenever you load an image.
byte Coords_rel; ///< Boolean, true to display coordinates as relative (instead of absolute) /// Header for gfx2.cfg. Warning, this one is saved/loaded as binary.
byte Backup; ///< Boolean, true to backup the original file whenever you save an image. typedef struct
byte Adjust_brush_pick; ///< Boolean, true to omit the right and bottom edges when grabbing a brush in Grid mode. {
byte Auto_save; ///< Boolean, true to save configuration when exiting program. char Signature[3]; ///< Signature for the file format. "CFG".
byte Max_undo_pages; ///< Number of steps to memorize for Undo/Redo. byte Version1; ///< Major version number (ex: 2)
byte Mouse_sensitivity_index_x; ///< Mouse sensitivity in X axis byte Version2; ///< Minor version number (ex: 0)
byte Mouse_sensitivity_index_y; ///< Mouse sensitivity in Y axis byte Beta1; ///< Major beta version number (ex: 96)
byte Mouse_fix_factor_X; ///< Mouse correction factor in X axis. byte Beta2; ///< Major beta version number (ex: 5)
byte Mouse_fix_factor_Y; ///< Mouse correction factor in Y axis. } __attribute__((__packed__)) T_Config_header;
byte Mouse_merge_movement; ///< Number of SDL mouse events that are merged into a single change of mouse coordinates.
byte Delay_left_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click. /// Header for a config chunk in for gfx2.cfg. Warning, this one is saved/loaded as binary.
byte Delay_right_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click. typedef struct
long Timer_delay; ///< Delay (in 1/55s) before showing a preview in a fileselector. {
T_Components Fav_menu_colors[4]; ///< Favorite colors to use for the menu. byte Number; ///< Section identfier. Possible values are in enum ::CHUNKS_CFG
int Nb_max_vertices_per_polygon; ///< Limit for the number of vertices in polygon tools. word Size; ///< Size of the configuration block that follows, in bytes.
byte Clear_palette; ///< Boolean, true to reset the palette (to black) before loading an image. } T_Config_chunk;
byte Set_resolution_according_to; ///< When Auto_set_res is on, this determines if the mode should be chosen according to the "original screen" information in the file (1) or the picture dimensons (2)
byte Ratio; ///< Determines the scaling of menu and windows: 0 no scaling, 1 scaling, 2 slight scaling. /// Configuration for one keyboard shortcut in gfx2.cfg. Warning, this one is saved/loaded as binary.
byte Fast_zoom; ///< Boolean, true if the magnifier shortcut should automatically view the mouse area. typedef struct
byte Find_file_fast; ///< In fileselectors, this determines which entries should be sought when typing letters: 0 all, 1 files only, 2 directories only. {
byte Separate_colors; ///< Boolean, true if the menu palette should separate color cells with a black outline. word Number; ///< Indicates the shortcut action. This is a number starting from 0, which matches ::T_Key_config.Number
word Palette_cells_X; ///< Number of colors to show in a row of the menu palette. word Key; ///< Keyboard shortcut: SDLK_something, or -1 for none
word Palette_cells_Y; ///< Number of colors to show in a column of the menu palette. word Key2; ///< Alternate keyboard shortcut: SDLK_something, or -1 for none
byte Palette_vertical; ///< Boolean, true if the menu palette should go top to bottom instead of left to right } __attribute__((__packed__)) T_Config_shortcut_info;
byte FX_Feedback; ///< Boolean, true if drawing effects should read the image being modified (instead of the image before clicking)
byte Safety_colors; ///< Boolean, true to make the palette automatically re-create menu colors if needed after a "Zap" or color reduction. /// This structure holds all the settings saved and loaded as gfx2.ini.
byte Opening_message; ///< Boolean, true to display the splash screen on strtup. typedef struct
byte Clear_with_stencil; ///< Boolean, true to take the stencil into effect (if active) when using the Clear function. {
byte Auto_discontinuous; ///< Boolean, true to automatically switch to the discontinuous freehand draw after grabbing a brush. char *Font_file; ///< Name of the font used in the menus. Matches file skins/font_*.png (Case-sensitive on some filesystems)
byte Screen_size_in_GIF; ///< Boolean, true to store current resolution in GIF files. char *Skin_file; ///< String, name of the file where all the graphic data is stored
byte Auto_nb_used; ///< Boolean, true to count colors in Palette screen. int Show_hidden_files; ///< Boolean, true to show hidden files in fileselectors.
byte Default_resolution; ///< Default video mode to use on startup. Index in ::Video_mode. int Show_hidden_directories; ///< Boolean, true to show hidden directories in fileselectors.
char *Bookmark_directory[NB_BOOKMARKS];///< Bookmarked directories in fileselectors: This is the full dierctory name. // int Show_system_directories; ///< (removed when converted from DOS)
char Bookmark_label[NB_BOOKMARKS][8+1];///< Bookmarked directories in fileselectors: This is the displayed name. byte Display_image_limits; ///< Boolean, true to display a dotted line at the borders of the image if it's smaller than screen.
int Window_pos_x; ///< Last window x position (9999 if unsupportd/irrelevant for the platform) byte Cursor; ///< Mouse cursor aspect: 1 Solid, 2 Transparent, 3 Thin
int Window_pos_y; ///< Last window y position (9999 if unsupportd/irrelevant for the platform) byte Maximize_preview; ///< Boolean, true to make previews in fileselector fit the whole rectangle.
} T_Config; byte Auto_set_res; ///< Boolean, true to make grafx2 switch to a new resolution whenever you load an image.
byte Coords_rel; ///< Boolean, true to display coordinates as relative (instead of absolute)
// Structures utilisées pour les descriptions de pages et de liste de pages. byte Backup; ///< Boolean, true to backup the original file whenever you save an image.
// Lorsqu'on gèrera les animations, il faudra aussi des listes de listes de byte Adjust_brush_pick; ///< Boolean, true to omit the right and bottom edges when grabbing a brush in Grid mode.
// pages. byte Auto_save; ///< Boolean, true to save configuration when exiting program.
byte Max_undo_pages; ///< Number of steps to memorize for Undo/Redo.
// Ces structures sont manipulées à travers des fonctions de gestion du byte Mouse_sensitivity_index_x; ///< Mouse sensitivity in X axis
// backup dans "graph.c". byte Mouse_sensitivity_index_y; ///< Mouse sensitivity in Y axis
byte Mouse_fix_factor_X; ///< Mouse correction factor in X axis.
/// This is the data for one step of Undo/Redo, for one image. byte Mouse_fix_factor_Y; ///< Mouse correction factor in Y axis.
typedef struct byte Mouse_merge_movement; ///< Number of SDL mouse events that are merged into a single change of mouse coordinates.
{ byte Delay_left_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click.
byte * Image; ///< Pixel data for the image. byte Delay_right_click_on_slider; ///< Delay (in 1/100s) between two activations of a repeatable button when you hold left-click.
int Width; ///< Image width in pixels. long Timer_delay; ///< Delay (in 1/55s) before showing a preview in a fileselector.
int Height; ///< Image height in pixels. T_Components Fav_menu_colors[4]; ///< Favorite colors to use for the menu.
T_Palette Palette; ///< Image palette. int Nb_max_vertices_per_polygon; ///< Limit for the number of vertices in polygon tools.
byte Clear_palette; ///< Boolean, true to reset the palette (to black) before loading an image.
char Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file. byte Set_resolution_according_to; ///< When Auto_set_res is on, this determines if the mode should be chosen according to the "original screen" information in the file (1) or the picture dimensons (2)
int8_t Ratio; ///< Determines the scaling of menu and windows: 0 no scaling, 1 scaling, 2 slight scaling, negative= opposite of max scaling
char File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file. byte Fast_zoom; ///< Boolean, true if the magnifier shortcut should automatically view the mouse area.
char Filename[MAX_PATH_CHARACTERS]; ///< Filename without directory. byte Find_file_fast; ///< In fileselectors, this determines which entries should be sought when typing letters: 0 all, 1 files only, 2 directories only.
byte File_format; ///< File format, in enum ::FILE_FORMATS byte Separate_colors; ///< Boolean, true if the menu palette should separate color cells with a black outline.
word Palette_cells_X; ///< Number of colors to show in a row of the menu palette.
} T_Page; word Palette_cells_Y; ///< Number of colors to show in a column of the menu palette.
byte Palette_vertical; ///< Boolean, true if the menu palette should go top to bottom instead of left to right
/// Collection of undo/redo steps. byte FX_Feedback; ///< Boolean, true if drawing effects should read the image being modified (instead of the image before clicking)
typedef struct byte Safety_colors; ///< Boolean, true to make the palette automatically re-create menu colors if needed after a "Zap" or color reduction.
{ byte Opening_message; ///< Boolean, true to display the splash screen on strtup.
int List_size; /// Number of ::T_Page in the vector "Pages". byte Clear_with_stencil; ///< Boolean, true to take the stencil into effect (if active) when using the Clear function.
int Nb_pages_allocated;/// Number of ::T_Page used so far in the vector "Pages". byte Auto_discontinuous; ///< Boolean, true to automatically switch to the discontinuous freehand draw after grabbing a brush.
T_Page * Pages; /// Vector of Pages, each one being a undo/redo step. byte Screen_size_in_GIF; ///< Boolean, true to store current resolution in GIF files.
} T_List_of_pages; byte Auto_nb_used; ///< Boolean, true to count colors in Palette screen.
byte Default_resolution; ///< Default video mode to use on startup. Index in ::Video_mode.
char *Bookmark_directory[NB_BOOKMARKS];///< Bookmarked directories in fileselectors: This is the full dierctory name.
char Bookmark_label[NB_BOOKMARKS][8+1];///< Bookmarked directories in fileselectors: This is the displayed name.
#endif int Window_pos_x; ///< Last window x position (9999 if unsupportd/irrelevant for the platform)
int Window_pos_y; ///< Last window y position (9999 if unsupportd/irrelevant for the platform)
word Double_click_speed; ///< Maximum delay for double-click, in ms.
word Double_key_speed; ///< Maximum delay for double-keypress, in ms.
byte Grid_XOR_color; ///< XOR value to apply for grid color.
} T_Config;
// Structures utilisées pour les descriptions de pages et de liste de pages.
// Lorsqu'on gèrera les animations, il faudra aussi des listes de listes de
// pages.
// Ces structures sont manipulées à travers des fonctions de gestion du
// backup dans "graph.c".
/// This is the data for one step of Undo/Redo, for one image.
typedef struct
{
byte * Image; ///< Pixel data for the image.
int Width; ///< Image width in pixels.
int Height; ///< Image height in pixels.
T_Palette Palette; ///< Image palette.
char Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file.
char File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file.
char Filename[MAX_PATH_CHARACTERS]; ///< Filename without directory.
byte File_format; ///< File format, in enum ::FILE_FORMATS
} T_Page;
/// Collection of undo/redo steps.
typedef struct
{
int List_size; ///< Number of ::T_Page in the vector "Pages".
int Nb_pages_allocated;///< Number of ::T_Page used so far in the vector "Pages".
T_Page * Pages; ///< Vector of Pages, each one being a undo/redo step.
} T_List_of_pages;
/// A single memorized brush from the Brush Container
typedef struct
{
byte Paintbrush_shape; ///< Kind of brush
byte Thumbnail[BRUSH_CONTAINER_PREVIEW_WIDTH][BRUSH_CONTAINER_PREVIEW_HEIGHT];
// Data for color brush
word Width;
word Height;
byte * Brush; /// < Color brush (if any)
T_Palette Palette;
byte Transp_color;
} T_Brush_template;
/// GUI skin data
typedef struct
{
// Mouse
/// X coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_WIDTH
word Cursor_offset_X[NB_CURSOR_SPRITES];
/// Y coordinate of the mouse cursor's "hot spot". It is < ::CURSOR_SPRITE_HEIGHT
word Cursor_offset_Y[NB_CURSOR_SPRITES];
/// Graphic resources for the mouse cursor.
byte Cursor_sprite[NB_CURSOR_SPRITES][CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH];
// Preset paintbrushes
/// Graphic resources for the preset paintbrushes.
byte Paintbrush_sprite [NB_PAINTBRUSH_SPRITES][PAINTBRUSH_HEIGHT][PAINTBRUSH_WIDTH];
/// Width of the preset paintbrushes.
word Preset_paintbrush_width[NB_PAINTBRUSH_SPRITES];
/// Height of the preset paintbrushes.
word Preset_paintbrush_height[NB_PAINTBRUSH_SPRITES];
/// Type of the preset paintbrush: index in enum PAINTBRUSH_SHAPES
byte Paintbrush_type[NB_PAINTBRUSH_SPRITES];
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_width[]/2
word Preset_paintbrush_offset_X[NB_PAINTBRUSH_SPRITES];
/// Brush handle for the preset brushes. Generally ::Preset_paintbrush_height[]/2
word Preset_paintbrush_offset_Y[NB_PAINTBRUSH_SPRITES];
// Sieve patterns
/// Preset sieve patterns, stored as binary (one word per line)
word Sieve_pattern[12][16];
// Menu and other graphics
/// Bitmap data for the menu, a single rectangle.
byte Menu_block[MENU_HEIGHT][MENU_WIDTH];
/// Bitmap data for the icons that are displayed over the menu.
byte Menu_sprite[NB_MENU_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
/// Bitmap data for the different "effects" icons.
byte Effect_sprite[NB_EFFECTS_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
/// Bitmap data for the Grafx2 logo that appears on splash screen. All 256 colors allowed.
byte Logo_grafx2[231*56];
/// Bitmap data for the 6x8 font used in help screens.
byte Help_font_norm [256][6][8];
/// Bitmap data for the 6x8 font used in help screens ("bold" verstion).
byte Bold_font [256][6][8];
// 12
// 34
/// Bitmap data for the title font used in help screens. Top-left quarter.
byte Help_font_t1 [64][6][8];
/// Bitmap data for the title font used in help screens. Top-right quarter.
byte Help_font_t2 [64][6][8];
/// Bitmap data for the title font used in help screens. Bottom-left quarter.
byte Help_font_t3 [64][6][8];
/// Bitmap data for the title font used in help screens. Bottom-right quarter.
byte Help_font_t4 [64][6][8];
/// Bitmap data for the small 8x8 icons.
byte Icon_sprite[NB_ICON_SPRITES][ICON_SPRITE_HEIGHT][ICON_SPRITE_WIDTH];
/// A default 256-color palette.
T_Palette Default_palette;
} T_Gui_skin;
#endif

108
text.h
View File

@ -1,54 +1,54 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2008 Adrien Destugues Copyright 2008 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file text.h ///@file text.h
/// Functions related to rendering text as a brush, using TrueType or SFont. /// Functions related to rendering text as a brush, using TrueType or SFont.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Initialization of text settings, needs to be called once on program startup. /// Initialization of text settings, needs to be called once on program startup.
void Init_text(void); void Init_text(void);
/// Returns true if text.c was compiled with TrueType support. /// Returns true if text.c was compiled with TrueType support.
int TrueType_is_supported(void); int TrueType_is_supported(void);
/// Add a new font to the list to propose to the user. /// Add a new font to the list to propose to the user.
void Add_font(const char *name); void Add_font(const char *name);
/// ///
/// Creates a brush, from the parameters given: /// Creates a brush, from the parameters given:
/// @param str The text to render /// @param str The text to render
/// @param font_number The index of the font to use. Pass 0 for the first font you declared with ::Add_font(), 1 for the second etc. /// @param font_number The index of the font to use. Pass 0 for the first font you declared with ::Add_font(), 1 for the second etc.
/// @param size The size in points (unused for bitmap fonts) /// @param size The size in points (unused for bitmap fonts)
/// @param antialias Boolean, true to use antialiasing in TrueType /// @param antialias Boolean, true to use antialiasing in TrueType
/// @param bold Boolean, true to use bold rendering in TrueType /// @param bold Boolean, true to use bold rendering in TrueType
/// @param italic Boolean, true to use italic rendering in TrueType /// @param italic Boolean, true to use italic rendering in TrueType
/// @param width Returns the width of the created brush, in pixels. /// @param width Returns the width of the created brush, in pixels.
/// @param height Returns the height of the created brush, in pixels. /// @param height Returns the height of the created brush, in pixels.
/// Returns true on success. /// Returns true on success.
byte *Render_text(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height); byte *Render_text(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height);
/// Finds a label to display for a font declared with ::Add_font(). /// Finds a label to display for a font declared with ::Add_font().
char * Font_label(int index); char * Font_label(int index);
/// Finds the filename of a font declared with ::Add_font(). /// Finds the filename of a font declared with ::Add_font().
char * Font_name(int index); char * Font_name(int index);
/// Returns true if the font of this number is TrueType, false if it's a SFont bitmap. /// Returns true if the font of this number is TrueType, false if it's a SFont bitmap.
char * TrueType_font(int index); char * TrueType_font(int index);
/// ///
/// Number of fonts declared with a series of ::Add_font(). This is public for /// Number of fonts declared with a series of ::Add_font(). This is public for
/// convenience, but functionaly it is read-only. /// convenience, but functionaly it is read-only.
extern int Nb_fonts; extern int Nb_fonts;

View File

@ -1,409 +1,412 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2009 Yves Rizoud Copyright 2009 Yves Rizoud
Copyright 2009 Adrien Destugues Copyright 2009 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "global.h" #include "global.h"
#include "struct.h" #include "struct.h"
#include "transform.h" #include "transform.h"
#include "engine.h" #include "engine.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "windows.h" #include "windows.h"
#include "input.h" #include "input.h"
#include "help.h" #include "help.h"
#include "misc.h" // Num2str #include "misc.h" // Num2str
#include "readline.h" #include "readline.h"
#include "buttons.h" // Message_out_of_memory() #include "buttons.h" // Message_out_of_memory()
#include "pages.h" // Backup_with_new_dimensions() #include "pages.h" // Backup_with_new_dimensions()
/// Reduces a fraction A/B to its smallest representation. ie (40,60) becomes (2/3) /// Reduces a fraction A/B to its smallest representation. ie (40,60) becomes (2/3)
void Factorize(short *a, short *b) void Factorize(short *a, short *b)
{ {
// Method: brute-force. // Method: brute-force.
short factor; short factor;
factor=2; factor=2;
while (factor<=*a && factor<=*b) while (factor<=*a && factor<=*b)
{ {
if (((*a % factor) == 0) && ((*b % factor) == 0)) if (((*a % factor) == 0) && ((*b % factor) == 0))
{ {
// common factor is found // common factor is found
*a/=factor; *a/=factor;
*b/=factor; *b/=factor;
// restart // restart
factor=2; factor=2;
} }
else else
factor++; factor++;
} }
} }
/// Multiplies original_size by new_ratio/old_ratio, but keeps result in 1-9999 range. /// Multiplies original_size by new_ratio/old_ratio, but keeps result in 1-9999 range.
short Compute_dimension(short original_size, short new_ratio, short old_ratio) short Compute_dimension(short original_size, short new_ratio, short old_ratio)
{ {
long amount; long amount;
amount = (long)original_size*new_ratio/old_ratio; amount = (long)original_size*new_ratio/old_ratio;
if (amount>9999) if (amount>9999)
return 9999; return 9999;
else if (amount<1) else if (amount<1)
return 1; return 1;
else else
return amount; return amount;
} }
void Button_Transform_menu(void) void Button_Transform_menu(void)
{ {
enum RESIZE_UNIT { enum RESIZE_UNIT {
UNIT_PIXELS = 1, UNIT_PIXELS = 1,
UNIT_PERCENT = 2, UNIT_PERCENT = 2,
UNIT_RATIO = 3 UNIT_RATIO = 3
}; };
char buffer[5]; char buffer[5];
short clicked_button; short clicked_button;
const char * unit_label[] = { const char * unit_label[] = {
"", "",
"Pixels ", "Pixels ",
"Percent", "Percent",
"Ratio "}; "Ratio "};
short last_unit_index = -1; short last_unit_index = -1;
short old_ratio_width; short old_ratio_width;
short old_ratio_height; short old_ratio_height;
short new_ratio_width; short new_ratio_width;
short new_ratio_height; short new_ratio_height;
short new_width=Main_image_width; short new_width=Main_image_width;
short new_height=Main_image_height; short new_height=Main_image_height;
byte need_display_size = 0; byte need_display_size = 0;
// Persistent data // Persistent data
static short unit_index = 1; // 1= Pixels, 2= Percent, 3=Ratio static short unit_index = 1; // 1= Pixels, 2= Percent, 3=Ratio
static short ratio_is_locked = 1; // True if X and Y resize should go together static short ratio_is_locked = 1; // True if X and Y resize should go together
T_Dropdown_button * unit_button; T_Dropdown_button * unit_button;
T_Special_button * input_button[4]; T_Special_button * input_button[4];
short *input_value[4]; short *input_value[4];
// Set initial ratio // Set initial ratio
if (unit_index == UNIT_PERCENT) if (unit_index == UNIT_PERCENT)
new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=100; new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=100;
else else
new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=1; new_ratio_width=old_ratio_width=new_ratio_height=old_ratio_height=1;
Open_window(215,165,"Picture transform"); Open_window(215,165,"Picture transform");
Window_display_frame( 5, 15,205,91); Window_display_frame( 5, 15,205,91);
Window_display_frame( 5,110, 55,49); Window_display_frame( 5,110, 55,49);
Window_display_frame(64,110, 85,49); Window_display_frame(64,110, 85,49);
Window_set_normal_button(154,140, 54,14,"Cancel",0,1,KEY_ESC); // 1 Window_set_normal_button(154,140, 54,14,"Cancel",0,1,KEY_ESC); // 1
Print_in_window( 9,114,"Mirror",MC_Dark,MC_Light); Print_in_window( 9,114,"Mirror",MC_Dark,MC_Light);
Window_set_normal_button( 17,125, 27,14,"X\035" ,1,1,SDLK_x); // 2 Window_set_normal_button( 17,125, 27,14,"X\035" ,1,1,SDLK_x); // 2
Window_set_normal_button( 17,140, 27,14,"Y\022" ,1,1,SDLK_y); // 3 Window_set_normal_button( 17,140, 27,14,"Y\022" ,1,1,SDLK_y); // 3
Print_in_window( 84,114,"Rotate",MC_Dark,MC_Light); Print_in_window( 84,114,"Rotate",MC_Dark,MC_Light);
Window_set_normal_button( 69,125, 37,14,"-90°" ,0,1,SDLK_LAST); // 4 Window_set_normal_button( 69,125, 37,14,"-90°" ,0,1,SDLK_LAST); // 4
Window_set_normal_button(107,125, 37,14,"+90°" ,0,1,SDLK_LAST); // 5 Window_set_normal_button(107,125, 37,14,"+90°" ,0,1,SDLK_LAST); // 5
Window_set_normal_button( 69,140, 75,14,"180°" ,0,1,SDLK_LAST); // 6 Window_set_normal_button( 69,140, 75,14,"180°" ,0,1,SDLK_LAST); // 6
Print_in_window( 87, 19,"Resize",MC_Dark,MC_Light); Print_in_window( 87, 19,"Resize",MC_Dark,MC_Light);
Window_set_normal_button( 80, 86, 60,14,"RESIZE",1,1,SDLK_r); // 7 Window_set_normal_button( 80, 86, 60,14,"RESIZE",1,1,SDLK_r); // 7
Print_in_window( 51, 34,"New",MC_Dark,MC_Light); Print_in_window( 51, 34,"New",MC_Dark,MC_Light);
Print_in_window( 96, 34,"Old",MC_Dark,MC_Light); Print_in_window( 96, 34,"Old",MC_Dark,MC_Light);
Print_in_window( 30, 44,"X:",MC_Dark,MC_Light); Print_in_window( 30, 44,"X:",MC_Dark,MC_Light);
Print_in_window( 30, 59,"Y:",MC_Dark,MC_Light); Print_in_window( 30, 59,"Y:",MC_Dark,MC_Light);
Print_in_window( 80, 44,":",MC_Dark,MC_Light); Print_in_window( 80, 44,":",MC_Dark,MC_Light);
Print_in_window( 80, 59,":",MC_Dark,MC_Light); Print_in_window( 80, 59,":",MC_Dark,MC_Light);
Print_in_window( 44, 75,"Lock proportions",MC_Dark,MC_Light); Print_in_window( 44, 75,"Lock proportions",MC_Dark,MC_Light);
Window_set_normal_button( 28, 72, 13,13,ratio_is_locked?"X":" ",0,1,SDLK_l);// 8 Window_set_normal_button( 28, 72, 13,13,ratio_is_locked?"X":" ",0,1,SDLK_l);// 8
unit_button = Window_set_dropdown_button(128,50,69,11,69,unit_label[unit_index],1,0,1,LEFT_SIDE|RIGHT_SIDE);// 9 unit_button = Window_set_dropdown_button(128,50,69,11,69,unit_label[unit_index],1,0,1,LEFT_SIDE|RIGHT_SIDE);// 9
Window_dropdown_add_item(unit_button,UNIT_PIXELS,unit_label[UNIT_PIXELS]); Window_dropdown_add_item(unit_button,UNIT_PIXELS,unit_label[UNIT_PIXELS]);
Window_dropdown_add_item(unit_button,UNIT_PERCENT,unit_label[UNIT_PERCENT]); Window_dropdown_add_item(unit_button,UNIT_PERCENT,unit_label[UNIT_PERCENT]);
Window_dropdown_add_item(unit_button,UNIT_RATIO,unit_label[UNIT_RATIO]); Window_dropdown_add_item(unit_button,UNIT_RATIO,unit_label[UNIT_RATIO]);
input_button[0] = Window_set_input_button(45,43,4); // 10 input_button[0] = Window_set_input_button(45,43,4); // 10
input_button[1] = Window_set_input_button(89,43,4); // 11 input_button[1] = Window_set_input_button(89,43,4); // 11
input_button[2] = Window_set_input_button(45,58,4); // 12 input_button[2] = Window_set_input_button(45,58,4); // 12
input_button[3] = Window_set_input_button(89,58,4); // 13 input_button[3] = Window_set_input_button(89,58,4); // 13
Update_window_area(0,0,Window_width, Window_height); Update_window_area(0,0,Window_width, Window_height);
Display_cursor(); Display_cursor();
do do
{ {
// Display the coordinates with the right unit // Display the coordinates with the right unit
if (last_unit_index != unit_index) if (last_unit_index != unit_index)
{ {
switch(unit_index) switch(unit_index)
{ {
case UNIT_PIXELS: case UNIT_PIXELS:
default: default:
input_value[0]=&new_width; input_value[0]=&new_width;
input_value[1]=&Main_image_width; // Don't worry, it's read-only input_value[1]=&Main_image_width; // Don't worry, it's read-only
input_value[2]=&new_height; input_value[2]=&new_height;
input_value[3]=&Main_image_height; // Don't worry, it's read-only input_value[3]=&Main_image_height; // Don't worry, it's read-only
break; break;
case UNIT_PERCENT: case UNIT_PERCENT:
case UNIT_RATIO: case UNIT_RATIO:
input_value[0]=&new_ratio_width; input_value[0]=&new_ratio_width;
input_value[1]=&old_ratio_width; input_value[1]=&old_ratio_width;
input_value[2]=&new_ratio_height; input_value[2]=&new_ratio_height;
input_value[3]=&old_ratio_height; input_value[3]=&old_ratio_height;
break; break;
} }
need_display_size=1; need_display_size=1;
last_unit_index=unit_index; last_unit_index=unit_index;
} }
if (need_display_size) if (need_display_size)
{ {
short i; short i;
Hide_cursor(); Hide_cursor();
for (i=0;i<4;i++) for (i=0;i<4;i++)
{ {
// "Old" values are not editable, unless the unit is "ratio" // "Old" values are not editable, unless the unit is "ratio"
byte color = ((unit_index!=UNIT_RATIO) && (i==1 || i==3)) ? MC_Dark : MC_Black; byte color = ((unit_index!=UNIT_RATIO) && (i==1 || i==3)) ? MC_Dark : MC_Black;
Num2str(*(input_value[i]),buffer,4); Num2str(*(input_value[i]),buffer,4);
Print_in_window_limited(input_button[i]->Pos_X+2,input_button[i]->Pos_Y+2,buffer,input_button[i]->Width/8,color,MC_Light); Print_in_window_limited(input_button[i]->Pos_X+2,input_button[i]->Pos_Y+2,buffer,input_button[i]->Width/8,color,MC_Light);
} }
Display_cursor(); Display_cursor();
need_display_size=0; need_display_size=0;
} }
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
// Contextual help // Contextual help
if (Is_shortcut(Key,0x100+BUTTON_HELP)) if (Is_shortcut(Key,0x100+BUTTON_HELP))
{ {
Key=0; Key=0;
Window_help(BUTTON_ADJUST, "PICTURE TRANSFORM"); Window_help(BUTTON_ADJUST, "PICTURE TRANSFORM");
} }
else switch(clicked_button) else if (Is_shortcut(Key,0x200+BUTTON_ADJUST))
{ clicked_button=1;
case 9: // Unit
switch(Window_attribute2) else switch(clicked_button)
{ {
case UNIT_PIXELS: case 9: // Unit
// Do nothing, pixel size was already computed. switch(Window_attribute2)
break; {
case UNIT_PERCENT: case UNIT_PIXELS:
if (unit_index == UNIT_RATIO) // Do nothing, pixel size was already computed.
{ break;
// Approximate from current ratio case UNIT_PERCENT:
new_ratio_width = Compute_dimension(new_ratio_width,100,old_ratio_width); if (unit_index == UNIT_RATIO)
new_ratio_height = Compute_dimension(new_ratio_height,100,old_ratio_height); {
old_ratio_width = 100; // Approximate from current ratio
old_ratio_height = 100; new_ratio_width = Compute_dimension(new_ratio_width,100,old_ratio_width);
// Update pixel dimensions, to match percentage exactly new_ratio_height = Compute_dimension(new_ratio_height,100,old_ratio_height);
new_width=Compute_dimension(Main_image_width, new_ratio_width, old_ratio_width); old_ratio_width = 100;
new_height=Compute_dimension(Main_image_height, new_ratio_height, old_ratio_height); old_ratio_height = 100;
} // Update pixel dimensions, to match percentage exactly
else // unit_index == UNIT_PIXELS new_width=Compute_dimension(Main_image_width, new_ratio_width, old_ratio_width);
{ new_height=Compute_dimension(Main_image_height, new_ratio_height, old_ratio_height);
// Approximate from current pixel size }
new_ratio_width = new_width*100/Main_image_width; else // unit_index == UNIT_PIXELS
new_ratio_height = new_height*100/Main_image_height; {
old_ratio_width = 100; // Approximate from current pixel size
old_ratio_height = 100; new_ratio_width = new_width*100/Main_image_width;
} new_ratio_height = new_height*100/Main_image_height;
break; old_ratio_width = 100;
case UNIT_RATIO: old_ratio_height = 100;
if (unit_index == UNIT_PERCENT) }
{ break;
// Compute simplest ratio from current % case UNIT_RATIO:
Factorize(&new_ratio_width, &old_ratio_width); if (unit_index == UNIT_PERCENT)
Factorize(&new_ratio_height, &old_ratio_height); {
} // Compute simplest ratio from current %
else // unit_index == UNIT_PIXELS Factorize(&new_ratio_width, &old_ratio_width);
{ Factorize(&new_ratio_height, &old_ratio_height);
// Compute simplest ratio from current pixel size }
new_ratio_width = new_width; else // unit_index == UNIT_PIXELS
new_ratio_height = new_height; {
old_ratio_width = Main_image_width; // Compute simplest ratio from current pixel size
old_ratio_height = Main_image_height; new_ratio_width = new_width;
Factorize(&new_ratio_width, &old_ratio_width); new_ratio_height = new_height;
Factorize(&new_ratio_height, &old_ratio_height); old_ratio_width = Main_image_width;
} old_ratio_height = Main_image_height;
break; Factorize(&new_ratio_width, &old_ratio_width);
} Factorize(&new_ratio_height, &old_ratio_height);
}
unit_index = Window_attribute2; break;
break; }
case 8: // Lock proportions unit_index = Window_attribute2;
ratio_is_locked = ! ratio_is_locked; break;
Hide_cursor();
Print_in_window(31,75,(ratio_is_locked)?"X":" ",MC_Black,MC_Light); case 8: // Lock proportions
Display_cursor(); ratio_is_locked = ! ratio_is_locked;
break; Hide_cursor();
Print_in_window(31,75,(ratio_is_locked)?"X":" ",MC_Black,MC_Light);
case 11: // input old width Display_cursor();
case 13: // input old height break;
// "Old" values are not editable, unless the unit is "ratio"
if (unit_index!=UNIT_RATIO) case 11: // input old width
break; case 13: // input old height
case 10: // input new width // "Old" values are not editable, unless the unit is "ratio"
case 12: // input new height if (unit_index!=UNIT_RATIO)
Num2str(*( input_value[clicked_button-10]),buffer,4); break;
Hide_cursor(); case 10: // input new width
if (Readline(input_button[clicked_button-10]->Pos_X+2, case 12: // input new height
input_button[clicked_button-10]->Pos_Y+2, Num2str(*( input_value[clicked_button-10]),buffer,4);
buffer, Hide_cursor();
4, if (Readline(input_button[clicked_button-10]->Pos_X+2,
1)) input_button[clicked_button-10]->Pos_Y+2,
{ buffer,
// Accept entered value 4,
*(input_value[clicked_button-10])=atoi(buffer); 1))
// 0 is not acceptable size {
if (*(input_value[clicked_button-10])==0) // Accept entered value
{ *(input_value[clicked_button-10])=atoi(buffer);
*(input_value[clicked_button-10])=1; // 0 is not acceptable size
} if (*(input_value[clicked_button-10])==0)
// Adapt the other coordinate if X and Y are locked {
if (ratio_is_locked) *(input_value[clicked_button-10])=1;
{ }
if (clicked_button == 10 || clicked_button == 11 ) // Adapt the other coordinate if X and Y are locked
{ if (ratio_is_locked)
// Get Y value because X changed {
if (unit_index == UNIT_PIXELS) if (clicked_button == 10 || clicked_button == 11 )
{ {
new_height=Compute_dimension(Main_image_height, new_width, Main_image_width); // Get Y value because X changed
} if (unit_index == UNIT_PIXELS)
else {
{ new_height=Compute_dimension(Main_image_height, new_width, Main_image_width);
// Copy the whole ratio }
new_ratio_height=new_ratio_width; else
old_ratio_height=old_ratio_width; {
} // Copy the whole ratio
} new_ratio_height=new_ratio_width;
else // (clicked_button == 12 || clicked_button == 13) old_ratio_height=old_ratio_width;
{ }
// Get X value because Y changed }
if (unit_index == UNIT_PIXELS) else // (clicked_button == 12 || clicked_button == 13)
{ {
new_width=Compute_dimension(Main_image_width, new_height, Main_image_height); // Get X value because Y changed
} if (unit_index == UNIT_PIXELS)
else {
{ new_width=Compute_dimension(Main_image_width, new_height, Main_image_height);
// Copy the whole ratio }
new_ratio_width=new_ratio_height; else
old_ratio_width=old_ratio_height; {
} // Copy the whole ratio
} new_ratio_width=new_ratio_height;
} old_ratio_width=old_ratio_height;
}
// Re-compute ratio from size in pixels }
if (unit_index == UNIT_PIXELS) }
{
//new_width=(long)Main_image_width*new_ratio_width/old_ratio_width; // Re-compute ratio from size in pixels
//new_height=(long)Main_image_height*new_ratio_height/old_ratio_height; if (unit_index == UNIT_PIXELS)
} {
else // Re-compute size in pixels from ratio //new_width=(long)Main_image_width*new_ratio_width/old_ratio_width;
{ //new_height=(long)Main_image_height*new_ratio_height/old_ratio_height;
new_width=Compute_dimension(Main_image_width,new_ratio_width,old_ratio_width); }
new_height=Compute_dimension(Main_image_height,new_ratio_height,old_ratio_height); else // Re-compute size in pixels from ratio
} {
need_display_size=1; new_width=Compute_dimension(Main_image_width,new_ratio_width,old_ratio_width);
} new_height=Compute_dimension(Main_image_height,new_ratio_height,old_ratio_height);
Display_cursor(); }
break; need_display_size=1;
} }
} Display_cursor();
while (clicked_button<=0 || clicked_button>=8); break;
}
Close_window(); }
while (clicked_button<=0 || clicked_button>=8);
// The Scroll operation uses the same button as transformation menu.
if (Current_operation != OPERATION_SCROLL) Close_window();
Unselect_button(BUTTON_ADJUST);
// The Scroll operation uses the same button as transformation menu.
if (clicked_button != 1) // 1 is Cancel if (Current_operation != OPERATION_SCROLL)
{ Unselect_button(BUTTON_ADJUST);
short old_width;
short old_height; if (clicked_button != 1) // 1 is Cancel
{
// Determine new image dimensions short old_width;
switch (clicked_button) short old_height;
{
case 7 : // Resize // Determine new image dimensions
// Keep new_width and new_height as entered. switch (clicked_button)
break; {
case 2 : // Flip X case 7 : // Resize
case 3 : // Flip Y // Keep new_width and new_height as entered.
case 6 : // 180° Rotation break;
new_width=Main_image_width; case 2 : // Flip X
new_height=Main_image_height; case 3 : // Flip Y
break; case 6 : // 180° Rotation
new_width=Main_image_width;
case 4 : // -90° Rotation new_height=Main_image_height;
case 5 : // +90° Rotation break;
new_width=Main_image_height; case 4 : // -90° Rotation
new_height=Main_image_width; case 5 : // +90° Rotation
break;
} new_width=Main_image_height;
// Memorize the current dimensions new_height=Main_image_width;
old_width=Main_image_width; break;
old_height=Main_image_height; }
// Memorize the current dimensions
// Allocate a new page old_width=Main_image_width;
if (Backup_with_new_dimensions(1,new_width,new_height)) old_height=Main_image_height;
{
// The new image is allocated, the new dimensions are already updated. // Allocate a new page
if (Backup_with_new_dimensions(1,new_width,new_height))
Main_image_is_modified=1; {
// The new image is allocated, the new dimensions are already updated.
// Process the transformation:
switch(clicked_button) Main_image_is_modified=1;
{
case 2 : // Flip X // Process the transformation:
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height); switch(clicked_button)
Flip_X_lowlevel(Main_screen, Main_image_width, Main_image_height); {
break; case 2 : // Flip X
case 3 : // Flip Y memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height); Flip_X_lowlevel(Main_screen, Main_image_width, Main_image_height);
Flip_Y_lowlevel(Main_screen, Main_image_width, Main_image_height); break;
break; case 3 : // Flip Y
case 4 : // -90° Rotation memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
Rotate_270_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height); Flip_Y_lowlevel(Main_screen, Main_image_width, Main_image_height);
break; break;
case 5 : // +90° Rotation case 4 : // -90° Rotation
Rotate_90_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height); Rotate_270_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height);
break; break;
case 6 : // 180° Rotation case 5 : // +90° Rotation
memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height); Rotate_90_deg_lowlevel(Screen_backup, Main_screen, old_width, old_height);
Rotate_180_deg_lowlevel(Main_screen, Main_image_width, Main_image_height); break;
break; case 6 : // 180° Rotation
case 7 : // Resize memcpy(Main_screen,Screen_backup,Main_image_width*Main_image_height);
Rescale(Screen_backup, old_width, old_height, Main_screen, Main_image_width, Main_image_height, 0, 0); Rotate_180_deg_lowlevel(Main_screen, Main_image_width, Main_image_height);
break; break;
} case 7 : // Resize
Display_all_screen(); Rescale(Screen_backup, old_width, old_height, Main_screen, Main_image_width, Main_image_height, 0, 0);
} break;
else }
{ Display_all_screen();
Display_cursor(); }
Message_out_of_memory(); else
Hide_cursor(); {
} Display_cursor();
} Message_out_of_memory();
Display_cursor(); Hide_cursor();
} }
}
Display_cursor();
}

View File

@ -1,27 +1,27 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2009 Yves Rizoud Copyright 2009 Yves Rizoud
Copyright 2009 Adrien Destugues Copyright 2009 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
Grafx2 is free software; you can redistribute it and/or Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 as published by the Free Software Foundation; version 2
of the License. of the License.
Grafx2 is distributed in the hope that it will be useful, Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
///@file transform.h ///@file transform.h
/// Screen and functions for picture transform. /// Screen and functions for picture transform.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// Opens and handles the Picture transform screen. /// Opens and handles the Picture transform screen.
void Button_Transform_menu(void); void Button_Transform_menu(void);

293
windows.c
View File

@ -32,6 +32,7 @@
#include "misc.h" #include "misc.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "errors.h" #include "errors.h"
#include "input.h"
// L'encapsulation tente une percée...ou un dernier combat. // L'encapsulation tente une percée...ou un dernier combat.
@ -409,8 +410,7 @@ int Pick_color_in_palette()
return color; return color;
} }
// -- Afficher tout le menu -- /// Display the whole menu
void Display_menu(void) void Display_menu(void)
{ {
word x_pos; word x_pos;
@ -420,17 +420,17 @@ void Display_menu(void)
if (Menu_is_visible) if (Menu_is_visible)
{ {
// Affichage du sprite du menu // display menu sprite
for (y_pos=0;y_pos<MENU_HEIGHT;y_pos++) for (y_pos=0;y_pos<MENU_HEIGHT;y_pos++)
for (x_pos=0;x_pos<MENU_WIDTH;x_pos++) for (x_pos=0;x_pos<MENU_WIDTH;x_pos++)
Pixel_in_menu(x_pos,y_pos,GFX_menu_block[y_pos][x_pos]); Pixel_in_menu(x_pos,y_pos,Gfx->Menu_block[y_pos][x_pos]);
// Affichage de la bande grise sous la palette // Grey area for filename below palette
Block(MENU_WIDTH*Menu_factor_X,Menu_status_Y-Menu_factor_Y,Screen_width-(MENU_WIDTH*Menu_factor_X),9*Menu_factor_Y,MC_Light); Block(MENU_WIDTH*Menu_factor_X,Menu_status_Y-Menu_factor_Y,Screen_width-(MENU_WIDTH*Menu_factor_X),9*Menu_factor_Y,MC_Light);
// Affichage de la palette // Display palette
Display_menu_palette(); Display_menu_palette();
// Affichage des couleurs de travail // Display selected colors
Display_foreback(); Display_foreback();
@ -439,12 +439,14 @@ void Display_menu(void)
if ((Mouse_Y<Menu_Y) && // Souris dans l'image if ((Mouse_Y<Menu_Y) && // Souris dans l'image
( (!Main_magnifier_mode) || (Mouse_X<Main_separator_position) || (Mouse_X>=Main_X_zoom) )) ( (!Main_magnifier_mode) || (Mouse_X<Main_separator_position) || (Mouse_X>=Main_X_zoom) ))
{ {
// Dans ces deux cas, on met dans la barre les XY courant, même s'il y a des chances que ça soit recouvert si la souris est sur un bouton (trop chiant à vérifier) // Prepare display of XY coordinates even if in some cases they will be
// erased with some other text
if ( (Current_operation!=OPERATION_COLORPICK) if ( (Current_operation!=OPERATION_COLORPICK)
&& (Current_operation!=OPERATION_REPLACE) ) && (Current_operation!=OPERATION_REPLACE) )
Print_in_menu("X: Y: ",0); Print_in_menu("X: Y: ",0);
else else
{ {
// The colorpicker display the color id between the parentheses
Print_in_menu("X: Y: ( )",0); Print_in_menu("X: Y: ( )",0);
Num2str(Colorpicker_color,str,3); Num2str(Colorpicker_color,str,3);
Print_in_menu(str,20); Print_in_menu(str,20);
@ -454,7 +456,8 @@ void Display_menu(void)
} }
Print_filename(); Print_filename();
} }
Update_rect(0,Menu_Y,Screen_width,MENU_HEIGHT*Menu_factor_Y); // on met toute la largur à jour, ça inclut la palette et la zone d'état avec le nom du fichier // Now update the area: menu height and whole screen width (including palette)
Update_rect(0,Menu_Y,Screen_width,MENU_HEIGHT*Menu_factor_Y);
} }
} }
@ -834,7 +837,7 @@ byte Confirmation_box(char * message)
//---- Fenêtre avertissant de quelque chose et attendant un click sur OK ----- /// Window that show a warning message and wait for a click on the OK button
void Warning_message(char * message) void Warning_message(char * message)
{ {
short clicked_button; short clicked_button;
@ -860,6 +863,47 @@ void Warning_message(char * message)
Display_cursor(); Display_cursor();
} }
/// Window that shows a big message, and waits for a click on OK
void Verbose_error_message(char * message)
{
short clicked_button;
int line;
int i;
char buffer[36]; // 35 characters + \0
Open_window(300,160,"Error!");
// Word-wrap the message
for (line=0; line < 10; line++)
{
for (i=0;i<35 && *message!='\0';i++)
{
if (*message == '\n')
{
message++;
break;
}
buffer[i]=*message;
message++;
}
buffer[i]='\0';
Print_in_window(10,20+line*8,buffer,MC_Black,MC_Light);
if (*message=='\0')
break;
}
Window_set_normal_button(300/2-20,160-23,40,14,"OK",1,1,SDLK_RETURN); // 1
Update_window_area(0,0,Window_width,Window_height);
Display_cursor();
do
clicked_button=Window_clicked_button();
while ((clicked_button<=0) && (Key!=KEY_ESC) && (Key!=SDLK_o));
Key=0;
Close_window();
Display_cursor();
}
// -- Redessiner le sprite d'un bouton dans le menu -- // -- Redessiner le sprite d'un bouton dans le menu --
@ -883,9 +927,9 @@ void Display_sprite_in_menu(int btn_number,int sprite_number)
for (y_pos=0;y_pos<MENU_SPRITE_HEIGHT;y_pos++) for (y_pos=0;y_pos<MENU_SPRITE_HEIGHT;y_pos++)
for (x_pos=0;x_pos<MENU_SPRITE_WIDTH;x_pos++) for (x_pos=0;x_pos<MENU_SPRITE_WIDTH;x_pos++)
{ {
color=GFX_menu_sprite[sprite_number][y_pos][x_pos]; color=Gfx->Menu_sprite[sprite_number][y_pos][x_pos];
Pixel_in_menu(menu_x_pos+x_pos,menu_y_pos+y_pos,color); Pixel_in_menu(menu_x_pos+x_pos,menu_y_pos+y_pos,color);
GFX_menu_block[menu_y_pos+y_pos][menu_x_pos+x_pos]=color; Gfx->Menu_block[menu_y_pos+y_pos][menu_x_pos+x_pos]=color;
} }
Update_rect(Menu_factor_X*(Buttons_Pool[btn_number].X_offset+1), Update_rect(Menu_factor_X*(Buttons_Pool[btn_number].X_offset+1),
(Buttons_Pool[btn_number].Y_offset+1)*Menu_factor_Y+Menu_Y, (Buttons_Pool[btn_number].Y_offset+1)*Menu_factor_Y+Menu_Y,
@ -909,9 +953,9 @@ void Display_paintbrush_in_menu(void)
for (menu_y_pos=2,y_pos=0;y_pos<MENU_SPRITE_HEIGHT;menu_y_pos++,y_pos++) for (menu_y_pos=2,y_pos=0;y_pos<MENU_SPRITE_HEIGHT;menu_y_pos++,y_pos++)
for (menu_x_pos=1,x_pos=0;x_pos<MENU_SPRITE_WIDTH;menu_x_pos++,x_pos++) for (menu_x_pos=1,x_pos=0;x_pos<MENU_SPRITE_WIDTH;menu_x_pos++,x_pos++)
{ {
color=GFX_menu_sprite[4][y_pos][x_pos]; color=Gfx->Menu_sprite[4][y_pos][x_pos];
Pixel_in_menu(menu_x_pos,menu_y_pos,color); Pixel_in_menu(menu_x_pos,menu_y_pos,color);
GFX_menu_block[menu_y_pos][menu_x_pos]=color; Gfx->Menu_block[menu_y_pos][menu_x_pos]=color;
} }
break; break;
default : // Pinceau default : // Pinceau
@ -920,7 +964,7 @@ void Display_paintbrush_in_menu(void)
for (menu_x_pos=1,x_pos=0;x_pos<MENU_SPRITE_WIDTH;menu_x_pos++,x_pos++) for (menu_x_pos=1,x_pos=0;x_pos<MENU_SPRITE_WIDTH;menu_x_pos++,x_pos++)
{ {
Pixel_in_menu(menu_x_pos,menu_y_pos,MC_Light); Pixel_in_menu(menu_x_pos,menu_y_pos,MC_Light);
GFX_menu_block[menu_y_pos][menu_x_pos]=MC_Light; Gfx->Menu_block[menu_y_pos][menu_x_pos]=MC_Light;
} }
// On affiche le nouveau // On affiche le nouveau
menu_start_x=8-Paintbrush_offset_X; menu_start_x=8-Paintbrush_offset_X;
@ -946,7 +990,7 @@ void Display_paintbrush_in_menu(void)
{ {
color=(Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos])?MC_Black:MC_Light; color=(Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos])?MC_Black:MC_Light;
Pixel_in_menu(menu_x_pos,menu_y_pos,color); Pixel_in_menu(menu_x_pos,menu_y_pos,color);
GFX_menu_block[menu_y_pos][menu_x_pos]=color; Gfx->Menu_block[menu_y_pos][menu_x_pos]=color;
} }
} }
Update_rect(0,Menu_Y,MENU_SPRITE_WIDTH*Menu_factor_X+3,MENU_SPRITE_HEIGHT*Menu_factor_Y+3); Update_rect(0,Menu_Y,MENU_SPRITE_WIDTH*Menu_factor_X+3,MENU_SPRITE_HEIGHT*Menu_factor_Y+3);
@ -973,18 +1017,18 @@ void Display_paintbrush_in_window(word x,word y,int number)
if (y_size<1) if (y_size<1)
y_size=1; y_size=1;
origin_x = (x + 8)*Menu_factor_X - (Preset_paintbrush_offset_X[number])*x_size+Window_pos_X; origin_x = (x + 8)*Menu_factor_X - (Gfx->Preset_paintbrush_offset_X[number])*x_size+Window_pos_X;
origin_y = (y + 8)*Menu_factor_Y - (Preset_paintbrush_offset_Y[number])*y_size+Window_pos_Y; origin_y = (y + 8)*Menu_factor_Y - (Gfx->Preset_paintbrush_offset_Y[number])*y_size+Window_pos_Y;
for (window_y_pos=0,y_pos=0; y_pos<Preset_paintbrush_height[number]; window_y_pos++,y_pos++) for (window_y_pos=0,y_pos=0; y_pos<Gfx->Preset_paintbrush_height[number]; window_y_pos++,y_pos++)
for (window_x_pos=0,x_pos=0; x_pos<Preset_paintbrush_width[number]; window_x_pos++,x_pos++) for (window_x_pos=0,x_pos=0; x_pos<Gfx->Preset_paintbrush_width[number]; window_x_pos++,x_pos++)
Block(origin_x+window_x_pos*x_size,origin_y+window_y_pos*y_size,x_size,y_size,(GFX_paintbrush_sprite[number][y_pos][x_pos])?MC_Black:MC_Light); Block(origin_x+window_x_pos*x_size,origin_y+window_y_pos*y_size,x_size,y_size,(Gfx->Paintbrush_sprite[number][y_pos][x_pos])?MC_Black:MC_Light);
// On n'utilise pas Pixel_in_window() car on ne dessine pas // On n'utilise pas Pixel_in_window() car on ne dessine pas
// forcément avec la même taille de pixel. // forcément avec la même taille de pixel.
Update_rect( ToWinX(origin_x), ToWinY(origin_y), Update_rect( ToWinX(origin_x), ToWinY(origin_y),
ToWinL(Preset_paintbrush_width[number]), ToWinL(Gfx->Preset_paintbrush_width[number]),
ToWinH(Preset_paintbrush_height[number]) ToWinH(Gfx->Preset_paintbrush_height[number])
); );
} }
@ -1041,7 +1085,7 @@ void Window_display_icon_sprite(word x_pos,word y_pos,byte type)
for (j=0; j<ICON_SPRITE_HEIGHT; j++) for (j=0; j<ICON_SPRITE_HEIGHT; j++)
for (i=0; i<ICON_SPRITE_WIDTH; i++) for (i=0; i<ICON_SPRITE_WIDTH; i++)
Pixel_in_window(x_pos+i,y_pos+j,GFX_icon_sprite[type][j][i]); Pixel_in_window(x_pos+i,y_pos+j,Gfx->Icon_sprite[type][j][i]);
Update_rect(ToWinX(x_pos),ToWinY(y_pos),ToWinL(ICON_SPRITE_WIDTH),ToWinH(ICON_SPRITE_HEIGHT)); Update_rect(ToWinX(x_pos),ToWinY(y_pos),ToWinL(ICON_SPRITE_WIDTH),ToWinH(ICON_SPRITE_HEIGHT));
} }
@ -1234,6 +1278,46 @@ void Compute_paintbrush_coordinates(void)
Paintbrush_X=(((Paintbrush_X+(Snap_width>>1)-Snap_offset_X)/Snap_width)*Snap_width)+Snap_offset_X; Paintbrush_X=(((Paintbrush_X+(Snap_width>>1)-Snap_offset_X)/Snap_width)*Snap_width)+Snap_offset_X;
Paintbrush_Y=(((Paintbrush_Y+(Snap_height>>1)-Snap_offset_Y)/Snap_height)*Snap_height)+Snap_offset_Y; Paintbrush_Y=(((Paintbrush_Y+(Snap_height>>1)-Snap_offset_Y)/Snap_height)*Snap_height)+Snap_offset_Y;
} }
// Handling the snap axis mode, when shift is pressed.
switch (Current_operation)
{
// Operations that don't implement it
case OPERATION_LINE:
Snap_axis=0;
break;
// Operations that implement it
default:
if (Snap_axis==0 && (SDL_GetModState() & KMOD_SHIFT))
{
// Start "Snap axis" mode
Snap_axis=1;
Snap_axis_origin_X=Paintbrush_X;
Snap_axis_origin_Y=Paintbrush_Y;
}
}
if (Snap_axis==1)
{
// Cursor moved
if (Paintbrush_X != Snap_axis_origin_X || Paintbrush_Y != Snap_axis_origin_Y)
{
if ((Paintbrush_X-Snap_axis_origin_X)*(Paintbrush_X-Snap_axis_origin_X) >
(Paintbrush_Y-Snap_axis_origin_Y)*(Paintbrush_Y-Snap_axis_origin_Y))
// Displacement was bigger on X axis: lock Y
Snap_axis=2;
else
Snap_axis=3;
}
}
if (Snap_axis==2)
{
Paintbrush_Y = Snap_axis_origin_Y;
}
else if (Snap_axis==3)
{
Paintbrush_X = Snap_axis_origin_X;
}
} }
@ -1522,7 +1606,7 @@ void Display_cursor(void)
short end_y; short end_y;
short x_pos; short x_pos;
short y_pos; short y_pos;
short counter_x; short counter_x = 0;
short counter_y; short counter_y;
int temp; int temp;
byte color; byte color;
@ -1567,21 +1651,23 @@ void Display_cursor(void)
else else
{ {
temp=(Config.Cursor)?CURSOR_SHAPE_THIN_TARGET:CURSOR_SHAPE_TARGET; temp=(Config.Cursor)?CURSOR_SHAPE_THIN_TARGET:CURSOR_SHAPE_TARGET;
start_x=Mouse_X-Cursor_offset_X[temp]; start_x=Mouse_X-Gfx->Cursor_offset_X[temp];
start_y=Mouse_Y-Cursor_offset_Y[temp]; start_y=Mouse_Y-Gfx->Cursor_offset_Y[temp];
for (x_pos=start_x,counter_x=0;counter_x<15 && x_pos < Screen_width;x_pos++,counter_x++) for (y_pos=start_y,counter_y=0; counter_y<15 && y_pos < Screen_height;
{ y_pos++,counter_y++)
if( x_pos < 0 ) continue; {
for (y_pos=start_y,counter_y=0;counter_y<15 && y_pos < Screen_height;y_pos++,counter_y++) if( y_pos < 0 ) continue;
{ for (x_pos=start_x,counter_x=0;
if( y_pos < 0 || y_pos >= Screen_height) continue; counter_x<15 && x_pos < Screen_width; x_pos++,counter_x++)
color=GFX_cursor_sprite[temp][counter_y][counter_x]; {
CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos); if( x_pos < 0 ) continue;
if (color!=MC_Trans) color=Gfx->Cursor_sprite[temp][counter_y][counter_x];
Pixel(x_pos,y_pos,color); Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
if (color!=MC_Trans)
Pixel(x_pos,y_pos,color);
} }
} }
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y); Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
} }
@ -1634,25 +1720,24 @@ void Display_cursor(void)
} }
else else
{ {
DEBUG("B",0);
temp=(Config.Cursor)?CURSOR_SHAPE_THIN_COLORPICKER:CURSOR_SHAPE_COLORPICKER; temp=(Config.Cursor)?CURSOR_SHAPE_THIN_COLORPICKER:CURSOR_SHAPE_COLORPICKER;
start_x=Mouse_X-Cursor_offset_X[temp]; start_x=Mouse_X-Gfx->Cursor_offset_X[temp];
start_y=Mouse_Y-Cursor_offset_Y[temp]; start_y=Mouse_Y-Gfx->Cursor_offset_Y[temp];
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++) for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
{ {
if(y_pos<0) continue;
if(y_pos>=Screen_height) break;
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
{
if(x_pos<0) continue; if(x_pos<0) continue;
if(x_pos>=Screen_width) break; if(x_pos>=Screen_width) break;
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++) color=Gfx->Cursor_sprite[temp][counter_y][counter_x];
{ // On sauvegarde dans Cursor_background pour restaurer plus tard
if(y_pos<0) continue; Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
if(y_pos>=Screen_height) break; if (color!=MC_Trans)
color=GFX_cursor_sprite[temp][counter_y][counter_x]; Pixel(x_pos,y_pos,color);
// On sauvegarde dans CURSOR_BACKGROUND pour restaurer plus tard }
CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
if (color!=MC_Trans)
Pixel(x_pos,y_pos,color);
}
} }
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y); Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
} }
@ -1666,20 +1751,20 @@ void Display_cursor(void)
case CURSOR_SHAPE_ARROW : case CURSOR_SHAPE_ARROW :
case CURSOR_SHAPE_HOURGLASS : case CURSOR_SHAPE_HOURGLASS :
start_x=Mouse_X-Cursor_offset_X[shape]; start_x=Mouse_X-Gfx->Cursor_offset_X[shape];
start_y=Mouse_Y-Cursor_offset_Y[shape]; start_y=Mouse_Y-Gfx->Cursor_offset_Y[shape];
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++) for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
{ {
if(x_pos<0) continue; if(y_pos<0) continue;
if(x_pos>=Screen_width) break; if(y_pos>=Screen_height) break;
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++) for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
{ {
if(y_pos<0) continue; if(x_pos<0) continue;
if(y_pos>=Screen_height) break; if(x_pos>=Screen_width) break;
color=GFX_cursor_sprite[shape][counter_y][counter_x]; color=Gfx->Cursor_sprite[shape][counter_y][counter_x];
// On sauvegarde dans CURSOR_BACKGROUND pour restaurer plus tard // On sauvegarde dans Cursor_background pour restaurer plus tard
CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos); Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos);
if (color!=MC_Trans) if (color!=MC_Trans)
Pixel(x_pos,y_pos,color); Pixel(x_pos,y_pos,color);
} }
} }
@ -1826,14 +1911,11 @@ void Hide_cursor(void)
int start_y; int start_y;
short end_x; short end_x;
short end_y; short end_y;
int x_pos; int x_pos = 0;
int y_pos; int y_pos;
short counter_x; short counter_x = 0;
short counter_y; short counter_y;
//short end_counter_x; // Position X ou s'arrête l'affichage de la brosse/pinceau
//short end_counter_y; // Position Y ou s'arrête l'affichage de la brosse/pinceau
int temp; int temp;
//byte color;
float cos_a,sin_a; float cos_a,sin_a;
short x1,y1,x2,y2,x3,y3,x4,y4; short x1,y1,x2,y2,x3,y3,x4,y4;
@ -1873,17 +1955,18 @@ void Hide_cursor(void)
else else
{ {
temp=(Config.Cursor)?CURSOR_SHAPE_THIN_TARGET:CURSOR_SHAPE_TARGET; temp=(Config.Cursor)?CURSOR_SHAPE_THIN_TARGET:CURSOR_SHAPE_TARGET;
start_x=Mouse_X-Cursor_offset_X[temp]; start_x=Mouse_X-Gfx->Cursor_offset_X[temp];
start_y=Mouse_Y-Cursor_offset_Y[temp]; start_y=Mouse_Y-Gfx->Cursor_offset_Y[temp];
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++) for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
{ {
if(y_pos < 0) continue;
if(y_pos>=Screen_height) break; if(y_pos>=Screen_height) break;
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++) for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
{ {
if ( (x_pos<0) || (y_pos < 0)) continue; if(x_pos < 0) continue;
else if (x_pos>=Screen_width) break; else if (x_pos>=Screen_width) break;
Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]); Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]);
} }
} }
@ -1941,21 +2024,21 @@ void Hide_cursor(void)
else else
{ {
temp=(Config.Cursor)?CURSOR_SHAPE_THIN_COLORPICKER:CURSOR_SHAPE_COLORPICKER; temp=(Config.Cursor)?CURSOR_SHAPE_THIN_COLORPICKER:CURSOR_SHAPE_COLORPICKER;
start_x=Mouse_X-Cursor_offset_X[temp]; start_x=Mouse_X-Gfx->Cursor_offset_X[temp];
start_y=Mouse_Y-Cursor_offset_Y[temp]; start_y=Mouse_Y-Gfx->Cursor_offset_Y[temp];
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++) for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
{ {
if(y_pos<0) continue;
if(y_pos>=Screen_height) break;
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
{
if(x_pos<0) continue; if(x_pos<0) continue;
if(x_pos>=Screen_width) break; if(x_pos>=Screen_width) break;
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++) Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]);
{
if(y_pos<0) continue;
if(y_pos>=Screen_height) break;
Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]);
}
} }
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y); }
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
} }
} }
if (!Paintbrush_hidden) if (!Paintbrush_hidden)
@ -1969,18 +2052,18 @@ void Hide_cursor(void)
case CURSOR_SHAPE_ARROW : case CURSOR_SHAPE_ARROW :
case CURSOR_SHAPE_HOURGLASS : case CURSOR_SHAPE_HOURGLASS :
start_x=Mouse_X-Cursor_offset_X[shape]; start_x=Mouse_X-Gfx->Cursor_offset_X[shape];
start_y=Mouse_Y-Cursor_offset_Y[shape]; start_y=Mouse_Y-Gfx->Cursor_offset_Y[shape];
for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++) for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++)
{ {
if(x_pos<0) continue; if(y_pos<0) continue;
if(x_pos>=Screen_width) break; if(y_pos>=Screen_height) break;
for (y_pos=start_y,counter_y=0;counter_y<15;y_pos++,counter_y++) for (x_pos=start_x,counter_x=0;counter_x<15;x_pos++,counter_x++)
{ {
if(y_pos<0) continue; if(x_pos<0) continue;
if(y_pos>=Screen_height) break; if(x_pos>=Screen_width) break;
Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]); Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]);
} }
} }
Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y); Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);
@ -2492,52 +2575,52 @@ void Compute_optimal_menu_colors(T_Components * palette)
for (k=0; k<NB_CURSOR_SPRITES; k++) for (k=0; k<NB_CURSOR_SPRITES; k++)
for (j=0; j<CURSOR_SPRITE_HEIGHT; j++) for (j=0; j<CURSOR_SPRITE_HEIGHT; j++)
for (i=0; i<CURSOR_SPRITE_WIDTH; i++) for (i=0; i<CURSOR_SPRITE_WIDTH; i++)
Remap_pixel(&GFX_cursor_sprite[k][j][i]); Remap_pixel(&Gfx->Cursor_sprite[k][j][i]);
// Le menu // Le menu
for (j=0; j<MENU_HEIGHT; j++) for (j=0; j<MENU_HEIGHT; j++)
for (i=0; i<MENU_WIDTH; i++) for (i=0; i<MENU_WIDTH; i++)
Remap_pixel(&GFX_menu_block[j][i]); Remap_pixel(&Gfx->Menu_block[j][i]);
// Sprites du menu // Sprites du menu
for (k=0; k<NB_MENU_SPRITES; k++) for (k=0; k<NB_MENU_SPRITES; k++)
for (j=0; j<MENU_SPRITE_HEIGHT; j++) for (j=0; j<MENU_SPRITE_HEIGHT; j++)
for (i=0; i<MENU_SPRITE_WIDTH; i++) for (i=0; i<MENU_SPRITE_WIDTH; i++)
Remap_pixel(&GFX_menu_sprite[k][j][i]); Remap_pixel(&Gfx->Menu_sprite[k][j][i]);
// Sprites d'effets // Sprites d'effets
for (k=0; k<NB_EFFECTS_SPRITES; k++) for (k=0; k<NB_EFFECTS_SPRITES; k++)
for (j=0; j<MENU_SPRITE_HEIGHT; j++) for (j=0; j<MENU_SPRITE_HEIGHT; j++)
for (i=0; i<MENU_SPRITE_WIDTH; i++) for (i=0; i<MENU_SPRITE_WIDTH; i++)
Remap_pixel(&GFX_effect_sprite[k][j][i]); Remap_pixel(&Gfx->Effect_sprite[k][j][i]);
// Fontes de l'aide // Fontes de l'aide
for (k=0; k<256; k++) for (k=0; k<256; k++)
for (j=0; j<8; j++) for (j=0; j<8; j++)
for (i=0; i<6; i++) for (i=0; i<6; i++)
Remap_pixel(&GFX_help_font_norm[k][i][j]); Remap_pixel(&Gfx->Help_font_norm[k][i][j]);
for (k=0; k<256; k++) for (k=0; k<256; k++)
for (j=0; j<8; j++) for (j=0; j<8; j++)
for (i=0; i<6; i++) for (i=0; i<6; i++)
Remap_pixel(&GFX_bold_font[k][i][j]); Remap_pixel(&Gfx->Bold_font[k][i][j]);
for (k=0; k<64; k++) for (k=0; k<64; k++)
for (j=0; j<8; j++) for (j=0; j<8; j++)
for (i=0; i<6; i++) for (i=0; i<6; i++)
Remap_pixel(&GFX_help_font_t1[k][i][j]); Remap_pixel(&Gfx->Help_font_t1[k][i][j]);
for (k=0; k<64; k++) for (k=0; k<64; k++)
for (j=0; j<8; j++) for (j=0; j<8; j++)
for (i=0; i<6; i++) for (i=0; i<6; i++)
Remap_pixel(&GFX_help_font_t2[k][i][j]); Remap_pixel(&Gfx->Help_font_t2[k][i][j]);
for (k=0; k<64; k++) for (k=0; k<64; k++)
for (j=0; j<8; j++) for (j=0; j<8; j++)
for (i=0; i<6; i++) for (i=0; i<6; i++)
Remap_pixel(&GFX_help_font_t3[k][i][j]); Remap_pixel(&Gfx->Help_font_t3[k][i][j]);
for (k=0; k<64; k++) for (k=0; k<64; k++)
for (j=0; j<8; j++) for (j=0; j<8; j++)
for (i=0; i<6; i++) for (i=0; i<6; i++)
Remap_pixel(&GFX_help_font_t4[k][i][j]); Remap_pixel(&Gfx->Help_font_t4[k][i][j]);
// Sprites de lecteurs (drives) // Sprites de lecteurs (drives)
for (k=0; k<NB_ICON_SPRITES; k++) for (k=0; k<NB_ICON_SPRITES; k++)
for (j=0; j<ICON_SPRITE_HEIGHT; j++) for (j=0; j<ICON_SPRITE_HEIGHT; j++)
for (i=0; i<ICON_SPRITE_WIDTH; i++) for (i=0; i<ICON_SPRITE_WIDTH; i++)
Remap_pixel(&GFX_icon_sprite[k][j][i]); Remap_pixel(&Gfx->Icon_sprite[k][j][i]);
} }
Clear_border(MC_Black); Clear_border(MC_Black);
} }

View File

@ -70,6 +70,7 @@ void Print_counter(short x,short y,const char * str,byte text_color,byte backgro
byte Confirmation_box(char * message); byte Confirmation_box(char * message);
void Warning_message(char * message); void Warning_message(char * message);
void Verbose_error_message(char * message);
void Display_image_limits(void); void Display_image_limits(void);
void Display_all_screen(void); void Display_all_screen(void);