Progress report. Status: awaiting structure review

This commit is contained in:
Jean Sirmai 2024-07-04 08:04:58 +02:00
parent 5208a224e4
commit 6f51ad8158
Signed by: jean
GPG Key ID: FB3115C340E057E3
15 changed files with 424 additions and 668 deletions

View File

@ -1,363 +0,0 @@
src/libide/tree/ide-tree.c (597) static void ide_tree_init (IdeTree *self) {.}
src/libide/tree/ide-tree-model.c (663) static void tree_model_iface_init (GtkTreeModelIface *iface) {.}
src/libide/tree/ide-tree-node.c (31) Since: 3.32
* The #IdeTreeNode class is used to represent an item that should be displayed in the tree of the Ide application.
* The #IdeTreeAddin plugins create and maintain these nodes during the lifetime of the program.
* Plugins that want to add items to the tree should implement the #IdeTreeAddin interface and register it during plugin initialization.
src/libide/tree/ide-tree-node.c (127) enum {
PROP_0,
PROP_CHILDREN_POSSIBLE,
PROP_DESTROY_ITEM,
PROP_DISPLAY_NAME,
PROP_EXPANDED_ICON,
PROP_EXPANDED_ICON_NAME,
PROP_HAS_ERROR,
PROP_ICON,
PROP_ICON_NAME,
PROP_IS_HEADER,
PROP_ITEM,
PROP_RESET_ON_COLLAPSE,
PROP_TAG,
PROP_USE_MARKUP,
N_PROPS
};
src/libide/tree/ide-tree-node.c (48) struct _IdeTreeNode
{
GObject parent_instance;
/* A pointer to the model, which is only set on the root node. */
IdeTreeModel *model;
/* The following are fields containing the values for various properties on the tree node.
* Usually, icon, display_name, and item will be set on all nodes. */
GIcon *icon;
GIcon *expanded_icon;
gchar *display_name;
GObject *item;
gchar *tag;
GList *emblems;
/* The following items are used to maintain a tree structure of nodes for which we can use O(1) operations.
* The link is inserted into the parents children queue. The parent pointer is unowned, and set by the parent (cleared upon removal).
* This also allows maintaining the tree structure with zero additional allocations beyond the nodes themselves.
*/
IdeTreeNode *parent;
GQueue children;
GList link;
/* Foreground and Background colors */
GdkRGBA background;
GdkRGBA foreground;
/* Flags for state cell renderer */
IdeTreeNodeFlags flags;
/* When did we start loading? This is used to avoid drawing "Loading..." when the tree loads really quickly. Otherwise, we risk looking janky when the loads are quite fast. */
gint64 started_loading_at;
/* If we're currently loading */
guint is_loading : 1;
/* If the node is a header (bold, etc) */
guint is_header : 1;
/* If this is a synthesized empty node */
guint is_empty : 1;
/* If there are errors associated with the node's item */
guint has_error : 1;
/* If the node maybe has children */
guint children_possible : 1;
/* If this node needs to have the children built */
guint needs_build_children : 1;
/* If true, we remove all children on collapse */
guint reset_on_collapse : 1;
/* If pango markup should be used */
guint use_markup : 1;
/* If true, we use ide_clear_and_destroy_object() */
guint destroy_item : 1;
/* If colors are set */
guint background_set : 1;
guint foreground_set : 1;
};
src/libide/tree/ide-tree-node.c (1763) /* If the node is not on screen, we need to animate until we get there. */
src/libide/tree/ide-tree-node.c (1776) /* FIXME: Time period comes from gtk animation duration. Not curently available in pubic API.
* We need to be greater than the max timeout it could take to move, since we must have it on screen by then.
* One alternative might be to check the result and if we are still not on screen, then just pin it to a row-height from the top or bottom.
/----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------/
src/libide/tree/ide-tree-addin.c (108) /* ide_tree_addin_build_children_async() Since: 3.32
* This function is called when building the children of a node.
* This happens when expanding an node that might have children, or building the root node.
* You may want to use ide_tree_node_holds() to determine if the node contains an item that you are interested in.
* This function will call the synchronous form of IdeTreeAddin.build_children() if no asynchronous form is available.
src/libide/tree/ide-tree-addin.c (143) /* ide_tree_addin_build_children_finish() Since: 3.32
* Completes an asynchronous request to ide_tree_addin_build_children_async().
* Returns: %TRUE if successful; otherwise %FALSE and @error is set.
src/libide/tree/ide-tree-addin.c (167) /* ide_tree_addin_build_node() Since: 3.32
* This function is called when preparing a node for display in the tree.
* Addins should adjust any state on the node that makes sense based on the addin.
* You may want to use ide_tree_node_holds() to determine if the node contains an item that you are interested in.
src/libide/tree/ide-tree-addin.c (194) /* ide_tree_addin_activated() Since: 3.32
* This function is called when a node has been activated in the tree and allows for the addin to perform any necessary operations in response to that.
* If the addin performs an action based on the activation request, then it should return %TRUE from this function so that no further addins may respond to the action.
* Returns: %TRUE if the activation was handled, otherwise %FALSE
/----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------/
src/libide/tree/ide-cell-renderer-status (29) #define CELL_HEIGHT 16, CELL_WIDTH 16, RPAD 8, LPAD 3
/----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------/
src/libide/gui/ide-cell-renderer-fancy.c (166)
HACK: @width is the min_width returned in our get_preferred_width() function. That results in pretty bad values here, so we will do this by assuming we are the only widget in the tree view.
* This makes this cell very much not usable for generic situations, but it does make it so we can do text wrapping without resorting to GtkListBox *for our exact usecase only*.
* The problem here is that we require the widget to already be realized and allocated and that we are the only renderer within the only column (and also, in a treeview) without exotic styling.
* If we get something absurdly small (like 50) that is because we are hitting our minimum size of (xpad * 2).
* So this works around the issue and tries to get something reasonable with wrapping at the 200px mark (our ~default width for panels).
* Furthermore, we need to queue a resize when the column size changes (as it will from resizing the widget). So the tree view must also call gtk_tree_view_column_queue_resize().
https://en.wikibooks.org/wiki/GTK%2B_By_Example/Tree_View/Custom_Models
Working Example: Custom List Model Source Code
Here is the complete source code for the custom list model presented above. Compile with:
gcc -o customlist custom-list.c main.c `pkg-config --cflags --libs gtk+-2.0`
* custom-list.h
* custom-list.c
* main.c
https://blog.gtk.org/2020/06/07/scalable-lists-in-gtk-4/
https://docs.gtk.org/gtk4/section-list-widget.html
A GtkListItemFactory creates widgets for the items taken from a GListModel.
https://docs.gtk.org/gtk4/class.ListItemFactory.html
GtkBuilderListItemFactory is a GtkListItemFactory that creates widgets by instantiating GtkBuilder UI templates.
The templates must be extending GtkListItem, and typically use GtkExpressions to obtain data from the items in the model.
https://docs.gtk.org/gtk4/class.BuilderListItemFactory.html
GListModel is an interface that represents a mutable list of GObjects. Its main intention is as a model for various widgets in user interfaces, such as list views, but it can also be used as a convenient method of returning lists of data, with support for updates.
https://docs.gtk.org/gio/iface.ListModel.html
----------------------------------------------------------------------------------------------------------------
https://docs.gtk.org/gtk4/getting_started.html
https://docs.gtk.org/gtk4/overview.html
https://flathub.org/apps/details/ar.xjuan.Cambalache
https://github.com/Taiko2k/GTK4PythonTutorial
https://github.com/ToshioCP/Gtk4-tutorial
https://developer.gnome.org/documentation/tutorials/beginners/getting_started.html
https://github.com/Taiko2k/GTK4PythonTutorial#readme
----------------------------------------------------------------------------------------------------------------
GTK Development Blog
All things GTK
Scalable lists in GTK 4
One of the last big missing pieces in GTK 4 is the infrastructure for new list and grid widgets. It has just been merged and is included in the 3.98.5 release. So it is time to take a closer look.
History: tree views and list boxes
Since ancient times (ie GTK 2), GtkTreeView has been the go-to data display widget in GTK. It uses a model-view pattern to keep the data separate from the display infrastructure. Over the years, it has grown a grid-display sibling (GtkIconView) and a selection cousin (GtkComboBox), using the same infrastructure (tree models and cell renderers).
Unfortunately, the approach taken for rendering in GtkTreeView with cell renderers left us with a schism: widgets use one set of vfuncs and technologies for size allocation and rendering, and cell renderers use another. One of the unfortunate consequences of this split is that it is very hard to do animations in tree views (since cell renderers dont keep state). Another is that most of the advances of the GTK CSS rendering machinery are unavailable in cell renderers.
Therefore, we would really like to use widgets for displaying the data in lists. During the GTK 3 era, we have introduced a number of containers for this purpose: GtkListBox for lists, and GtkFlowBox for grids. They dont use cell renderers, so the aforementioned limitations are not a concern. And they can even use list models to hold the data. But they generate a widget for each data item, and this severely limits their scalability. As a rule of thumb, GtkListBox can handle 1000 items well, while GtkTreeView works fine for 100000.
Overcoming the scalability limitations, while still using widgets for all rendering has been on our roadmap for a long time.
Scalability limits Widget Scalability
GtkIconView 100
GtkListBox 1000
GtkTreeView 100000
GtkListView unlimited
New infrastructure
With list view family of widgets, we hope to finally achieve that. The goal is to handle unlimited numbers of items well. If youve worked with things like the Android recycler view, you will recognize the basic ideas behind list views:
The data for items is provided in the form of a model (containing objects)
Widgets are created just for the viewable range of items
Widgets can be recycled by binding them to different items
Avoid iterating over all items in the model as much as possible, and just deal with the items in the visible range which are bound to widgets
Models
For the model side of our model-view architecture, weve moved away from GtkTreeModel, and are now using GListModel. There are several reasons for this. One is that we want the items to be objects with properties, so we can use property bindings. Another one is that GtkTreeModel is not all that scalable in the first place (see e.g. this case of unintentional quadratic behavior).
GTK 4 comes with a rich assortment of GListModel implementations, from various ways to combine or modify existing models to filtering and sorting. Filtering and sorting is supported by several GtkFilter and GtkSorter classes. Selections are also handled on the model side, with GtkSelectionModel and its subclasses.
Finally, there are concrete models for the kinds of data that we are dealing with: GtkDirectoryList for files, PangoFontMap for fonts.
APIs that have traditionally returns GLists of various items have been changed or supplemented with APIs returning a GListModel, for example gdk_display_get_monitors(), gtk_window_get_toplevels() and gtk_stack_get_pages().
Factories
Since we are talking about automatically creating widgets on demand, there will be factories involved. GtkListItemFactory is the object that is tasked with creating widgets for the items in the model.
There are different implementations of this factory. One of them, GtkBuilderListItemFactory, is using ui files as templates for the list item widgets. Here is a typical example:
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<property name="wrap">1</property>
<property name="width-chars">50</property>
<property name="max-width-chars">50</property>
<binding name="label">
<lookup name="summary" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
The full example can be found in gtk4-demo.
Another list item factory implementation, GtkSignalListItemFactory, takes callbacks to setup, teardown, bind and unbind widgets from the items.
static void
setup_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
image = gtk_image_new ();
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_list_item_set_child (list_item, image);
}
static void
bind_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
GAppInfo *app_info;
image = gtk_list_item_get_child (list_item);
app_info = gtk_list_item_get_item (list_item);
gtk_image_set_from_gicon (GTK_IMAGE (image),
g_app_info_get_icon (app_info));
}
static void
activate_cb (GtkListView *list,
guint position,
gpointer unused)
{
GListModel *model;
GAppInfo *app_info;
model = gtk_list_view_get_model (list);
app_info = g_list_model_get_item (model, position);
g_app_info_launch (app_info, NULL, NULL, NULL);
g_object_unref (app_info);
}
...
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", setup_listitem_cb, NULL);
g_signal_connect (factory, "bind", bind_listitem_cb, NULL);
list = gtk_list_view_new_with_factory (factory);
g_signal_connect (list, "activate", activate_cb, NULL);
model = create_application_list ();
gtk_list_view_set_model (GTK_LIST_VIEW (list), model);
g_object_unref (model);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
The full example can be found here.
Expressions
To bind the widgets that are created by the factory to the data in your items, we need a flexible mechanism for binding properties. GObjects GBinding mechanism goes in the right direction, but is not flexible enough to handle situations where you may need to bind properties of sub-objects or widgets deep inside the hierarchy of your widget, and where the objects in questions may not even exist at the time you are setting up the binding.
To handle this, weve introduced GtkExpression as a more flexible binding system which can express things like:
label = this->item->value
where this is a GtkListItem, which has an item property (of type SettingsKey), whose value property we want to bind to the label property. Expressing the same in a GtkBuilder ui file looks a bit more unwieldy:
<binding name="label">
<lookup name="value" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
New widgets
GtkListView is a simple list, without columns or headers. An example where this kind of list is used is GtkFontChooser. One little way in which GtkListView breaks new ground is that it can be set up as a horizontal list, as well as the usual vertical orientation.
GtkGridView puts the widgets in a reflowing grid, much like GtkFlowBox or GtkIconView.
GtkColumnView is the equivalent of a full GtkTreeView, with multiple columns and headers, and features such as interactive resizing and reordering. Just like a GtkTreeView has GtkTreeViewColumns, a GtkColumnView has a list of GtkColumnViewColumns. Each column has a factory that produces a cell for each item. The cells are then combined into the row for the item.
Examples
Many of the lists in complex GTK dialogs (although not all yet) have been replaced with the new list widgets. For example, the font chooser is now using a GtkListView, and most of the lists in the GTK inspector use GtkColumnView.
But gtk4-demo contains a number of examples for the new widgets. Here are a few:
The clocks examples shows the advantages of having the full flexibility of widget rendering available.
The colors example shows the a medium-size dataset rendered in various ways.
The settings example shows that the column view more or less matches GtkTreeView, feature-wise.
Summary
This post gave an introduction to the new list widgets. Theres more that we havent touched on here, such as trees or the combo box replacement. One place to learn more about the new apis is the detailed introduction in the GTK documentation.
Weve merged the listview infrastructure to master now. That doesnt mean that it is finished. But we think it is ready for some wider use, and we hope to get feedback from you on what works, what doesnt and what is missing.
And, to be clear, it also does not mean that we are removing treeviews and combo boxes from GTK 4—it is too late for that, and they are still used in many places inside GTK. That may be a GTK 5 goal.

79
(notes)
View File

@ -117,57 +117,6 @@ GtkWidget *get_text_view(){ // WTF ?!& @Grr #~!
/*
https://docs.gtk.org/gtk4/class.ApplicationWindow.html
GtkApplication *app = gtk_application_new ("org.gtk.test", 0);
GtkBuilder *builder = gtk_builder_new_from_string (
"<interface>"
" <menu id='menubar'>"
" <submenu>"
" <attribute name='label' translatable='yes'>_Edit</attribute>"
" <item>"
" <attribute name='label' translatable='yes'>_Copy</attribute>"
" <attribute name='action'>win.copy</attribute>"
" </item>"
" <item>"
" <attribute name='label' translatable='yes'>_Paste</attribute>"
" <attribute name='action'>win.paste</attribute>"
" </item>"
" </submenu>"
" </menu>"
"</interface>",
-1);
GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"));
gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
g_object_unref (builder);
// ...
GtkWidget *window = gtk_application_window_new (app);
*/
//------------------------------------------------------------------------------
GtkScrolledWindow *get_scrolled_gl_area(){
GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new());
gtk_scrolled_window_set_min_content_width (scrolled, W_IMAGE);
gtk_scrolled_window_set_min_content_height (scrolled, H_IMAGE);
// GtkAdjustment *width = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
// GtkAdjustment *height = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
// (value, lower, upper, step_increment, page_increment, page_size)
// GtkWidget *GLarea = gtk_gl_area_new();
// gtk_scrolled_window_set_child (scrolled, GLarea);
// https://docs.gtk.org/gtk4/class.GLArea.html
return scrolled;
}
// https://docs.gtk.org/gtk4/getting_started.html (m'aura bien servi, quand même !)
@ -176,6 +125,34 @@ GtkScrolledWindow *get_scrolled_gl_area(){
https://blog.gtk.org/2020/06/07/scalable-lists-in-gtk-4/
https://docs.gtk.org/gtk4/section-list-widget.html
A GtkListItemFactory creates widgets for the items taken from a GListModel.
https://docs.gtk.org/gtk4/class.ListItemFactory.html
GtkBuilderListItemFactory is a GtkListItemFactory that creates widgets by instantiating GtkBuilder UI templates.
The templates must be extending GtkListItem, and typically use GtkExpressions to obtain data from the items in the model.
https://docs.gtk.org/gtk4/class.BuilderListItemFactory.html
GListModel is an interface that represents a mutable list of GObjects. Its main intention is as a model for various widgets in user interfaces, such as list views, but it can also be used as a convenient method of returning lists of data, with support for updates.
https://docs.gtk.org/gio/iface.ListModel.html
----------------------------------------------------------------------------------------------------------------
https://docs.gtk.org/gtk4/getting_started.html
https://docs.gtk.org/gtk4/overview.html
https://flathub.org/apps/details/ar.xjuan.Cambalache
https://github.com/Taiko2k/GTK4PythonTutorial
https://github.com/ToshioCP/Gtk4-tutorial
https://developer.gnome.org/documentation/tutorials/beginners/getting_started.html
https://github.com/Taiko2k/GTK4PythonTutorial#readme
----------------------------------------------------------------------------------------------------------------
GTK Development Blog

View File

@ -6,7 +6,6 @@
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Arthur Menges <arthur.menges@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
@ -140,4 +139,4 @@ static inline char *read_file(char *filename)
char *get_space_run_edit_specif();
char *get_rules_run_edit_specif();
/* (texts are in widgets_lab or wdgt_lab_I or II) */
/* (texts are in widget / stock) */

View File

@ -61,3 +61,40 @@ void on_glarea_unrealize (GtkWidget *widget);
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
void on_reset_image (GtkWidget *btt_reset, gpointer data);
void on_clicked_HOME (GtkWidget *btt_reset, gpointer data);

View File

@ -44,3 +44,57 @@ long model_get_state_arrows_count(const char *state_id);
bool model_get_next_arrow(struct arrow_t *new_arrow,
const char *state_id,
char dimension);

View File

@ -28,6 +28,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <gtk-4.0/gtk/gtk.h>
void set_main_window (GtkApplication *app);
@ -55,3 +56,46 @@ GtkScrolledWindow *get_user_rules_tree ();
void icons_for_fun (GtkHeaderBar *header_bar);
GtkWidget *get_window_child_DATA_lab();

View File

@ -306,6 +306,11 @@ void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL,
printf ("callback.c (line 300) - WRITE_CURRENT_MODEL\n");
}
void on_clicked_HOME (GtkWidget *btt_reset, gpointer data) {
printf ("on_clicked_HOME button presents the dialog_window ( :- ) but it works only once.\n");
gtk_window_present (GTK_WINDOW (get_dialog_window())); // works once only !
}
void on_reset_image (GtkWidget *btt_reset, gpointer data) {
printf ("callback.on_reset_image() <> Comment remettre tous les curseurs à zéro ?\n");
}

