Skip to content

Commit

Permalink
New file requester.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed May 20, 2024
1 parent 4c2c735 commit e720292
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 102 deletions.
79 changes: 79 additions & 0 deletions mrv2/icons/Music.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 60 additions & 32 deletions mrv2/lib/mrvFLU/Flu_Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ Fl_Pixmap preview_img((char* const*)monalisa_xpm),
documents((char* const*)filled_folder_xpm),
little_favorites((char* const*)mini_folder_favorites_xpm),
little_desktop((char* const*)mini_desktop_xpm),
reel((char* const*)reel_xpm), picture((char* const*)image_xpm),
music((char* const*)music_xpm);
reel((char* const*)reel_xpm), picture((char* const*)image_xpm);

Fl_Image* usd = nullptr;
Fl_Image* music = nullptr;

static const int kColorOne = fl_rgb_color(200, 200, 200);
static const int kColorTwo = fl_rgb_color(180, 180, 180);
Expand Down Expand Up @@ -556,22 +556,59 @@ void Flu_Entry::editCB()
chooser->trashBtn->deactivate();
redraw();
}
void Flu_Entry::updateSize()

void Flu_Entry::updateSize(int& W, int& H, int& iW, int& iH, int& tW, int& tH)
{
int H = 20;
// Some constants
const int marginW = 2;
const int marginH = 4;

// Measure the name in width and height
tW = 0;
tH = 0;
fl_font(textfont(), textsize());

// measure the name and see if we need a truncated version
fl_measure(filename.c_str(), tW, tH);

// how big is the icon?
iW = 22, iH = marginH;
bool wide = chooser->fileListWideBtn->value();
if (icon)
{
if (chooser->previewBtn->value() &&
(icon == &reel || icon == &picture) &&
Flu_File_Chooser::thumbnailsFileReq)
{
H = 68;
iW = icon->w() + marginW;
if (!isPicture)
{
isPicture = true;
iH = 64 + marginH;
}
else
{
iH = icon->h() + marginH;
}
}
else
{
H = icon->h() + 4;
iW = icon->w() + marginW;
iH = icon->h() + marginH;
if (!isPicture || wide)
tH = 0;
}
}

W = tW;
H = tH + iH;
}

void Flu_Entry::updateSize()
{
int W, H, iW, iH, tW, tH;
updateSize(W, H, iW, iH, tW, tH);

if (type == ENTRY_FAVORITE || chooser->fileListWideBtn->value())
{
resize(x(), y(), chooser->filelist->w() - 4, H);
Expand All @@ -592,19 +629,7 @@ void Flu_Entry::updateSize()
else
nameW = w();

// how big is the icon?
int iW = 22;
if (icon)
{
iW = icon->w() + 2;
}

fl_font(textfont(), textsize());

// measure the name and see if we need a truncated version
int W = 0;
fl_measure(filename.c_str(), W, H);
const int maxW = nameW - iW;
const int maxW = nameW;
if (W > maxW)
{
// progressively strip characters off the end of the name until
Expand Down Expand Up @@ -717,8 +742,6 @@ void Flu_Entry::draw()
return;
}

// startRequest();

if (selected)
{
fl_draw_box(FL_FLAT_BOX, x(), y(), w(), h(), Fl_Color(0x8f8f0000));
Expand All @@ -730,26 +753,31 @@ void Flu_Entry::draw()
fl_color(FL_BLACK);
}

int W, H, iW, iH, tW, tH;
updateSize(W, H, iW, iH, tW, tH);

bool below = (!chooser->fileListWideBtn->value()) && isPicture;
int X = x() + 4;
int Y = y();
int iH = 0;
int tY = Y;

if (icon)
{
icon->draw(X, y() + (H - iH - tH) / 2 + 2);
if (!below)
{
icon->draw(X, y() + h() / 2 - icon->h() / 2);
X += icon->w() + 2;
tH = H;
}
else
{
tY += icon->h() + 2;
}
}

int iW = 0, W = 0, H = 0;
if (icon)
{
iW = icon->w() + 2;
}

fl_font(textfont(), textsize());
fl_measure(filename.c_str(), W, H);
int maxW = nameW - iW;
int maxW = nameW - iW * !below;
if (W > maxW)
{
// progressively strip characters off the end of the name until
Expand All @@ -772,7 +800,7 @@ void Flu_Entry::draw()
pos += 2;
}

fl_draw(shortname.c_str(), X, Y, nameW, h() - iH, FL_ALIGN_LEFT);
fl_draw(shortname.c_str(), X, tY, nameW, tH, FL_ALIGN_LEFT);

X = x() + 4 + nameW;

Expand Down Expand Up @@ -813,7 +841,7 @@ void Flu_Entry::bind_image(Fl_RGB_Image* image)
void Flu_Entry::startRequest()
{
TLRENDER_P();
if (!p.thumbnailCreator || p.id != -1 || icon == &music)
if (!p.thumbnailCreator || p.id != -1 || icon == music)
return;

file::Path path(toTLRender());
Expand Down
15 changes: 10 additions & 5 deletions mrv2/lib/mrvFLU/Flu_Entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace mrv
extern Fl_Pixmap preview_img, file_list_img, file_listwide_img, fileDetails,
desktop, folder_closed, default_file, my_computer, computer, disk_drive,
cd_drive, floppy_drive, removable_drive, ram_drive, network_drive,
documents, little_favorites, little_desktop, reel, picture, music;
extern Fl_Image* usd;
documents, little_favorites, little_desktop, reel, picture;
extern Fl_Image *usd, *music;

class Fl_RGB_Image;
class Flu_File_Chooser;
Expand All @@ -31,7 +31,7 @@ class Flu_Entry : public Fl_Input
void draw() FL_OVERRIDE;

void bind_image(Fl_RGB_Image*);

void set_colors();

void updateSize();
Expand All @@ -54,6 +54,10 @@ class Flu_Entry : public Fl_Input
inline static void _editCB(void* arg) { ((Flu_Entry*)arg)->editCB(); }
void editCB();

//! Convert our internal information to a tlRender friendly filename.
std::string toTLRender();

public:
std::string filename, date, filesize, shortname, owner, description,
shortDescription, toolTip, altname;
std::string permissions;
Expand All @@ -66,9 +70,10 @@ class Flu_Entry : public Fl_Input
Flu_File_Chooser* chooser;
Fl_Image* icon;

//! Convert our internal information to a tlRender friendly filename.
std::string toTLRender();
protected:
void updateSize(int& W, int& H, int& iW, int& iH, int& tW, int& tH);

bool isPicture = false;
bool details;
int nameW, typeW, sizeW, dateW;

Expand Down
Loading

0 comments on commit e720292

Please sign in to comment.