From 1eb463c94f6a9d132687e6f25610b24510ab4eab Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Mon, 23 Jun 2025 12:31:24 +0300 Subject: [PATCH 1/6] STM32 HAL library example --- README.md | 2 + STM32_HAL_Lib/README.md | 13 +++++ STM32_HAL_Lib/mctext.c | 107 ++++++++++++++++++++++++++++++++++++++++ STM32_HAL_Lib/mctext.h | 21 ++++++++ 4 files changed, 143 insertions(+) create mode 100644 STM32_HAL_Lib/README.md create mode 100644 STM32_HAL_Lib/mctext.c create mode 100644 STM32_HAL_Lib/mctext.h diff --git a/README.md b/README.md index 711a5e1..b10d6bd 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Some basic hints on the interface: Download in the [Releases](https://gitea.mcflyer.ru/McFLY/McBitFont/releases) section! +Library example instructions to implement to STM32 code: [mctext](STM32_HAL_Lib/README.md) + #### Important: **Since v2.0 new save file format is implemented. You can use [McBitFont v1.7](https://gitea.mcflyer.ru/McFLY/McBitFont/releases/tag/v1.7) to convert old saved files to the new format.** diff --git a/STM32_HAL_Lib/README.md b/STM32_HAL_Lib/README.md new file mode 100644 index 0000000..dec9c23 --- /dev/null +++ b/STM32_HAL_Lib/README.md @@ -0,0 +1,13 @@ +# McText Library + +- The library uses "Left to Right, Top to bottom" scan and "LSB Top" for pixels alignment + +#### Instructions + +To use the library you have to have a display driver with a function that paints a single pixel with X and Y coordinates and 0/1 color.
+Find "SET A FUNCTION NAME HERE!" text in *mctext.c* file and change the function name that suits your driver.
+**Note:** it is possible that you will have to change parameters in the function to match your driver. + +**Note:** check the "include" in *mctext.h* file to match your HAL. (stm32f1xx_hal.h is fo STM32F1 MCU series) + +Now use **mct_String** function to draw a string of text. \ No newline at end of file diff --git a/STM32_HAL_Lib/mctext.c b/STM32_HAL_Lib/mctext.c new file mode 100644 index 0000000..4777348 --- /dev/null +++ b/STM32_HAL_Lib/mctext.c @@ -0,0 +1,107 @@ +/* + * mctext.c + * + * Created on: May 16, 2025 + * Author: User + */ + + +#include "mctext.h" +#include "ST7565.h" + +//=========================== SET A FUNCTION NAME HERE! ===========================// +// A function from display driver to set a pixel (x, y, color) +void (*mct_SetPixel)(uint8_t, uint8_t, uint8_t) = ST7565_SetPixel; +//=================================================================================// + + +// Draw a single character. Returns width of drawn character +uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font) { + uint8_t pk = font[0]; // Is it a packed font? + uint8_t w = font[1]; // Font char width + uint8_t h = font[2]; // Font char height + uint8_t fc = font[4]; // First char code in the font + uint8_t lc = font[5]; // Last char code in the font + uint8_t i, j, p, s, b, seg; // i-cur.column, j-cur.row of 8, p-rows of 8, s-height in cur.row of 8, b-cur.bit in cur.row, seg-byte.segment + uint8_t bps; // Bytes per symbol for packed fonts + uint16_t o; // Current offset + + if (c < fc || c > lc) return 0; + if (x > LCDWIDTH) return 0; + if (y+h > LCDHEIGHT) return 0; + + // Calc the offset for desired symbol + if (pk) { // The font is packed + if (w) { // The font is monospaced + bps = w*h/8 + 1; // Bytes per symbol + width byte + if ((w*h)%8 > 0) bps++; // Correction for the last byte + o = FONT_HEADER+(c-fc)*bps; // Offset for desired symbol + } else { // The font is not monospaced + o = FONT_HEADER; // Starting offset + for (i=0; i 0) bps++; // Correction for the last byte + o += bps + 1; // Adding symbol's width to the offset (+ width byte) + } + w = font[o]; // Desired symbol's width + o++; // Offset for desired symbol's data + } + + // Draw the packed symbol! + bps = w*h/8; // Bytes per current symbol + if ((w*h)%8 > 0) bps++; // Correction for the last byte + b = 0; // bit indexer in "current" byte + for (i=0; i LCDWIDTH) return i-1; // Check if we're out of display size + for (j=0; j>b) & 1) mct_SetPixel(x+i, y+j, color); // Paint the pixel + if (b < 7) b++; else {b = 0; o++;} // Track bits and bytes + } + } + + } else { // The font is not packed + p = (h%8 > 0) ? h/8 + 1 : h/8; // Bytes in one column + if (w) { // The font is monospaced + o = FONT_HEADER+(c-fc)*w*p; // Offset for desired symbol + } else { // The font is not monospaced + o = FONT_HEADER; // Starting offset + for (i=0; i LCDWIDTH) return i-1; // Check if we're out of display size + for (j=0; j= 8) ? 8 : (h - j*8) % 8; // Clac the amount of pixels in current byte + + seg = font[o]; + for (b=0; b>b) & 1) mct_SetPixel(x+i, y+j*8+b, color); + } + o++; + } + //mct_SetPixel(x+i, y, color); // For testing purposes + } + } + return w; +} + +// Draw a string of characters +void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font) { + uint8_t w = font[0]; // Font char width + uint8_t h = font[1]; // Font char height + uint8_t s = font[2]; // Font space between characters + + if (y+h > LCDHEIGHT) return; + while (c[0] != 0) { + if (x+w > LCDWIDTH) return; + w = mct_Char(x, y, (unsigned char)*c, color, font); + c++; + x += w + s; + } +} diff --git a/STM32_HAL_Lib/mctext.h b/STM32_HAL_Lib/mctext.h new file mode 100644 index 0000000..c21b0f3 --- /dev/null +++ b/STM32_HAL_Lib/mctext.h @@ -0,0 +1,21 @@ +/* + * mctext.h + * + * Created on: May 16, 2025 + * Author: User + */ + +#ifndef INC_MCTEXT_H_ +#define INC_MCTEXT_H_ + +#include "stm32f1xx_hal.h" + + + +// Draw a single character. Returns width of drawn character +uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font); + +// Draw a string of characters +void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font); + +#endif /* INC_MCTEXT_H_ */ From 8ed1e33f22cb4888f292b327c79b8dc45c86206a Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Wed, 25 Jun 2025 02:00:28 +0300 Subject: [PATCH 2/6] Alagard 9x17 font finished --- examples/Font_9x17_Alagard_cyr_vw.mbfont | Bin 36211 -> 36211 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/examples/Font_9x17_Alagard_cyr_vw.mbfont b/examples/Font_9x17_Alagard_cyr_vw.mbfont index a180d290315b89f2f2121f8aa4be64025a596054..4720ecd3063d2a42dd11d1fce4df195582cac4c5 100644 GIT binary pat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, 26 Jun 2025 14:42:19 +0300 Subject: [PATCH 3/6] mctext.c library fix --- STM32_HAL_Lib/mctext.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/STM32_HAL_Lib/mctext.c b/STM32_HAL_Lib/mctext.c index 4777348..7079441 100644 --- a/STM32_HAL_Lib/mctext.c +++ b/STM32_HAL_Lib/mctext.c @@ -16,7 +16,7 @@ void (*mct_SetPixel)(uint8_t, uint8_t, uint8_t) = ST7565_SetPixel; // Draw a single character. Returns width of drawn character -uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font) { +uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font, uint8_t transp) { uint8_t pk = font[0]; // Is it a packed font? uint8_t w = font[1]; // Font char width uint8_t h = font[2]; // Font char height @@ -33,7 +33,7 @@ uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uin // Calc the offset for desired symbol if (pk) { // The font is packed if (w) { // The font is monospaced - bps = w*h/8 + 1; // Bytes per symbol + width byte + bps = w*h/8; // Bytes per symbol if ((w*h)%8 > 0) bps++; // Correction for the last byte o = FONT_HEADER+(c-fc)*bps; // Offset for desired symbol } else { // The font is not monospaced @@ -82,6 +82,7 @@ uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uin seg = font[o]; for (b=0; b>b) & 1) mct_SetPixel(x+i, y+j*8+b, color); + else if (!transp) mct_SetPixel(x+i, y+j*8+b, !color); } o++; } @@ -91,11 +92,16 @@ uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uin return w; } +// Draw a single character. Transparent background. Returns width of drawn character +uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font) { + mct_CharT(x, y, c, color, font, 1); +} + // Draw a string of characters void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font) { - uint8_t w = font[0]; // Font char width - uint8_t h = font[1]; // Font char height - uint8_t s = font[2]; // Font space between characters + uint8_t w = font[1]; // Font char width + uint8_t h = font[2]; // Font char height + uint8_t s = font[3]; // Font space between characters if (y+h > LCDHEIGHT) return; while (c[0] != 0) { From 3778a753fb6b3ea8589cf3e5adaadf937d300a09 Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Fri, 27 Jun 2025 12:18:27 +0300 Subject: [PATCH 4/6] Update TODO --- TODO.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO.txt b/TODO.txt index c78f137..39556bb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -5,3 +5,4 @@ Application: Functionality: Bugs: +- Fix selection info: change comma to x From fc4822065a4b4b1b9bf1a0ae09ff930418bb15b3 Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Fri, 27 Jun 2025 12:45:31 +0300 Subject: [PATCH 5/6] mctext library fix --- STM32_HAL_Lib/mctext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STM32_HAL_Lib/mctext.c b/STM32_HAL_Lib/mctext.c index 7079441..308051f 100644 --- a/STM32_HAL_Lib/mctext.c +++ b/STM32_HAL_Lib/mctext.c @@ -94,7 +94,7 @@ uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const ui // Draw a single character. Transparent background. Returns width of drawn character uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font) { - mct_CharT(x, y, c, color, font, 1); + return mct_CharT(x, y, c, color, font, 1); } // Draw a string of characters From 4fe2af03b0cc0dd91589cba0f1cdfcf6624a0457 Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Tue, 1 Jul 2025 00:07:01 +0300 Subject: [PATCH 6/6] TODO features: V Cursor for rectangular selection tool V Icons for tool buttons V Tooltips now has keyboard shortcuts info V Fix selection info: change comma to x --- McBitFont/Form1.Designer.cs | 46 ++++++++++++++++---------------- McBitFont/Form1.cs | 12 ++++++--- McBitFont/McBitFont.csproj | 6 ++--- McBitFont/McCursor.cs | 26 ++++++++++++++++++ TODO.txt | 6 +++-- examples/SelectionCursor.mbfont | Bin 0 -> 1045 bytes 6 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 examples/SelectionCursor.mbfont diff --git a/McBitFont/Form1.Designer.cs b/McBitFont/Form1.Designer.cs index d6f70b6..a30ab85 100644 --- a/McBitFont/Form1.Designer.cs +++ b/McBitFont/Form1.Designer.cs @@ -214,7 +214,7 @@ cbZoom.Size = new System.Drawing.Size(75, 23); cbZoom.TabIndex = 6; cbZoom.TabStop = false; - toolTip1.SetToolTip(cbZoom, "Canvas zoom level"); + toolTip1.SetToolTip(cbZoom, "Canvas zoom level (Ctrl+Scroll)"); // // label4 // @@ -249,38 +249,38 @@ // btnFill // btnFill.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnFill.Image = Properties.Resources.Canvas_Fill; btnFill.Location = new System.Drawing.Point(92, 9); btnFill.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnFill.Name = "btnFill"; btnFill.Size = new System.Drawing.Size(35, 35); btnFill.TabIndex = 8; - btnFill.Text = "⬤"; - toolTip1.SetToolTip(btnFill, "Paint canvas black"); + toolTip1.SetToolTip(btnFill, "Paint canvas black (Ctrl+B)"); btnFill.UseVisualStyleBackColor = true; btnFill.Click += btnFill_Click; // // btnClear // btnClear.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnClear.Image = Properties.Resources.Canvas_Clear; btnClear.Location = new System.Drawing.Point(8, 9); btnClear.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnClear.Name = "btnClear"; btnClear.Size = new System.Drawing.Size(35, 35); btnClear.TabIndex = 7; - btnClear.Text = "○"; - toolTip1.SetToolTip(btnClear, "Paint canvas white"); + toolTip1.SetToolTip(btnClear, "Paint canvas white (Ctrl+W)"); btnClear.UseVisualStyleBackColor = true; btnClear.Click += btnClear_Click; // // btnMirrorY // btnMirrorY.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnMirrorY.Image = Properties.Resources.Famfamfam_Silk_Shape_flip_vertical_16; btnMirrorY.Location = new System.Drawing.Point(92, 92); btnMirrorY.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnMirrorY.Name = "btnMirrorY"; btnMirrorY.Size = new System.Drawing.Size(35, 35); btnMirrorY.TabIndex = 6; - btnMirrorY.Text = "⩥"; toolTip1.SetToolTip(btnMirrorY, "Mirror by Y axis (vertical)"); btnMirrorY.UseVisualStyleBackColor = true; btnMirrorY.Click += btnMirrorY_Click; @@ -288,12 +288,12 @@ // btnMirrorX // btnMirrorX.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnMirrorX.Image = Properties.Resources.Famfamfam_Silk_Shape_flip_horizontal_16; btnMirrorX.Location = new System.Drawing.Point(50, 92); btnMirrorX.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnMirrorX.Name = "btnMirrorX"; btnMirrorX.Size = new System.Drawing.Size(35, 35); btnMirrorX.TabIndex = 5; - btnMirrorX.Text = "◮"; toolTip1.SetToolTip(btnMirrorX, "Mirror by X axis (horizontal)"); btnMirrorX.UseVisualStyleBackColor = true; btnMirrorX.Click += btnMirrorX_Click; @@ -301,65 +301,65 @@ // btnInvert // btnInvert.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnInvert.Image = Properties.Resources.z_contrast; btnInvert.Location = new System.Drawing.Point(8, 92); btnInvert.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnInvert.Name = "btnInvert"; btnInvert.Size = new System.Drawing.Size(35, 35); btnInvert.TabIndex = 4; - btnInvert.Text = "◪"; - toolTip1.SetToolTip(btnInvert, "Invert pixel colors"); + toolTip1.SetToolTip(btnInvert, "Invert pixel colors (Ctrl+I)"); btnInvert.UseVisualStyleBackColor = true; btnInvert.Click += btnInvert_Click; // // btnShiftDown // btnShiftDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnShiftDown.Image = Properties.Resources.z_down; btnShiftDown.Location = new System.Drawing.Point(50, 51); btnShiftDown.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnShiftDown.Name = "btnShiftDown"; btnShiftDown.Size = new System.Drawing.Size(35, 35); btnShiftDown.TabIndex = 3; - btnShiftDown.Text = "▼"; - toolTip1.SetToolTip(btnShiftDown, "Shift pixels down"); + toolTip1.SetToolTip(btnShiftDown, "Shift pixels down (Ctrl+Down)"); btnShiftDown.UseVisualStyleBackColor = true; btnShiftDown.Click += btnShiftDown_Click; // // btnShiftUp // btnShiftUp.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnShiftUp.Image = Properties.Resources.z_uo; btnShiftUp.Location = new System.Drawing.Point(50, 9); btnShiftUp.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnShiftUp.Name = "btnShiftUp"; btnShiftUp.Size = new System.Drawing.Size(35, 35); btnShiftUp.TabIndex = 2; - btnShiftUp.Text = "▲"; - toolTip1.SetToolTip(btnShiftUp, "Shift pixels up"); + toolTip1.SetToolTip(btnShiftUp, "Shift pixels up (Ctrl+Up)"); btnShiftUp.UseVisualStyleBackColor = true; btnShiftUp.Click += btnShiftUp_Click; // // btnShiftRight // btnShiftRight.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnShiftRight.Image = Properties.Resources.z_right; btnShiftRight.Location = new System.Drawing.Point(92, 51); btnShiftRight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnShiftRight.Name = "btnShiftRight"; btnShiftRight.Size = new System.Drawing.Size(35, 35); btnShiftRight.TabIndex = 1; - btnShiftRight.Text = "▶"; - toolTip1.SetToolTip(btnShiftRight, "Shift pixels right"); + toolTip1.SetToolTip(btnShiftRight, "Shift pixels right (Ctrl+Right)"); btnShiftRight.UseVisualStyleBackColor = true; btnShiftRight.Click += btnShiftRight_Click; // // btnShiftLeft // btnShiftLeft.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204); + btnShiftLeft.Image = Properties.Resources.z_left; btnShiftLeft.Location = new System.Drawing.Point(8, 51); btnShiftLeft.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnShiftLeft.Name = "btnShiftLeft"; btnShiftLeft.Size = new System.Drawing.Size(35, 35); btnShiftLeft.TabIndex = 0; - btnShiftLeft.Text = "◀"; - toolTip1.SetToolTip(btnShiftLeft, "Shift pixels left"); + toolTip1.SetToolTip(btnShiftLeft, "Shift pixels left (Ctrl+Left)"); btnShiftLeft.UseVisualStyleBackColor = true; btnShiftLeft.Click += btnShiftLeft_Click; // @@ -374,7 +374,7 @@ btnExport.Text = " Export"; btnExport.TextAlign = System.Drawing.ContentAlignment.MiddleRight; btnExport.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - toolTip1.SetToolTip(btnExport, "Configure and export data"); + toolTip1.SetToolTip(btnExport, "Configure and export data (Ctrl+E)"); btnExport.UseVisualStyleBackColor = true; btnExport.Click += Export_Click; // @@ -491,7 +491,7 @@ btnApply.Text = " Apply"; btnApply.TextAlign = System.Drawing.ContentAlignment.MiddleRight; btnApply.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - toolTip1.SetToolTip(btnApply, "Apply changes made to the symbol"); + toolTip1.SetToolTip(btnApply, "Apply changes made to the symbol (Ctrl+Space)"); btnApply.UseVisualStyleBackColor = true; btnApply.Click += button2_Click; // @@ -1065,7 +1065,7 @@ chkRectSelect.Text = " Select"; chkRectSelect.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; chkRectSelect.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - toolTip1.SetToolTip(chkRectSelect, "Turn on/off rectangle selection"); + toolTip1.SetToolTip(chkRectSelect, "Turn on/off rectangle selection (Ctrl+R)"); chkRectSelect.UseVisualStyleBackColor = true; chkRectSelect.CheckedChanged += chkRectSelect_CheckedChanged; // @@ -1078,7 +1078,7 @@ nudBrush.Name = "nudBrush"; nudBrush.Size = new System.Drawing.Size(47, 23); nudBrush.TabIndex = 24; - toolTip1.SetToolTip(nudBrush, "Symbol height"); + toolTip1.SetToolTip(nudBrush, "Symbol height (Alt+Scroll)"); nudBrush.Value = new decimal(new int[] { 1, 0, 0, 0 }); nudBrush.ValueChanged += nudBrush_ValueChanged; // @@ -1110,9 +1110,9 @@ lblSelection.Location = new System.Drawing.Point(5, 84); lblSelection.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); lblSelection.Name = "lblSelection"; - lblSelection.Size = new System.Drawing.Size(30, 15); + lblSelection.Size = new System.Drawing.Size(32, 15); lblSelection.TabIndex = 24; - lblSelection.Text = "W,H"; + lblSelection.Text = "WxH"; lblSelection.TextAlign = System.Drawing.ContentAlignment.TopRight; lblSelection.Visible = false; // diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs index 9da77c4..d735281 100644 --- a/McBitFont/Form1.cs +++ b/McBitFont/Form1.cs @@ -59,7 +59,7 @@ namespace McBitFont { public bool monospaced = false; private bool modified = false; private bool prjModified = false; - public const string version = "2.6"; + public const string version = "2.7"; public string prjName = "Untitled"; public string prjFileName = ""; public int codepage = 1251; @@ -83,7 +83,7 @@ namespace McBitFont { } private void UpdateSelectionLabel(int width, int height) { - lblSelection.Text = width.ToString() + ',' + height.ToString(); + lblSelection.Text = width.ToString() + 'x' + height.ToString(); } public void SetModified(bool modif = true, bool prj = false) { @@ -346,7 +346,7 @@ namespace McBitFont { vScroll.Enabled = true; } - dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); + if (!chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); dotPanel.Refresh(); } @@ -1394,6 +1394,10 @@ namespace McBitFont { private void chkRectSelect_CheckedChanged(object sender, EventArgs e) { lblSelection.Visible = lblSelectionLabel.Visible = chkRectSelect.Checked; selectAllToolStripMenuItem.Enabled = chkRectSelect.Checked; + + if (chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursorSelect(); + else dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); + dotPanel.Refresh(); } @@ -1688,7 +1692,7 @@ namespace McBitFont { } private void nudBrush_ValueChanged(object sender, EventArgs e) { - dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); + if (!chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); } } } diff --git a/McBitFont/McBitFont.csproj b/McBitFont/McBitFont.csproj index ff2d703..4034c37 100644 --- a/McBitFont/McBitFont.csproj +++ b/McBitFont/McBitFont.csproj @@ -20,9 +20,9 @@ true true icon_64.ico - 2.6.0.0 - 2.6.0.0 - $(VersionPrefix)2.6.0 + 2.7.0.0 + 2.7.0.0 + $(VersionPrefix)2.7.0 Anton Mukhin diff --git a/McBitFont/McCursor.cs b/McBitFont/McCursor.cs index c253520..a2cb6e4 100644 --- a/McBitFont/McCursor.cs +++ b/McBitFont/McCursor.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Linq; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; @@ -101,5 +102,30 @@ namespace McBitFont { return CreateCursorNoResize(bmp, cellSize / 2, cellSize / 2); } + public static Cursor GetCursorSelect() { + Point[] arrow = { new(1, 1), new(12, 12), new(11, 13), new(6, 13), new(2, 17), new(1, 16) }; + Point[] corner1 = { new(13, 6), new(20, 6), new(20, 13), new(17, 13), new(17, 9), new(13, 9) }; + Point[] corner2 = { new(17, 16), new(20, 16), new(20, 23), new(13, 23), new(13, 20), new(17, 20) }; + Point[] corner3 = { new(3, 16), new(6, 16), new(6, 20), new(10, 20), new(10, 23), new(3, 23) }; + Point[] corner4 = { new(6, 6), new(10, 6), new(10, 9), new(6, 9) }; + + Bitmap bmp = new(21, 24); + Pen pb = new(Color.Black, 1); + SolidBrush bw = new (Color.White); + using (Graphics g = Graphics.FromImage(bmp)) { + g.FillPolygon(bw, corner1); + g.DrawPolygon(pb, corner1); + g.FillPolygon(bw, corner2); + g.DrawPolygon(pb, corner2); + g.FillPolygon(bw, corner3); + g.DrawPolygon(pb, corner3); + g.FillPolygon(bw, corner4); + g.DrawPolygon(pb, corner4); + g.FillPolygon(bw, arrow); + g.DrawPolygon(pb, arrow); + } + return CreateCursorNoResize(bmp, 1, 1); + } + } } diff --git a/TODO.txt b/TODO.txt index 39556bb..5ec0a7a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,8 +1,10 @@ Application: - Consider migrating to WPF in order to make DPI aware UI -- Cursor for rectangular selection tool +V Cursor for rectangular selection tool +V Icons for tool buttons +V Tooltips now has keyboard shortcuts info Functionality: Bugs: -- Fix selection info: change comma to x +V Fix selection info: change comma to x diff --git a/examples/SelectionCursor.mbfont b/examples/SelectionCursor.mbfont new file mode 100644 index 0000000000000000000000000000000000000000..dcd90e2e7587e933464f6a014cb9a1947e22e6c0 GIT binary patch literal 1045 zcmdTkChJMm!fz~ z3fXH+QtJ_uf|#=16BGJgk5qrPZKw;V!h0R-2p~eje?0hle=22yc7`&+@A`J4R~#64 JKi+=3VNd6969@nR literal 0 HcmV?d00001