Skip to content

Commit

Permalink
Added dotted grid pattern & ability to change patterns in the settings
Browse files Browse the repository at this point in the history
...also removed the grid toggle from the toolbar
  • Loading branch information
mbrlabs committed Nov 5, 2023
1 parent 1e48012 commit aeb3a73
Show file tree
Hide file tree
Showing 21 changed files with 133 additions and 96 deletions.
5 changes: 4 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Rebindable keyboard shortcuts
- Use eraser tool while tablet pen is inverted
- Dotted grid pattern; can be changed back to lines (or none at all) in the settings
- Translations: Simplified Chinese, Traditional Chinese

### Fixed
- Fixed blurry interface on some macOS devices
- Fixed invisible cursor in some situations
- Fixed issue where moved brush strokes stayed in their original positions after exporting to SVG

### Changed
- Changing the application language does not require a restart now
- Improved translations: Spanish, Brasilian Portuguese
- Improved UI auto scaling, especially for Windows and OSX
- Updated to Godot 3.5.2
- Moved to grid toggle button from the toolbar to the settings
- Updated to Godot 3.5.3

## [0.5.0] - 2022-06-12

Expand Down
3 changes: 2 additions & 1 deletion lorien/Assets/I18n/de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL Auswahl Werkzeug {{ shortcut_list("shortcut_sele
TOOLBAR_TOOLTIP_BRUSH_COLOR Pinsel Farbe
TOOLBAR_TOOLTIP_BRUSH_SIZE Pinsel Größe
TOOLBAR_TOOLTIP_CANVAS_COLOR Canvas Farbe
TOOLBAR_TOOLTIP_GRID Gitter anzeigen

# -----------------------------------------------------------------------------
# Color Palette Picker
Expand Down Expand Up @@ -65,6 +64,8 @@ SETTINGS_CANVAS_COLOR Default Canvas Farbe
SETTINGS_PROJECT_FOLDER Default Project Ordner
SETTINGS_LANGUAGE Sprache
SETTINGS_THEME Theme
SETTINGS_GRID_SIZE Grid Größe
SETTINGS_GRID_PATTERN Grid Pattern
SETTINGS_AA_METHOD Anti Aliasing Methode
SETTINGS_AA_METHOD_NONE Keine
SETTINGS_FPS_FOREGROUND Vordergrund Fps
Expand Down
5 changes: 3 additions & 2 deletions lorien/Assets/I18n/en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL Selection Tool {{ shortcut_list("shortcut_select
TOOLBAR_TOOLTIP_BRUSH_COLOR Brush Color
TOOLBAR_TOOLTIP_BRUSH_SIZE Brush Size
TOOLBAR_TOOLTIP_CANVAS_COLOR Canvas Color
TOOLBAR_TOOLTIP_GRID Show Grid
TOOLBAR_FULLSCREEN_TOGGLE Toggle fullscreen

# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -70,7 +69,9 @@ SETTINGS_LANGUAGE Language
SETTINGS_THEME Theme
SETTINGS_UI_SCALE UI Scale
SETTINGS_UI_SCALE_AUTO Auto
SETTINGS_UI_SCALE_CUSTOM Custom
SETTINGS_UI_SCALE_CUSTOM Custom
SETTINGS_GRID_SIZE Grid Size
SETTINGS_GRID_PATTERN Grid Pattern
SETTINGS_AA_METHOD Anti Aliasing Method
SETTINGS_AA_METHOD_NONE None
SETTINGS_FPS_FOREGROUND Foreground Fps
Expand Down
1 change: 0 additions & 1 deletion lorien/Assets/I18n/es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL Herramienta de Selección {{ shortcut_list("shor
TOOLBAR_TOOLTIP_BRUSH_COLOR Color de Pincel
TOOLBAR_TOOLTIP_BRUSH_SIZE Tamaño de Pincel
TOOLBAR_TOOLTIP_CANVAS_COLOR Color de Canvas
TOOLBAR_TOOLTIP_GRID Mostrar cuadrícula

# -----------------------------------------------------------------------------
# Color Palette Picker
Expand Down
1 change: 0 additions & 1 deletion lorien/Assets/I18n/fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL Outil de sélection {{ shortcut_list("shortcut_s
TOOLBAR_TOOLTIP_BRUSH_COLOR Couleur de la brosse
TOOLBAR_TOOLTIP_BRUSH_SIZE Épaisseur de la brosse
TOOLBAR_TOOLTIP_CANVAS_COLOR Couleur du canevas
TOOLBAR_TOOLTIP_GRID Afficher la grille

# -----------------------------------------------------------------------------
# Color Palette Picker
Expand Down
3 changes: 1 addition & 2 deletions lorien/Assets/I18n/it.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ TOOLBAR_TOOLTIP_ERASER_TOOL Gomma per cancellare {{ shortcut_list("shortcut_
TOOLBAR_TOOLTIP_SELECT_TOOL Seleziona strumento {{ shortcut_list("shortcut_select_tool") }}
TOOLBAR_TOOLTIP_BRUSH_COLOR Colore Pennello
TOOLBAR_TOOLTIP_BRUSH_SIZE Dimensione del Pennello
TOOLBAR_TOOLTIP_CANVAS_COLOR Colore della Tela
TOOLBAR_TOOLTIP_GRID Mostra Griglia
TOOLBAR_TOOLTIP_CANVAS_COLOR Colore della Tela
TOOLBAR_FULLSCREEN_TOGGLE Commuta la modalità a schermo intero

# -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion lorien/Assets/I18n/ko.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL 범위 선택 {{ shortcut_list("shortcut_select_
TOOLBAR_TOOLTIP_BRUSH_COLOR 브러쉬 색깔
TOOLBAR_TOOLTIP_BRUSH_SIZE 브러쉬 크기
TOOLBAR_TOOLTIP_CANVAS_COLOR 배경 색깔
TOOLBAR_TOOLTIP_GRID 눈금
TOOLBAR_FULLSCREEN_TOGGLE 전체화면/원래대로

# -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion lorien/Assets/I18n/pt-BR.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL Ferramenta de Seleção {{ shortcut_list("shortc
TOOLBAR_TOOLTIP_BRUSH_COLOR Cor do Pincel
TOOLBAR_TOOLTIP_BRUSH_SIZE Tamanho do Pincel
TOOLBAR_TOOLTIP_CANVAS_COLOR Cor da Área de Desenho
TOOLBAR_TOOLTIP_GRID Exibir Grade
TOOLBAR_FULLSCREEN_TOGGLE (Des)ativar Tela Cheia

# -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion lorien/Assets/I18n/ru.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL Выделить {{ shortcut_list("shortcut_sel
TOOLBAR_TOOLTIP_BRUSH_COLOR Цвет кисти
TOOLBAR_TOOLTIP_BRUSH_SIZE Размер кисти
TOOLBAR_TOOLTIP_CANVAS_COLOR Цвет холста
TOOLBAR_TOOLTIP_GRID Show Grid # TODO

# -----------------------------------------------------------------------------
# Color Palette Picker
Expand Down
1 change: 0 additions & 1 deletion lorien/Assets/I18n/tr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL Seçim Aracı {{ shortcut_list("shortcut_select_
TOOLBAR_TOOLTIP_BRUSH_COLOR Fırça Rengi
TOOLBAR_TOOLTIP_BRUSH_SIZE Fırça Boyutu
TOOLBAR_TOOLTIP_CANVAS_COLOR Tuval Rengi
TOOLBAR_TOOLTIP_GRID Izgarayı Göster
TOOLBAR_FULLSCREEN_TOGGLE Tam Ekran

# -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion lorien/Assets/I18n/zh-CN.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL 选择工具 {{ shortcut_list("shortcut_select_t
TOOLBAR_TOOLTIP_BRUSH_COLOR 画笔颜色
TOOLBAR_TOOLTIP_BRUSH_SIZE 画笔大小
TOOLBAR_TOOLTIP_CANVAS_COLOR 画布颜色
TOOLBAR_TOOLTIP_GRID 显示网格
TOOLBAR_FULLSCREEN_TOGGLE 切换全屏

# -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion lorien/Assets/I18n/zh-TW.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ TOOLBAR_TOOLTIP_SELECT_TOOL 選擇工具 {{ shortcut_list("shortcut_select_t
TOOLBAR_TOOLTIP_BRUSH_COLOR 畫筆顏色
TOOLBAR_TOOLTIP_BRUSH_SIZE 畫筆大小
TOOLBAR_TOOLTIP_CANVAS_COLOR 畫布底色
TOOLBAR_TOOLTIP_GRID 顯示格線
TOOLBAR_FULLSCREEN_TOGGLE 全螢幕切換

# -----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions lorien/Config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ const DEFAULT_BACKGROUND_FPS := 10
const DEFAULT_BRUSH_ROUNDING := Types.BrushRoundingType.ROUNDED
const DEFAULT_UI_SCALE_MODE := Types.UIScale.AUTO
const DEFAULT_UI_SCALE := 1.0
const DEFAULT_GRID_PATTERN := Types.GridPattern.DOTS
const DEFAULT_GRID_SIZE := 25.0

60 changes: 35 additions & 25 deletions lorien/InfiniteCanvas/InfiniteCanvasGrid.gd
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
class_name InfiniteCanvasGrid
extends Node2D

# -------------------------------------------------------------------------------------------------
const COLOR := Color.red

# -------------------------------------------------------------------------------------------------
export var camera_path: NodePath
var _enabled: bool
var _pattern: int = Types.GridPattern.DOTS
var _camera: Camera2D
var _grid_size := Config.DEFAULT_GRID_SIZE
var _grid_color: Color

# -------------------------------------------------------------------------------------------------
func _ready():
_grid_size = Settings.get_value(Settings.APPEARANCE_GRID_SIZE, Config.DEFAULT_GRID_SIZE)
_pattern = Settings.get_value(Settings.APPEARANCE_GRID_PATTERN, Config.DEFAULT_GRID_PATTERN)

_camera = get_node(camera_path)
_camera.connect("zoom_changed", self, "_on_zoom_changed")
_camera.connect("position_changed", self, "_on_position_changed")
Expand All @@ -33,6 +34,11 @@ func set_grid_size(size: int) -> void:
_grid_size = size
update()

# -------------------------------------------------------------------------------------------------
func set_grid_pattern(pattern: int) -> void:
_pattern = pattern
update()

# -------------------------------------------------------------------------------------------------
func set_canvas_color(c: Color) -> void:
_grid_color = c * 1.25
Expand All @@ -47,25 +53,29 @@ func _draw() -> void:
var size = get_viewport().size * _camera.zoom
var zoom = _camera.zoom.x
var offset = _camera.offset

var grid_size = _grid_size
if zoom > 50:
grid_size *= 50
elif zoom > 25:
grid_size *= 25
elif zoom > 10:
grid_size *= 10
elif zoom > 5:
grid_size *= 5

# Vertical lines
var start_index := int((offset.x - size.x) / grid_size) - 1
var end_index := int((size.x + offset.x) / grid_size) + 1
for i in range(start_index, end_index):
draw_line(Vector2(i * grid_size, offset.y + size.y), Vector2(i * grid_size, offset.y - size.y), _grid_color)

# Horizontal lines
start_index = int((offset.y - size.y) / grid_size) - 1
end_index = int((size.y + offset.y) / grid_size) + 1
for i in range(start_index, end_index):
draw_line(Vector2(offset.x + size.x, i * grid_size), Vector2(offset.x - size.x, i * grid_size), _grid_color)
var grid_size := int(ceil((_grid_size * pow(zoom, 0.75))))

match _pattern:
Types.GridPattern.DOTS:
var dot_size := int(ceil(grid_size * 0.12))
var x_start := int(offset.x / grid_size) - 1
var x_end := int((size.x + offset.x) / grid_size) + 1
var y_start := int(offset.y / grid_size) - 1
var y_end = int((size.y + offset.y) / grid_size) + 1

for x in range(x_start, x_end):
for y in range(y_start, y_end):
var pos := Vector2(x, y) * grid_size
draw_rect(Rect2(pos.x, pos.y, dot_size, dot_size), _grid_color)
Types.GridPattern.LINES:
# Vertical lines
var start_index := int(offset.x / grid_size) - 1
var end_index := int((size.x + offset.x) / grid_size) + 1
for i in range(start_index, end_index):
draw_line(Vector2(i * grid_size, offset.y + size.y), Vector2(i * grid_size, offset.y - size.y), _grid_color)

# Horizontal lines
start_index = int(offset.y / grid_size) - 1
end_index = int((size.y + offset.y) / grid_size) + 1
for i in range(start_index, end_index):
draw_line(Vector2(offset.x + size.x, i * grid_size), Vector2(offset.x - size.x, i * grid_size), _grid_color)
11 changes: 5 additions & 6 deletions lorien/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func _ready():
_toolbar.connect("brush_size_changed", self, "_on_brush_size_changed")
_toolbar.connect("canvas_background_changed", self, "_on_canvas_background_changed")
_toolbar.connect("tool_changed", self, "_on_tool_changed")
_toolbar.connect("grid_enabled", self, "_on_grid_enabled")

_menubar.connect("create_new_project", self, "_on_create_new_project")
_menubar.connect("project_selected", self, "_on_project_selected")
Expand All @@ -72,7 +71,7 @@ func _ready():

_settings_dialog.connect("ui_scale_changed", self, "_on_scale_changed")
_settings_dialog.connect("grid_size_changed", self, "_on_grid_size_changed")

_settings_dialog.connect("grid_pattern_changed", self, "_on_grid_pattern_changed")

# Initialize scale
_on_scale_changed()
Expand Down Expand Up @@ -336,6 +335,10 @@ func _on_brush_size_changed(size: int) -> void:
func _on_grid_size_changed(size: int) -> void:
_canvas_grid.set_grid_size(size)

# -------------------------------------------------------------------------------------------------
func _on_grid_pattern_changed(pattern: int) -> void:
_canvas_grid.set_grid_pattern(pattern)

# -------------------------------------------------------------------------------------------------
func _on_clear_canvas() -> void:
_canvas.clear()
Expand Down Expand Up @@ -410,10 +413,6 @@ func _on_canvas_background_changed(color: Color) -> void:
project.meta_data[ProjectMetadata.CANVAS_COLOR] = color.to_html()
project.dirty = true

# -------------------------------------------------------------------------------------------------
func _on_grid_enabled(enabled: bool) -> void:
_canvas.enable_grid(enabled)

# -------------------------------------------------------------------------------------------------
func _on_undo_action() -> void:
var project: Project = ProjectManager.get_active_project()
Expand Down
2 changes: 2 additions & 0 deletions lorien/Misc/Settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const GENERAL_LANGUAGE := "general_language"
const APPEARANCE_THEME := "appearance_theme"
const APPEARANCE_UI_SCALE_MODE := "appearance_ui_scale_mode"
const APPEARANCE_UI_SCALE := "appearance_ui_scale"
const APPEARANCE_GRID_PATTERN := "appearance_grid_pattern"
const APPEARANCE_GRID_SIZE := "appearance_grid_size"
const RENDERING_AA_MODE := "rendering_aa_mode"
const RENDERING_FOREGROUND_FPS := "rendering_foreground_fps"
const RENDERING_BACKGROUND_FPS := "rendering_background_fps"
Expand Down
7 changes: 7 additions & 0 deletions lorien/Misc/Types.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ enum AAMode {
TEXTURE_FILL
}

# -------------------------------------------------------------------------------------------------
enum GridPattern {
DOTS,
LINES,
NONE
}

# -------------------------------------------------------------------------------------------------
enum UITheme {
DARK,
Expand Down
26 changes: 23 additions & 3 deletions lorien/UI/Dialogs/SettingsDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ extends WindowDialog
const THEME_DARK_INDEX := 0
const THEME_LIGHT_INDEX := 1

const GRID_PATTERN_DOTS_INDEX := 0
const GRID_PATTERN_LINES_INDEX := 1
const GRID_PATTERN_NONE_INDEX := 2

const AA_NONE_INDEX := 0
const AA_OPENGL_HINT_INDEX := 1
const AA_TEXTURE_FILL_INDEX := 2
Expand All @@ -14,6 +18,7 @@ const UI_SCALE_CUSTOM_INDEX := 1
# -------------------------------------------------------------------------------------------------
signal ui_scale_changed
signal grid_size_changed(size)
signal grid_pattern_changed(pattern)

# -------------------------------------------------------------------------------------------------
onready var _tab_container: TabContainer = $MarginContainer/TabContainer
Expand All @@ -36,6 +41,7 @@ onready var _brush_rounding_options: OptionButton = $MarginContainer/TabContaine
onready var _ui_scale_options: OptionButton = $MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer/UIScaleOptions
onready var _ui_scale: SpinBox = $MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer/UIScale
onready var _grid_size: SpinBox = $MarginContainer/TabContainer/Appearance/VBoxContainer/GridSize/GridSize
onready var _grid_pattern: OptionButton = $MarginContainer/TabContainer/Appearance/VBoxContainer/GridPattern/GridPattern

# -------------------------------------------------------------------------------------------------
func _ready():
Expand All @@ -54,7 +60,6 @@ func _apply_language() -> void:
func _set_values() -> void:
var brush_size = Settings.get_value(Settings.GENERAL_DEFAULT_BRUSH_SIZE, Config.DEFAULT_BRUSH_SIZE)
var canvas_color = Settings.get_value(Settings.GENERAL_DEFAULT_CANVAS_COLOR, Config.DEFAULT_CANVAS_COLOR)
var grid_size = Config.DEFAULT_GRID_SIZE
var project_dir = Settings.get_value(Settings.GENERAL_DEFAULT_PROJECT_DIR, "")
var theme = Settings.get_value(Settings.APPEARANCE_THEME, Types.UITheme.DARK)
var aa_mode = Settings.get_value(Settings.RENDERING_AA_MODE, Config.DEFAULT_AA_MODE)
Expand All @@ -64,6 +69,8 @@ func _set_values() -> void:
var pressure_sensitivity = Settings.get_value(Settings.GENERAL_PRESSURE_SENSITIVITY, Config.DEFAULT_PRESSURE_SENSITIVITY)
var ui_scale_mode = Settings.get_value(Settings.APPEARANCE_UI_SCALE_MODE, Config.DEFAULT_UI_SCALE_MODE)
var ui_scale = Settings.get_value(Settings.APPEARANCE_UI_SCALE, Config.DEFAULT_UI_SCALE)
var grid_pattern = Settings.get_value(Settings.APPEARANCE_GRID_PATTERN, Config.DEFAULT_GRID_PATTERN)
var grid_size = Settings.get_value(Settings.APPEARANCE_GRID_SIZE, Config.DEFAULT_GRID_SIZE)

match theme:
Types.UITheme.DARK: _theme.selected = THEME_DARK_INDEX
Expand All @@ -86,6 +93,10 @@ func _set_values() -> void:
_brush_size.value = brush_size
_canvas_color.color = canvas_color
_grid_size.value = grid_size
match grid_pattern:
Types.GridPattern.DOTS: _grid_pattern.selected = GRID_PATTERN_DOTS_INDEX
Types.GridPattern.LINES: _grid_pattern.selected = GRID_PATTERN_LINES_INDEX
Types.GridPattern.NONE: _grid_pattern.selected = GRID_PATTERN_NONE_INDEX
_project_dir.text = project_dir
_foreground_fps.value = foreground_fps
_background_fps.value = background_fps
Expand Down Expand Up @@ -137,12 +148,21 @@ func _on_DefaultBrushSize_value_changed(value: int) -> void:
# -------------------------------------------------------------------------------------------------
func _on_DefaultCanvasColor_color_changed(color: Color) -> void:
Settings.set_value(Settings.GENERAL_DEFAULT_CANVAS_COLOR, color)


# -------------------------------------------------------------------------------------------------
func _on_GridSize_value_changed(value: int) -> void:
emit_signal("grid_size_changed", int(value))
Settings.set_value(Settings.APPEARANCE_GRID_SIZE, value)
emit_signal("grid_size_changed", value)

# -------------------------------------------------------------------------------------------------
func _on_GridPattern_item_selected(index: int) -> void:
var pattern: int = Types.GridPattern.NONE
match index:
GRID_PATTERN_DOTS_INDEX: pattern = Types.GridPattern.DOTS
GRID_PATTERN_LINES_INDEX: pattern = Types.GridPattern.LINES
Settings.set_value(Settings.APPEARANCE_GRID_PATTERN, pattern)
emit_signal("grid_pattern_changed", pattern)

# -------------------------------------------------------------------------------------------------
func _on_PressureSensitivity_value_changed(value: float):
Settings.set_value(Settings.GENERAL_PRESSURE_SENSITIVITY, value)
Expand Down
Loading

0 comments on commit aeb3a73

Please sign in to comment.