Skip to content

Commit

Permalink
update libf3d to work with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokse22 committed Dec 17, 2024
1 parent 911cbec commit 89fd4c8
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 119 deletions.
25 changes: 10 additions & 15 deletions build-aux/libf3d.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"config-opts": [
"-DF3D_BUILD_APPLICATION:BOOL=OFF",
"-DF3D_MODULE_EXTERNAL_RENDERING:BOOL=ON",
"-DF3D_MODULE_EXR:BOOL=ON",
"-DF3D_MODULE_UI:BOOL=OFF",
"-DF3D_BINDINGS_PYTHON:BOOL=ON",
"-DCMAKE_INSTALL_PREFIX:PATH=/app",
"-DBUILD_TESTING:BOOL=OFF",
Expand All @@ -26,15 +26,9 @@
],
"sources": [
{
"type": "archive",
"url": "https://github.com/f3d-app/f3d/archive/refs/tags/v2.5.0.tar.gz",
"sha256": "d7f6dd7d9e4465c1f44d168c3a38aad24569a25907673180c8791a783e73f02f",
"x-checker-data": {
"type": "anitya",
"project-id": 224911,
"stable-only": true,
"url-template": "https://github.com/f3d-app/f3d/archive/refs/tags/v$version.tar.gz"
}
"type": "git",
"url": "https://github.com/f3d-app/f3d",
"commit": "346269c3acec41d3081d47707db607b8d7156c81"
}
],
"modules": [
Expand Down Expand Up @@ -109,9 +103,10 @@
"config-opts": [
"-DBUILD_SHARED_LIBS=ON",
"-DOpenGL_GL_PREFERENCE=GLVND",
"-DVTK_ENABLE_LOGGING=OFF",
"-DVTK_ENABLE_LOGGING=ON",
"-DVTK_OPENGL_HAS_EGL=ON",
"-DVTK_ENABLE_WRAPPING=OFF",
"-DVTK_ENABLE_REMOTE_MODULES=OFF",
"-DVTK_BUILD_TESTING=OFF",
"-DVTK_LEGACY_REMOVE=ON",
"-DVTK_VERSIONED_INSTALL=OFF",
Expand Down Expand Up @@ -148,8 +143,8 @@
"sources": [
{
"type": "archive",
"url": "https://www.vtk.org/files/release/9.3/VTK-9.3.1.tar.gz",
"sha256": "8354ec084ea0d2dc3d23dbe4243823c4bfc270382d0ce8d658939fd50061cab8",
"url": "https://www.vtk.org/files/release/9.4/VTK-9.4.0.tar.gz",
"sha256": "16f3ffd65fafd68fab469bcb091395bf5432617c7db27cbce86a737bf09ec5b0",
"x-checker-data": {
"type": "anitya",
"project-id": 15084,
Expand Down Expand Up @@ -320,8 +315,8 @@
"sources": [
{
"type": "archive",
"url": "https://github.com/alembic/alembic/archive/refs/tags/1.8.6.tar.gz",
"sha256": "c572ebdea3a5f0ce13774dd1fceb5b5815265cd1b29d142cf8c144b03c131c8c",
"url": "https://github.com/alembic/alembic/archive/refs/tags/1.8.8.tar.gz",
"sha256": "ba1f34544608ef7d3f68cafea946ec9cc84792ddf9cda3e8d5590821df71f6c6",
"x-checker-data": {
"type": "anitya",
"project-id": 13980,
Expand Down
26 changes: 26 additions & 0 deletions data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,29 @@
flowbox flowboxchild {
padding: 0px;
}

.main-view headerbar button {
background-color: alpha(var(--view-bg-color), 0.6);
border-radius:9999px;
}

.main-view headerbar button:hover {
background-color: alpha(var(--view-bg-color), 0.7);
}

.main-view headerbar button:active {
background-color: alpha(var(--view-bg-color), 0.9);
}

.main-view headerbar button:selected {
background-color: alpha(var(--view-bg-color), 1);
}

windowcontrols button{
padding: 0px;
}

windowcontrols {
padding-left: 6px;
padding-right: 6px;
}
2 changes: 1 addition & 1 deletion data/ui/f3d_viewer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<property name="has-stencil-buffer">true</property>
<property name="vexpand">true</property>
<property name="overflow">hidden</property>
<property name="css-classes">fix-render</property>
<property name="css-name">f3dviewer</property>
<child>
<object class="GtkGestureDrag">
<signal name="drag-update" handler="on_drag_update"/>
Expand Down
60 changes: 57 additions & 3 deletions data/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@
<property name="valign">center</property>
<property name="rgba">rgb(119,118,123)</property>
<property name="dialog">
<object class="GtkColorDialog"/>
<object class="GtkColorDialog">
<property name="title" translatable="yes">Model Color</property>
<property name="with-alpha">False</property>
</object>
</property>
</object>
</child>
Expand Down Expand Up @@ -578,13 +581,15 @@
<property name="hexpand">True</property>
<property name="hexpand-set">True</property>
<property name="title" translatable="yes">Background Color</property>
<property name="subtitle" translatable="yes">Transparent colors not supported</property>
<child>
<object class="GtkColorDialogButton" id="background_color_button">
<property name="valign">center</property>
<property name="rgba">rgb(246,97,81)</property>
<property name="dialog">
<object class="GtkColorDialog"/>
<object class="GtkColorDialog">
<property name="title" translatable="yes">Background Color</property>
<property name="with-alpha">False</property>
</object>
</property>
</object>
</child>
Expand Down Expand Up @@ -646,6 +651,53 @@
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="animation_group">
<property name="title" translatable="yes">Animation</property>
<child>
<object class="AdwSpinRow" id="animation_spin_button">
<property name="title" translatable="yes">Animation Index</property>
<property name="adjustment">
<object class="GtkAdjustment" id="animation_adj">
<property name="upper">99</property>
<property name="step-increment">1.0</property>
</object>
</property>
</object>
</child>
<child>
<object class="AdwPreferencesRow">
<child>
<object class="GtkBox">
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton" id="play_button">
<property name="icon-name">media-playback-start-symbolic</property>
<property name="tooltip-text" translatable="yes">Play</property>
<property name="has-tooltip">true</property>
</object>
</child>
<child>
<object class="GtkScale">
<property name="digits">2</property>
<property name="hexpand">true</property>
<property name="adjustment">
<object class="GtkAdjustment" id="animation_time_adj">
<property name="upper">20.0</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="hexpand">True</property>
Expand Down Expand Up @@ -691,6 +743,7 @@
<object class="AdwToolbarView" id="toolbar_view">
<property name="top-bar-style">flat</property>
<property name="extend-content-to-top-edge">true</property>
<property name="css-classes">main-view</property>
<child type="top">
<object class="AdwHeaderBar" id="header_bar">
<property name="css-classes">preview-headerbar</property>
Expand Down Expand Up @@ -756,6 +809,7 @@
<object class="AdwToastOverlay" id="toast_overlay">
<property name="child">
<object class="F3DViewer" id="f3d_viewer">
<property name="css-classes">fix-render</property>
</object>
</property>
</object>
Expand Down
101 changes: 65 additions & 36 deletions src/settings_manager.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,60 @@
import gi
from gi.repository import Adw
from gi.repository import Gtk, Gdk, Gio, GLib, GObject
# settings_manager.py
#
# Copyright 2024 Nokse22
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later


from gi.repository import Gio, GObject

from enum import IntEnum

from . import logger_lib

#
# Other special
# functions if <──────┐ On change
# connected┌─────────┐ update the UI
# │ ∨
# ┌─────────┐ ┌──┐
# Update ━━━▶│ListStore│ │UI│
# the settings └─────────┘ └──┘
# │ ∧ │
# │ └─────────┘ On change update
# │ the ListStore
# ┏━━━━━━┓ │ On change
# ┃Viewer┃<───────┘ update the
# ┗━━━━━━┛ view options
#
# Made with ASCII Draw
# Other special
# functions if <──────┐ On change
# connected ┌─────────┐ update the UI
# │ ∨
# ┌─────────┐ ┌──┐
# Update ━━━▶│ListStore│ │UI│
# the settings └─────────┘ └──┘
# │ ∧ │
# │ └─────────┘ On change update
# │ the ListStore
# ┏━━━━━━┓ │ On change
# ┃Viewer┃<───────┘ update the
# ┗━━━━━━┛ view options
#
# Made with ASCII Draw


class SettingType(IntEnum):
VIEW = 0
OTHER = 1
INTERNAL = 2


class Setting(GObject.Object):
__gtype_name__ = 'Setting'

__gsignals__ = {
'changed': (GObject.SignalFlags.RUN_FIRST, None, (str, int, )),
'changed-no-ui-update': (GObject.SignalFlags.RUN_FIRST, None, (str, int, )),
'changed': (
GObject.SignalFlags.RUN_FIRST, None, (str, int, )),
'changed-no-ui-update': (
GObject.SignalFlags.RUN_FIRST, None, (str, int, )),
}

def __init__(self, name, value, setting_type):
Expand Down Expand Up @@ -68,6 +89,7 @@ def set_value_without_ui_update(self, value):
def __repr__(self):
return f"<Setting {self._name}: {self._value}>"


class WindowSettings(Gio.ListStore):
__gtype_name__ = 'WindowSettings'

Expand Down Expand Up @@ -112,33 +134,37 @@ class WindowSettings(Gio.ListStore):
"up": "+Y",
"orthographic": False,

"animation-index": 0,
"animation-time": 0.0,

# There is no UI for the following ones
"texture-matcap": "",
"texture-base-color": "",

# "texture-matcap": "",
# "texture-base-color": "",
"emissive-factor": (1.0, 1.0, 1.0),
"texture-emissive": "",
"texture-material": "",
# "texture-emissive": "",
# "texture-material": "",
"normal-scale": 1.0,
"texture-normal": "",
# "texture-normal": "",
"point-type": "sphere",
"volume": False,
"inverse": False,
"final-shader": "",
"grid-unit": 0.0,
"grid-subdivisions": 10,
# "final-shader": "",
# "grid-unit": 0.0,
# "grid-subdivisions": 10,
"grid-color": (0.0, 0.0, 0.0),
"scalar" : ""
"scalar": ""
}

other_settings = {
"use-color": False,
"point-up" : True,
"point-up": True,
"auto-reload": True
}

internal_settings = {
"auto-best" : True,
"load-type": None, # 0 for geometry and 1 for scene
"auto-best": True,
"load-type": None, # 0 for geometry and 1 for scene
"sidebar-show": True
}

Expand All @@ -150,19 +176,22 @@ def __init__(self):
for name, value in self.default_settings.items():
setting = Setting(name, value, SettingType.VIEW)
setting.connect("changed", self.on_view_setting_changed)
setting.connect("changed-no-ui-update", self.on_other_setting_changed)
setting.connect(
"changed-no-ui-update", self.on_other_setting_changed)
self.append(setting)

for name, value in self.other_settings.items():
setting = Setting(name, value, SettingType.OTHER)
setting.connect("changed", self.on_other_setting_changed)
setting.connect("changed-no-ui-update", self.on_other_setting_changed)
setting.connect(
"changed-no-ui-update", self.on_other_setting_changed)
self.append(setting)

for name, value in self.internal_settings.items():
setting = Setting(name, value, SettingType.INTERNAL)
setting.connect("changed", self.on_internal_setting_changed)
setting.connect("changed-no-ui-update", self.on_other_setting_changed)
setting.connect(
"changed-no-ui-update", self.on_other_setting_changed)
self.append(setting)

def sync_all_settings(self):
Expand Down
Loading

0 comments on commit 89fd4c8

Please sign in to comment.