Skip to content

Commit

Permalink
Makes main panel itself a FLUID design
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Nov 15, 2024
1 parent 5be25bf commit e0f0fe2
Show file tree
Hide file tree
Showing 19 changed files with 2,179 additions and 143 deletions.
2 changes: 2 additions & 0 deletions fluid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set(CPPFILES
streams/project_writer.cxx
streams/string_writer.cxx
ui/about_panel.cxx
ui/main_panel.cxx
ui/panel.cxx
widgets/bin_buttons.cxx
widgets/code_viewers.cxx
Expand Down Expand Up @@ -74,6 +75,7 @@ set(HEADERFILES
project/project.h
project/undo.h
ui/about_panel.h
ui/main_panel.h
ui/panel.h
streams/code_writer.h
streams/project_reader.h
Expand Down
18 changes: 7 additions & 11 deletions fluid/Fd_Snap_Action.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "Fd_Snap_Action.h"

#include "ui/main_panel.h"
#include "Fl_Group_Type.h"
#include "settings_panel.h"
#include "shell_command.h" // get and set Fl_String preferences
Expand Down Expand Up @@ -132,6 +133,10 @@ void select_layout_suite_cb(Fl_Widget *, void *user_data) {

void select_layout_preset_cb(Fl_Widget *, void *user_data) {
int index = (int)(fl_intptr_t)user_data;
select_layout_preset(index);
}

void select_layout_preset(int index) {
assert(index >= 0);
assert(index < 3);
g_layout_list.current_preset(index);
Expand Down Expand Up @@ -624,11 +629,6 @@ Fd_Layout_List::~Fd_Layout_List() {
Update the Setting dialog and menus to reflect the current Layout selection state.
*/
void Fd_Layout_List::update_dialogs() {
static Fl_Menu_Item *preset_menu = NULL;
if (!preset_menu) {
preset_menu = (Fl_Menu_Item*)main_menubar->find_item(select_layout_preset_cb);
assert(preset_menu);
}
assert(this);
assert(current_suite_ >= 0 );
assert(current_suite_ < list_size_);
Expand All @@ -640,7 +640,7 @@ void Fd_Layout_List::update_dialogs() {
w_settings_layout_tab->do_callback(w_settings_layout_tab, LOAD);
layout_choice->redraw();
}
preset_menu[current_preset_].setonly(preset_menu);
fluid::ui::main_panel.preset_menu[current_preset_].setonly(fluid::ui::main_panel.preset_menu);
main_menu_[current_suite_].setonly(main_menu_);
}

Expand Down Expand Up @@ -819,10 +819,6 @@ void Fd_Layout_List::current_preset(int ix) {
Allocate enough space for n entries in the list.
*/
void Fd_Layout_List::capacity(int n) {
static Fl_Menu_Item *suite_menu = NULL;
if (!suite_menu)
suite_menu = (Fl_Menu_Item*)main_menubar->find_item(layout_suite_marker);

int old_n = list_size_;
int i;

Expand All @@ -837,7 +833,7 @@ void Fd_Layout_List::capacity(int n) {
new_main_menu[i] = main_menu_[i];
if (!list_is_static_) ::free(main_menu_);
main_menu_ = new_main_menu;
suite_menu->user_data(main_menu_);
fluid::ui::main_panel.suite_menu->user_data(main_menu_);

Fl_Menu_Item *new_choice_menu = (Fl_Menu_Item*)::calloc(n+1, sizeof(Fl_Menu_Item));
for (i = 0; i < old_n; i++)
Expand Down
4 changes: 4 additions & 0 deletions fluid/Fl_Group_Type.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ void group_cb(Fl_Widget *, void *) {
extern void ungroup_selected_menuitems();

void ungroup_cb(Fl_Widget *, void *) {
ungroup_selected();
}

void ungroup_selected() {
if (!Fl_Type::current) {
fl_message("No widgets selected.");
return;
Expand Down
1 change: 1 addition & 0 deletions fluid/Fl_Group_Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

void group_cb(Fl_Widget *, void *);
void ungroup_cb(Fl_Widget *, void *);
void ungroup_selected();

// ---- Fl_Group_Type -------------------------------------------------- MARK: -

Expand Down
53 changes: 38 additions & 15 deletions fluid/Fl_Window_Type.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "application/application.h"
#include "project/project.h"
#include "ui/main_panel.h"
#include "Fl_Group_Type.h"
#include "Fl_Grid_Type.h"
#include "fluid.h"
Expand Down Expand Up @@ -104,11 +105,18 @@ void i18n_type_cb(Fl_Choice *c, void *v) {
}

void show_grid_cb(Fl_Widget *, void *) {
settings_show_grid();
}
void settings_show_grid() {
settings_window->show();
w_settings_tabs->value(w_settings_layout_tab);
}

void show_settings_cb(Fl_Widget *, void *) {
show_settings();
}

void show_settings() {
settings_window->hotspot(settings_window);
settings_window->show();
}
Expand Down Expand Up @@ -184,6 +192,7 @@ void Overlay_Window::draw() {
extern Fl_Window *main_window;

// Read an image of the overlay window
// TODO: is this actually called from anywhere?
uchar *Overlay_Window::read_image(int &ww, int &hh) {
// Create an off-screen buffer for the window...
//main_window->make_current();
Expand Down Expand Up @@ -722,7 +731,7 @@ extern Fl_Menu_Item Main_Menu[];

// Calculate new bounding box of selected widgets:
void Fl_Window_Type::fix_overlay() {
overlay_item->label("Hide O&verlays");
fluid::ui::main_panel.overlay_item->label("Hide O&verlays");
if (overlay_button) overlay_button->label("Hide &Overlays");
overlays_invisible = 0;
recalc = 1;
Expand Down Expand Up @@ -755,14 +764,14 @@ void redraw_overlays() {
if (o->is_a(ID_Window)) ((Fl_Window_Type*)o)->fix_overlay();
}

void toggle_overlays(Fl_Widget *,void *) {
void toggle_overlays() {
overlays_invisible = !overlays_invisible;

if (overlays_invisible) {
overlay_item->label("Show O&verlays");
fluid::ui::main_panel.overlay_item->label("Show O&verlays");
if (overlay_button) overlay_button->label("Show &Overlays");
} else {
overlay_item->label("Hide O&verlays");
fluid::ui::main_panel.overlay_item->label("Hide O&verlays");
if (overlay_button) overlay_button->label("Hide &Overlays");
}

Expand All @@ -773,19 +782,18 @@ void toggle_overlays(Fl_Widget *,void *) {
}
}

/**
\brief User changes settings to show positioning guides in layout editor overlay.
This is called from the main menu and from the check button in the Settings
dialog.
*/
void toggle_guides(Fl_Widget *,void *) {
void toggle_overlays(Fl_Widget *,void *) {
toggle_overlays();
}

void toggle_guides() {
Fluid.settings.show_guides = !Fluid.settings.show_guides;
fluid_prefs.set("show_guides", Fluid.settings.show_guides);

if (Fluid.settings.show_guides)
guides_item->label("Hide Guides");
fluid::ui::main_panel.guides_item->label("Hide Guides");
else
guides_item->label("Show Guides");
fluid::ui::main_panel.guides_item->label("Show Guides");
if (guides_button)
guides_button->value(Fluid.settings.show_guides);

Expand All @@ -797,6 +805,17 @@ void toggle_guides(Fl_Widget *,void *) {
}
}

/**
\brief User changes settings to show positioning guides in layout editor overlay.
This is called from the main menu and from the check button in the Settings
dialog.
*/
void toggle_guides(Fl_Widget *,void *) {
toggle_guides();
}



/**
\brief User changes settings to show positioning guides in layout editor overlay.
This is called from the check button in the Settings dialog.
Expand All @@ -810,14 +829,14 @@ void toggle_guides_cb(Fl_Check_Button *o, void *v) {
This is called from the main menu and from the check button in the Settings
dialog.
*/
void toggle_restricted(Fl_Widget *,void *) {
void toggle_restricted() {
Fluid.settings.show_restricted = !Fluid.settings.show_restricted;
fluid_prefs.set("show_restricted", Fluid.settings.show_restricted);

if (Fluid.settings.show_restricted)
restricted_item->label("Hide Restricted");
fluid::ui::main_panel.restricted_item->label("Hide Restricted");
else
restricted_item->label("Show Restricted");
fluid::ui::main_panel.restricted_item->label("Show Restricted");
if (restricted_button)
restricted_button->value(Fluid.settings.show_restricted);

Expand All @@ -829,6 +848,10 @@ void toggle_restricted(Fl_Widget *,void *) {
}
}

void toggle_restricted(Fl_Widget *,void *) {
toggle_restricted();
}

/**
\brief User changes settings to show low contrast groups with a ghosted outline.
*/
Expand Down
4 changes: 3 additions & 1 deletion fluid/align_widget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
#define BREAK_ON_FIRST break
//#define BREAK_ON_FIRST

void align_widget_cb(Fl_Widget*, long how)
void align_widget_cb(Fl_Widget*, void *how_ptr)
{
Fluid.project.undo.checkpoint();
const int max = 32768, min = -32768;
int left, right, top, bot, wdt, hgt, n;
Fl_Type *o;
int changed = 0;
long how = reinterpret_cast<intptr_t>(how_ptr);
switch ( how )
{
//---- align
Expand Down
2 changes: 1 addition & 1 deletion fluid/application/application.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Fl_String Application::open_project_filechooser(const Fl_String &title) {
\param[in] filename_arg load from this file, or show file chooser if empty
\return false if the operation was canceled or failed otherwise
*/
bool Application::open_project_file(const Fl_String &filename_arg) {
bool Application::open_project_from_file(const Fl_String &filename_arg) {
// verify user intention
if (project.confirm_clear() == false)
return false;
Expand Down
2 changes: 1 addition & 1 deletion fluid/application/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Application {
/// Open a native file chooser to allow choosing a project file for reading.
Fl_String open_project_filechooser(const Fl_String &title);
/// Open a file chooser and load an exiting project file.
bool open_project_file(const Fl_String &filename_arg);
bool open_project_from_file(const Fl_String &filename_arg);

/// Generate a path to a directory for temporary data storage.
void create_tmpdir();
Expand Down
14 changes: 5 additions & 9 deletions fluid/application/history.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "application/history.h"
#include "fluid.h"
#include "ui/main_panel.h"

using namespace fluid;

Expand Down Expand Up @@ -46,15 +47,12 @@ void application::History::load() {
// Make a relative version of the filename for the menu...
fl_filename_relative(short_path[i], sizeof(short_path[i]),
full_path[i]);

if (i == 9) history_item[i].flags = FL_MENU_DIVIDER;
else history_item[i].flags = 0;
fluid::ui::main_panel.history_item[i].flags = 0;
} else break;
}

for (; i < 10; i ++) {
if (i) history_item[i-1].flags |= FL_MENU_DIVIDER;
history_item[i].hide();
fluid::ui::main_panel.history_item[i].hide();
}
}

Expand Down Expand Up @@ -109,15 +107,13 @@ void application::History::add(const char *flname) {
for (i = 0; i < max_files; i ++) {
fluid_prefs.set( Fl_Preferences::Name("file%d", i), full_path[i]);
if (full_path[i][0]) {
if (i == 9) history_item[i].flags = FL_MENU_DIVIDER;
else history_item[i].flags = 0;
fluid::ui::main_panel.history_item[i].flags = 0;
} else break;
}

for (; i < 10; i ++) {
fluid_prefs.set( Fl_Preferences::Name("file%d", i), "");
if (i) history_item[i-1].flags |= FL_MENU_DIVIDER;
history_item[i].hide();
fluid::ui::main_panel.history_item[i].hide();
}
fluid_prefs.flush();
}
Loading

0 comments on commit e0f0fe2

Please sign in to comment.