gflow-dock.vala 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /********************************************************************
  2. # Copyright 2014-2017 Daniel 'grindhold' Brendle, 2015 Daniel Espinosa <esodan@gmail.com>
  3. #
  4. # This file is part of libgflow.
  5. #
  6. # libgflow is free software: you can redistribute it and/or
  7. # modify it under the terms of the GNU Lesser General Public License
  8. # as published by the Free Software Foundation, either
  9. # version 3 of the License, or (at your option) any later
  10. # version.
  11. #
  12. # libgtkflow is distributed in the hope that it will be
  13. # useful, but WITHOUT ANY WARRANTY; without even the implied
  14. # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. # PURPOSE. See the GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with libgtkflow.
  19. # If not, see http://www.gnu.org/licenses/.
  20. *********************************************************************/
  21. namespace GFlow {
  22. /**
  23. * This class represents an endpoint of a node. These endpoints can be
  24. * connected in order to let them exchange data. The data contained
  25. * in this endpoint is stored as GLib.Value. Only Docks that contain
  26. * data with the same VariantType can be interconnected.
  27. */
  28. public interface Dock : Object {
  29. /**
  30. * The name that will be rendered for this dock
  31. */
  32. public abstract string? name { get; set; }
  33. /**
  34. * The string rendered as typehint for this dock.
  35. * If this string is "" and the show_type is set to true
  36. * libgflow will attempt to determine the type of this
  37. * dock and display it, but it produces nicer results to set
  38. * them manually.
  39. */
  40. public abstract string? typename { get; set; }
  41. /**
  42. * Determines whether this dock is highlighted
  43. * this is usually triggered when the mouse hovers over it
  44. */
  45. public abstract bool highlight { get; set; }
  46. /**
  47. * Determines whether this dock is active
  48. */
  49. public abstract bool active { get; set; }
  50. /**
  51. * A reference to the node this Dock resides in
  52. */
  53. public abstract weak Node? node { get; set; }
  54. /**
  55. * The initial value that has been set to this dock
  56. * The dock will be set to this value when it is rendered
  57. * invalid
  58. */
  59. public abstract GLib.Value? initial { get; }
  60. /**
  61. * This signal is being triggered, when there is a connection being established
  62. * from or to this Dock.
  63. */
  64. public signal void linked (Dock d);
  65. /**
  66. * This signal is being triggered, before a connection is made
  67. * between two docks. If the implementor returns false, the
  68. * connection is not being made
  69. */
  70. public virtual signal bool before_linking (Dock self, Dock other){
  71. return true;
  72. }
  73. /**
  74. * This signal is being triggered, when there is a connection being established
  75. * from or to this Dock.
  76. */
  77. public signal void unlinked (Dock d);
  78. /**
  79. * Triggers when the value of this dock changes
  80. */
  81. public signal void changed ();
  82. /**
  83. * Implementations should return true if this dock has at least one
  84. * connection to another dock
  85. */
  86. public abstract bool is_linked ();
  87. /**
  88. * Implementations should return true if this dock is connected
  89. * to the supplied dock
  90. */
  91. public abstract bool is_linked_to (Dock dock);
  92. /**
  93. * Connect this {@link Dock} to other {@link Dock}
  94. */
  95. public abstract void link (Dock dock) throws GLib.Error;
  96. /**
  97. * Disconnect this {@link Dock} from other {@link Dock}
  98. */
  99. public abstract void unlink (Dock dock) throws GLib.Error;
  100. /**
  101. * Disconnect this {@link Dock} from all {@link Dock}s it is connected to
  102. */
  103. public abstract void unlink_all () throws GLib.Error;
  104. /**
  105. * Tries to resolve this Dock's value-type to a displayable string
  106. */
  107. public virtual string determine_typestring () {
  108. if (this.initial != null)
  109. return this.initial.type().name();
  110. else
  111. return "";
  112. }
  113. /**
  114. * Returs true if this and the supplied dock have
  115. * same type
  116. */
  117. public virtual bool has_same_type (Dock other) {
  118. return this.initial.type_name() == other.initial.type_name();
  119. }
  120. }
  121. }