Results 1 to 6 of 6

Thread: Changes to the current ClanLib development branch

  1. #1
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default Changes to the current ClanLib development branch

    Removed callbacks from the ClanLib API. We now prefer to use std::functions

    The CallbackContainer has been replaced with a SlotContainer

    Slots can be connected in the container using the clan::bind_member helper, or via a lambda function "[=](int width, int height){return my_func(width, height, another_variable_in_scope);}

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    To be more clear, the Signal/Slot syntax has changed to:

    Code:
    Signal<void(int,int)> signal;
    
    SlotContainer slots;
    slots.connect(signal, static_function);
    slots.connect(signal, instance, &ClassName::member_function);
    slots.connect(signal, [](int a, int b) { });
    
    signal(42, 21);
    Note that signal.connect() now again returns a Slot. This is how it used to be, however if any code was ported to the Callback connect syntax they will now find that their slots immediately disconnect. Generally, always use a SlotContainer.

    The syntax for Callbacks changes to:

    Code:
    std::function<void(int, int)> callback = static_function;
    std::function<void(int, int)> callback = clan::bind_member(instance, &ClassName::member_function);
    std::function<void(int, int)> callback = [](int a, int b) { };
    
    if (callback) callback(42, 21);
    The rationale behind these changes are:

    • Callback had the same purpose as the C++11 std::function template. Standardizing on std::function makes callbacks easier to understand for everyone. It also pretty much guarantees solid lambda and other C++11 support
    • Callbacks had the extra feature that they could connect member functions with a much nicer syntax. The bind_member function adds this feature to all situations where an API uses std::function
    • Using initializer lists for signals created a rather odd syntax. Now, the mix of std::function and bind_member saves typing {} for the common cases and at the same time allowing lambdas for anything more advanced
    • Using operator() for invoke, and operator bool for empty/null checking aligns the API with how C++11's std::function behaves
    • Reintroduced Slot because std::function cannot support the more complex destructor-based disconnects used by the signal/slot system

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    The Canvas "modelview" functions have changed as follows:

    Renamed "modelview" to "transform"

    Removed the modelview "pull() and pop()" functions, because these are not exception friendly and do not belong inside the Canvas class.

    Removed the translate and scale functions, because these are not required (bloat the API)

    To port this code:

    Code:
    	canvas.push_translate(center);
    	canvas.mult_scale(radius_x/max_radius, radius_y/max_radius);
    	...
    	canvas.pop_modelview();
    Write as:

    Code:
    	const Mat4f original_transform = canvas.get_transform();
    	canvas.mult_transform(Mat4f::translate(center.x, center.y, 0));
    	canvas.mult_transform(Mat4f::scale(radius_x / max_radius, radius_y / max_radius, 1.0f));
    	...
    	canvas.set_transform(original_transform);

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    The Euler angle order convention has changed in Mat4<Type>::rotate() and get_euler() has been repaired.

    The order now matches the quaternion euler order.

    Tests are in Tests/Core/Math (test_matrix.cpp, test_quaternion.cpp)

    If you used these functions, then changing "order_XYZ" to "order_ZYX" will be sufficient.

  5. #5
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Fixed a bug in clan::Mat4<Type> transpose function.

    "matrix[15] = original[13]"; should have been "matrix[15] = original[15];"

    Also, the get_origin_x, get_origin_y and get_origin_x functions have been replaced by get_translate() returning clan::Vec3<Type>
    Last edited by rombust; 08-06-2014 at 10:27 AM.

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    DisplayWindowDescription:

    set_tool_window() is now set_type(WindowType::tool)
    set_dialog_window() is now set_type(WindowType:dialog)

Similar Threads

  1. Are there no more development towards LORD?
    By Tifa in forum Other RTsoft Games
    Replies: 2
    Last Post: 02-18-2014, 04:37 AM
  2. Game in development!
    By TheFanoftech in forum RTsoft Tavern
    Replies: 23
    Last Post: 05-22-2013, 04:13 AM
  3. Development of the HDR example
    By rombust in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 03-31-2010, 09:38 AM
  4. Replies: 1
    Last Post: 10-27-2007, 11:19 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •