Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog

**New Features and Improvements**

* Tools: added a new HSV color picker.
* Tools: added a new "flythrough" camera mode for navigating viewports.
* Tools: added textual tooltips to main object types and prominent interface elements.
* Tools: crown-launcher can now be executed from any directory.
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ clean-samples:
codespell:
@codespell docs src tools \
--ignore-words=scripts/codespell-dictionary.txt \
--skip "*.ttf.h,*.png,docs/_themes,tools/level_editor/resources/theme/Adwaita" \
--skip "*.ttf.h,*.png,*.css,docs/_themes,tools/level_editor/resources/theme/Adwaita" \
-q4 # 4: omit warnings about automatic fixes that were disabled in the dictionary.

.PHONY: cppcheck
Expand Down
12 changes: 12 additions & 0 deletions scripts/crown-editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ project "crown-editor"
CROWN_DIR .. "3rdparty/ufbx/ufbx.c",
}

configuration { "linux" }
removefiles {
CROWN_DIR .. "tools/widgets/gtk/gtkcolorpickerquartz.c",
CROWN_DIR .. "tools/widgets/gtk/gtkcolorpickerwin32.c",
}
configuration { "windows" }
removefiles {
CROWN_DIR .. "tools/widgets/gtk/gtkcolorpickerkwin.c",
CROWN_DIR .. "tools/widgets/gtk/gtkcolorpickerquartz.c",
CROWN_DIR .. "tools/widgets/gtk/gtkcolorpickershell.c",
}

strip()

configuration {}
5 changes: 3 additions & 2 deletions scripts/uncrustify/format-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ format_src () {
}

format_tools_c () {
find tools/ -iname '*.c' \
| tr '\n' '\0' \
find tools/ -iname '*.c' \
| grep -v 'tools/widgets/gtk/*' \
| tr '\n' '\0' \
| xargs -0 -n1 -P"$1" ./scripts/uncrustify/uncrustify-wrapper.sh scripts/uncrustify/cpp.cfg
}

Expand Down
17 changes: 17 additions & 0 deletions tools/core/math/math_utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ namespace MathUtils
return rad * 180.0 / Math.PI;
}

public double floor(double a)
{
return Math.floor(a);
}

public double fract(double a)
{
return a - floor(a);
}

public double lerp(double p0, double p1, double t)
{
return (1.0 - t) * p0 + t * p1;
}

} /* namespace MathUtils */

public const double PI_TWO = Math.PI * 2.0;

} /* namespace Crown */
15 changes: 15 additions & 0 deletions tools/core/math/vector2.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ public struct Vector2
return arr;
}

public double dot(Vector2 b)
{
return this.x * b.x + this.y * b.y;
}

public double length_squared()
{
return dot(this);
}

public double length()
{
return Math.sqrt(length_squared());
}

public string to_string()
{
return "%f, %f".printf(x, y);
Expand Down
4 changes: 3 additions & 1 deletion tools/level_editor/property_grid.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class PropertyGrid : Gtk.Grid
public int _rows;
public double _order;
public bool _visible;
public int label_width_chars;

public Gee.HashMap<string, InputField> _widgets;
public Gee.HashMap<InputField, PropertyDefinition?> _definitions;
Expand Down Expand Up @@ -97,6 +98,7 @@ public class PropertyGrid : Gtk.Grid
this.row_spacing = 4;
this.row_homogeneous = true;
this.column_spacing = 12;
this.label_width_chars = 13;

// Data
_expander = null;
Expand Down Expand Up @@ -144,7 +146,7 @@ public class PropertyGrid : Gtk.Grid
public Gtk.Widget add_row(string label, Gtk.Widget w, string? tooltip = null)
{
Gtk.Label l = new Gtk.Label(label);
l.width_chars = 13;
l.width_chars = label_width_chars;
l.xalign = 1.0f;
l.yalign = 0.5f;
l.set_tooltip_text(tooltip);
Expand Down
17 changes: 17 additions & 0 deletions tools/level_editor/resources/ui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,20 @@ button.compact {
.colorfast-link link {
color: @theme_fg_color;
}

.hsv-v-scale {
padding-top: 0px;
padding-bottom: 0px;
padding-right: 0px;
}

.hsv-v-scale trough {
padding-left: 6px;
padding-right: 6px;
background-image: linear-gradient(to bottom, white, black);
}

.hsv-v-scale highlight {
background-color: transparent;
border: 0px;
}
17 changes: 17 additions & 0 deletions tools/widgets/gtk/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// To make gtkcolorpicker* compile.

#ifndef GTK_COMPILATION
# define GTK_COMPILATION
#endif

#if defined(_WIN32) || defined(_WIN64)
# if !defined(G_OS_WIN32)
# define G_OS_WIN32 1
# endif
#elif defined(__linux__)
# if !defined(G_OS_UNIX)
# define G_OS_UNIX 1
# endif
#else
# error "Unknown platform."
#endif
87 changes: 87 additions & 0 deletions tools/widgets/gtk/gtkcolorpicker.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2018, Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

#include "config.h"

#include "gtkcolorpickerprivate.h"
#include "gtkcolorpickerportalprivate.h"
#include "gtkcolorpickershellprivate.h"
#include "gtkcolorpickerkwinprivate.h"

#ifdef __APPLE__
#include "gtkcolorpickerquartzprivate.h"
#endif

#ifdef G_OS_WIN32
#include "gtkcolorpickerwin32private.h"
#endif

#include <gio/gio.h>


G_DEFINE_INTERFACE_WITH_CODE (GtkColorPicker, gtk_color_picker, G_TYPE_OBJECT,
g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_INITABLE);)

static void
gtk_color_picker_default_init (GtkColorPickerInterface *iface)
{
}

void
gtk_color_picker_pick (GtkColorPicker *picker,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTK_COLOR_PICKER_GET_INTERFACE (picker)->pick (picker, callback, user_data);
}

GdkRGBA *
gtk_color_picker_pick_finish (GtkColorPicker *picker,
GAsyncResult *res,
GError **error)
{
return GTK_COLOR_PICKER_GET_INTERFACE (picker)->pick_finish (picker, res, error);
}

GtkColorPicker *
gtk_color_picker_new (void)
{
GtkColorPicker *picker = NULL;

#if defined (G_OS_UNIX) && !defined(__APPLE__)
if (!picker)
picker = gtk_color_picker_portal_new ();
if (!picker)
picker = gtk_color_picker_shell_new ();
if (!picker)
picker = gtk_color_picker_kwin_new ();
#elif defined (__APPLE__)
if (!picker)
picker = gtk_color_picker_quartz_new ();
#elif defined (G_OS_WIN32)
if (!picker)
picker = gtk_color_picker_win32_new ();
#endif

if (!picker)
g_debug ("No suitable GtkColorPicker implementation");
else
g_debug ("Using %s for picking colors", G_OBJECT_TYPE_NAME (picker));

return picker;
}

Loading