View File

@ -29,6 +29,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../include/callbacks.h"
int main (int argc, char **argv)
@ -45,3 +46,55 @@ int main (int argc, char **argv)
g_object_unref (app);
return status;
}

View File

@ -5,19 +5,21 @@
* Parsing model XML *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2023 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2024 Jean Sirmai <jean@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, or (at your option) any later version. *
* 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. *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Main *
* Windows && Headers *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
@ -126,9 +126,10 @@ static void window_header_bar (GtkWindow *window, char *title){
// https://iconduck.com/sets/adwaita-icon-theme https://iconduck.com/sets/carbon-icons
GtkButton *go_home = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (go_home, "go-home-symbolic");
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (go_home));
GtkButton *btt_go_home = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (btt_go_home, "go-home-symbolic");
g_signal_connect (btt_go_home, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_go_home));
GtkButton *search = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (search, "user-trash-symbolic");

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Widgets header *
* Labo *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
@ -29,92 +29,110 @@
#include "../../include/widgets.h"
/******************************************************************************/
/* */
/* ! W A R N I N G ! W A R N I N G ! W A R N I N G ! */
/* _______ */
/* */
/* Potentially dangerous experiments underway! */
/* Sensitive individuals should be accompanied */
/* */
/* <> You who enter here, leave all hope of an accomplished code <> */
/* _______ */
/* */
/* Y O U E N T E R H E R E A T Y O U R O W N R I S K ! */
/* */
/******************************************************************************/
// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
// https://iconduck.com/sets/adwaita-icon-theme https://iconduck.com/sets/carbon-icons
// https://docs.gtk.org/gtk4/section-text-widget.html
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
/*
GtkFrame *get_frame_with_label() { // EN ATTENDANT DE SAVOIR UTILISER : GtkTextTagTable , GtkTextBuffer
GtkFrame *space_specif = GTK_FRAME(gtk_frame_new ("Space (run / edit) specifications"));
GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (get_space_run_edit_specif()));
gtk_frame_set_child (GTK_FRAME (space_specif), GTK_WIDGET (any_Label));
return space_specif;
}
*/
GtkWidget *get_edit_rules_page_new() {
GtkPaned *hpaned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));
GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre des règles");
GtkWidget *édition_de_la_règle_sélectionnée = gtk_frame_new ("Édition de la règle sélectionnée");
gtk_paned_set_start_child (hpaned, GTK_WIDGET (arbre_des_règles));
gtk_paned_set_end_child (hpaned, GTK_WIDGET (édition_de_la_règle_sélectionnée));
// gtk_widget_set_size_request (GTK_WIDGET (hpaned), W, H);
gtk_paned_set_wide_handle (hpaned, TRUE);
return GTK_WIDGET (hpaned);
void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root) {
struct TreeNode_t *a = create_user_tree_node("We, the people");add_child_node(tree_root, a);
struct TreeNode_t *b = create_user_tree_node("in Order to"); add_child_node(tree_root, b);
struct TreeNode_t *c = create_user_tree_node("do establish"); add_child_node(tree_root, c);
struct TreeNode_t *aa = create_user_tree_node("aware of"); add_child_node(a, aa);
struct TreeNode_t *aaa = create_user_tree_node("our rights"); add_child_node(aa, aaa);
struct TreeNode_t *aab = create_user_tree_node("our duties"); add_child_node(aa, aab);
struct TreeNode_t *aaaa = create_user_tree_node("read"); add_child_node(aaa, aaaa);
struct TreeNode_t *aaab = create_user_tree_node("write"); add_child_node(aaa, aaab);
struct TreeNode_t *aaac = create_user_tree_node("copy"); add_child_node(aaa, aaac);
struct TreeNode_t *aaad = create_user_tree_node("edit"); add_child_node(aaa, aaad);
struct TreeNode_t *aaaba= create_user_tree_node("code"); add_child_node(aaab, aaaba);
struct TreeNode_t *aaabb= create_user_tree_node("language"); add_child_node(aaab, aaabb);
struct TreeNode_t *aaabc= create_user_tree_node("any art..."); add_child_node(aaab, aaabc);
struct TreeNode_t *aaadb= create_user_tree_node("publish"); add_child_node(aaac, aaadb);
struct TreeNode_t *aaada= create_user_tree_node("create"); add_child_node(aaad, aaada);
struct TreeNode_t *aaba = create_user_tree_node("learn"); add_child_node(aab, aaba);
struct TreeNode_t *aabb = create_user_tree_node("help"); add_child_node(aab, aabb);
struct TreeNode_t *ba = create_user_tree_node("promote"); add_child_node(b, ba);
struct TreeNode_t *bb = create_user_tree_node("individual"); add_child_node(b, bb);
struct TreeNode_t *bc = create_user_tree_node("and common"); add_child_node(b, bc);
struct TreeNode_t *bca = create_user_tree_node("education"); add_child_node(bc, bca);
struct TreeNode_t *bcb = create_user_tree_node("mutual"); add_child_node(bc, bcb);
struct TreeNode_t *bcc = create_user_tree_node("support"); add_child_node(bc, bcc);
struct TreeNode_t *bcd = create_user_tree_node("health"); add_child_node(bc, bcd);
struct TreeNode_t *bcda = create_user_tree_node("mental"); add_child_node(bcd, bcda);
struct TreeNode_t *bcdb = create_user_tree_node("physical"); add_child_node(bcd, bcdb);
struct TreeNode_t *ca = create_user_tree_node("free"); add_child_node(c, ca);
struct TreeNode_t *cb = create_user_tree_node("code"); add_child_node(c, cb);
struct TreeNode_t *cc = create_user_tree_node("access"); add_child_node(c, cc);
}
GtkWidget *get_edit_measures_page_new() {
GtkWidget *measures_grid = gtk_grid_new();
return measures_grid;
char *get_space_run_edit_specif(){
return "\n\
\
>>> Dans : [space_page - mode RUN] doivent être : ------------------------------------------------------\n\n\
(1) les commandes de mouvement:\n\
- run/stop, slow down/speed up, step by step, do/undo/redo\n\
+ le buffer [elapsed time] qui montre le temps de simulation écoulé\n\n\
(2) les commandes qui modifient la perception de l'espace (la caméra)\n\
- son orientation (X,Y,Z),\n\
+ l'orientation (X,Y,Z) de l'état dans l'espace (six possibilités),\n\
+ le zoom,\n\
+ les paramètres qui définissent la perspective (distances oeil/écran, écran/objet virtuel) \n\n\
(3) les commandes qui modifient les apparences des objets et des situations d'intérêt\n\
(+/- transparents, colorés, etc.)\n\n\
(4) les commandes qui modifient l'apparence de l'espace (grilles, +/- surfaces, aspect des flèches, etc.)\n\n\
\
(0) NB >>> AUCUNE COMMANDE NE DOIT PERMETTRE D'ÉDITER L'ESPACE ! <<<\n\n\n\
\
>>> Dans : [space_page - mode EDIT] doivent être : ------------------------------------------------------\n\n\
(1) les commandes qui modifient la perception de l'espace (la caméra)\n\
- son orientation (X,Y,Z),\n\
+ l'orientation (X,Y,Z) de l'état dans l'espace (six possibilités),\n\
+ le zoom,\n\
+ les paramètres qui définissent la perspective (distances oeil/écran, écran/objet virtuel) \n\n\
(2) les commandes qui modifient les apparences des objets et des situations d'intérêt\n\
(+/- transparents, colorés, etc.)\n\n\
(3) les commandes qui modifient l'apparence de l'espace (grilles, +/- surfaces, aspect des flèches, etc.)\n\n\
(4) les commandes d'édition locales (drag and drop une flèche)\n\
('faire de la place' pour insérer)\n\
(sélectionner pour déplacer ou enlever...)\n\
NB ces commandes doivent être graphiques et/ou accessibles par raccourcis ou en ligne\n\n\
(5) les commandes d'édition globales\n\
(ex: introduire, retirer, transformer +/-aléatoirement (n) objets dans l'espace)\n\n\n\
NB une action effectuée sur une zone d'intérêt devrait pouvoir être automatiquement appliquée\n\
à d'autres zones d'intérêt identifiées comme similaires\n\n\
\
(0) NB >>> AUCUNE COMMANDE NE DOIT PERMETTRE D'EXÉCUTER UN RUN ! <<<\n\n\n\
\
>>> L'objectif est que l'utilisateur ait accès à une organsisation aussi ergonomique que possible -----\n\n\
i.e : chaque utilisateur devrait disposer de 'préférences'\n\
c'est-à-dire avoir la possiblité de faire des choix ergonomiques personnalisés.\n";
}
GtkWidget *get_edit_results_page_new() {
GtkWidget *xxx_grid = gtk_grid_new();
return xxx_grid;
}
GtkWidget *get_edit_discuss_page_new() {
GtkWidget *xxx_grid = gtk_grid_new();
return xxx_grid;
}
/*
GtkWidget *get_edit_help_page_new() {
GtkWidget *edit_help_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID(edit_help_grid), GTK_WIDGET(get_frame_with_label()), 0, 0, 1, 1);
return edit_help_grid;
}
*/
GtkWidget *get_measures_page_new() {
GtkWidget *measures_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("movements"), 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transports"), 1, 0, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transformations"), 2, 0, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("objects"), 0, 1, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("situations"), 1, 1, 1, 1);
return measures_grid;
}
GtkWidget *get_results_page_new() {
GtkWidget *results_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Repartitions"), 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Correlations"), 0, 1, 1, 1);
gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Evolutions"), 0, 2, 1, 1);
return results_grid;
}
GtkWidget *get_discuss_page_new() {
GtkWidget *discuss_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Interpretations"), 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Discussions"), 0, 1, 1, 1);
return discuss_grid;
}
/*
GtkWidget *get_help_page_new() {
GtkWidget *run_help_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID(run_help_grid), GTK_WIDGET(get_frame_with_label()), 0, 0, 1, 1);
return run_help_grid;
}
*/
//---------------------------------------------------------------------------
GtkWidget *get_window_child_DATA_lab () {
if (0) printf("widgets.get_window_child_DATA (line 279)\n");
@ -212,52 +230,9 @@ GtkWidget *get_window_child_DATA_lab () {
gtk_box_append (help_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (help_box, gtk_button_new_with_label ("preferences"));
//SWITCH_TO (DATA);
return GTK_WIDGET (data_box);
}
char *get_space_run_edit_specif(){
return "\n\
\
>>> Dans : [space_page - mode RUN] doivent être : ------------------------------------------------------\n\n\
(1) les commandes de mouvement:\n\
- run/stop, slow down/speed up, step by step, do/undo/redo\n\
+ le buffer [elapsed time] qui montre le temps de simulation écoulé\n\n\
(2) les commandes qui modifient la perception de l'espace (la caméra)\n\
- son orientation (X,Y,Z),\n\
+ l'orientation (X,Y,Z) de l'état dans l'espace (six possibilités),\n\
+ le zoom,\n\
+ les paramètres qui définissent la perspective (distances oeil/écran, écran/objet virtuel) \n\n\
(3) les commandes qui modifient les apparences des objets et des situations d'intérêt\n\
(+/- transparents, colorés, etc.)\n\n\
(4) les commandes qui modifient l'apparence de l'espace (grilles, +/- surfaces, aspect des flèches, etc.)\n\n\
\
(0) NB >>> AUCUNE COMMANDE NE DOIT PERMETTRE D'ÉDITER L'ESPACE ! <<<\n\n\n\
\
>>> Dans : [space_page - mode EDIT] doivent être : ------------------------------------------------------\n\n\
(1) les commandes qui modifient la perception de l'espace (la caméra)\n\
- son orientation (X,Y,Z),\n\
+ l'orientation (X,Y,Z) de l'état dans l'espace (six possibilités),\n\
+ le zoom,\n\
+ les paramètres qui définissent la perspective (distances oeil/écran, écran/objet virtuel) \n\n\
(2) les commandes qui modifient les apparences des objets et des situations d'intérêt\n\
(+/- transparents, colorés, etc.)\n\n\
(3) les commandes qui modifient l'apparence de l'espace (grilles, +/- surfaces, aspect des flèches, etc.)\n\n\
(4) les commandes d'édition locales (drag and drop une flèche)\n\
('faire de la place' pour insérer)\n\
(sélectionner pour déplacer ou enlever...)\n\
NB ces commandes doivent être graphiques et/ou accessibles par raccourcis ou en ligne\n\n\
(5) les commandes d'édition globales\n\
(ex: introduire, retirer, transformer +/-aléatoirement (n) objets dans l'espace)\n\n\n\
NB une action effectuée sur une zone d'intérêt devrait pouvoir être automatiquement appliquée\n\
à d'autres zones d'intérêt identifiées comme similaires\n\n\
\
(0) NB >>> AUCUNE COMMANDE NE DOIT PERMETTRE D'EXÉCUTER UN RUN ! <<<\n\n\n\
\
>>> L'objectif est que l'utilisateur ait accès à une organsisation aussi ergonomique que possible -----\n\n\
i.e : chaque utilisateur devrait disposer de 'préférences'\n\
c'est-à-dire avoir la possiblité de faire des choix ergonomiques personnalisés.\n";
}
void icons_for_fun (GtkHeaderBar *header_bar) // https://iconduck.com/sets/adwaita-icon-theme
@ -336,40 +311,4 @@ void icons_for_fun (GtkHeaderBar *header_bar) // https://iconduck.com/sets/a
// gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "process-stop-symbolic");
}
void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root) {
struct TreeNode_t *a = create_user_tree_node("We, the people");add_child_node(tree_root, a);
struct TreeNode_t *b = create_user_tree_node("in Order to"); add_child_node(tree_root, b);
struct TreeNode_t *c = create_user_tree_node("do establish"); add_child_node(tree_root, c);
struct TreeNode_t *aa = create_user_tree_node("aware of"); add_child_node(a, aa);
struct TreeNode_t *aaa = create_user_tree_node("our rights"); add_child_node(aa, aaa);
struct TreeNode_t *aab = create_user_tree_node("our duties"); add_child_node(aa, aab);
struct TreeNode_t *aaaa = create_user_tree_node("read"); add_child_node(aaa, aaaa);
struct TreeNode_t *aaab = create_user_tree_node("write"); add_child_node(aaa, aaab);
struct TreeNode_t *aaac = create_user_tree_node("copy"); add_child_node(aaa, aaac);
struct TreeNode_t *aaad = create_user_tree_node("edit"); add_child_node(aaa, aaad);
struct TreeNode_t *aaaba= create_user_tree_node("code"); add_child_node(aaab, aaaba);
struct TreeNode_t *aaabb= create_user_tree_node("language"); add_child_node(aaab, aaabb);
struct TreeNode_t *aaabc= create_user_tree_node("any art..."); add_child_node(aaab, aaabc);
struct TreeNode_t *aaadb= create_user_tree_node("publish"); add_child_node(aaac, aaadb);
struct TreeNode_t *aaada= create_user_tree_node("create"); add_child_node(aaad, aaada);
struct TreeNode_t *aaba = create_user_tree_node("learn"); add_child_node(aab, aaba);
struct TreeNode_t *aabb = create_user_tree_node("help"); add_child_node(aab, aabb);
struct TreeNode_t *ba = create_user_tree_node("promote"); add_child_node(b, ba);
struct TreeNode_t *bb = create_user_tree_node("individual"); add_child_node(b, bb);
struct TreeNode_t *bc = create_user_tree_node("and common"); add_child_node(b, bc);
struct TreeNode_t *bca = create_user_tree_node("education"); add_child_node(bc, bca);
struct TreeNode_t *bcb = create_user_tree_node("mutual"); add_child_node(bc, bcb);
struct TreeNode_t *bcc = create_user_tree_node("support"); add_child_node(bc, bcc);
struct TreeNode_t *bcd = create_user_tree_node("health"); add_child_node(bc, bcd);
struct TreeNode_t *bcda = create_user_tree_node("mental"); add_child_node(bcd, bcda);
struct TreeNode_t *bcdb = create_user_tree_node("physical"); add_child_node(bcd, bcdb);
struct TreeNode_t *ca = create_user_tree_node("free"); add_child_node(c, ca);
struct TreeNode_t *cb = create_user_tree_node("code"); add_child_node(c, cb);
struct TreeNode_t *cc = create_user_tree_node("access"); add_child_node(c, cc);
}

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Widgets header *
* Rules *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
@ -31,56 +31,35 @@
#define W 1920 // TODO 2024-06-30
#define H 960 // Ad hoc (pour mon écran)
#define W_IMAGE W - 320
#define H_IMAGE H - 126
#define H_STYLES_PANE 30
#define W_IMAGE_LOCAL W / 16
#define H_IMAGE_LOCAL H / 16
#define W_IMAGE_LOCAL W / 64
#define H_IMAGE_LOCAL H / 64
static GtkWidget *get_image_GLUTAMATE(){
GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/glutamate.png");
gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
return image;
}
static GtkWidget *get_image_GLUTAMINE(){
GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/glutamine.png");
gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
return image;
}
static GtkWidget *get_image_HISTIDINE(){
GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/histidine.png");
gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
return image;
}
static GtkWidget *get_image_PHENYLALANINE(){
GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/phénylalanine.png");
gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
return image;
}
static GtkWidget *get_image_DOPAMINE(){
GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/dopamine.png");
gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
return image;
}
static GtkWidget *get_image_ATP(){
GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/ATP.png");
gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
return image;
}
static GtkWidget *get_image_AMP(){
GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/AMP.png");
gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
return image;
}
static GtkWidget *get_selected_rules_vpaned_new() {
GtkPaned *EXEC_CONTROLS_pane = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL));
gtk_widget_set_size_request (GTK_WIDGET (EXEC_CONTROLS_pane), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
// if mode EDIT set_shrink FALSE < TODO
gtk_paned_set_shrink_start_child (EXEC_CONTROLS_pane, FALSE);
gtk_paned_set_shrink_end_child (EXEC_CONTROLS_pane, FALSE);
GtkBox *up_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMATE()));
@ -100,6 +79,7 @@ static GtkWidget *get_selected_rules_vpaned_new() {
static GtkBox *get_rules_comparator_new(){
GtkBox *comparator = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_widget_set_size_request (GTK_WIDGET (comparator), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
gtk_box_append (comparator, GTK_WIDGET (get_image_ATP()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (get_image_AMP()));
@ -108,11 +88,11 @@ static GtkBox *get_rules_comparator_new(){
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (get_image_GLUTAMINE()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (get_image_HISTIDINE()));
gtk_box_append (comparator, GTK_WIDGET (gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/histidine.png")));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (get_image_PHENYLALANINE()));
gtk_box_append (comparator, GTK_WIDGET (gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/phénylalanine.png")));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (get_image_DOPAMINE()));
gtk_box_append (comparator, GTK_WIDGET (gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/dopamine.png")));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
return comparator;
}
@ -127,6 +107,7 @@ static GtkWidget *get_rules_tree_hpaned_new(){
gtk_paned_set_end_child (H_tree_vs_comparison, GTK_WIDGET (get_rules_comparator_new()));
gtk_paned_set_position (H_tree_vs_comparison, 300);
gtk_paned_set_wide_handle (H_tree_vs_comparison, TRUE);
gtk_widget_set_size_request (GTK_WIDGET (H_tree_vs_comparison), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
gtk_paned_set_shrink_start_child (H_tree_vs_comparison, FALSE);
gtk_paned_set_shrink_end_child (H_tree_vs_comparison, FALSE);
return GTK_WIDGET (H_tree_vs_comparison);
@ -140,6 +121,8 @@ GtkWidget *widget_get_RULES_page() {
gtk_paned_set_end_child (H_tree_vs_selected, GTK_WIDGET (get_selected_rules_vpaned_new()));
gtk_paned_set_position (H_tree_vs_selected, 400); // WARNING : c'est une position "absolue"
gtk_paned_set_wide_handle (H_tree_vs_selected, TRUE);
gtk_paned_set_shrink_start_child (H_tree_vs_selected, FALSE);
gtk_paned_set_shrink_end_child (H_tree_vs_selected, FALSE);
return GTK_WIDGET (H_tree_vs_selected);
}

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Main *
* State *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
@ -29,13 +29,13 @@
#include "../../include/base.h"
#include "../../include/callbacks.h"
#include "../../include/widgets.h"
//#include "../../include/widgets.h" < usefulness ??
#define W 1920 // TODO 2024-06-30 (Ad hoc pour mon écran)
#define H 960
#define H_STYLES_PANE 30
#define LOWER_COMPARTMENT_PARTITION 1100
#define UPPER_COMPARTMENT_PARTITION 600
#define LOWER_COMPARTMENT_PARTITION 1300
GtkBox *get_XYZ_box(){
GtkBox *XYZ_labels_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); // spacing = 2
@ -72,27 +72,6 @@ static GtkBox *get_ZOOM_box(){
return ZOOM_box;
}
static GtkBox *get_RUN_STOP_box(){
GtkBox *RUN_STOP_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10));
gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("R U N / S T O P")));
gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("SPEED UP <> SLOW DOWN")));
gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("STEP by STEP (+ show active rule)")));
return RUN_STOP_box;
}
static GtkBox *get_DO_UNDO_REDO_box(){
GtkBox *DO_UNDO_REDO_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\
a progress bar showing the time elapsed during the simulation")));
gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET (gtk_progress_bar_new ()));
GtkAdjustment *adjust = gtk_adjustment_new (30, 0, 100, 1, 0, 0);
gtk_box_append (DO_UNDO_REDO_box,
GTK_WIDGET (gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjust)));
gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\
DO - UNDO - REDO")));
return DO_UNDO_REDO_box;
}
static GtkBox *get_OBJECTS_box(){
GtkBox *objects_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
GtkWidget *btt_reset = gtk_check_button_new_with_label ("reset");
@ -148,6 +127,7 @@ static GtkBox *get_SITUATIONS_box(){
static GtkWidget *get_OBJECTS_and_SITUATIONS(){
GtkWidget *scroll_objects = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_objects), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparency
gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (get_OBJECTS_box()));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_objects), frame_objects);
@ -162,6 +142,8 @@ static GtkWidget *get_OBJECTS_and_SITUATIONS(){
gtk_paned_set_start_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_objects));
gtk_paned_set_end_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_situations));
gtk_paned_set_position (GTK_PANED (objects_and_situations_horizontal_pane), UPPER_COMPARTMENT_PARTITION);
gtk_paned_set_shrink_start_child (GTK_PANED (objects_and_situations_horizontal_pane), FALSE);
gtk_paned_set_shrink_end_child (GTK_PANED (objects_and_situations_horizontal_pane), FALSE);
gtk_widget_set_size_request (objects_and_situations_horizontal_pane, 0, 127);
return objects_and_situations_horizontal_pane;
@ -186,17 +168,31 @@ GtkWidget *get_SPACE_VIEW_box() {
return GTK_WIDGET (central_box);
}
static GtkWidget *get_SPACE_EDIT_CONTROLS_box(){
static GtkWidget *get_SPACE_EDIT_CONTROL_box(){
return gtk_label_new
("_____________\n SPACE EDIT\n controls\n'''''''''''''''''''''''");
}
static GtkWidget *get_TIME_EXEC_CONTROLS_box() {
GtkPaned *EXEC_CONTROLS_pane = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));
gtk_paned_set_start_child (EXEC_CONTROLS_pane, GTK_WIDGET (get_DO_UNDO_REDO_box()));
gtk_paned_set_end_child (EXEC_CONTROLS_pane, GTK_WIDGET (get_RUN_STOP_box()));
gtk_paned_set_position (EXEC_CONTROLS_pane, LOWER_COMPARTMENT_PARTITION);
return GTK_WIDGET (EXEC_CONTROLS_pane);
static GtkWidget *get_SEQUENCE_CONTROL_box() {
GtkBox *SEQUENCE_CONTROL_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
GtkBox *DO_UNDO_REDO_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\
a progress bar showing the time elapsed during the simulation")));
gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET (gtk_progress_bar_new ()));
GtkAdjustment *adjust = gtk_adjustment_new (30, 0, 100, 1, 0, 0);
gtk_box_append (DO_UNDO_REDO_box,
GTK_WIDGET (gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjust)));
gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\
DO - UNDO - REDO")));
gtk_widget_set_size_request (GTK_WIDGET (DO_UNDO_REDO_box), LOWER_COMPARTMENT_PARTITION, 0);
gtk_box_append (SEQUENCE_CONTROL_box, GTK_WIDGET (DO_UNDO_REDO_box));
gtk_box_append (SEQUENCE_CONTROL_box, GTK_WIDGET (gtk_button_new_with_label ("R U N / S T O P")));
gtk_box_append (SEQUENCE_CONTROL_box, GTK_WIDGET (gtk_button_new_with_label ("SPEED UP <> SLOW DOWN")));
gtk_box_append (SEQUENCE_CONTROL_box, GTK_WIDGET (gtk_button_new_with_label ("STEP by STEP (+ show active rule)")));
return GTK_WIDGET (SEQUENCE_CONTROL_box);
}
/******************************************************************************/
@ -209,8 +205,8 @@ GtkWidget *widget_get_STATE_page() {
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
if (get_EXEC_EDIT ()) gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_CONTROLS_box()));
else gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_CONTROLS_box()));
if (get_EXEC_EDIT ()) gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_CONTROL_box()));
else gtk_box_append (page_box, GTK_WIDGET (get_SEQUENCE_CONTROL_box()));
return GTK_WIDGET (page_box);
}

View File

@ -2,10 +2,9 @@
* *
* Gem-graph client *
* *
* Main *
* Stock *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
@ -66,3 +65,36 @@ GtkWidget *widget_get_STOCK_page () {
}

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Widgets header *
* Tree *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
@ -31,9 +31,6 @@
#include "../../include/callbacks.h"
#include "../../include/widgets.h"
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
// https://docs.gtk.org/gtk4/section-text-widget.html
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL